Commit 2c806c1408dbf94c1f16394f6b680acc9f3e1fb8

Authored by binarylogic
1 parent 598d70ab
Exists in master

Switch to jewler from hoe

LICENSE 0 → 100644
@@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
  1 +Copyright (c) 2008 Ben Johnson of Binary Logic (binarylogic.com)
  2 +
  3 +Permission is hereby granted, free of charge, to any person obtaining
  4 +a copy of this software and associated documentation files (the
  5 +"Software"), to deal in the Software without restriction, including
  6 +without limitation the rights to use, copy, modify, merge, publish,
  7 +distribute, sublicense, and/or sell copies of the Software, and to
  8 +permit persons to whom the Software is furnished to do so, subject to
  9 +the following conditions:
  10 +
  11 +The above copyright notice and this permission notice shall be
  12 +included in all copies or substantial portions of the Software.
  13 +
  14 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  18 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  19 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  20 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0 \ No newline at end of file 21 \ No newline at end of file
MIT-LICENSE
@@ -1,20 +0,0 @@ @@ -1,20 +0,0 @@
1 -Copyright (c) 2008 Ben Johnson of Binary Logic (binarylogic.com)  
2 -  
3 -Permission is hereby granted, free of charge, to any person obtaining  
4 -a copy of this software and associated documentation files (the  
5 -"Software"), to deal in the Software without restriction, including  
6 -without limitation the rights to use, copy, modify, merge, publish,  
7 -distribute, sublicense, and/or sell copies of the Software, and to  
8 -permit persons to whom the Software is furnished to do so, subject to  
9 -the following conditions:  
10 -  
11 -The above copyright notice and this permission notice shall be  
12 -included in all copies or substantial portions of the Software.  
13 -  
14 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,  
15 -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF  
16 -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND  
17 -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE  
18 -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION  
19 -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION  
20 -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  
21 \ No newline at end of file 0 \ No newline at end of file
Manifest.txt
@@ -1,15 +0,0 @@ @@ -1,15 +0,0 @@
1 -CHANGELOG.rdoc  
2 -MIT-LICENSE  
3 -Manifest.txt  
4 -README.rdoc  
5 -Rakefile  
6 -init.rb  
7 -lib/settingslogic.rb  
8 -lib/settingslogic/config.rb  
9 -lib/settingslogic/settings.rb  
10 -lib/settingslogic/version.rb  
11 -test/application.yml  
12 -test/application2.yml  
13 -test/test_config.rb  
14 -test/test_helper.rb  
15 -test/test_setting.rb  
1 -ENV['RDOCOPT'] = "-S -f html -T hanna" 1 +require 'rubygems'
  2 +require 'rake'
2 3
3 -require "rubygems"  
4 -require "hoe"  
5 -require File.dirname(__FILE__) << "/lib/settingslogic/version" 4 +begin
  5 + require 'jeweler'
  6 + Jeweler::Tasks.new do |gem|
  7 + gem.name = "settingslogic"
  8 + gem.summary = "A simple and straightforward settings solution that uses an ERB enabled YAML file and a singleton design pattern."
  9 + gem.email = "bjohnson@binarylogic.com"
  10 + gem.homepage = "http://github.com/binarylogic/settingslogic"
  11 + gem.authors = ["Ben Johnson of Binary Logic"]
  12 + gem.rubyforge_project = "settingslogic"
  13 + gem.add_dependency "activesupport"
  14 + end
  15 +rescue LoadError
  16 + puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
  17 +end
