arrayfu 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 77b5a20091ff3fd52e2a31aa176d205ad90253a8
4
- data.tar.gz: 38595e560fb27d9dabf1054d2611d01a04e6ed2d
3
+ metadata.gz: f8a581261b1085192b39d9ee0442495e7742cdca
4
+ data.tar.gz: 37649be36fcce6fbc684697c7743418074e23718
5
5
  SHA512:
6
- metadata.gz: 9e87aa4a17062bec29f00791c4f5a35727757dc9bee1639ed2c17a967a69dc9426f16c6480d73c9f599aee7d98be1ea12b94338e2d4fe949a067c559979599fe
7
- data.tar.gz: 583d5bbc51a7d8e44a24472fd3093ef53e9ca0fe6ea587b5007310fc4d0b28bd87ce7caac3242e77c8522759c0669f907d317f62c9bedd1209029b642c326f9f
6
+ metadata.gz: d80a706581acfd6e410179855b302b2cba7ec09b72935d00d4f16a9a653fc5e6faa8e8454bd114f83c5266f1598b0792c082fa52c66f51d593f8070339fed218
7
+ data.tar.gz: 017eb6d72e4aa5ac11347a2a624b6c066fe29b85452e76e4b457330615b3bb664b87dab3c09e5f63d6e101b39be06849d27dfb78b5cd1dfd2e10970d866ec3c5
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2012 - 2014 Jean-Paul Sylvain Boodhoo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/arrayfu.gemspec CHANGED
@@ -7,6 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = ArrayFu::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Develop With Passion®"]
10
+ s.license = 'MIT'
10
11
  s.email = ["open_source@developwithpassion.com"]
11
12
  s.homepage = "http://www.developwithpassion.com"
12
13
  s.summary = %q{Simple DSL For Declaritive Arrays}
@@ -18,8 +19,8 @@ Gem::Specification.new do |s|
18
19
  s.require_paths = ["lib"]
19
20
 
20
21
  # specify any dependencies here; for example:
21
- s.add_development_dependency "rake"
22
- s.add_development_dependency "guard"
23
- s.add_development_dependency "guard-rspec"
24
- s.add_development_dependency "fakes-rspec"
22
+ s.add_development_dependency("rake", "~> 0.9.0")
23
+ s.add_development_dependency("guard", "~> 2.6.1")
24
+ s.add_development_dependency("guard-rspec", "~> 4.2.9")
25
+ s.add_development_dependency("fakes-rspec", "~> 2.0.0")
25
26
  end
@@ -5,17 +5,13 @@ module ArrayFu
5
5
  base.extend ClassMethods
6
6
  end
7
7
 
8
- def initialize_arrayfu
8
+ def initialize
9
9
  self.class.each_array_definition do |array_definition|
10
10
  initialize_arrays(array_definition.name)
11
11
  ArrayFu::ModuleRegistry.configure(self, array_definition)
12
12
  end
13
13
  end
14
14
 
15
- def array(name, &block)
16
- self.class.array(name, &block)
17
- end
18
-
19
15
  module ClassMethods
20
16
  def array_definitions
21
17
  @array_definitions ||= {}
@@ -25,12 +21,12 @@ module ArrayFu
25
21
  array_definitions.values.each &block
26
22
  end
27
23
 
24
+ def array_definition(name)
25
+ array_definitions[name] ||= ArrayDefinition.new(name)
26
+ end
27
+
28
28
  def array(name, &block)
29
- unless array_definitions.has_key?(name)
30
- array_definition = ArrayDefinition.new(name)
31
- array_definitions[name] = array_definition
32
- end
33
- definition = array_definitions[name]
29
+ definition = array_definition(name)
34
30
  definition.instance_eval(&block) if block_given?
35
31
  definition
36
32
  end
@@ -1,3 +1,3 @@
1
1
  module ArrayFu
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -5,7 +5,6 @@ example "Basic" do
5
5
  include ArrayFu
6
6
 
7
7
  array :names
8
-
9
8
  end
10
9
  end
11
10
 
@@ -13,14 +12,7 @@ example 'Allow the array to have a read accessor' do
13
12
  class SomeClass
14
13
  include ArrayFu
15
14
 
