mixlib-config 1.1.0 → 1.1.2.rc01

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  ---
2
- :patch: 0
3
- :build:
2
+ :patch: 2
3
+ :build: rc01
4
4
  :major: 1
5
5
  :minor: 1
@@ -18,12 +18,6 @@
18
18
  # limitations under the License.
19
19
  #
20
20
 
21
- class Object # http://whytheluckystiff.net/articles/seeingMetaclassesClearly.html
22
- def meta_def name, &blk
23
- (class << self; self; end).instance_eval { define_method name, &blk }
24
- end
25
- end
26
-
27
21
  module Mixlib
28
22
  module Config
29
23
 
@@ -125,7 +119,7 @@ module Mixlib
125
119
  #
126
120
  def internal_set(method_symbol,value)
127
121
  method_name = method_symbol.id2name
128
- if (self.public_methods - ["[]="]).include?("#{method_name}=")
122
+ if self.respond_to?("#{method_name}=".to_sym)
129
123
  self.send("#{method_name}=", value)
130
124
  else
131
125
  self.configuration[method_symbol] = value
@@ -142,8 +136,9 @@ module Mixlib
142
136
  # value<Object>:: Value to be set in config hash
143
137
  #
144
138
  def config_attr_writer(method_symbol, &blk)
145
- method_name = "#{method_symbol.to_s}="
146
- meta_def method_name do |value|
139
+ meta = class << self; self; end
140
+ method_name = "#{method_symbol.to_s}=".to_sym
141
+ meta.send :define_method, method_name do |value|
147
142
  self.configuration[method_symbol] = blk.call(value)
148
143
  end
149
144
  end
@@ -18,6 +18,11 @@
18
18
 
19
19
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
20
20
 
21
+ class ConfigIt
22
+ extend ::Mixlib::Config
23
+ end
24
+
25
+
21
26
  describe Mixlib::Config do
22
27
  before(:each) do
23
28
  ConfigIt.configure do |c|
@@ -96,47 +101,41 @@ describe Mixlib::Config do
96
101
 
97
102
  describe "when a class method override accessor exists" do
98
103
  before do
99
- class ConfigIt
100
-
104
+ @klass = Class.new
105
+ @klass.extend(::Mixlib::Config)
106
+ @klass.class_eval(<<-EVAL)
101
107
  config_attr_writer :test_method do |blah|
102
108
  blah.is_a?(Integer) ? blah * 1000 : blah
103
109
  end
104
-
105
- end
110
+ pp self.methods
111
+ EVAL
106
112
  end
107
113
 
108
114
  it "should multiply an integer by 1000" do
109
- ConfigIt[:test_method] = 53
110
- ConfigIt[:test_method].should == 53000
115
+ @klass[:test_method] = 53
116
+ @klass[:test_method].should == 53000
111
117
  end
112
118
 
113
119
  it "should multiply an integer by 1000 with the method_missing form" do
114
- ConfigIt.test_method = 63
115
- ConfigIt.test_method.should == 63000
120
+ @klass.test_method = 63
121
+ @klass.test_method.should == 63000
116
122
  end
117
123
 
118
124
  it "should multiply an integer by 1000 with the instance_eval DSL form" do
119
- ConfigIt.instance_eval("test_method 73")
120
- ConfigIt.test_method.should == 73000
125
+ @klass.instance_eval("test_method 73")
126
+ @klass.test_method.should == 73000
121
127
  end
122
128
 
123
129
  it "should multiply an integer by 1000 via from-file, too" do
124
130
  IO.stub!(:read).with('config.rb').and_return("test_method 99")
125
- ConfigIt.from_file('config.rb')
126
- ConfigIt.test_method.should == 99000
131
+ @klass.from_file('config.rb')
132
+ @klass.test_method.should == 99000
127
133
  end
128
134
 
129
135
  it "should receive internal_set with the method name and config value" do
130
- ConfigIt.should_receive(:internal_set).with(:test_method, 53).and_return(true)
131
- ConfigIt[:test_method] = 53
136
+ @klass.should_receive(:internal_set).with(:test_method, 53).and_return(true)
137
+ @klass[:test_method] = 53
132
138
  end
133
139
 
134
- after do
135
- class ConfigIt
136
- class << self
137
- undef test_method=
138
- end
139
- end
140
- end
141
140
  end
142
141
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixlib-config
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ prerelease: true
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 0
9
- version: 1.1.0
8
+ - 2
9
+ - rc01
10
+ version: 1.1.2.rc01
10
11
  platform: ruby
11
12
  authors:
12
13
  - Opscode, Inc.
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-02-28 00:00:00 -08:00
18
+ date: 2010-06-15 00:00:00 -07:00
18
19
  default_executable:
19
20
  dependencies: []
20
21
 
@@ -54,6 +55,7 @@ rdoc_options:
54
55
  require_paths:
55
56
  - lib
56
57
  required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
57
59
  requirements:
58
60
  - - ">="
59
61
  - !ruby/object:Gem::Version
@@ -61,16 +63,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
61
63
  - 0
62
64
  version: "0"
63
65
  required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
64
67
  requirements:
65
- - - ">="
68
+ - - ">"
66
69
  - !ruby/object:Gem::Version
67
70
  segments:
68
- - 0
69
- version: "0"
71
+ - 1
72
+ - 3
73
+ - 1
74
+ version: 1.3.1
70
75
  requirements: []
71
76
 
72
77
  rubyforge_project:
73
- rubygems_version: 1.3.6
78
+ rubygems_version: 1.3.7
74
79
  signing_key:
75
80
  specification_version: 3
76
81
  summary: A class based config mixin, similar to the one found in Chef.