diff -Nru libmixlib-config-ruby-1.0.12/debian/changelog libmixlib-config-ruby-1.0.9/debian/changelog --- libmixlib-config-ruby-1.0.12/debian/changelog 2009-09-15 09:05:39.000000000 -0600 +++ libmixlib-config-ruby-1.0.9/debian/changelog 2009-09-15 09:05:39.000000000 -0600 @@ -1,11 +1,3 @@ -libmixlib-config-ruby (1.0.12-1) unstable; urgency=low - - * New upstream release - [ Joshua Timberman ] - * New package maintainer - - -- Joshua Timberman Wed, 02 Sep 2009 22:21:43 -0600 - libmixlib-config-ruby (1.0.9-1) unstable; urgency=low * new upstream version diff -Nru libmixlib-config-ruby-1.0.12/debian/control libmixlib-config-ruby-1.0.9/debian/control --- libmixlib-config-ruby-1.0.12/debian/control 2009-09-15 09:05:39.000000000 -0600 +++ libmixlib-config-ruby-1.0.9/debian/control 2009-09-15 09:05:39.000000000 -0600 @@ -1,10 +1,10 @@ Source: libmixlib-config-ruby Section: ruby Priority: extra -Maintainer: Joshua Timberman +Maintainer: Bryan McLellan Build-Depends: debhelper (>= 7), cdbs, ruby-pkg-tools (>= 0.14) Build-Depends-Indep: ruby1.8, libsetup-ruby1.8 -Standards-Version: 3.8.3 +Standards-Version: 3.8.2 Homepage: http://github.com/opscode/mixlib-config/tree/master Package: libmixlib-config-ruby diff -Nru libmixlib-config-ruby-1.0.12/lib/mixlib/config.rb libmixlib-config-ruby-1.0.9/lib/mixlib/config.rb --- libmixlib-config-ruby-1.0.12/lib/mixlib/config.rb 2009-08-25 08:28:43.000000000 -0600 +++ libmixlib-config-ruby-1.0.9/lib/mixlib/config.rb 2009-06-24 06:31:25.000000000 -0600 @@ -16,12 +16,6 @@ # limitations under the License. # -class Object # http://whytheluckystiff.net/articles/seeingMetaclassesClearly.html - def meta_def name, &blk - (class << self; self; end).instance_eval { define_method name, &blk } - end -end - module Mixlib module Config @@ -35,13 +29,17 @@ # === Parameters # :: A filename to read from def from_file(filename) - self.instance_eval(IO.read(filename), filename, 1) + begin + self.instance_eval(IO.read(filename), filename, 1) + rescue Exception => e + raise IOError, "Cannot open or read #{filename}!" + e + end end - # Pass Mixlib::Config.configure() a block, and it will yield @@configuration. + # Pass Mixlib::Config.configure() a block, and it will yield @configuration. # # === Parameters - # :: A block that is sent @@configuration as its argument + # :: A block that takes @configure as it's argument def configure(&block) block.call(@@configuration) end @@ -127,22 +125,8 @@ end end - protected :internal_set + private :internal_set - # metaprogramming to ensure that the slot for method_symbol - # gets set to value after any other logic is run - # === Parameters - # method_symbol:: Name of the method (variable setter) - # blk:: logic block to run in setting slot method_symbol to value - # value:: Value to be set in config hash - # - def config_attr_writer(method_symbol, &blk) - method_name = "#{method_symbol.to_s}=" - meta_def method_name do |value| - @@configuration[method_symbol] = blk.call(value) - end - end - # Allows for simple lookups and setting of configuration options via method calls # on Mixlib::Config. If there any arguments to the method, they are used to set # the value of the configuration option. Otherwise, it's a simple get operation. @@ -158,15 +142,18 @@ # :: If the method_symbol does not match a configuration option. def method_missing(method_symbol, *args) num_args = args.length - # Setting - if num_args > 0 - method_symbol = $1.to_sym unless (method_symbol.to_s =~ /(.+)=$/).nil? - internal_set method_symbol, (num_args == 1 ? args[0] : args) + + # If we have the symbol, or if we need to set it + if @@configuration.has_key?(method_symbol) || num_args > 0 + if num_args > 0 + internal_set(method_symbol, num_args == 1 ? args[0] : args) + end + return @@configuration[method_symbol] + else + # Otherwise, we're just looking it up + raise ArgumentError, "Cannot find configuration option #{method_symbol.to_s}" end - - # Returning - @@configuration[method_symbol] - end + end end diff -Nru libmixlib-config-ruby-1.0.12/mixlib-config.gemspec libmixlib-config-ruby-1.0.9/mixlib-config.gemspec --- libmixlib-config-ruby-1.0.12/mixlib-config.gemspec 2009-08-25 08:28:43.000000000 -0600 +++ libmixlib-config-ruby-1.0.9/mixlib-config.gemspec 2009-06-24 06:31:25.000000000 -0600 @@ -2,11 +2,11 @@ Gem::Specification.new do |s| s.name = %q{mixlib-config} - s.version = "1.0.12" + s.version = "1.0.9" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Opscode, Inc."] - s.date = %q{2009-08-26} + s.date = %q{2009-06-25} s.email = %q{info@opscode.com} s.extra_rdoc_files = [ "LICENSE", @@ -25,7 +25,7 @@ s.homepage = %q{http://www.opscode.com} s.rdoc_options = ["--charset=UTF-8"] s.require_paths = ["lib"] - s.rubygems_version = %q{1.3.5} + s.rubygems_version = %q{1.3.3} s.summary = %q{A class based config mixin, similar to the one found in Chef.} s.test_files = [ "spec/mixlib/config_spec.rb", diff -Nru libmixlib-config-ruby-1.0.12/spec/mixlib/config_spec.rb libmixlib-config-ruby-1.0.9/spec/mixlib/config_spec.rb --- libmixlib-config-ruby-1.0.12/spec/mixlib/config_spec.rb 2009-08-25 08:28:43.000000000 -0600 +++ libmixlib-config-ruby-1.0.9/spec/mixlib/config_spec.rb 2009-06-24 06:31:25.000000000 -0600 @@ -41,17 +41,10 @@ }.should_not raise_error(ArgumentError) end - it "should raise an Errno::ENOENT if it can't find the file" do + it "should raise an IOError if it can't find the file" do lambda { ConfigIt.from_file("/tmp/timmytimmytimmy") - }.should raise_error(Errno::ENOENT) - end - - it "should allow the error to bubble up when it's anything other than IOError" do - IO.stub!(:read).with('config.rb').and_return("@#asdf") - lambda { - ConfigIt.from_file('config.rb') - }.should raise_error(SyntaxError) + }.should raise_error(IOError) end it "should allow you to reference a value by index" do @@ -62,12 +55,6 @@ ConfigIt[:alpha] = "one" ConfigIt[:alpha].should == "one" end - - it "should allow setting a value with attribute form" do - ConfigIt.arbitrary_value = 50 - ConfigIt.arbitrary_value.should == 50 - ConfigIt[:arbitrary_value].should == 50 - end describe "when a block has been used to set config values" do before do @@ -97,33 +84,20 @@ describe "when a class method override accessor exists" do before do class ConfigIt - - config_attr_writer :test_method do |blah| - blah.is_a?(Integer) ? blah * 1000 : blah + def self.test_method=(blah) + configure { |c| c[:test_method] = blah.is_a?(Integer) ? blah * 1000 : blah } end - end end - + it "should multiply an integer by 1000" do ConfigIt[:test_method] = 53 ConfigIt[:test_method].should == 53000 end it "should multiply an integer by 1000 with the method_missing form" do - ConfigIt.test_method = 63 - ConfigIt.test_method.should == 63000 - end - - it "should multiply an integer by 1000 with the instance_eval DSL form" do - ConfigIt.instance_eval("test_method 73") - ConfigIt.test_method.should == 73000 - end - - it "should multiply an integer by 1000 via from-file, too" do - IO.stub!(:read).with('config.rb').and_return("test_method 99") - ConfigIt.from_file('config.rb') - ConfigIt.test_method.should == 99000 + ConfigIt.test_method = 53 + ConfigIt.test_method.should == 53000 end it "should receive internal_set with the method name and config value" do diff -Nru libmixlib-config-ruby-1.0.12/VERSION.yml libmixlib-config-ruby-1.0.9/VERSION.yml --- libmixlib-config-ruby-1.0.12/VERSION.yml 2009-08-25 08:28:43.000000000 -0600 +++ libmixlib-config-ruby-1.0.9/VERSION.yml 2009-06-24 06:31:25.000000000 -0600 @@ -1,4 +1,4 @@ --- :major: 1 :minor: 0 -:patch: 12 +:patch: 9