16
- array :names do
17
- readable
18
- end
19
-
20
- def initialize
21
- initialize_arrayfu
22
- end
23
-
15
+ array(:names) { readable }
24
16
  end
25
17
  SomeClass.new.names.should_not be_nil
26
18
  end
@@ -29,13 +21,7 @@ example 'Allow the array to have a write accessor' do
29
21
  class SomeClass
30
22
  include ArrayFu
31
23
 
32
- array :names do
33
- writable
34
- end
35
-
36
- def initialize
37
- initialize_arrayfu
38
- end
24
+ array(:names) { writable }
39
25
  end
40
26
  SomeClass.new.names.should_not be_nil
41
27
  end
@@ -44,13 +30,7 @@ example 'Allow the array to have a read and write accessor' do
44
30
  class SomeClass
45
31
  include ArrayFu
46
32
 
47
- array :names do
48
- read_and_write
49
- end
50
-
51
- def initialize
52
- initialize_arrayfu
53
- end
33
+ array(:names) { read_and_write }
54
34
  end
55
35
  SomeClass.new.names.should_not be_nil
56
36
  end
@@ -59,12 +39,7 @@ example 'Add a mutator method to the class that stores the array' do
59
39
  class SomeClass
60
40
  include ArrayFu
61
41
 
62
- array :names do
63
- mutator :add_item
64
- end
65
- def initialize
66
- initialize_arrayfu
67
- end
42
+ array(:names) { mutator :add_item }
68
43
  end
69
44
 
70
45
  items = SomeClass.new
@@ -79,10 +54,6 @@ example 'Add multiple mutators to the class that stores the array' do
79
54
  array :names do
80
55
  mutator :add_item, :add_it, :push_it
81
56
  end
82
- def initialize
83
- initialize_arrayfu
84
- end
85
-
86
57
  end
87
58
 
88
59
  items = SomeClass.new
@@ -100,10 +71,6 @@ example 'Add a mutator that ignores addition' do
100
71
  mutator :add_item do|item|
101
72
  end
102
73
  end
103
- def initialize
104
- initialize_arrayfu
105
- end
106
-
107
74
  end
108
75
 
109
76
  items = SomeClass.new
@@ -115,9 +82,7 @@ example 'Add a mutator that does other custom logic as well as addition' do
115
82
  class SomeClass
116
83
  include ArrayFu
117
84
 
118
- array :secondary do
119
- readable
120
- end
85
+ array(:secondary) { readable }
121
86
 
122
87
  array :names do
123
88
  readable
@@ -126,10 +91,6 @@ example 'Add a mutator that does other custom logic as well as addition' do
126
91
  @names.push item
127
92
  end
128
93
  end
129
-
130
- def initialize
131
- initialize_arrayfu
132
- end
133
94
  end
134
95
 
135
96
  items = SomeClass.new
@@ -166,10 +127,6 @@ example 'Add a singular constraint and failure condition to each of the mutators
166
127
  mutator :add_item,:add_it
167
128
  new_item_must NotBeJP, CriteriaViolation
168
129
  end
169
-
170
- def initialize
171
- initialize_arrayfu
172
- end
173
130
  end
174
131
 
175
132
  items = SomeClass.new
@@ -219,10 +176,6 @@ example 'Add multiple constraints and a failure condition to each of the mutator
219
176
  addition_constraint NotBeJP
220
177
  addition_constraint NotBeNil, CriteriaViolation
221
178
  end
222
-
223
- def initialize
224
- initialize_arrayfu
225
- end
226
179
  end
227
180
 
228
181
  items = SomeClass.new
@@ -252,10 +205,6 @@ example 'Add an explicit processing visitor to the array' do
252
205
  mutator :add_item
253
206
  process_using :display_all,DisplayItem
254
207
  end
255
- def initialize
256
- initialize_arrayfu
257
- end
258
-
259
208
  end
260
209
 
261
210
  items = SomeClass.new
@@ -288,9 +237,6 @@ example 'Add an method based processing visitor to the array based on a method t
288
237
  def self.number_of_items_visited
289
238
  @@items_visited
290
239
  end
291
- def initialize
292
- initialize_arrayfu
293
- end
294
240
  end
295
241
 
296
242
  items = SomeClass.new
@@ -313,10 +259,6 @@ example 'Augment configuration using configuration block' do
313
259
  mutator :add_item
