configure_me 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -1
- data/{README.md → README.rdoc} +7 -7
- data/Rakefile +1 -7
- data/configure_me.gemspec +3 -7
- data/lib/configure_me/attribute_methods.rb +88 -0
- data/lib/configure_me/base.rb +58 -62
- data/lib/configure_me/caching.rb +19 -14
- data/lib/configure_me/identity.rb +15 -0
- data/lib/configure_me/loading.rb +57 -0
- data/lib/configure_me/naming.rb +18 -0
- data/lib/configure_me/nesting.rb +30 -24
- data/lib/configure_me/persistence.rb +29 -0
- data/lib/configure_me/persisting.rb +33 -20
- data/lib/configure_me/setting.rb +61 -12
- data/lib/configure_me/validations.rb +33 -0
- data/lib/configure_me/version.rb +1 -1
- data/lib/configure_me.rb +25 -3
- data/lib/generators/configure_me/setup_generator.rb +21 -0
- data/lib/generators/configure_me/templates/initializer.rb +1 -0
- data/lib/generators/{templates → configure_me/templates}/migration.rb +0 -0
- data/lib/generators/{templates/model.rb → configure_me/templates/model.erb} +0 -0
- data/lib/generators/configure_me/templates/model.rb +2 -0
- data/spec/configure_me/attribute_methods_spec.rb +113 -0
- data/spec/configure_me/base_spec.rb +43 -88
- data/spec/configure_me/caching_spec.rb +75 -0
- data/spec/configure_me/identity_spec.rb +30 -0
- data/spec/configure_me/loading_spec.rb +84 -0
- data/spec/configure_me/naming_spec.rb +23 -0
- data/spec/configure_me/nesting_spec.rb +36 -0
- data/spec/configure_me/persistence_spec.rb +62 -0
- data/spec/configure_me/persisting_spec.rb +123 -0
- data/spec/configure_me/setting_spec.rb +180 -13
- data/spec/spec_helper.rb +6 -0
- data/spec/support/active_model_lint.rb +16 -0
- metadata +52 -81
- data/features/memory.feature +0 -16
- data/features/step_definitions/base_steps.rb +0 -33
- data/lib/configure_me/settings.rb +0 -101
- data/lib/generators/configure_me_generator.rb +0 -19
- data/lib/generators/templates/initializer.rb +0 -1
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ConfigureMe::Nesting, 'the class' do
|
4
|
+
subject { ConfigureMe::Base }
|
5
|
+
it { should respond_to(:nest_me) }
|
6
|
+
end
|
7
|
+
|
8
|
+
describe ConfigureMe::Nesting do
|
9
|
+
before {
|
10
|
+
@parent_class = define_test_class('ParentConfig', ConfigureMe::Base)
|
11
|
+
@nested_class = define_test_class('NestedConfig', ConfigureMe::Base)
|
12
|
+
@parent_config = @parent_class.instance
|
13
|
+
@nested_config = @nested_class.instance
|
14
|
+
@parent_class.stubs(:instance).returns(@parent_config)
|
15
|
+
@nested_class.stubs(:instance).returns(@nested_config)
|
16
|
+
@nested_class.send(:nest_me, @parent_class)
|
17
|
+
}
|
18
|
+
|
19
|
+
context 'a nested class' do
|
20
|
+
subject { @nested_config }
|
21
|
+
its(:children) { should be_empty }
|
22
|
+
its(:all_configs) { should have(1).items }
|
23
|
+
its(:parent_config) { should eql(@parent_config) }
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'a parent class' do
|
27
|
+
subject { @parent_config }
|
28
|
+
its(:children) { should have(1).items }
|
29
|
+
its(:children) { should eql(:nested => @nested_config) }
|
30
|
+
its(:all_configs) { should have(2).items }
|
31
|
+
its(:parent_config) { should be_nil }
|
32
|
+
it { should respond_to(:nested) }
|
33
|
+
its(:nested) { should eql(@nested_config) }
|
34
|
+
its(:class) { should respond_to(:nested) }
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ConfigureMe::Persistence do
|
4
|
+
before {
|
5
|
+
@persistence_class = define_test_class('PersistenceConfig', ConfigureMe::Base)
|
6
|
+
@config = @persistence_class.instance
|
7
|
+
}
|
8
|
+
subject { @config }
|
9
|
+
describe 'saving' do
|
10
|
+
before {
|
11
|
+
@config.stubs(:write_persist)
|
12
|
+
@config.stubs(:write_cache)
|
13
|
+
@config.stubs(:make_clean)
|
14
|
+
@temp_attrs = {:testsetting => 'newvalue'}
|
15
|
+
@config.stubs(:temp_attributes).returns(@temp_attrs)
|
16
|
+
@config.stubs(:persist_guard).yields
|
17
|
+
}
|
18
|
+
it 'should run callbacks' do
|
19
|
+
@config.expects(:run_callbacks).at_least_once.yields
|
20
|
+
@config.save
|
21
|
+
end
|
22
|
+
it 'should not run the validations if :validate => false is passed' do
|
23
|
+
@config.expects(:valid?).never
|
24
|
+
@config.save(:validate => false)
|
25
|
+
end
|
26
|
+
it 'should start a transaction' do
|
27
|
+
@config.expects(:persist_guard)
|
28
|
+
@config.save
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should persist the temp settings' do
|
32
|
+
@config.expects(:write_persist).with(:testsetting, 'newvalue')
|
33
|
+
@config.save
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should cache the temp settings' do
|
37
|
+
@config.expects(:write_cache).with(:testsetting, 'newvalue')
|
38
|
+
@config.save
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should clear the dirty status' do
|
42
|
+
@config.expects(:make_clean)
|
43
|
+
@config.save
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'update_attributes' do
|
48
|
+
before {
|
49
|
+
@config.stubs(:write_attribute)
|
50
|
+
}
|
51
|
+
it 'should store the new attributes' do
|
52
|
+
@config.stubs(:save)
|
53
|
+
@config.expects(:write_attribute).with(:testsetting, 'updatedvalue')
|
54
|
+
@config.update_attributes(:testsetting => 'updatedvalue')
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should attempt to save' do
|
58
|
+
@config.expects(:save)
|
59
|
+
@config.update_attributes(:testsetting => 'updatedvalue')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ConfigureMe::Persisting, 'the class' do
|
4
|
+
subject { ConfigureMe::Base }
|
5
|
+
it { should respond_to(:persist_me) }
|
6
|
+
it { should respond_to(:persisting?) }
|
7
|
+
|
8
|
+
context 'when the persistence_klass is nil' do
|
9
|
+
before {
|
10
|
+
@persisting_klass = define_test_class('PersistingConfig', ConfigureMe::Base)
|
11
|
+
@persisting_klass.send(:persist_me)
|
12
|
+
ConfigureMe.stubs(:persistence_klass).returns(nil)
|
13
|
+
}
|
14
|
+
subject { @persisting_klass }
|
15
|
+
its(:persisting?) { should be_false }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'persist_guard' do
|
19
|
+
before {
|
20
|
+
@persisting_klass = define_test_class('PersistingConfig', ConfigureMe::Base)
|
21
|
+
}
|
22
|
+
subject { @persisting_klass.instance }
|
23
|
+
context 'when transactions are supported' do
|
24
|
+
it 'should begin a transaction' do
|
25
|
+
@transaction_class = mock('TransactionClass') do
|
26
|
+
stubs(:transaction)
|
27
|
+
end
|
28
|
+
ConfigureMe.stubs(:persistence_klass).returns(@transaction_class)
|
29
|
+
@transaction_class.expects(:transaction)
|
30
|
+
subject.persist_guard
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when persisting with something else' do
|
35
|
+
it 'should just execute the block' do
|
36
|
+
@non_transaction_class = mock('NonTransactionClass')
|
37
|
+
ConfigureMe.stubs(:persistence_klass).returns(@non_transaction_class)
|
38
|
+
@testvalue = 'default'
|
39
|
+
subject.persist_guard do
|
40
|
+
@testvalue = 'changed'
|
41
|
+
end
|
42
|
+
@testvalue.should eql('changed')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe ConfigureMe::Persisting, 'when persisting is enabled' do
|
49
|
+
before {
|
50
|
+
@persisting_class = define_test_class('PersistingConfig', ConfigureMe::Base)
|
51
|
+
@persisted_setting = mock('PersistedSetting') do
|
52
|
+
stubs(:value).returns('foo'.to_yaml)
|
53
|
+
stubs(:value=)
|
54
|
+
stubs(:save!)
|
55
|
+
end
|
56
|
+
@persistence_klass = mock('PersistenceKlass')
|
57
|
+
@persistence_klass.stubs(:find_or_create_by_key).returns(@persisted_setting)
|
58
|
+
@persistence_klass.stubs(:find_by_key).returns(@persisted_setting)
|
59
|
+
ConfigureMe.stubs(:persistence_klass).returns(@persistence_klass)
|
60
|
+
@persisting_class.send(:persist_me)
|
61
|
+
}
|
62
|
+
subject { @persisting_class.instance }
|
63
|
+
|
64
|
+
describe 'read_persist' do
|
65
|
+
it 'should read from the persistence store' do
|
66
|
+
@persistence_klass.expects(:find_by_key).once.returns(@persisted_setting)
|
67
|
+
subject.read_persist('persistedsetting')
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'with a persisted value' do
|
71
|
+
it 'should return the converted value' do
|
72
|
+
subject.read_persist('persistedsetting').should eql('foo')
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'with a non-persisted value' do
|
77
|
+
it 'should return nil' do
|
78
|
+
@persistence_klass.stubs(:find_by_key).returns(nil)
|
79
|
+
subject.read_persist('persistedsetting').should be_nil
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe 'write_persist' do
|
85
|
+
it 'should retrieve or create the setting' do
|
86
|
+
@persistence_klass.expects(:find_or_create_by_key).once.returns(@persisted_setting)
|
87
|
+
subject.write_persist('persistedsetting', 'newvalue')
|
88
|
+
end
|
89
|
+
it 'should update the value' do
|
90
|
+
@persisted_setting.expects(:value=).with('newvalue'.to_yaml)
|
91
|
+
subject.write_persist('persistedsetting', 'newvalue')
|
92
|
+
end
|
93
|
+
it 'should save the record' do
|
94
|
+
@persisted_setting.expects(:save!)
|
95
|
+
subject.write_persist('persistedsetting', 'newvalue')
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe ConfigureMe::Persisting, 'when persisting is disabled' do
|
101
|
+
before {
|
102
|
+
@persisting_class = define_test_class('PersistingConfig', ConfigureMe::Base)
|
103
|
+
@persisting_class.stubs(:persisting?).returns(false)
|
104
|
+
}
|
105
|
+
subject { @persisting_class.instance }
|
106
|
+
|
107
|
+
describe 'read_persist' do
|
108
|
+
it 'should not attempt to read from the persistence store' do
|
109
|
+
ConfigureMe.expects(:persistence_klass).never
|
110
|
+
subject.read_persist('persistedsetting')
|
111
|
+
end
|
112
|
+
it 'should return nil' do
|
113
|
+
subject.read_persist('persistedsetting').should be_nil
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe 'write_persist' do
|
118
|
+
it 'should not attempt to write to the persistence store' do
|
119
|
+
ConfigureMe.expects(:persistence_klass).never
|
120
|
+
subject.write_persist('persistedsetting', 'newvalue')
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -1,23 +1,190 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ConfigureMe::Setting do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
|
5
|
+
def mock_setting(name, *args)
|
6
|
+
ConfigureMe::Setting.new(name, *args)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'an instance' do
|
10
|
+
subject do
|
11
|
+
mock_setting(:foo, :type => :string, :default => 'bar')
|
12
|
+
end
|
13
|
+
it { should respond_to(:name) }
|
14
|
+
it { should respond_to(:type) }
|
15
|
+
it { should respond_to(:default) }
|
16
|
+
its(:name) { should eql('foo') }
|
17
|
+
its(:type) { should eql(:string) }
|
18
|
+
its(:default) { should eql('bar') }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'inferring the type' do
|
22
|
+
context 'with a string default value' do
|
23
|
+
subject do
|
24
|
+
mock_setting(:foo, :default => 'stringvalue')
|
25
|
+
end
|
26
|
+
its(:type) { should eql(:string) }
|
27
|
+
its(:default) { should eql('stringvalue') }
|
28
|
+
end
|
29
|
+
context 'with a numeric default value' do
|
30
|
+
subject do
|
31
|
+
mock_setting(:foo, :default => 123)
|
32
|
+
end
|
33
|
+
its(:type) { should eql(:integer) }
|
34
|
+
its(:default) { should eql(123) }
|
35
|
+
end
|
36
|
+
context 'with a float default value' do
|
37
|
+
subject do
|
38
|
+
mock_setting(:foo, :default => 1.23)
|
39
|
+
end
|
40
|
+
its(:type) { should eql(:float) }
|
41
|
+
its(:default) { should eql(1.23) }
|
42
|
+
end
|
43
|
+
context 'with a boolean default value' do
|
44
|
+
subject do
|
45
|
+
mock_setting(:foo, :default => true)
|
46
|
+
end
|
47
|
+
its(:type) { should eql(:boolean) }
|
48
|
+
its(:default) { should eql(true) }
|
49
|
+
end
|
50
|
+
context 'with a nil default value' do
|
51
|
+
subject do
|
52
|
+
mock_setting(:foo, :default => nil)
|
53
|
+
end
|
54
|
+
its(:type) { should eql(:unknown) }
|
55
|
+
its(:default) { should be_nil }
|
56
|
+
end
|
57
|
+
context 'with an unsupported default value' do
|
58
|
+
it 'should raise an exception' do
|
59
|
+
lambda {
|
60
|
+
ConfigureMe::Setting.new(:foo, :default => {:invalid => 'hash'})
|
61
|
+
}.should raise_error(ConfigureMe::InvalidDefault)
|
62
|
+
end
|
7
63
|
end
|
8
|
-
@setting = ConfigureMe::Setting.new(@owner, :foo, :string, :default => 'bar')
|
9
64
|
end
|
10
65
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
66
|
+
describe 'convert' do
|
67
|
+
before(:each) do
|
68
|
+
@string_setting = mock_setting(:stringsetting, :type => :string)
|
69
|
+
@integer_setting = mock_setting(:integersetting, :type => :integer)
|
70
|
+
@float_setting = mock_setting(:floatsetting, :type => :float)
|
71
|
+
@boolean_setting = mock_setting(:booleansetting, :type => :boolean)
|
72
|
+
end
|
73
|
+
context 'an empty string' do
|
74
|
+
it 'should return "" with a string type' do
|
75
|
+
@string_setting.convert('').should eql('')
|
76
|
+
end
|
77
|
+
it 'should return 0 with an integer type' do
|
78
|
+
@integer_setting.convert('').should eql(0)
|
79
|
+
end
|
80
|
+
it 'should return 0.0 with a float type' do
|
81
|
+
@float_setting.convert('').should eql(0.0)
|
82
|
+
end
|
83
|
+
it 'should return nil with a boolean type' do
|
84
|
+
@boolean_setting.convert('').should be_nil
|
85
|
+
end
|
86
|
+
end
|
87
|
+
context 'a string value of "foo"' do
|
88
|
+
it 'should return "foo" with a string type' do
|
89
|
+
@string_setting.convert('foo').should eql('foo')
|
90
|
+
end
|
91
|
+
it 'should return 0 with an integer type' do
|
92
|
+
@integer_setting.convert('foo').should eql(0)
|
93
|
+
end
|
94
|
+
it 'should return 0.0 with a float type' do
|
95
|
+
@float_setting.convert('foo').should eql(0.0)
|
96
|
+
end
|
97
|
+
it 'should return false with a boolean type' do
|
98
|
+
@boolean_setting.convert('foo').should be_false
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'an integer value of 123' do
|
103
|
+
it 'should return "123" with a string type' do
|
104
|
+
@string_setting.convert(123).should eql('123')
|
105
|
+
end
|
106
|
+
it 'should return 123 with an integer type' do
|
107
|
+
@integer_setting.convert(123).should eql(123)
|
108
|
+
end
|
109
|
+
it 'should return 123.0 with a float type' do
|
110
|
+
@float_setting.convert(123).should eql(123.0)
|
111
|
+
end
|
112
|
+
it 'should return false with a boolean type' do
|
113
|
+
@boolean_setting.convert(123).should be_false
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'a float value of 1.23' do
|
118
|
+
it 'should return "1.23" with a string type' do
|
119
|
+
@string_setting.convert(1.23).should eql('1.23')
|
120
|
+
end
|
121
|
+
it 'should return 1 with an integer type' do
|
122
|
+
@integer_setting.convert(1.23).should eql(1)
|
123
|
+
end
|
124
|
+
it 'should return 1.23 with a float type' do
|
125
|
+
@float_setting.convert(1.23).should eql(1.23)
|
126
|
+
end
|
127
|
+
it 'should return false with a boolean type' do
|
128
|
+
@boolean_setting.convert(1.23).should be_false
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
context 'a boolean value of true' do
|
133
|
+
it 'should return "true" with a string type' do
|
134
|
+
@string_setting.convert(true).should eql('true')
|
135
|
+
end
|
136
|
+
it 'should return 1 with an integer type' do
|
137
|
+
@integer_setting.convert(true).should eql(1)
|
138
|
+
end
|
139
|
+
it 'should return 1.0 with a float type' do
|
140
|
+
@float_setting.convert(true).should eql(1.0)
|
141
|
+
end
|
142
|
+
it 'should return true with a boolean type' do
|
143
|
+
@boolean_setting.convert(true).should be_true
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'a nil value' do
|
148
|
+
it 'should return "" with a string type' do
|
149
|
+
@string_setting.convert(nil).should eql('')
|
150
|
+
end
|
151
|
+
it 'should return 0 with an integer type' do
|
152
|
+
@integer_setting.convert(nil).should eql(0)
|
153
|
+
end
|
154
|
+
it 'should return 0.0 with a float type' do
|
155
|
+
@float_setting.convert(nil).should eql(0.0)
|
156
|
+
end
|
157
|
+
it 'should return false with a boolean type' do
|
158
|
+
@boolean_setting.convert(nil).should be_false
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe 'to string with an unsupported type' do
|
163
|
+
it 'should raise InvalidConversion' do
|
164
|
+
lambda { @string_setting.convert([]) }.should raise_error(ConfigureMe::InvalidConversion)
|
165
|
+
end
|
166
|
+
end
|
15
167
|
|
16
|
-
|
17
|
-
|
18
|
-
|
168
|
+
describe 'with an unknown type' do
|
169
|
+
before(:each) do
|
170
|
+
@unknown = mock_setting(:unknownsetting, :default => nil)
|
171
|
+
end
|
172
|
+
it 'should set the type to :string when a string value is converted' do
|
173
|
+
@unknown.convert('string')
|
174
|
+
@unknown.type.should eql(:string)
|
175
|
+
end
|
176
|
+
it 'should set the type to :integer when an integer value is converted' do
|
177
|
+
@unknown.convert(123)
|
178
|
+
@unknown.type.should eql(:integer)
|
179
|
+
end
|
180
|
+
it 'should set the type to :float when a float value is converted' do
|
181
|
+
@unknown.convert(1.23)
|
182
|
+
@unknown.type.should eql(:float)
|
183
|
+
end
|
184
|
+
it 'should set the type to :boolean when a boolean value is converted' do
|
185
|
+
@unknown.convert(true)
|
186
|
+
@unknown.type.should eql(:boolean)
|
187
|
+
end
|
19
188
|
end
|
20
|
-
setting = ConfigureMe::Setting.new(owner, :foo, :string, :default => 'bar')
|
21
|
-
setting.define_methods!
|
22
189
|
end
|
23
190
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,9 +2,15 @@ require 'rubygems'
|
|
2
2
|
require 'bundler/setup'
|
3
3
|
Bundler.require(:default)
|
4
4
|
require 'rspec/core'
|
5
|
+
require 'support/active_model_lint'
|
5
6
|
|
6
7
|
require 'configure_me'
|
7
8
|
|
8
9
|
RSpec.configure do |config|
|
9
10
|
config.mock_with :mocha
|
10
11
|
end
|
12
|
+
|
13
|
+
def define_test_class(name, base)
|
14
|
+
Object.send(:remove_const, name.to_sym) if Object.const_defined?(name)
|
15
|
+
Object.const_set(name, Class.new(base))
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
shared_examples_for "ActiveModel" do
|
2
|
+
require 'test/unit/assertions'
|
3
|
+
include ActiveModel::Lint::Tests
|
4
|
+
include Test::Unit::Assertions
|
5
|
+
|
6
|
+
# to_s is to support ruby-1.9
|
7
|
+
ActiveModel::Lint::Tests.public_instance_methods.map{|m| m.to_s}.grep(/^test/).each do |m|
|
8
|
+
example m.gsub('_',' ') do
|
9
|
+
send m
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def model
|
14
|
+
subject
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: configure_me
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 15
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Josh Williams
|
@@ -15,61 +15,44 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-05-16 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
21
|
+
name: rails
|
23
22
|
prerelease: false
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
24
|
none: false
|
26
25
|
requirements:
|
27
|
-
- -
|
26
|
+
- - "="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
28
|
+
hash: 1
|
30
29
|
segments:
|
31
30
|
- 3
|
32
31
|
- 0
|
33
|
-
- 1
|
34
|
-
version: 3.0.1
|
35
|
-
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: activesupport
|
39
|
-
prerelease: false
|
40
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 5
|
46
|
-
segments:
|
47
32
|
- 3
|
48
|
-
|
49
|
-
- 1
|
50
|
-
version: 3.0.1
|
33
|
+
version: 3.0.3
|
51
34
|
type: :runtime
|
52
|
-
version_requirements: *
|
35
|
+
version_requirements: *id001
|
53
36
|
- !ruby/object:Gem::Dependency
|
54
37
|
name: rspec
|
55
38
|
prerelease: false
|
56
|
-
requirement: &
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
57
40
|
none: false
|
58
41
|
requirements:
|
59
42
|
- - ~>
|
60
43
|
- !ruby/object:Gem::Version
|
61
|
-
hash:
|
44
|
+
hash: 7
|
62
45
|
segments:
|
63
46
|
- 2
|
47
|
+
- 2
|
64
48
|
- 0
|
65
|
-
|
66
|
-
version: 2.0.1
|
49
|
+
version: 2.2.0
|
67
50
|
type: :development
|
68
|
-
version_requirements: *
|
51
|
+
version_requirements: *id002
|
69
52
|
- !ruby/object:Gem::Dependency
|
70
53
|
name: rcov
|
71
54
|
prerelease: false
|
72
|
-
requirement: &
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
73
56
|
none: false
|
74
57
|
requirements:
|
75
58
|
- - ~>
|
@@ -81,11 +64,11 @@ dependencies:
|
|
81
64
|
- 9
|
82
65
|
version: 0.9.9
|
83
66
|
type: :development
|
84
|
-
version_requirements: *
|
67
|
+
version_requirements: *id003
|
85
68
|
- !ruby/object:Gem::Dependency
|
86
69
|
name: mocha
|
87
70
|
prerelease: false
|
88
|
-
requirement: &
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
89
72
|
none: false
|
90
73
|
requirements:
|
91
74
|
- - ~>
|
@@ -97,39 +80,7 @@ dependencies:
|
|
97
80
|
- 8
|
98
81
|
version: 0.9.8
|
99
82
|
type: :development
|
100
|
-
version_requirements: *
|
101
|
-
- !ruby/object:Gem::Dependency
|
102
|
-
name: cucumber
|
103
|
-
prerelease: false
|
104
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ~>
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
hash: 51
|
110
|
-
segments:
|
111
|
-
- 0
|
112
|
-
- 9
|
113
|
-
- 4
|
114
|
-
version: 0.9.4
|
115
|
-
type: :development
|
116
|
-
version_requirements: *id006
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: activerecord
|
119
|
-
prerelease: false
|
120
|
-
requirement: &id007 !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - ~>
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
hash: 5
|
126
|
-
segments:
|
127
|
-
- 3
|
128
|
-
- 0
|
129
|
-
- 1
|
130
|
-
version: 3.0.1
|
131
|
-
type: :development
|
132
|
-
version_requirements: *id007
|
83
|
+
version_requirements: *id004
|
133
84
|
description: Simple gem to assist with persisting configuration data.
|
134
85
|
email:
|
135
86
|
- theprime@codingprime.com
|
@@ -143,27 +94,39 @@ files:
|
|
143
94
|
- .gitignore
|
144
95
|
- .rspec
|
145
96
|
- Gemfile
|
146
|
-
- README.
|
97
|
+
- README.rdoc
|
147
98
|
- Rakefile
|
148
99
|
- configure_me.gemspec
|
149
|
-
- features/memory.feature
|
150
|
-
- features/step_definitions/base_steps.rb
|
151
100
|
- lib/configure_me.rb
|
101
|
+
- lib/configure_me/attribute_methods.rb
|
152
102
|
- lib/configure_me/base.rb
|
153
103
|
- lib/configure_me/caching.rb
|
104
|
+
- lib/configure_me/identity.rb
|
105
|
+
- lib/configure_me/loading.rb
|
106
|
+
- lib/configure_me/naming.rb
|
154
107
|
- lib/configure_me/nesting.rb
|
108
|
+
- lib/configure_me/persistence.rb
|
155
109
|
- lib/configure_me/persisting.rb
|
156
110
|
- lib/configure_me/setting.rb
|
157
|
-
- lib/configure_me/
|
111
|
+
- lib/configure_me/validations.rb
|
158
112
|
- lib/configure_me/version.rb
|
159
|
-
- lib/generators/
|
160
|
-
- lib/generators/templates/initializer.rb
|
161
|
-
- lib/generators/templates/migration.rb
|
162
|
-
- lib/generators/templates/model.
|
113
|
+
- lib/generators/configure_me/setup_generator.rb
|
114
|
+
- lib/generators/configure_me/templates/initializer.rb
|
115
|
+
- lib/generators/configure_me/templates/migration.rb
|
116
|
+
- lib/generators/configure_me/templates/model.erb
|
117
|
+
- lib/generators/configure_me/templates/model.rb
|
118
|
+
- spec/configure_me/attribute_methods_spec.rb
|
163
119
|
- spec/configure_me/base_spec.rb
|
120
|
+
- spec/configure_me/caching_spec.rb
|
121
|
+
- spec/configure_me/identity_spec.rb
|
122
|
+
- spec/configure_me/loading_spec.rb
|
123
|
+
- spec/configure_me/naming_spec.rb
|
124
|
+
- spec/configure_me/nesting_spec.rb
|
125
|
+
- spec/configure_me/persistence_spec.rb
|
126
|
+
- spec/configure_me/persisting_spec.rb
|
164
127
|
- spec/configure_me/setting_spec.rb
|
165
128
|
- spec/spec_helper.rb
|
166
|
-
|
129
|
+
- spec/support/active_model_lint.rb
|
167
130
|
homepage: http://www.github.com/t3hpr1m3/configure_me
|
168
131
|
licenses: []
|
169
132
|
|
@@ -193,13 +156,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
156
|
requirements: []
|
194
157
|
|
195
158
|
rubyforge_project: configure_me
|
196
|
-
rubygems_version: 1.
|
159
|
+
rubygems_version: 1.7.2
|
197
160
|
signing_key:
|
198
161
|
specification_version: 3
|
199
162
|
summary: Simple configuration library
|
200
163
|
test_files:
|
201
|
-
-
|
202
|
-
- features/step_definitions/base_steps.rb
|
164
|
+
- spec/configure_me/attribute_methods_spec.rb
|
203
165
|
- spec/configure_me/base_spec.rb
|
166
|
+
- spec/configure_me/caching_spec.rb
|
167
|
+
- spec/configure_me/identity_spec.rb
|
168
|
+
- spec/configure_me/loading_spec.rb
|
169
|
+
- spec/configure_me/naming_spec.rb
|
170
|
+
- spec/configure_me/nesting_spec.rb
|
171
|
+
- spec/configure_me/persistence_spec.rb
|
172
|
+
- spec/configure_me/persisting_spec.rb
|
204
173
|
- spec/configure_me/setting_spec.rb
|
205
174
|
- spec/spec_helper.rb
|
175
|
+
- spec/support/active_model_lint.rb
|
176
|
+
has_rdoc:
|
data/features/memory.feature
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
Feature: Store configuration in memory
|
2
|
-
In order to store configuration information
|
3
|
-
As a ruby developer
|
4
|
-
I want to create a configuration class that stores settings in memory
|
5
|
-
|
6
|
-
Scenario: Simple configuration object
|
7
|
-
Given a Configuration class that derives from ConfigureMe::Base
|
8
|
-
And I add a "color" setting with a type of "string" and a default of "red"
|
9
|
-
When I create an instance of the class
|
10
|
-
And I read the "color" setting
|
11
|
-
Then the result should be "red"
|
12
|
-
|
13
|
-
When I set the "color" setting to "blue"
|
14
|
-
And I read the "color" setting
|
15
|
-
Then the result should be "blue"
|
16
|
-
|