6 18
7 -Hoe.new("Settingslogic", Settingslogic::Version::STRING) do |p|  
8 - p.name = "settingslogic"  
9 - p.author = "Ben Johnson of Binary Logic"  
10 - p.email = 'bjohnson@binarylogic.com'  
11 - p.summary = "A simple and straightforward settings solution that uses an ERB enabled YAML file and a singleton design pattern."  
12 - p.description = "A simple and straightforward settings solution that uses an ERB enabled YAML file and a singleton design pattern."  
13 - p.url = "http://github.com/binarylogic/settingslogic"  
14 - p.history_file = "CHANGELOG.rdoc"  
15 - p.readme_file = "README.rdoc"  
16 - p.extra_rdoc_files = ["CHANGELOG.rdoc", "README.rdoc"]  
17 - p.remote_rdoc_dir = ''  
18 - p.test_globs = ["test/*/test_*.rb", "test/*_test.rb", "test/*/*_test.rb"]  
19 - p.extra_deps = %w(activesupport)  
20 -end  
21 \ No newline at end of file 19 \ No newline at end of file
  20 +require 'rake/testtask'
  21 +Rake::TestTask.new(:test) do |test|
  22 + test.libs << 'lib' << 'test'
  23 + test.pattern = 'test/**/*_test.rb'
  24 + test.verbose = true
  25 +end
  26 +
  27 +begin
  28 + require 'rcov/rcovtask'
  29 + Rcov::RcovTask.new do |test|
  30 + test.libs << 'test'
  31 + test.pattern = 'test/**/*_test.rb'
  32 + test.verbose = true
  33 + end
  34 +rescue LoadError
  35 + task :rcov do
  36 + abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
  37 + end
  38 +end
  39 +
  40 +task :default => :test
  41 +
  42 +begin
  43 + require 'rake/contrib/sshpublisher'
  44 + namespace :rubyforge do
  45 + desc "Release gem to RubyForge"
  46 + task :release => ["rubyforge:release:gem"]
  47 + end
  48 +rescue LoadError
  49 + puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
  50 +end
@@ -1 +0,0 @@ @@ -1 +0,0 @@
1 -0.0.0  
1 -require "settingslogic"  
2 \ No newline at end of file 1 \ No newline at end of file
  2 +require File.dirname(__FILE__) + "/rails/init.rb"
3 \ No newline at end of file 3 \ No newline at end of file
lib/settingslogic/version.rb
@@ -1,54 +0,0 @@ @@ -1,54 +0,0 @@
1 -module Settingslogic  
2 - # A class for describing the current version of a library. The version  
3 - # consists of three parts: the +major+ number, the +minor+ number, and the  
4 - # +tiny+ (or +patch+) number.  
5 - class Version  
6 -  
7 - include Comparable  
8 -  
9 - # A convenience method for instantiating a new Version instance with the  
10 - # given +major+, +minor+, and +tiny+ components.  
11 - def self.[](major, minor, tiny)  
12 - new(major, minor, tiny)  
13 - end  
14 -  
15 - attr_reader :major, :minor, :tiny  
16 -  
17 - # Create a new Version object with the given components.  
18 - def initialize(major, minor, tiny)  
19 - @major, @minor, @tiny = major, minor, tiny  
20 - end  
21 -  
22 - # Compare this version to the given +version+ object.  
23 - def <=>(version)  
24 - to_i <=> version.to_i  
25 - end  
26 -  
27 - # Converts this version object to a string, where each of the three  
28 - # version components are joined by the '.' character. E.g., 2.0.0.  
29 - def to_s  
30 - @to_s ||= [@major, @minor, @tiny].join(".")  
31 - end  
32 -  
33 - # Converts this version to a canonical integer that may be compared  
34 - # against other version objects.  
35 - def to_i  
36 - @to_i ||= @major * 1_000_000 + @minor * 1_000 + @tiny  
37 - end  
38 -  
39 - def to_a  
40 - [@major, @minor, @tiny]  
41 - end  
42 -  
43 - MAJOR = 1  
44 - MINOR = 0  
45 - TINY = 3  
46 -  
47 - # The current version as a Version instance  
48 - CURRENT = new(MAJOR, MINOR, TINY)  
49 - # The current version as a String  
50 - STRING = CURRENT.to_s  
51 -  
52 - end  
53 -  
54 -end  
55 \ No newline at end of file 0 \ No newline at end of file
rails/init.rb 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +require "settingslogic"
0 \ No newline at end of file 2 \ No newline at end of file
test/config_test.rb 0 → 100644
@@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
  1 +require File.dirname(__FILE__) + '/test_helper.rb'
  2 +
  3 +class TestConfig < Test::Unit::TestCase
  4 + def test_settings_file
  5 + Settingslogic::Config.configure do |config|
  6 + config.settings_file = File.dirname(__FILE__) + '/application2.yml'
  7 + end
  8 +
  9 + Settings.reset!
  10 + assert_equal "BenJohnson", Settings.neat.cool.awesome
  11 + assert_equal 5, Settings.silly
  12 + assert_equal 25, Settings.fun
  13 + end
  14 +end