314
260
  configure_using ArrayConfigs.add_another_mutator
315
261
  end
316
-
317
- def initialize
318
- initialize_arrayfu
319
- end
320
262
  end
321
263
 
322
264
  items = SomeClass.new
@@ -342,10 +284,6 @@ example 'Augment configuration using configuration instance (anything that respo
342
284
  mutator :add_item
343
285
  configure_using ArrayConfiguration
344
286
  end
345
-
346
- def initialize
347
- initialize_arrayfu
348
- end
349
287
  end
350
288
 
351
289
  items = SomeClass.new
@@ -373,10 +311,6 @@ example 'Augment configuration using configuration block' do
373
311
  mutator :add_item
374
312
  configure_using ArrayConfiguration.configuration_block
375
313
  end
376
- def initialize
377
- initialize_arrayfu
378
- end
379
-
380
314
  end
381
315
 
382
316
  items = SomeClass.new
data/spec/spec_helper.rb CHANGED
@@ -9,6 +9,14 @@ Dir.chdir(File.join(File.dirname(__FILE__),"..,lib".split(','))) do
9
9
  require 'arrayfu.rb'
10
10
  end
11
11
 
12
+ class Sample
13
+ attr_reader :value_attempted_to_be_added
14
+
15
+ def initialize(numbers = [])
16
+ @numbers = numbers
17
+ end
18
+ end
19
+
12
20
 
13
21
  def catch_exception
14
22
  begin
@@ -80,8 +80,8 @@ module ArrayFu
80
80
  end
81
81
 
82
82
  it "should invoke the configurator with the definition" do
83
- configurator1.should have_received(:configure,subject)
84
- configurator2.should have_received(:configure,subject)
83
+ configurator1.should have_received_message(:configure, subject)
84
+ configurator2.should have_received_message(:configure, subject)
85
85
  end
86
86
  end
87
87
 
@@ -118,7 +118,7 @@ module ArrayFu
118
118
 
119
119
  it "should invoke blocks and configurators" do
120
120
  @first_ran.should be_true
121
- configurator1.should have_received(:configure,subject)
121
+ configurator1.should have_received_message(:configure,subject)
122
122
  end
123
123
  end
124
124
  end
@@ -11,10 +11,6 @@ module ArrayFu
11
11
  readable
12
12
  mutator :register_child
13
13
  end
14
-
15
- def initialize
16
- initialize_arrayfu
17
- end
18
14
  end
19
15
 
20
16
  item = Item.new
@@ -37,8 +33,8 @@ module ArrayFu
37
33
  end
38
34
 
39
35
  def initialize
36
+ super
40
37
  @added = 0
41
- initialize_arrayfu
42
38
  end
43
39
  end
44
40
 
@@ -73,8 +69,8 @@ module ArrayFu
73
69
  end
74
70
 
75
71
  def initialize
72
+ super
76
73
  @added = 0
77
- initialize_arrayfu
78
74
  end
79
75
  end
80
76
 
@@ -97,8 +93,8 @@ module ArrayFu
97
93
  end
98
94
 
99
95
  def initialize
96
+ super
100
97
  @added = 0
101
- initialize_arrayfu
102
98
  end
103
99
  end
104
100
 
@@ -130,10 +126,6 @@ module ArrayFu
130
126
  readable
131
127
  mutator :register_child
132
128
  end
133
-
134
- def initialize
135
- initialize_arrayfu
136
- end
137
129
  end
138
130
 
139
131
  item = Item.new
@@ -157,8 +149,8 @@ module ArrayFu
157
149
  end
158
150
 
159
151
  def initialize
152
+ super
160
153
  @added = 0
161
- initialize_arrayfu
162
154
  end
163
155
  end
164
156
 
@@ -196,10 +188,6 @@ module ArrayFu
196
188
  mutator :add_item,:add_this,:add_that
197
189
  new_item_must BeGreaterThanZero, RaiseCriteriaFailure
198
190
  end
199
-
200
- def initialize
201
- initialize_arrayfu
202
- end
203
191
  end
204
192
  let(:target){OneClass.new}
205
193
  before (:each) do
@@ -232,10 +220,6 @@ module ArrayFu
232
220
  mutator :add_item,:add_this,:add_that
