arrayfu 0.0.4 → 0.0.6
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.
- data/arrayfu.gemspec +0 -1
- data/lib/core/dsl.rb +7 -0
- data/lib/core/module_registry.rb +4 -0
- data/lib/core/mutator_step.rb +1 -1
- data/lib/core/object_extensions.rb +1 -1
- data/lib/core/readable_step.rb +1 -1
- data/lib/core/version.rb +1 -1
- data/lib/core/visitor_detail_step.rb +1 -1
- data/lib/core/writeable_step.rb +1 -1
- data/spec/examples/instance_usage.rb +46 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/specs/dsl_spec.rb +38 -194
- data/spec/specs/dsl_usage_spec.rb +222 -0
- data/spec/specs/mutator_step_spec.rb +2 -2
- data/spec/specs/readable_step_spec.rb +1 -1
- data/spec/specs/visitor_detail_step_spec.rb +2 -2
- data/spec/specs/writeable_step_spec.rb +1 -1
- metadata +33 -13
- data/bin/dwp_expand +0 -4
data/arrayfu.gemspec
CHANGED
|
@@ -15,7 +15,6 @@ Gem::Specification.new do |s|
|
|
|
15
15
|
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
18
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
19
18
|
s.require_paths = ["lib"]
|
|
20
19
|
|
|
21
20
|
# specify any dependencies here; for example:
|
data/lib/core/dsl.rb
CHANGED
|
@@ -32,5 +32,12 @@ module ArrayFu
|
|
|
32
32
|
def readable
|
|
33
33
|
@readable = true
|
|
34
34
|
end
|
|
35
|
+
|
|
36
|
+
def configure_using(*configurators)
|
|
37
|
+
configurators.each do|configurator|
|
|
38
|
+
method = configurator.respond_to?(:configure) ? :configure : 'call'.to_sym
|
|
39
|
+
configurator.send(method,self)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
35
42
|
end
|
|
36
43
|
end
|
data/lib/core/module_registry.rb
CHANGED
data/lib/core/mutator_step.rb
CHANGED
|
@@ -21,7 +21,7 @@ class Object
|
|
|
21
21
|
initialize_arrays(name)
|
|
22
22
|
dsl = ArrayFu::Dsl.new(name)
|
|
23
23
|
yield dsl if block_given?
|
|
24
|
-
ArrayFu::ModuleRegistry.
|
|
24
|
+
ArrayFu::ModuleRegistry.configure(self,dsl)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
end
|
data/lib/core/readable_step.rb
CHANGED
data/lib/core/version.rb
CHANGED
data/lib/core/writeable_step.rb
CHANGED
|
@@ -241,3 +241,49 @@ example 'Add an method based processing visitor to the array based on a method t
|
|
|
241
241
|
items.display_all
|
|
242
242
|
SomeClass.number_of_items_visited.should == 10
|
|
243
243
|
end
|
|
244
|
+
|
|
245
|
+
example 'Augment configuration using configuration block' do
|
|
246
|
+
class ArrayConfigs
|
|
247
|
+
def self.add_another_mutator
|
|
248
|
+
return lambda{|item| item.mutator :another_push}
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
class SomeClass
|
|
253
|
+
|
|
254
|
+
def initialize
|
|
255
|
+
array :names do|a|
|
|
256
|
+
a.mutator :add_item
|
|
257
|
+
a.configure_using ArrayConfigs.add_another_mutator
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
items = SomeClass.new
|
|
263
|
+
items.add_item("Yo")
|
|
264
|
+
items.another_push("Yo")
|
|
265
|
+
items.names.count.should == 2
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
example 'Augment configuration using configuration instance' do
|
|
269
|
+
class ArrayConfigs
|
|
270
|
+
def configure(item)
|
|
271
|
+
item.mutator :once_more
|
|
272
|
+
end
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
class SomeClass
|
|
276
|
+
|
|
277
|
+
def initialize
|
|
278
|
+
array :names do|a|
|
|
279
|
+
a.mutator :add_item
|
|
280
|
+
a.configure_using ArrayConfigs.new
|
|
281
|
+
end
|
|
282
|
+
end
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
items = SomeClass.new
|
|
286
|
+
items.add_item("Yo")
|
|
287
|
+
items.once_more("Yo")
|
|
288
|
+
items.names.count.should == 2
|
|
289
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/specs/dsl_spec.rb
CHANGED
|
@@ -64,221 +64,65 @@ module ArrayFu
|
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
context "
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
context "when a set of configurators are provided" do
|
|
68
|
+
context "and they are explicit configurators" do
|
|
69
|
+
let(:configurator1){fake}
|
|
70
|
+
let(:configurator2){fake}
|
|
71
|
+
subject{Dsl.new('name')}
|
|
70
72
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
item = Item.new
|
|
79
|
-
item.methods.include?(:register_child).should be_true
|
|
80
|
-
item.register_child("hello")
|
|
81
|
-
item.kids.count.should == 1
|
|
82
|
-
end
|
|
83
|
-
it "should be able to expose a mutator with custom logic" do
|
|
84
|
-
class Item
|
|
85
|
-
attr_accessor :added,:item_added
|
|
86
|
-
|
|
87
|
-
def initialize
|
|
88
|
-
@added = 0
|
|
89
|
-
|
|
90
|
-
array :kids do|a|
|
|
91
|
-
a.mutator :register_child do|the_item|
|
|
92
|
-
@item_added = the_item
|
|
93
|
-
@added +=1
|
|
94
|
-
@kids.push(the_item)
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
73
|
+
before (:each) do
|
|
74
|
+
def configurator1.respond_to?(name) true end
|
|
75
|
+
def configurator2.respond_to?(name) true end
|
|
98
76
|
end
|
|
99
77
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
item.kids.count.should == 1
|
|
103
|
-
item.item_added.should == "hello"
|
|
104
|
-
item.added.should == 1
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
it "should be able to expose a processing visitor" do
|
|
108
|
-
class Item
|
|
109
|
-
attr_accessor :added
|
|
110
|
-
|
|
111
|
-
def initialize(visitor)
|
|
112
|
-
@added = 0
|
|
113
|
-
array :kids do|a|
|
|
114
|
-
a.mutator :register_child
|
|
115
|
-
a.process_using :register_kids,visitor
|
|
116
|
-
end
|
|
117
|
-
end
|
|
78
|
+
before (:each) do
|
|
79
|
+
subject.configure_using configurator1,configurator2
|
|
118
80
|
end
|
|
119
81
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
@items = 0
|
|
124
|
-
end
|
|
125
|
-
def run_using(item)
|
|
126
|
-
@items +=1
|
|
127
|
-
end
|
|
82
|
+
it "should invoke the configurator with the dsl" do
|
|
83
|
+
configurator1.should have_received(:configure,subject)
|
|
84
|
+
configurator2.should have_received(:configure,subject)
|
|
128
85
|
end
|
|
129
|
-
|
|
130
|
-
our_visitor = OurVisitor.new
|
|
131
|
-
item = Item.new(our_visitor)
|
|
132
|
-
item.register_child("hello")
|
|
133
|
-
item.kids.count.should == 1
|
|
134
|
-
item.register_kids
|
|
135
|
-
our_visitor.items.should == 1
|
|
136
86
|
end
|
|
137
87
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
a.mutator :register_child
|
|
146
|
-
a.process_using :register_kids,:speak
|
|
147
|
-
end
|
|
148
|
-
end
|
|
88
|
+
context "and they are a set of blocks" do
|
|
89
|
+
let(:configurator1){fake}
|
|
90
|
+
let(:configurator2){fake}
|
|
91
|
+
subject{Dsl.new('name')}
|
|
92
|
+
before (:each) do
|
|
93
|
+
@first_ran = false
|
|
94
|
+
@second_ran = false
|
|
149
95
|
end
|
|
150
96
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
@array = array
|
|
154
|
-
end
|
|
155
|
-
def speak
|
|
156
|
-
@array.push("spoke")
|
|
157
|
-
end
|
|
97
|
+
before (:each) do
|
|
98
|
+
subject.configure_using lambda{|item| item.should == subject;@first_ran = true},lambda{|item| item.should == subject;@second_ran = true}
|
|
158
99
|
end
|
|
159
100
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
item.kids.count.should == 1
|
|
164
|
-
item.register_kids
|
|
165
|
-
items.count.should == 1
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
context "when specifying a mutator" do
|
|
170
|
-
context "and no block is provided" do
|
|
171
|
-
it "should expose the specified method to trigger addition" do
|
|
172
|
-
class Item
|
|
173
|
-
|
|
174
|
-
def initialize
|
|
175
|
-
array :kids do|a|
|
|
176
|
-
a.mutator :register_child
|
|
177
|
-
end
|
|
178
|
-
end
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
item = Item.new
|
|
182
|
-
item.methods.include?(:register_child).should be_true
|
|
183
|
-
item.register_child("hello")
|
|
184
|
-
item.kids.count.should == 1
|
|
101
|
+
it "should invoke each block with the dsl" do
|
|
102
|
+
@first_ran.should be_true
|
|
103
|
+
@second_ran.should be_true
|
|
185
104
|
end
|
|
186
105
|
end
|
|
187
106
|
|
|
188
|
-
context "and a
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
@added = 0
|
|
195
|
-
|
|
196
|
-
array :kids do|a|
|
|
197
|
-
a.mutator :register_child do|item|
|
|
198
|
-
@kids.push(item)
|
|
199
|
-
@added+=1
|
|
200
|
-
end
|
|
201
|
-
end
|
|
202
|
-
end
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
item = Item.new
|
|
206
|
-
item.register_child("hello")
|
|
207
|
-
item.kids.count.should == 1
|
|
208
|
-
item.added.should == 1
|
|
107
|
+
context "and they are a mixture of blocks and explicit configurators" do
|
|
108
|
+
let(:configurator1){fake}
|
|
109
|
+
subject{Dsl.new('name')}
|
|
110
|
+
before (:each) do
|
|
111
|
+
@first_ran = false
|
|
112
|
+
def configurator1.respond_to?(name) true end
|
|
209
113
|
end
|
|
210
|
-
end
|
|
211
|
-
|
|
212
114
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
def name
|
|
216
|
-
return "Be greater than 0"
|
|
217
|
-
end
|
|
218
|
-
def is_satisfied_by(item)
|
|
219
|
-
return item > 0
|
|
220
|
-
end
|
|
115
|
+
before (:each) do
|
|
116
|
+
subject.configure_using lambda{|item| item.should == subject;@first_ran = true},configurator1
|
|
221
117
|
end
|
|
222
|
-
context "and the criteria is not met" do
|
|
223
|
-
context "and the failure strategy is set to raise an error" do
|
|
224
|
-
class RaiseCriteriaFailure
|
|
225
|
-
def run(name,value)
|
|
226
|
-
raise "The value #{value} does not meet the criteria #{name}"
|
|
227
|
-
end
|
|
228
|
-
end
|
|
229
|
-
class OneClass
|
|
230
|
-
def initialize
|
|
231
|
-
array :items do|a|
|
|
232
|
-
a.mutator :add_item,:add_this,:add_that
|
|
233
|
-
a.new_item_must BeGreaterThanZero.new, RaiseCriteriaFailure.new
|
|
234
|
-
end
|
|
235
|
-
end
|
|
236
|
-
end
|
|
237
|
-
let(:target){OneClass.new}
|
|
238
|
-
before (:each) do
|
|
239
|
-
@exception = catch_exception do
|
|
240
|
-
target.add_item(0)
|
|
241
|
-
end
|
|
242
|
-
end
|
|
243
|
-
|
|
244
|
-
it "should raise an error when a failed add is attempted" do
|
|
245
|
-
(@exception.message =~ /does not meet/).should be_true
|
|
246
|
-
end
|
|
247
|
-
it "should not add the item to the underlying list" do
|
|
248
|
-
target.items.count.should == 0
|
|
249
|
-
end
|
|
250
|
-
end
|
|
251
118
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
attr_accessor :message
|
|
256
|
-
def run(name,value)
|
|
257
|
-
@message = "The value #{value} does not meet the criteria #{name}"
|
|
258
|
-
end
|
|
259
|
-
end
|
|
260
|
-
class AnotherClass
|
|
261
|
-
def initialize
|
|
262
|
-
array :items do|a|
|
|
263
|
-
a.mutator :add_item,:add_this,:add_that
|
|
264
|
-
a.new_item_must BeGreaterThanZero.new, DisplayCriteriaFailure.instance
|
|
265
|
-
end
|
|
266
|
-
end
|
|
267
|
-
end
|
|
268
|
-
let(:target){AnotherClass.new}
|
|
269
|
-
before (:each) do
|
|
270
|
-
target.add_item(0)
|
|
271
|
-
end
|
|
272
|
-
it "should have leveraged the failure strategy that does not throw an exception" do
|
|
273
|
-
DisplayCriteriaFailure.instance.message.should_not be_nil
|
|
274
|
-
end
|
|
275
|
-
|
|
276
|
-
it "should not add the item to the underlying list" do
|
|
277
|
-
target.items.count.should == 0
|
|
278
|
-
end
|
|
279
|
-
end
|
|
119
|
+
it "should invoke blocks and configurators" do
|
|
120
|
+
@first_ran.should be_true
|
|
121
|
+
configurator1.should have_received(:configure,subject)
|
|
280
122
|
end
|
|
281
123
|
end
|
|
124
|
+
|
|
282
125
|
end
|
|
126
|
+
|
|
283
127
|
end
|
|
284
128
|
end
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module ArrayFu
|
|
4
|
+
describe Dsl do
|
|
5
|
+
context "using the dsl" do
|
|
6
|
+
it "should be able to initialize all arrays specified on the instance and provide a method to expose addition" do
|
|
7
|
+
class Item
|
|
8
|
+
|
|
9
|
+
def initialize
|
|
10
|
+
array :kids do|a|
|
|
11
|
+
a.mutator :register_child
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
item = Item.new
|
|
17
|
+
item.methods.include?(:register_child).should be_true
|
|
18
|
+
item.register_child("hello")
|
|
19
|
+
item.kids.count.should == 1
|
|
20
|
+
end
|
|
21
|
+
it "should be able to expose a mutator with custom logic" do
|
|
22
|
+
class Item
|
|
23
|
+
attr_accessor :added,:item_added
|
|
24
|
+
|
|
25
|
+
def initialize
|
|
26
|
+
@added = 0
|
|
27
|
+
|
|
28
|
+
array :kids do|a|
|
|
29
|
+
a.mutator :register_child do|the_item|
|
|
30
|
+
@item_added = the_item
|
|
31
|
+
@added +=1
|
|
32
|
+
@kids.push(the_item)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
item = Item.new
|
|
39
|
+
item.register_child("hello")
|
|
40
|
+
item.kids.count.should == 1
|
|
41
|
+
item.item_added.should == "hello"
|
|
42
|
+
item.added.should == 1
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "should be able to expose a processing visitor" do
|
|
46
|
+
class Item
|
|
47
|
+
attr_accessor :added
|
|
48
|
+
|
|
49
|
+
def initialize(visitor)
|
|
50
|
+
@added = 0
|
|
51
|
+
array :kids do|a|
|
|
52
|
+
a.mutator :register_child
|
|
53
|
+
a.process_using :register_kids,visitor
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
class OurVisitor
|
|
59
|
+
attr_accessor :items
|
|
60
|
+
def initialize
|
|
61
|
+
@items = 0
|
|
62
|
+
end
|
|
63
|
+
def run_using(item)
|
|
64
|
+
@items +=1
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
our_visitor = OurVisitor.new
|
|
69
|
+
item = Item.new(our_visitor)
|
|
70
|
+
item.register_child("hello")
|
|
71
|
+
item.kids.count.should == 1
|
|
72
|
+
item.register_kids
|
|
73
|
+
our_visitor.items.should == 1
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "should be able to expose a processing visitor by symbol" do
|
|
77
|
+
class Item
|
|
78
|
+
attr_accessor :added
|
|
79
|
+
|
|
80
|
+
def initialize
|
|
81
|
+
@added = 0
|
|
82
|
+
array :kids do|a|
|
|
83
|
+
a.mutator :register_child
|
|
84
|
+
a.process_using :register_kids,:speak
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
class Kid
|
|
90
|
+
def initialize(array)
|
|
91
|
+
@array = array
|
|
92
|
+
end
|
|
93
|
+
def speak
|
|
94
|
+
@array.push("spoke")
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
items = []
|
|
99
|
+
item = Item.new
|
|
100
|
+
item.register_child(Kid.new(items))
|
|
101
|
+
item.kids.count.should == 1
|
|
102
|
+
item.register_kids
|
|
103
|
+
items.count.should == 1
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
context "when specifying a mutator" do
|
|
108
|
+
context "and no block is provided" do
|
|
109
|
+
it "should expose the specified method to trigger addition" do
|
|
110
|
+
class Item
|
|
111
|
+
|
|
112
|
+
def initialize
|
|
113
|
+
array :kids do|a|
|
|
114
|
+
a.mutator :register_child
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
item = Item.new
|
|
120
|
+
item.methods.include?(:register_child).should be_true
|
|
121
|
+
item.register_child("hello")
|
|
122
|
+
item.kids.count.should == 1
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
context "and a block is provided" do
|
|
127
|
+
it "should provide a method that delegates to the block when invoked" do
|
|
128
|
+
class Item
|
|
129
|
+
attr_accessor :added
|
|
130
|
+
|
|
131
|
+
def initialize
|
|
132
|
+
@added = 0
|
|
133
|
+
|
|
134
|
+
array :kids do|a|
|
|
135
|
+
a.mutator :register_child do|item|
|
|
136
|
+
@kids.push(item)
|
|
137
|
+
@added+=1
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
item = Item.new
|
|
144
|
+
item.register_child("hello")
|
|
145
|
+
item.kids.count.should == 1
|
|
146
|
+
item.added.should == 1
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
context "when criterias have been specified on the array" do
|
|
152
|
+
class BeGreaterThanZero
|
|
153
|
+
def name
|
|
154
|
+
return "Be greater than 0"
|
|
155
|
+
end
|
|
156
|
+
def is_satisfied_by(item)
|
|
157
|
+
return item > 0
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
context "and the criteria is not met" do
|
|
161
|
+
context "and the failure strategy is set to raise an error" do
|
|
162
|
+
class RaiseCriteriaFailure
|
|
163
|
+
def run(name,value)
|
|
164
|
+
raise "The value #{value} does not meet the criteria #{name}"
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
class OneClass
|
|
168
|
+
def initialize
|
|
169
|
+
array :items do|a|
|
|
170
|
+
a.mutator :add_item,:add_this,:add_that
|
|
171
|
+
a.new_item_must BeGreaterThanZero.new, RaiseCriteriaFailure.new
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
let(:target){OneClass.new}
|
|
176
|
+
before (:each) do
|
|
177
|
+
@exception = catch_exception do
|
|
178
|
+
target.add_item(0)
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
it "should raise an error when a failed add is attempted" do
|
|
183
|
+
(@exception.message =~ /does not meet/).should be_true
|
|
184
|
+
end
|
|
185
|
+
it "should not add the item to the underlying list" do
|
|
186
|
+
target.items.count.should == 0
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
context "and the failure strategy is not set to raise an error" do
|
|
191
|
+
class DisplayCriteriaFailure
|
|
192
|
+
include Singleton
|
|
193
|
+
attr_accessor :message
|
|
194
|
+
def run(name,value)
|
|
195
|
+
@message = "The value #{value} does not meet the criteria #{name}"
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
class AnotherClass
|
|
199
|
+
def initialize
|
|
200
|
+
array :items do|a|
|
|
201
|
+
a.mutator :add_item,:add_this,:add_that
|
|
202
|
+
a.new_item_must BeGreaterThanZero.new, DisplayCriteriaFailure.instance
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
let(:target){AnotherClass.new}
|
|
207
|
+
before (:each) do
|
|
208
|
+
target.add_item(0)
|
|
209
|
+
end
|
|
210
|
+
it "should have leveraged the failure strategy that does not throw an exception" do
|
|
211
|
+
DisplayCriteriaFailure.instance.message.should_not be_nil
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
it "should not add the item to the underlying list" do
|
|
215
|
+
target.items.count.should == 0
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
end
|
|
@@ -14,7 +14,7 @@ module ArrayFu
|
|
|
14
14
|
builder.mutator(:add_a_number)
|
|
15
15
|
end
|
|
16
16
|
before (:each) do
|
|
17
|
-
target.extend(sut.
|
|
17
|
+
target.extend(sut.create_using(builder))
|
|
18
18
|
end
|
|
19
19
|
it "should create a member on the target that allows mutation of the original list" do
|
|
20
20
|
target.respond_to?(:add_a_number).should be_true
|
|
@@ -29,7 +29,7 @@ module ArrayFu
|
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
before (:each) do
|
|
32
|
-
target.extend(sut.
|
|
32
|
+
target.extend(sut.create_using(builder))
|
|
33
33
|
end
|
|
34
34
|
it "should create a member on the target that intercepts mutation using the provided block" do
|
|
35
35
|
target.respond_to?(:add_a_number).should be_true
|
|
@@ -13,7 +13,7 @@ module ArrayFu
|
|
|
13
13
|
builder.readable
|
|
14
14
|
end
|
|
15
15
|
before (:each) do
|
|
16
|
-
target.extend(sut.
|
|
16
|
+
target.extend(sut.create_using(builder))
|
|
17
17
|
end
|
|
18
18
|
it "should create a member on the target that allows reading of the array" do
|
|
19
19
|
target.numbers.should be_a(Array)
|
|
@@ -33,7 +33,7 @@ module ArrayFu
|
|
|
33
33
|
builder.process_using(:run,:hello)
|
|
34
34
|
end
|
|
35
35
|
before (:each) do
|
|
36
|
-
target.extend(sut.
|
|
36
|
+
target.extend(sut.create_using(builder))
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it "should create a method on the target that triggers each item in the list using its provided action" do
|
|
@@ -63,7 +63,7 @@ module ArrayFu
|
|
|
63
63
|
builder.process_using(:run,visitor)
|
|
64
64
|
end
|
|
65
65
|
before (:each) do
|
|
66
|
-
target.extend(sut.
|
|
66
|
+
target.extend(sut.create_using(builder))
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
it "should create a method on the target that triggers the visitor once for each item in the list" do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: arrayfu
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.6
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -13,7 +13,7 @@ date: 2012-03-29 00:00:00.000000000 Z
|
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rake
|
|
16
|
-
requirement:
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
@@ -21,10 +21,15 @@ dependencies:
|
|
|
21
21
|
version: '0'
|
|
22
22
|
type: :development
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements:
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ! '>='
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '0'
|
|
25
30
|
- !ruby/object:Gem::Dependency
|
|
26
31
|
name: guard
|
|
27
|
-
requirement:
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
28
33
|
none: false
|
|
29
34
|
requirements:
|
|
30
35
|
- - ! '>='
|
|
@@ -32,10 +37,15 @@ dependencies:
|
|
|
32
37
|
version: '0'
|
|
33
38
|
type: :development
|
|
34
39
|
prerelease: false
|
|
35
|
-
version_requirements:
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ! '>='
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0'
|
|
36
46
|
- !ruby/object:Gem::Dependency
|
|
37
47
|
name: guard-rspec
|
|
38
|
-
requirement:
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
39
49
|
none: false
|
|
40
50
|
requirements:
|
|
41
51
|
- - ! '>='
|
|
@@ -43,10 +53,15 @@ dependencies:
|
|
|
43
53
|
version: '0'
|
|
44
54
|
type: :development
|
|
45
55
|
prerelease: false
|
|
46
|
-
version_requirements:
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
58
|
+
requirements:
|
|
59
|
+
- - ! '>='
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
47
62
|
- !ruby/object:Gem::Dependency
|
|
48
63
|
name: fakes-rspec
|
|
49
|
-
requirement:
|
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
65
|
none: false
|
|
51
66
|
requirements:
|
|
52
67
|
- - ! '>='
|
|
@@ -54,12 +69,16 @@ dependencies:
|
|
|
54
69
|
version: '0'
|
|
55
70
|
type: :development
|
|
56
71
|
prerelease: false
|
|
57
|
-
version_requirements:
|
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
+
none: false
|
|
74
|
+
requirements:
|
|
75
|
+
- - ! '>='
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: '0'
|
|
58
78
|
description: Simple DSL For Declaritive Arrays
|
|
59
79
|
email:
|
|
60
80
|
- open_source@developwithpassion.com
|
|
61
|
-
executables:
|
|
62
|
-
- dwp_expand
|
|
81
|
+
executables: []
|
|
63
82
|
extensions: []
|
|
64
83
|
extra_rdoc_files: []
|
|
65
84
|
files:
|
|
@@ -69,7 +88,6 @@ files:
|
|
|
69
88
|
- Guardfile
|
|
70
89
|
- Rakefile
|
|
71
90
|
- arrayfu.gemspec
|
|
72
|
-
- bin/dwp_expand
|
|
73
91
|
- lib/arrayfu.rb
|
|
74
92
|
- lib/core/add_criterion.rb
|
|
75
93
|
- lib/core/dsl.rb
|
|
@@ -87,6 +105,7 @@ files:
|
|
|
87
105
|
- spec/spec_helper.rb
|
|
88
106
|
- spec/specs/add_criterion_spec.rb
|
|
89
107
|
- spec/specs/dsl_spec.rb
|
|
108
|
+
- spec/specs/dsl_usage_spec.rb
|
|
90
109
|
- spec/specs/mutator_step_spec.rb
|
|
91
110
|
- spec/specs/object_extensions_spec.rb
|
|
92
111
|
- spec/specs/readable_step_spec.rb
|
|
@@ -113,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
113
132
|
version: '0'
|
|
114
133
|
requirements: []
|
|
115
134
|
rubyforge_project: arrayfu
|
|
116
|
-
rubygems_version: 1.8.
|
|
135
|
+
rubygems_version: 1.8.21
|
|
117
136
|
signing_key:
|
|
118
137
|
specification_version: 3
|
|
119
138
|
summary: Simple DSL For Declaritive Arrays
|
|
@@ -123,6 +142,7 @@ test_files:
|
|
|
123
142
|
- spec/spec_helper.rb
|
|
124
143
|
- spec/specs/add_criterion_spec.rb
|
|
125
144
|
- spec/specs/dsl_spec.rb
|
|
145
|
+
- spec/specs/dsl_usage_spec.rb
|
|
126
146
|
- spec/specs/mutator_step_spec.rb
|
|
127
147
|
- spec/specs/object_extensions_spec.rb
|
|
128
148
|
- spec/specs/readable_step_spec.rb
|
data/bin/dwp_expand
DELETED