0 \ No newline at end of file 15 \ No newline at end of file
test/setting_test.rb 0 → 100644
@@ -0,0 +1,43 @@ @@ -0,0 +1,43 @@
  1 +require File.dirname(__FILE__) + '/test_helper.rb'
  2 +
  3 +class TestSetting < Test::Unit::TestCase
  4 + def test_conflicting_class_methods
  5 + assert_equal "test", Settings.name
  6 + end
  7 +
  8 + def test_singleton_access
  9 + assert_equal Settings, Settings.setting1.class
  10 + assert_equal "saweet", Settings.setting1.setting1_child
  11 + assert_equal 5, Settings.setting2
  12 + assert_equal 25, Settings.setting3
  13 + end
  14 +
  15 + def test_instances
  16 + settings1 = Settings.new(File.dirname(__FILE__) + '/application.yml')
  17 + assert_equal "saweet", settings1.setting1.setting1_child
  18 + assert_equal 5, settings1.setting2
  19 + assert_equal 25, settings1.setting3
  20 +
  21 + settings2 = Settings.new(File.dirname(__FILE__) + '/application2.yml')
  22 + assert_equal "BenJohnson", settings2.neat.cool.awesome
  23 + assert_equal 5, settings2.silly
  24 + assert_equal 25, settings2.fun
  25 + end
  26 +
  27 + def test_method_missing
  28 + assert_raise(NoMethodError) { Settings.doesnt_exist }
  29 + settings1 = Settings.new(File.dirname(__FILE__) + '/application.yml')
  30 + assert_raise(NoMethodError) { settings1.doesnt_exist }
  31 + end
  32 +
  33 + def test_initialized_with_hash
  34 + settings1 = Settings.new(
  35 + :silly => 5,
  36 + 'fun' => 25,
  37 + :neat => { 'cool' => { :awesome => "BenJohnson" } }
  38 + )
  39 + assert_equal "BenJohnson", settings1.neat.cool.awesome
  40 + assert_equal 5, settings1.silly
  41 + assert_equal 25, settings1.fun
  42 + end
  43 +end
0 \ No newline at end of file 44 \ No newline at end of file
test/test_config.rb
@@ -1,14 +0,0 @@ @@ -1,14 +0,0 @@
1 -require File.dirname(__FILE__) + '/test_helper.rb'  
2 -  
3 -class TestConfig < Test::Unit::TestCase  
4 - def test_settings_file  
5 - Settingslogic::Config.configure do |config|  
6 - config.settings_file = File.dirname(__FILE__) + '/application2.yml'  
7 - end  
8 -  
9 - Settings.reset!  
10 - assert_equal "BenJohnson", Settings.neat.cool.awesome  
11 - assert_equal 5, Settings.silly  
12 - assert_equal 25, Settings.fun  
13 - end  
14 -end  
15 \ No newline at end of file 0 \ No newline at end of file
test/test_setting.rb
@@ -1,43 +0,0 @@ @@ -1,43 +0,0 @@
1 -require File.dirname(__FILE__) + '/test_helper.rb'  
2 -  
3 -class TestSetting < Test::Unit::TestCase  
4 - def test_conflicting_class_methods  
5 - assert_equal "test", Settings.name  
6 - end  
7 -  
8 - def test_singleton_access  
9 - assert_equal Settings, Settings.setting1.class  
10 - assert_equal "saweet", Settings.setting1.setting1_child  
11 - assert_equal 5, Settings.setting2  
12 - assert_equal 25, Settings.setting3  
13 - end  
14 -  
15 - def test_instances  
16 - settings1 = Settings.new(File.dirname(__FILE__) + '/application.yml')  
17 - assert_equal "saweet", settings1.setting1.setting1_child  
18 - assert_equal 5, settings1.setting2  
19 - assert_equal 25, settings1.setting3  
20 -  
21 - settings2 = Settings.new(File.dirname(__FILE__) + '/application2.yml')  
22 - assert_equal "BenJohnson", settings2.neat.cool.awesome  
23 - assert_equal 5, settings2.silly  
24 - assert_equal 25, settings2.fun  
25 - end  
26 -  
27 - def test_method_missing  
28 - assert_raise(NoMethodError) { Settings.doesnt_exist }  
29 - settings1 = Settings.new(File.dirname(__FILE__) + '/application.yml')  
30 - assert_raise(NoMethodError) { settings1.doesnt_exist }  
31 - end  
32 -  
33 - def test_initialized_with_hash  
34 - settings1 = Settings.new(  
35 - :silly => 5,  
36 - 'fun' => 25,  
37 - :neat => { 'cool' => { :awesome => "BenJohnson" } }  
38 - )  
39 - assert_equal "BenJohnson", settings1.neat.cool.awesome  
40 - assert_equal 5, settings1.silly  
41 - assert_equal 25, settings1.fun  
42 - end  
43 -end  
44 \ No newline at end of file 0 \ No newline at end of file