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