breadboard 0.2.0 → 1.0.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ *.sw?
2
+ pkg/*
3
+ *.gemspec
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm gemset use breadboard
@@ -0,0 +1,8 @@
1
+ v0.2.0
2
+ Rails 3 compatible! thx Dorren Chen!
3
+
4
+ v0.1.0
5
+ beta version. works on actual rails sites.
6
+
7
+ v0.0.2
8
+ now honors site settings that have already been configured in your activeresource derived model
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,46 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ breadboard (1.0.0)
5
+ activeresource (~> 3.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ activemodel (3.0.7)
11
+ activesupport (= 3.0.7)
12
+ builder (~> 2.1.2)
13
+ i18n (~> 0.5.0)
14
+ activeresource (3.0.7)
15
+ activemodel (= 3.0.7)
16
+ activesupport (= 3.0.7)
17
+ activesupport (3.0.7)
18
+ builder (2.1.2)
19
+ cucumber (0.10.2)
20
+ builder (>= 2.1.2)
21
+ diff-lcs (>= 1.1.2)
22
+ gherkin (>= 2.3.5)
23
+ json (>= 1.4.6)
24
+ term-ansicolor (>= 1.0.5)
25
+ diff-lcs (1.1.2)
26
+ gherkin (2.3.6)
27
+ json (>= 1.4.6)
28
+ i18n (0.5.0)
29
+ json (1.5.1)
30
+ rspec (2.4.0)
31
+ rspec-core (~> 2.4.0)
32
+ rspec-expectations (~> 2.4.0)
33
+ rspec-mocks (~> 2.4.0)
34
+ rspec-core (2.4.0)
35
+ rspec-expectations (2.4.0)
36
+ diff-lcs (~> 1.1.2)
37
+ rspec-mocks (2.4.0)
38
+ term-ansicolor (1.0.5)
39
+
40
+ PLATFORMS
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ breadboard!
45
+ cucumber (~> 0.10.0)
46
+ rspec (~> 2.4.0)
@@ -0,0 +1,103 @@
1
+ This software is PUBLIC DOMAIN
2
+
3
+
4
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
5
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
6
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
7
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
8
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
9
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;iiii;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
10
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;ijffffffffffffffffji;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
11
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;iffffffffffffffffffffffffffi;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
12
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, iffffffffffffffffffffffffffffffi ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
13
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,ijffffffffffffffffffffffffffffffffffji,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
14
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,iffffffffffffffffffffffffffffffffffffffffi,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
15
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,jffffffffffffffffffffffffffffffffffffffffffffj,,,,,,,,,,,,,,,,,,,,,,,,,,,
16
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,tfffffffffffffffffffffffffffffffffffffffffffffft,,,,,,,,,,,,,,,,,,,,,,,,,,
17
+ ,,,,,,,,,,,,,,,,,,,,,,,,;ffffffffffffffffffffffffffffffffffffffffffffffffff;,,,,,,,,,,,,,,,,,,,,,,,,
18
+ ,,,,,,,,,,,,,,,,,,,,,,,ffffffffffffffffffffffjt;;,,;;tjffffffffffffffffffffff,,,,,,,,,,,,,,,,,,,,,,,
19
+ ,,,,,,,,,,,,,,,,,,,,,;fffffffffffffffffft: :tffffffffffffffffff;,,,,,,,,,,,,,,,,,,,,,
20
+ ,,,,,,,,,,,,,,,,,,,,,jfffffffffffffffft. .tffffffffffffffffj,,,,,,,,,,,,,,,,,,,,,
21
+ ,,,,,,,,,,,,,,,,,,,ifffffffffffffffi: :ifffffffffffffffi,,,,,,,,,,,,,,,,,,,
22
+ ,,,,,,,,,,,,,,,,,,tffffffffffffffi ifffffffffffffft,,,,,,,,,,,,,,,,,,
23
+ ,,,,,,,,,,,,,,,,,ifffffffffffff, ,fffffffffffffi,,,,,,,,,,,,,,,,,
24
+ ,,,,,,,,,,,,,,,,,fffffffffffffi ifffffffffffff,,,,,,,,,,,,,,,,,
25
+ ,,,,,,,,,,,,,,,;jffffffffffff ffffffffffffj;,,,,,,,,,,,,,,,
26
+ ,,,,,,,,,,,,,,,ffffffffffff: jffffffffffffff,,,,,,,,,,,,,,,
27
+ ,,,,,,,,,,,,,,ffffffffffff. jffffffffffffffff,,,,,,,,,,,,,,
28
+ ,,,,,,,,,,,,,;ffffffffffft :fffffffffffffffff;,,,,,,,,,,,,,
29
+ ,,,,,,,,,,,,,ffffffffffft ,tfffffft; jfffffffffffffffffff,,,,,,,,,,,,,
30
+ ,,,,,,,,,,,,tffffffffff. ;ffffffffffffffff; jfffffffffffffffffffft,,,,,,,,,,,,
31
+ ,,,,,,,,,,,jffffffffff: ,ffffffffffffffffffffff, jffffffffffffffffffffffj,,,,,,,,,,,
32
+ ,,,,,,,,,,,fffffffffff :ffffffffffffffffffffffff: :ffffffffffffffffffffffff,,,,,,,,,,,
33
+ ,,,,,,,,,,iffffffffff ,jfffffffffffffffffffffffff jfffffffffffffffffffffffffi,,,,,,,,,,
34
+ ,,,,,,,,,,ffffffffffi tffffffffffffffffffffffffff jfffffffffffffff iffffffffff,,,,,,,,,,
35
+ ,,,,,,,,,ifffffffff, jfffffffffffffffffffffffff, jfffffffffffffff ,fffffffffi,,,,,,,,,
36
+ ,,,,,,,,,jfffffffff :ffffffffffffffffffffffffff :fffffffffffffff; fffffffffj,,,,,,,,,
37
+ ,,,,,,,, fffffffffi jffffffffffffffffffffffffff jfffffffffffffff ifffffffff ,,,,,,,,
38
+ ,,,,,,,,ifffffffff tffffffffffffffffffffffffff jfffffffffffffff fffffffffi,,,,,,,,
39
+ ,,,,,,,;fffffffffi :fffffffffffffffffffffffff, jfffffffffffffff ifffffffff;,,,,,,,
40
+ ,,,,,,,ifffffffff: jfffffffffffffffffffffffff :fffffffffffffff; :fffffffffi,,,,,,,
41
+ ,,,,,,,ffffffffff :fffffffffffffffffffffffff jfffffffffffffff ffffffffff,,,,,,,
42
+ ,,,,,,,ffffffffft ,fffffffffffffffff; jfffffffffffffff t, tfffffffff,,,,,,,
43
+ ,,,,,,;fffffffff ffffffffffffffff jfffffffffffffff tff fffffffff;,,,,,,
44
+ ,,,,,,ifffffffft fffffffffffffff, :fffffffffffffff;.fff tffffffffi,,,,,,
45
+ ,,,,,,jffffffff: ;ffffffffffffff. jfffffffffffffff .ffff; :ffffffffj,,,,,,
46
+ ,,,,,,fffffffff ffffffffffffff, jfffffffffffffff tffffff fffffffff,,,,,,
47
+ ,,,,,,fffffffff fffffffffffff jfffffffffffffff tfffffff fffffffff,,,,,,
48
+ ,,,,,,fffffffff fffffffffffff :fffffffffffffff; ........ fffffffff,,,,,,
49
+ ,,,,,;ffffffffj ,ffffffffffff; jfffffffffffffff jffffffff;,,,,,
50
+ ,,,,,;ffffffffi tffffffffffff jfffffffffffffff iffffffff;,,,,,
51
+ ,,,,,;ffffffff; fffffffffffff jfffffffffffffff ;ffffffff;,,,,,
52
+ ,,,,,;ffffffff; fffffffffffff :fffffffffffffff; ;ffffffff;,,,,,
53
+ ,,,,,iffffffff, fffffffffffff jfffffffffffffff ,ffffffffi,,,,,
54
+ ,,,,,iffffffff, fffffffffffff jfffffffffffffff ,ffffffffi,,,,,
55
+ ,,,,,;ffffffff; fffffffffffff jfffffffffffffff ;ffffffff;,,,,,
56
+ ,,,,,;ffffffff; fffffffffffff :fffffffffffffff; ;ffffffff;,,,,,
57
+ ,,,,,;ffffffffi tffffffffffff jfffffffffffffff iffffffff;,,,,,
58
+ ,,,,,;ffffffffj ,fffffffffff jfffffffffffffff jffffffff;,,,,,
59
+ ,,,,,,fffffffff fffffffff, jfffffffffffffff jjjjjjjjjjjjj fffffffff,,,,,,
60
+ ,,,,,,fffffffff fffffffff :fffffffffffffff; .fffffffffffff fffffffff,,,,,,
61
+ ,,,,,,fffffffff ffffffff jfffffffffffffff ,ffffffffffffff fffffffff,,,,,,
62
+ ,,,,,,jffffffff: ;ffffff jfffffffffffffff .ffffffffffffff; :ffffffffj,,,,,,
63
+ ,,,,,,ifffffffft ffff, jfffffffffffffff ,fffffffffffffff tffffffffi,,,,,,
64
+ ,,,,,,;fffffffff ffff :fffffffffffffff; ffffffffffffffff fffffffff;,,,,,,
65
+ ,,,,,,,ffffffffft ,ff jfffffffffffffff ifffffffffffffffff, tfffffffff,,,,,,,
66
+ ,,,,,,,ffffffffff : jfffffffffffffff tfffffffffffffffffffffff: ffffffffff,,,,,,,
67
+ ,,,,,,,ifffffffff: jfffffffffffffff tfffffffffffffffffffffffj :fffffffffi,,,,,,,
68
+ ,,,,,,,;fffffffffi :fffffffffffffff;.ffffffffffffffffffffffff: ifffffffff;,,,,,,,
69
+ ,,,,,,,,ifffffffff jfffffffffffffff .fffffffffffffffffffffffft fffffffffi,,,,,,,,
70
+ ,,,,,,,, fffffffffi jfffffffffffffff tffffffffffffffffffffffffj ifffffffff ,,,,,,,,
71
+ ,,,,,,,,,jfffffffff jfffffffffffffff tffffffffffffffffffffffff: fffffffffj,,,,,,,,,
72
+ ,,,,,,,,,ifffffffff, :fffffffffffffff;.ffffffffffffffffffffffffj ,fffffffffi,,,,,,,,,
73
+ ,,,,,,,,,,ffffffffffi jfffffffffffffff .fffffffffffffffffffffffft iffffffffff,,,,,,,,,,
74
+ ,,,,,,,,,,iffffffffff jfffffffffffffff tfffffffffffffffffffffffj, ffffffffffi,,,,,,,,,,
75
+ ,,,,,,,,,,,ffffffffffffffffffffffffff tfffffffffffffffffffffff: fffffffffff,,,,,,,,,,,
76
+ ,,,,,,,,,,,jffffffffffffffffffffffff; ,ffffffffffffffffffffff, :ffffffffffj,,,,,,,,,,,
77
+ ,,,,,,,,,,,,tffffffffffffffffffffff ;ffffffffffffffff; .fffffffffft,,,,,,,,,,,,
78
+ ,,,,,,,,,,,,,fffffffffffffffffffff ,tfffffft; tfffffffffff,,,,,,,,,,,,,
79
+ ,,,,,,,,,,,,,;fffffffffffffffffff tfffffffffff;,,,,,,,,,,,,,
80
+ ,,,,,,,,,,,,,,ffffffffffffffffff; .ffffffffffff,,,,,,,,,,,,,,
81
+ ,,,,,,,,,,,,,,,ffffffffffffffff :ffffffffffff,,,,,,,,,,,,,,,
82
+ ,,,,,,,,,,,,,,,;jfffffffffffff ffffffffffffj;,,,,,,,,,,,,,,,
83
+ ,,,,,,,,,,,,,,,,,fffffffffffffi ifffffffffffff,,,,,,,,,,,,,,,,,
84
+ ,,,,,,,,,,,,,,,,,ifffffffffffff, ,fffffffffffffi,,,,,,,,,,,,,,,,,
85
+ ,,,,,,,,,,,,,,,,,,tffffffffffffffi ifffffffffffffft,,,,,,,,,,,,,,,,,,
86
+ ,,,,,,,,,,,,,,,,,,,ifffffffffffffffi: :ifffffffffffffffi,,,,,,,,,,,,,,,,,,,
87
+ ,,,,,,,,,,,,,,,,,,,,,jfffffffffffffffft. .tffffffffffffffffj,,,,,,,,,,,,,,,,,,,,,
88
+ ,,,,,,,,,,,,,,,,,,,,,;fffffffffffffffffft: :tffffffffffffffffff;,,,,,,,,,,,,,,,,,,,,,
89
+ ,,,,,,,,,,,,,,,,,,,,,,,ffffffffffffffffffffffjt;;,,;;tjffffffffffffffffffffff,,,,,,,,,,,,,,,,,,,,,,,
90
+ ,,,,,,,,,,,,,,,,,,,,,,,,;ffffffffffffffffffffffffffffffffffffffffffffffffff;,,,,,,,,,,,,,,,,,,,,,,,,
91
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,tfffffffffffffffffffffffffffffffffffffffffffffft,,,,,,,,,,,,,,,,,,,,,,,,,,
92
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,jffffffffffffffffffffffffffffffffffffffffffffj,,,,,,,,,,,,,,,,,,,,,,,,,,,
93
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,iffffffffffffffffffffffffffffffffffffffffi,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
94
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,ijffffffffffffffffffffffffffffffffffji,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
95
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, iffffffffffffffffffffffffffffffi ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
96
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;iffffffffffffffffffffffffffi;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
97
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;ijffffffffffffffffji;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
98
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;iiii;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
99
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
100
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
101
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
102
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
103
+ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0.alpha.1
@@ -0,0 +1,62 @@
1
+ Feature: ActiveResource::Base looks up site config in breadboard
2
+
3
+ Scenario: Site configuration on the model itself takes highest precedence
4
+ Given an ActiveResource model with a site attribute
5
+ And a Breadboard configuration for that model
6
+ When I call the model's site method
7
+ Then I should recieve the value configured directly on the model
8
+ And ActiveResource should ignore the configuration in Breadboard
9
+
10
+ Scenario: Specific environment configuration for an exact model match in Breadboard should take the next highest precedence
11
+ Given an ActiveResource model without a site attribute
12
+ And a Breadboard configuration with 'production' environment settings for that model
13
+ And my Rails environment is "production"
14
+ When I call the model's site method
15
+ Then I should recieve the value configured in the Breadboard "production" environment settings for that model
16
+ And ActiveResource should ignore more generic configurations in Breadboard
17
+
18
+ Scenario: "all" configuration for an exact model match in Breadboard should take the next highest precedence
19
+ Given an ActiveResource model without a site attribute
20
+ And a Breadboard configuration with 'all' environment settings for that model
21
+ And my Rails environment is "production"
22
+ When I call the model's site method
23
+ Then I should recieve the value configured in the Breadboard "all" environment settings for that model
24
+ And ActiveResource should ignore more generic configurations in Breadboard
25
+
26
+ Scenario: Specific environment configuration in Breadboard for an ancestor of the model should take the next highest precedence
27
+ Given an ActiveResource model without a site attribute
28
+ And a Breadboard configuration with 'production' environment settings for an ancestor of that model
29
+ And my Rails environment is "production"
30
+ When I call the model's site method
31
+ Then I should recieve the value configured in the Breadboard "production" environment settings for the ancestor of that model
32
+ And ActiveResource should ignore more generic configurations in Breadboard
33
+
34
+ Scenario: "all" environment configuration in Breadboard for an ancestor of the model should take the next highest precedence
35
+ Given an ActiveResource model without a site attribute
36
+ And a Breadboard configuration with 'all' environment settings for an ancestor of that model
37
+ And my Rails environment is "production"
38
+ When I call the model's site method
39
+ Then I should recieve the value configured in the Breadboard "all" environment settings for the ancestor of that model
40
+ And ActiveResource should ignore more generic configurations in Breadboard
41
+
42
+ Scenario: Specific environment configuration in Breadboard set in the defaults should take the next highest precedence
43
+ Given an ActiveResource model without a site attribute
44
+ And a Breadboard configuration with 'production' environment settings in the breadboard defaults section
45
+ And my Rails environment is "production"
46
+ When I call the model's site method
47
+ Then I should recieve the value configured in the Breadboard "production" environment settings in the breadboard defaults section
48
+ And ActiveResource should ignore more generic configurations in Breadboard
49
+
50
+ Scenario: "all" configuration in Breadboard set in the defaults should take the next highest precedence
51
+ Given an ActiveResource model without a site attribute
52
+ And a Breadboard configuration with 'all' environment settings in the breadboard defaults section
53
+ And my Rails environment is "production"
54
+ When I call the model's site method
55
+ Then I should recieve the value configured in the Breadboard "all" environment settings in the breadboard defaults section
56
+
57
+ Scenario: no applicable configuration in Breadboard
58
+ Given an ActiveResource model without a site attribute
59
+ And an empty Breadboard configuration
60
+ And my Rails environment is "production"
61
+ When I call the model's site method
62
+ Then I should recieve an empty string
@@ -0,0 +1,28 @@
1
+ Feature: Configuring Breadboard
2
+ As a programmer
3
+ I want to be able to configure breadboard in ruby (not YAML)
4
+ So that my engines can each update the breadboard configuration
5
+
6
+ Scenario: Configure Breadboard with Ruby, not YAML
7
+ Given I have required breadboard
8
+ Then I should be able to configure breadboard via Ruby blocks
9
+
10
+ Scenario: default configuration
11
+ Given I have required breadboard
12
+ Then I should be able to create a default configuration via the "default" Config method
13
+
14
+ Scenario: configuring a model by lowercase methods
15
+ Given I have required breadboard
16
+ Then I should be able to configure models via their lowercased, underscored method equivalents
17
+
18
+ Scenario: configuring a model via the "model" method
19
+ Given I have required breadboard
20
+ Then I should be able to configure a model by passing the constant for the model to the "model" method
21
+
22
+ Scenario: configuring multiple models via the "models" method
23
+ Given I have required breadboard
24
+ Then I should be able to configure multiple models simultaneously by passing their constants to the "models" method
25
+
26
+ Scenario: configuring the method for determining the Rails environment
27
+ Given I have required breadboard
28
+ Then I should be able to override the default Rails.env environment retrieval in case I'm not in a rails app
@@ -0,0 +1,7 @@
1
+ Feature: Resetting Breadboard
2
+
3
+ Scenario: Resetting Breadboard should clear out all configuration data
4
+ Given I have required breadboard
5
+ And I have configured breadboard
6
+ When I call the method Breadboard.reset
7
+ Then the Breadboard configuration should be reset to an empty configuration
@@ -0,0 +1,159 @@
1
+ Given /^an ActiveResource model with a site attribute$/ do
2
+ class SomeModel < ActiveResource::Base
3
+ self.site = "http://set.on.model.com"
4
+ end
5
+ end
6
+
7
+ Given /^a Breadboard configuration for that model$/ do
8
+ Breadboard.configure do
9
+ model SomeModel do
10
+ all "http://set.in.breadboard.com"
11
+ end
12
+ end
13
+ end
14
+
15
+ When /^I call the model's site method$/ do
16
+ @site = SomeModel.site
17
+ end
18
+
19
+ Then /^I should recieve the value configured directly on the model$/ do
20
+ @site.to_s.should == "http://set.on.model.com"
21
+ end
22
+
23
+ Then /^ActiveResource should ignore the configuration in Breadboard$/ do
24
+ end
25
+
26
+ Given /^an ActiveResource model without a site attribute$/ do
27
+ class Parent < ActiveResource::Base; end
28
+ class NoSiteAttribute < Parent; end
29
+ end
30
+
31
+ Given /^a Breadboard configuration with 'production' environment settings for that model$/ do
32
+ Breadboard.configure do
33
+ model NoSiteAttribute do
34
+ production "http://set.in.breadboard.exact.match.com"
35
+ end
36
+
37
+ model Parent do
38
+ production "http://set.in.breadboard.on.parent.com"
39
+ end
40
+
41
+ default do
42
+ production "http://default.production.com"
43
+ all "http://default.all.com"
44
+ end
45
+ end
46
+ end
47
+
48
+ Given /^a Breadboard configuration with 'all' environment settings for that model$/ do
49
+ Breadboard.configure do
50
+ model NoSiteAttribute do
51
+ all "http://set.in.breadboard.exact.match.com"
52
+ end
53
+
54
+ model Parent do
55
+ production "http://set.in.breadboard.on.parent.com"
56
+ end
57
+
58
+ default do
59
+ production "http://default.production.com"
60
+ all "http://default.all.com"
61
+ end
62
+ end
63
+ end
64
+
65
+ Given /^a Breadboard configuration with 'production' environment settings for an ancestor of that model$/ do
66
+ Breadboard.configure do
67
+ model NoSiteAttribute do
68
+ test "http://set.in.breadboard.exact.match.test.com"
69
+ end
70
+
71
+ model Parent do
72
+ production "http://set.in.breadboard.on.parent.com"
73
+ end
74
+
75
+ default do
76
+ production "http://default.production.com"
77
+ all "http://default.all.com"
78
+ end
79
+ end
80
+ end
81
+
82
+ Given /^a Breadboard configuration with 'all' environment settings for an ancestor of that model$/ do
83
+ Breadboard.configure do
84
+ model NoSiteAttribute do
85
+ test "http://set.in.breadboard.exact.match.test.com"
86
+ end
87
+
88
+ model Parent do
89
+ all "http://set.in.breadboard.on.parent.com"
90
+ end
91
+
92
+ default do
93
+ production "http://default.production.com"
94
+ all "http://default.all.com"
95
+ end
96
+ end
97
+ end
98
+
99
+ Given /^a Breadboard configuration with 'production' environment settings in the breadboard defaults section$/ do
100
+ Breadboard.configure do
101
+ model NoSiteAttribute do
102
+ test "http://set.in.breadboard.exact.match.test.com"
103
+ end
104
+
105
+ model Parent do
106
+ preview "http://set.in.breadboard.on.parent.com"
107
+ end
108
+
109
+ default do
110
+ production "http://default.production.com"
111
+ all "http://default.all.com"
112
+ end
113
+ end
114
+ end
115
+
116
+ Given /^a Breadboard configuration with 'all' environment settings in the breadboard defaults section$/ do
117
+ Breadboard.configure do
118
+ model NoSiteAttribute do
119
+ test "http://set.in.breadboard.exact.match.test.com"
120
+ end
121
+
122
+ model Parent do
123
+ preview "http://set.in.breadboard.on.parent.com"
124
+ end
125
+
126
+ default do
127
+ all "http://default.all.com"
128
+ end
129
+ end
130
+ end
131
+
132
+ Given /^my Rails environment is "([^"]*)"$/ do |environment|
133
+ unless defined? Rails
134
+ Rails = double "Rails"
135
+ end
136
+ Rails.stub(:env).and_return environment
137
+ end
138
+
139
+ Then /^I should recieve the value configured in the Breadboard "([^"]*)" environment settings for that model$/ do |environment|
140
+ NoSiteAttribute.site.to_s.should == Breadboard.config.NoSiteAttribute.send(environment.to_sym)
141
+ end
142
+
143
+ Then /^I should recieve the value configured in the Breadboard "([^"]*)" environment settings for the ancestor of that model$/ do |environment|
144
+ NoSiteAttribute.site.to_s.should == Breadboard.config.Parent.send(environment.to_sym)
145
+ end
146
+
147
+ Then /^I should recieve the value configured in the Breadboard "([^"]*)" environment settings in the breadboard defaults section$/ do |environment|
148
+ NoSiteAttribute.site.to_s.should == Breadboard.config.default.send(environment.to_sym)
149
+ end
150
+
151
+ Then /^ActiveResource should ignore more generic configurations in Breadboard$/ do
152
+ end
153
+
154
+ Given /^an empty Breadboard configuration$/ do
155
+ end
156
+
157
+ Then /^I should recieve an empty string$/ do
158
+ NoSiteAttribute.site.to_s.should be_empty
159
+ end
@@ -0,0 +1,89 @@
1
+ class Particle; end
2
+ class Yarticle; end
3
+ class Article; end
4
+ class Smarticle; end
5
+
6
+ Given /^I have required breadboard$/ do
7
+ require 'breadboard'
8
+ end
9
+
10
+ Then /^I should be able to configure breadboard via Ruby blocks$/ do
11
+ Breadboard.config.default.all.should == nil
12
+
13
+ Breadboard.configure do
14
+ default do
15
+ all "http://localhost:3000"
16
+ production "http://test.com"
17
+ end
18
+ end
19
+
20
+ Breadboard.config.default.all.should == "http://localhost:3000"
21
+ Breadboard.config.default.production.should == "http://test.com"
22
+ end
23
+
24
+ Then /^I should be able to create a default configuration via the "default" Config method$/ do
25
+ Breadboard.config.default.all.should == nil
26
+
27
+ Breadboard.configure do
28
+ default do
29
+ all "http://localhost:3000"
30
+ production "http://test.com"
31
+ end
32
+ end
33
+
34
+ Breadboard.config.default.all.should == "http://localhost:3000"
35
+ Breadboard.config.default.production.should == "http://test.com"
36
+ end
37
+
38
+ Then /^I should be able to configure models via their lowercased, underscored method equivalents$/ do
39
+ Breadboard.config.Article.production.should == nil
40
+
41
+ Breadboard.configure do
42
+ article do
43
+ production "haha"
44
+ end
45
+ end
46
+
47
+ Breadboard.config.Article.production.should == "haha"
48
+ end
49
+
50
+ Then /^I should be able to configure a model by passing the constant for the model to the "model" method$/ do
51
+ Breadboard.config.Smarticle.production.should == nil
52
+
53
+ Breadboard.configure do
54
+ model Smarticle do
55
+ production "haha"
56
+ end
57
+ end
58
+
59
+ Breadboard.config.Smarticle.production.should == "haha"
60
+ end
61
+
62
+ Then /^I should be able to configure multiple models simultaneously by passing their constants to the "models" method$/ do
63
+ Breadboard.config.Particle.production.should == nil
64
+ Breadboard.config.Yarticle.production.should == nil
65
+
66
+ Breadboard.configure do
67
+ models Particle, Yarticle do
68
+ production "haha"
69
+ end
70
+ end
71
+
72
+ Breadboard.config.Particle.production.should == "haha"
73
+ Breadboard.config.Yarticle.production.should == "haha"
74
+ end
75
+
76
+ Then /^I should be able to override the default Rails\.env environment retrieval in case I'm not in a rails app$/ do
77
+ unless defined? Rails
78
+ Rails = double "Rails"
79
+ end
80
+ Rails.stub(:env).and_return "rails-breadboard-test"
81
+ Rails.env.should == "rails-breadboard-test"
82
+ Breadboard.env.should == "rails-breadboard-test"
83
+ Breadboard.configure do
84
+ env do
85
+ "override!"
86
+ end
87
+ end
88
+ Breadboard.env.should == "override!"
89
+ end
@@ -0,0 +1,16 @@
1
+ Given /^I have configured breadboard$/ do
2
+ Breadboard.configure do
3
+ default do
4
+ all "http://test.com"
5
+ end
6
+ end
7
+ end
8
+
9
+ When /^I call the method Breadboard\.reset$/ do
10
+ Breadboard.config.default.all.should == "http://test.com"
11
+ Breadboard.reset
12
+ end
13
+
14
+ Then /^the Breadboard configuration should be reset to an empty configuration$/ do
15
+ Breadboard.config.default.all.should be_nil
16
+ end
@@ -0,0 +1,4 @@
1
+ $LOAD_PATH.unshift './lib'
2
+ require 'breadboard'
3
+ require 'rspec/mocks/standalone'
4
+ require 'cucumber/rspec/doubles'
@@ -0,0 +1,3 @@
1
+ Before do
2
+ Breadboard.reset
3
+ end
@@ -1,4 +1,6 @@
1
1
  require 'active_resource'
2
- require 'active_support'
2
+ require 'active_support/core_ext/string'
3
3
  require 'breadboard/breadboard'
4
- BREAD_BOARD = Breadboard.new((File.open(RAILS_ROOT.to_s + "/config/breadboard.yml") rescue "")) if defined?(RAILS_ROOT)
4
+ require 'breadboard/config'
5
+ require 'breadboard/environment'
6
+ require 'breadboard/active_resource'
@@ -0,0 +1,11 @@
1
+ module ActiveResource
2
+ class Base
3
+ class << self
4
+ def site_with_breadboard
5
+ @site || Breadboard.service_for(self)
6
+ end
7
+
8
+ alias_method_chain :site, :breadboard
9
+ end
10
+ end
11
+ end
@@ -1,58 +1,91 @@
1
- class Breadboard
2
- attr_reader :config
3
-
4
- class EnvironmentUnknownError < StandardError; end
5
-
6
- def initialize(config_yml)
7
- @config = YAML.load config_yml
1
+ module Breadboard
2
+ extend self
3
+
4
+ def config
5
+ Config
8
6
  end
9
-
10
- def environment
11
- begin
12
- RAILS_ENV
13
- rescue
14
- raise EnvironmentUnknownError, "RAILS_ENV environment unknown"
15
- end
7
+
8
+ def env
9
+ Config.env
10
+ end
11
+
12
+ def configure(&block)
13
+ Config.instance_eval &block
16
14
  end
17
15
 
18
- def service_for(klass)
19
- serv = nil
20
- while serv.nil? && klass != ActiveResource::Base do
21
- table = klass.to_s.tableize.singularize
22
- serv = (@config[table][environment] rescue nil) ||
23
- (@config[table]['all'] rescue nil) ||
24
- nil
25
- klass = klass.superclass
16
+ def service_for(model, environment=nil)
17
+ environment ||= Config.env.to_s.to_sym rescue :all
18
+ model_superclass_chain = [model] + model.ancestors
19
+ model_superclass_chain.each do |klass|
20
+ klass_symbol = klass.to_s.to_sym
21
+ site = config.send(klass_symbol).send(environment) || config.send(klass_symbol).send(:all)
22
+ return site if site
26
23
  end
27
- serv ||
28
- (@config['default'][environment] rescue nil) ||
29
- (@config['default']['all'] rescue nil) ||
30
- ''
24
+ return config.default.send(environment) || config.default.send(:all)
31
25
  end
32
- end
33
-
34
- class ActiveResource::Base
35
- class << self
36
- def site_with_breadboard
37
- if defined?(BREAD_BOARD)
38
- unless @site
39
- self.site = BREAD_BOARD.service_for(self)
40
- end
41
- @site
42
- else
43
- self.site_without_breadboard
44
- end
45
- end
46
26
 
47
- alias_method_chain :site, :breadboard
48
-
49
- def connection_with_breadboard(refresh = false)
50
- # setting @connection = nil would trigger Connection.new(site...
51
- # @connection is set to nil when calling self.site = 'url' as well
52
- @connection = nil
53
- connection_without_breadboard
54
- end
55
-
56
- alias_method_chain :connection, :breadboard
27
+ def reset
28
+ Config.reset
57
29
  end
58
30
  end
31
+
32
+ #
33
+ #
34
+ # class Breadboard
35
+ # attr_reader :config
36
+ #
37
+ # class EnvironmentUnknownError < StandardError; end
38
+ #
39
+ # def initialize(config_yml)
40
+ # @config = YAML.load config_yml
41
+ # end
42
+ #
43
+ # def environment
44
+ # begin
45
+ # RAILS_ENV
46
+ # rescue
47
+ # raise EnvironmentUnknownError, "RAILS_ENV environment unknown"
48
+ # end
49
+ # end
50
+ #
51
+ # def service_for(klass)
52
+ # serv = nil
53
+ # while serv.nil? && klass != ActiveResource::Base do
54
+ # table = klass.to_s.tableize.singularize
55
+ # serv = (@config[table][environment] rescue nil) ||
56
+ # (@config[table]['all'] rescue nil) ||
57
+ # nil
58
+ # klass = klass.superclass
59
+ # end
60
+ # serv ||
61
+ # (@config['default'][environment] rescue nil) ||
62
+ # (@config['default']['all'] rescue nil) ||
63
+ # ''
64
+ # end
65
+ # end
66
+ # #
67
+ # # class ActiveResource::Base
68
+ # # class << self
69
+ # # def site_with_breadboard
70
+ # # if defined?(BREAD_BOARD)
71
+ # # unless @site
72
+ # # self.site = BREAD_BOARD.service_for(self)
73
+ # # end
74
+ # # @site
75
+ # # else
76
+ # # self.site_without_breadboard
77
+ # # end
78
+ # # end
79
+ # #
80
+ # # alias_method_chain :site, :breadboard
81
+ # #
82
+ # # def connection_with_breadboard(refresh = false)
83
+ # # # setting @connection = nil would trigger Connection.new(site...
84
+ # # # @connection is set to nil when calling self.site = 'url' as well
85
+ # # @connection = nil
86
+ # # connection_without_breadboard
87
+ # # end
88
+ # #
89
+ # # alias_method_chain :connection, :breadboard
90
+ # # end
91
+ # # end
@@ -0,0 +1,49 @@
1
+ module Breadboard
2
+ module Config
3
+ extend self
4
+
5
+ def config
6
+ @config ||= {}
7
+ end
8
+
9
+ def env(&block)
10
+ @env ||= proc { Rails.env }
11
+ return @env.call unless block
12
+ @env = block
13
+ end
14
+
15
+ def default(&block)
16
+ config_or_access :default, &block
17
+ end
18
+
19
+ def model(model_name, &block)
20
+ config_or_access model_name, &block
21
+ end
22
+
23
+ def reset
24
+ @config = {}
25
+ end
26
+
27
+ def models(*model_classes, &block)
28
+ raise "You must pass a block to the `models` method" if block.nil?
29
+
30
+ model_classes.each do |model_class|
31
+ config_or_access model_class, &block
32
+ end
33
+ end
34
+
35
+ def method_missing(method_name, *args, &block)
36
+ config_or_access method_name.to_s.camelize.constantize, &block
37
+ end
38
+
39
+ private
40
+ def config_or_access(model, &block)
41
+ config[model] ||= Environment.new
42
+ if block
43
+ config[model].instance_eval &block
44
+ else
45
+ config[model]
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,19 @@
1
+ module Breadboard
2
+ module Config
3
+ class Environment
4
+ def initialize
5
+ @environments = {}
6
+ end
7
+
8
+ def test(url=nil)
9
+ return @environments[:test] if url.nil?
10
+ @environments[:test] = url
11
+ end
12
+
13
+ def method_missing(method_name, *args, &block)
14
+ return @environments[method_name] if args.length == 0
15
+ @environments[method_name] = args.first
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,8 +1,8 @@
1
- =Introduction
1
+ #Introduction
2
2
 
3
3
  breadboard.yml is to ActiveResource as database.yml is to ActiveRecord, taking the data source configuration out of the models and putting it where it belongs, in a configuration file. If the services you connect your ActiveResource models to depends on your RAILS_ENV, then breadboard is for you.
4
4
 
5
- =Install
5
+ ##Install
6
6
 
7
7
  Breadboard is available as a gem:
8
8
 
@@ -12,7 +12,7 @@ If you'd like to use this in your rails project, add the following to your confi
12
12
 
13
13
  config.gem 'breadboard'
14
14
 
15
- =Usage
15
+ ##Usage
16
16
 
17
17
  All you have to do is create a breadboard.yml file in your RAILS_ROOT/config directory.
18
18
 
@@ -50,4 +50,4 @@ Now suppose you have a 'Book' model that needs to connect to a different service
50
50
  book:
51
51
  production: http://my.book.production.service.provider
52
52
 
53
- I think you can see where this is going...
53
+ I think you can see where this is going...
metadata CHANGED
@@ -1,40 +1,72 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: breadboard
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
4
+ hash: -3702664322
5
+ prerelease: 6
6
6
  segments:
7
+ - 1
7
8
  - 0
8
- - 2
9
9
  - 0
10
- version: 0.2.0
10
+ - alpha
11
+ - 1
12
+ version: 1.0.0.alpha.1
11
13
  platform: ruby
12
14
  authors:
13
15
  - Matt Parker
14
- - Steve Koppelman
15
16
  autorequire:
16
17
  bindir: bin
17
18
  cert_chain: []
18
19
 
19
- date: 2010-09-29 00:00:00 -04:00
20
+ date: 2011-04-26 00:00:00 -04:00
20
21
  default_executable:
21
22
  dependencies:
22
23
  - !ruby/object:Gem::Dependency
23
- name: rails
24
+ name: activeresource
24
25
  prerelease: false
25
26
  requirement: &id001 !ruby/object:Gem::Requirement
26
27
  none: false
27
28
  requirements:
28
- - - ">="
29
+ - - ~>
29
30
  - !ruby/object:Gem::Version
30
- hash: 5
31
+ hash: 7
31
32
  segments:
32
- - 2
33
- - 3
34
33
  - 3
35
- version: 2.3.3
34
+ - 0
35
+ version: "3.0"
36
36
  type: :runtime
37
37
  version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ name: cucumber
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ hash: 55
47
+ segments:
48
+ - 0
49
+ - 10
50
+ - 0
51
+ version: 0.10.0
52
+ type: :development
53
+ version_requirements: *id002
54
+ - !ruby/object:Gem::Dependency
55
+ name: rspec
56
+ prerelease: false
57
+ requirement: &id003 !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ hash: 31
63
+ segments:
64
+ - 2
65
+ - 4
66
+ - 0
67
+ version: 2.4.0
68
+ type: :development
69
+ version_requirements: *id003
38
70
  description: "Breadboard allows you to define what services your ActiveResource derived classes connect to based on your rails environment. "
39
71
  email: moonmaster9000@gmail.com
40
72
  executables: []
@@ -42,20 +74,36 @@ executables: []
42
74
  extensions: []
43
75
 
44
76
  extra_rdoc_files:
45
- - README.rdoc
77
+ - readme.md
46
78
  files:
47
- - README.rdoc
79
+ - .gitignore
80
+ - .rvmrc
81
+ - CHANGELOG
82
+ - Gemfile
83
+ - Gemfile.lock
84
+ - PUBLIC_DOMAIN
85
+ - VERSION
86
+ - features/active_resource.feature
87
+ - features/configure.feature
88
+ - features/reset.feature
89
+ - features/step_definitions/active_resource_steps.rb
90
+ - features/step_definitions/configure_steps.rb
91
+ - features/step_definitions/reset_steps.rb
92
+ - features/support/env.rb
93
+ - features/support/hooks.rb
48
94
  - lib/breadboard.rb
95
+ - lib/breadboard/active_resource.rb
49
96
  - lib/breadboard/breadboard.rb
50
- - spec/lib_specs/breadboard_spec.rb
51
- - spec/spec_helper.rb
97
+ - lib/breadboard/config.rb
98
+ - lib/breadboard/environment.rb
99
+ - readme.md
52
100
  has_rdoc: true
53
101
  homepage: http://github.com/moonmaster9000/breadboard
54
102
  licenses: []
55
103
 
56
104
  post_install_message:
57
- rdoc_options:
58
- - --charset=UTF-8
105
+ rdoc_options: []
106
+
59
107
  require_paths:
60
108
  - lib
61
109
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -79,10 +127,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
127
  requirements: []
80
128
 
81
129
  rubyforge_project:
82
- rubygems_version: 1.3.7
130
+ rubygems_version: 1.6.2
83
131
  signing_key:
84
132
  specification_version: 3
85
- summary: breadboard.yml is to ActiveResource as database.yml is to ActiveRecord
133
+ summary: Simple, environment-based service provider configuration for ActiveResource
86
134
  test_files:
87
- - spec/lib_specs/breadboard_spec.rb
88
- - spec/spec_helper.rb
135
+ - features/active_resource.feature
136
+ - features/configure.feature
137
+ - features/reset.feature
138
+ - features/step_definitions/active_resource_steps.rb
139
+ - features/step_definitions/configure_steps.rb
140
+ - features/step_definitions/reset_steps.rb
141
+ - features/support/env.rb
142
+ - features/support/hooks.rb
@@ -1,76 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- describe Breadboard do
4
- before do
5
- @yml =
6
- "default:\n all: http://services.com\n\n" +
7
- "article:\n production: http://article.services.com\n\n" +
8
- "author:\n development: http://development.author.services.com\n\n" +
9
- "book:\n all: http://all.book.services.com\n\n" +
10
- "genre:\n all: http://all.genre.services.com\n\n" +
11
- "sub_genre:\n production: http://all.sub.genre.services.com"
12
- end
13
-
14
- describe "#initialize" do
15
- it "should accept a yml file string" do
16
- proc { Breadboard.new(@yml) }.should_not raise_error
17
- end
18
-
19
- it "should require that the yml be valid" do
20
- proc { Breadboard.new(true) }.should raise_error
21
- end
22
-
23
- it "should parse the configuration and store it internally" do
24
- Breadboard.new(@yml).config["default"]["all"].should == "http://services.com"
25
- end
26
-
27
- it "should configure any ActiveResource::Base derived class with the appropriate site" do
28
- define_const "RAILS_ENV", "development"
29
- class Book < ActiveResource::Base; end
30
- class Author < ActiveResource::Base; end
31
- class Article < ActiveResource::Base; end
32
- class Genre < ActiveResource::Base; end
33
- class SubGenre < Genre; end
34
- define_const "BREAD_BOARD", Breadboard.new(@yml)
35
- Book.site.host.should == "all.book.services.com"
36
- Author.site.host.should == "development.author.services.com"
37
- Article.site.host.should == "services.com"
38
- Genre.site.host.should == "all.genre.services.com"
39
- SubGenre.site.host.should == "all.genre.services.com"
40
- end
41
- end
42
-
43
- describe "#environment" do
44
- before do
45
- define_const "RAILS_ENV", 'breadboard_test'
46
- end
47
-
48
- it "should return the rails environment if it is set" do
49
- Breadboard.new(@yml).environment.should == 'breadboard_test'
50
- end
51
-
52
- it "should return UNKNOWN_ENVIRONMENT if the rails environment isn't set" do
53
- undefine_const "RAILS_ENV"
54
- proc {Breadboard.new(@yml).environment}.should raise_error(Breadboard::EnvironmentUnknownError)
55
- end
56
- end
57
-
58
- describe "#service_for" do
59
- before do
60
- @s = Breadboard.new(@yml)
61
- define_const "RAILS_ENV", 'production'
62
- end
63
-
64
- it "should require a class name" do
65
- proc { @s.service_for }.should raise_error(ArgumentError)
66
- end
67
-
68
- it "should return the appropriate service for that class" do
69
- @s.service_for(Article).should == 'http://article.services.com'
70
- @s.service_for(Author).should == 'http://services.com'
71
- @s.service_for(Book).should == 'http://all.book.services.com'
72
- @s.service_for(Genre).should == 'http://all.genre.services.com'
73
- @s.service_for(SubGenre).should == 'http://all.sub.genre.services.com'
74
- end
75
- end
76
- end
@@ -1,11 +0,0 @@
1
- $LOAD_PATH.unshift './lib'
2
- require 'breadboard'
3
-
4
- def define_const(const, value)
5
- Object.send(:remove_const, const.to_sym) if Object.send(:const_defined?, const.to_sym)
6
- Object.send :const_set, const, value
7
- end
8
-
9
- def undefine_const(const)
10
- Object.send :remove_const, const.to_sym if Object.send(:const_defined?, const.to_sym)
11
- end