233
221
  new_item_must BeGreaterThanZero, DisplayCriteriaFailure.instance
234
222
  end
235
-
236
- def initialize
237
- initialize_arrayfu
238
- end
239
223
  end
240
224
  let(:target){AnotherClass.new}
241
225
  before (:each) do
@@ -18,7 +18,7 @@ module ArrayFu
18
18
  sut.apply_to(value)
19
19
  end
20
20
  it "should run the failure strategy with the correct information" do
21
- failure_strategy.should have_received(:run, name, value)
21
+ failure_strategy.should have_received_message(:run, name, value)
22
22
  end
23
23
  end
24
24
 
@@ -31,7 +31,7 @@ module ArrayFu
31
31
  @result = sut.apply_to(value)
32
32
  end
33
33
  it "should not use the failure strategy" do
34
- failure_strategy.should_not have_received(:run)
34
+ failure_strategy.should_not have_received_message(:run)
35
35
  end
36
36
  it "should return true" do
37
37
  @result.should be_true
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arrayfu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Develop With Passion®
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-31 00:00:00.000000000 Z
11
+ date: 2014-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.9.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.9.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: guard
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 2.6.1
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 2.6.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: guard-rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 4.2.9
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 4.2.9
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: fakes-rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 2.0.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 2.0.0
69
69
  description: Simple DSL For Declaritive Arrays
70
70
  email:
71
71
  - open_source@developwithpassion.com
@@ -73,9 +73,10 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
76
+ - ".gitignore"
77
77
  - Gemfile
78
78
  - Guardfile
79
+ - LICENSE
79
80
  - Rakefile
80
81
  - arrayfu.gemspec
81
82
  - lib/arrayfu.rb
@@ -91,7 +92,7 @@ files:
91
92
  - lib/arrayfu/mutator_definition.rb
92
93
  - lib/arrayfu/version.rb
93
94
  - lib/arrayfu/visitor_definition.rb
94
- - spec/examples/usage.rb
95
+ - spec/examples/usage_spec.rb
95
96
  - spec/spec_helper.rb
96
97
  - spec/specs/array_definition_spec.rb
97
98
  - spec/specs/dsl_usage_spec.rb
@@ -101,9 +102,9 @@ files:
101
102
  - spec/specs/generate_writers_step_spec.rb
102
103
  - spec/specs/initializer_spec.rb
103
104
  - spec/specs/item_constraint_spec.rb
104
- - spec/specs/sample.rb
105
105
  homepage: http://www.developwithpassion.com
106
- licenses: []
106
+ licenses:
107
+ - MIT
107
108
  metadata: {}
108
109
  post_install_message:
109
110
  rdoc_options: []
@@ -111,22 +112,22 @@ require_paths:
111
112
  - lib
112
113
  required_ruby_version: !ruby/object:Gem::Requirement
113
114
  requirements:
114
- - - '>='
115
+ - - ">="
115
116
  - !ruby/object:Gem::Version
116
117
  version: '0'
117
118
  required_rubygems_version: !ruby/object:Gem::Requirement
118
119
  requirements:
119
- - - '>='
120
+ - - ">="
120
121
  - !ruby/object:Gem::Version
121
122
  version: '0'
122
123
  requirements: []
123
124
  rubyforge_project: arrayfu
124
- rubygems_version: 2.0.3
125
+ rubygems_version: 2.2.2
125
126
  signing_key:
126
127
  specification_version: 4
127
128
  summary: Simple DSL For Declaritive Arrays
128
129
  test_files:
129
- - spec/examples/usage.rb
130
+ - spec/examples/usage_spec.rb
130
131
  - spec/spec_helper.rb
131
132
  - spec/specs/array_definition_spec.rb
132
133
  - spec/specs/dsl_usage_spec.rb
@@ -136,4 +137,3 @@ test_files:
136
137
  - spec/specs/generate_writers_step_spec.rb
137
138
  - spec/specs/initializer_spec.rb
138
139
  - spec/specs/item_constraint_spec.rb
139
- - spec/specs/sample.rb
data/spec/specs/sample.rb DELETED
@@ -1,7 +0,0 @@
1
- class Sample
2
- attr_reader :value_attempted_to_be_added
3
-
4
- def initialize(numbers = [])
5
- @numbers = numbers
6
- end
7
- end