blockenspiel 0.2.1-java → 0.2.2-java

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.
@@ -36,7 +36,7 @@
36
36
 
37
37
  module Blockenspiel
38
38
 
39
- # Current gem version
40
- VERSION_STRING = '0.2.1'.freeze
39
+ # Current gem version, as a frozen string.
40
+ VERSION_STRING = '0.2.2'.freeze
41
41
 
42
42
  end
Binary file
@@ -37,19 +37,19 @@
37
37
 
38
38
 
39
39
  require 'test/unit'
40
- require File.expand_path("#{File.dirname(__FILE__)}/../lib/blockenspiel.rb")
40
+ require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/blockenspiel.rb")
41
41
 
42
42
 
43
43
  module Blockenspiel
44
44
  module Tests # :nodoc:
45
45
 
46
- class TestBasic < Test::Unit::TestCase # :nodoc:
46
+ class TestBasic < ::Test::Unit::TestCase # :nodoc:
47
47
 
48
48
 
49
- class SimpleTarget < Blockenspiel::Base
49
+ class SimpleTarget < ::Blockenspiel::Base
50
50
 
51
51
  def initialize
52
- @hash = Hash.new
52
+ @hash = ::Hash.new
53
53
  end
54
54
 
55
55
  def set_value(key_, value_)
@@ -81,7 +81,7 @@ module Blockenspiel
81
81
  assert(!self.respond_to?(:set_value_by_block))
82
82
  end
83
83
  target_ = SimpleTarget.new
84
- Blockenspiel.invoke(block_, target_)
84
+ ::Blockenspiel.invoke(block_, target_)
85
85
  assert_equal(1, target_.get_value(:a))
86
86
  assert_equal(2, target_.get_value(:b))
87
87
  end
@@ -99,7 +99,7 @@ module Blockenspiel
99
99
  set_value_by_block(:b){ 2 }
100
100
  end
101
101
  target_ = SimpleTarget.new
102
- Blockenspiel.invoke(block_, target_)
102
+ ::Blockenspiel.invoke(block_, target_)
103
103
  assert(!self.respond_to?(:set_value))
104
104
  assert(!self.respond_to?(:set_value_by_block))
105
105
  assert_equal(1, target_.get_value(:a))
@@ -117,8 +117,8 @@ module Blockenspiel
117
117
  set_value(:a, 1)
118
118
  set_value_by_block(:b){ 2 }
119
119
  end
120
- hash_ = Hash.new
121
- Blockenspiel.invoke(block_) do
120
+ hash_ = ::Hash.new
121
+ ::Blockenspiel.invoke(block_) do
122
122
  add_method(:set_value) do |key_, value_|
123
123
  hash_[key_] = value_
124
124
  end
@@ -37,16 +37,16 @@
37
37
 
38
38
 
39
39
  require 'test/unit'
40
- require File.expand_path("#{File.dirname(__FILE__)}/../lib/blockenspiel.rb")
40
+ require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/blockenspiel.rb")
41
41
 
42
42
 
43
43
  module Blockenspiel
44
44
  module Tests # :nodoc:
45
45
 
46
- class TextBehaviors < Test::Unit::TestCase # :nodoc:
46
+ class TextBehaviors < ::Test::Unit::TestCase # :nodoc:
47
47
 
48
48
 
49
- class Target1 < Blockenspiel::Base
49
+ class Target1 < ::Blockenspiel::Base
50
50
 
51
51
  dsl_methods false
52
52
 
@@ -86,19 +86,19 @@ module Blockenspiel
86
86
  # * Asserts that the caller's helper methods are not available.
87
87
 
88
88
  def test_instance_eval_behavior
89
- hash_ = Hash.new
89
+ hash_ = ::Hash.new
90
90
  context_self_ = self
91
91
  @my_instance_variable_test = :hello
92
92
  block_ = proc do
93
93
  set_value1('a', 1)
94
94
  set_value2('b'){ 2 }
95
95
  set_value3('c', 3)
96
- context_self_.assert_raise(NoMethodError){ set_value3_dslversion('d', 4) }
97
- context_self_.assert_raise(NoMethodError){ helper_method() }
96
+ context_self_.assert_raise(::NoMethodError){ set_value3_dslversion('d', 4) }
97
+ context_self_.assert_raise(::NoMethodError){ helper_method() }
98
98
  context_self_.assert(!instance_variable_defined?(:@my_instance_variable_test))
99
- context_self_.assert_instance_of(Blockenspiel::Tests::TextBehaviors::Target1, self)
99
+ context_self_.assert_instance_of(::Blockenspiel::Tests::TextBehaviors::Target1, self)
100
100
  end
101
- Blockenspiel.invoke(block_, Target1.new(hash_), :parameterless => :instance)
101
+ ::Blockenspiel.invoke(block_, Target1.new(hash_), :parameterless => :instance)
102
102
  assert_equal(1, hash_['a1'])
103
103
  assert_equal(2, hash_['b2'])
104
104
  assert_equal(3, hash_['c3'])
@@ -113,20 +113,20 @@ module Blockenspiel
113
113
  # * Asserts that the caller's helper methods *are* available.
114
114
 
115
115
  def test_proxy_behavior
116
- hash_ = Hash.new
116
+ hash_ = ::Hash.new
117
117
  context_self_ = self
118
118
  @my_instance_variable_test = :hello
119
119
  block_ = proc do
120
120
  set_value1('a', 1)
121
121
  set_value2('b'){ 2 }
122
122
  set_value3_dslversion('c', 3)
123
- context_self_.assert_raise(NoMethodError){ set_value3('d', 4) }
123
+ context_self_.assert_raise(::NoMethodError){ set_value3('d', 4) }
124
124
  context_self_.assert(helper_method())
125
125
  context_self_.assert(!instance_variable_defined?(:@my_instance_variable_test))
126
- context_self_.assert(!self.kind_of?(Blockenspiel::Tests::TextBehaviors::Target1))
126
+ context_self_.assert(!self.kind_of?(::Blockenspiel::Tests::TextBehaviors::Target1))
127
127
  context_self_.assert_not_equal(context_self_, self)
128
128
  end
129
- Blockenspiel.invoke(block_, Target1.new(hash_), :parameterless => :proxy)
129
+ ::Blockenspiel.invoke(block_, Target1.new(hash_), :parameterless => :proxy)
130
130
  assert_equal(1, hash_['a1'])
131
131
  assert_equal(2, hash_['b2'])
132
132
  assert_equal(3, hash_['c3'])
@@ -139,7 +139,7 @@ module Blockenspiel
139
139
  # * Asserts that sending a one-parameter block still works.
140
140
 
141
141
  def test_disable_parameterless
142
- hash_ = Hash.new
142
+ hash_ = ::Hash.new
143
143
  block1_ = proc do ||
144
144
  set_value1('a', 1)
145
145
  end
@@ -149,12 +149,12 @@ module Blockenspiel
149
149
  block3_ = proc do
150
150
  set_value1('c', 3)
151
151
  end
152
- assert_raise(Blockenspiel::BlockParameterError) do
153
- Blockenspiel.invoke(block1_, Target1.new(hash_), :parameterless => false)
152
+ assert_raise(::Blockenspiel::BlockParameterError) do
153
+ ::Blockenspiel.invoke(block1_, Target1.new(hash_), :parameterless => false)
154
154
  end
155
- Blockenspiel.invoke(block2_, Target1.new(hash_), :parameterless => false)
156
- assert_raise(Blockenspiel::BlockParameterError) do
157
- Blockenspiel.invoke(block3_, Target1.new(hash_), :parameterless => false)
155
+ ::Blockenspiel.invoke(block2_, Target1.new(hash_), :parameterless => false)
156
+ assert_raise(::Blockenspiel::BlockParameterError) do
157
+ ::Blockenspiel.invoke(block3_, Target1.new(hash_), :parameterless => false)
158
158
  end
159
159
  assert_equal(2, hash_['b1'])
160
160
  end
@@ -166,7 +166,7 @@ module Blockenspiel
166
166
  # * Asserts that sending a no-parameter block still works.
167
167
 
168
168
  def test_disable_parametered
169
- hash_ = Hash.new
169
+ hash_ = ::Hash.new
170
170
  block1_ = proc do ||
171
171
  set_value1('a', 1)
172
172
  end
@@ -176,11 +176,11 @@ module Blockenspiel
176
176
  block3_ = proc do
177
177
  set_value1('c', 3)
178
178
  end
179
- Blockenspiel.invoke(block1_, Target1.new(hash_), :parameter => false)
180
- assert_raise(Blockenspiel::BlockParameterError) do
181
- Blockenspiel.invoke(block2_, Target1.new(hash_), :parameter => false)
179
+ ::Blockenspiel.invoke(block1_, Target1.new(hash_), :parameter => false)
180
+ assert_raise(::Blockenspiel::BlockParameterError) do
181
+ ::Blockenspiel.invoke(block2_, Target1.new(hash_), :parameter => false)
182
182
  end
183
- Blockenspiel.invoke(block3_, Target1.new(hash_), :parameter => false)
183
+ ::Blockenspiel.invoke(block3_, Target1.new(hash_), :parameter => false)
184
184
  assert_equal(1, hash_['a1'])
185
185
  assert_equal(3, hash_['c1'])
186
186
  end
@@ -37,16 +37,16 @@
37
37
 
38
38
 
39
39
  require 'test/unit'
40
- require File.expand_path("#{File.dirname(__FILE__)}/../lib/blockenspiel.rb")
40
+ require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/blockenspiel.rb")
41
41
 
42
42
 
43
43
  module Blockenspiel
44
44
  module Tests # :nodoc:
45
45
 
46
- class TestDSLMethods < Test::Unit::TestCase # :nodoc:
46
+ class TestDSLMethods < ::Test::Unit::TestCase # :nodoc:
47
47
 
48
48
 
49
- class Target1 < Blockenspiel::Base
49
+ class Target1 < ::Blockenspiel::Base
50
50
 
51
51
  def initialize(hash_)
52
52
  @hash = hash_
@@ -67,7 +67,7 @@ module Blockenspiel
67
67
  end
68
68
 
69
69
 
70
- class Target2 < Blockenspiel::Base
70
+ class Target2 < ::Blockenspiel::Base
71
71
 
72
72
  def initialize(hash_)
73
73
  @hash = hash_
@@ -92,7 +92,7 @@ module Blockenspiel
92
92
  end
93
93
 
94
94
 
95
- class Target3 < Blockenspiel::Base
95
+ class Target3 < ::Blockenspiel::Base
96
96
 
97
97
  def initialize(hash_)
98
98
  @hash = hash_
@@ -114,7 +114,7 @@ module Blockenspiel
114
114
  end
115
115
 
116
116
 
117
- class Target4 < Blockenspiel::Base
117
+ class Target4 < ::Blockenspiel::Base
118
118
 
119
119
  def initialize(hash_)
120
120
  @hash = hash_
@@ -134,7 +134,7 @@ module Blockenspiel
134
134
  end
135
135
 
136
136
 
137
- class Target5a < Blockenspiel::Base
137
+ class Target5a < ::Blockenspiel::Base
138
138
 
139
139
  def initialize(hash_)
140
140
  @hash = hash_
@@ -176,7 +176,7 @@ module Blockenspiel
176
176
  end
177
177
 
178
178
 
179
- class Target6 < Blockenspiel::Base
179
+ class Target6 < ::Blockenspiel::Base
180
180
 
181
181
  def initialize(hash_)
182
182
  @hash = hash_
@@ -202,13 +202,13 @@ module Blockenspiel
202
202
  # * Asserts the right dsl methods are added for the default setting.
203
203
 
204
204
  def test_default_setting
205
- hash_ = Hash.new
205
+ hash_ = ::Hash.new
206
206
  block_ = proc do
207
207
  set_value1('a', 1)
208
208
  set_value2('b'){ 2 }
209
- assert_raise(NoMethodError){ _set_value3('c', 3) }
209
+ assert_raise(::NoMethodError){ _set_value3('c', 3) }
210
210
  end
211
- Blockenspiel.invoke(block_, Target1.new(hash_))
211
+ ::Blockenspiel.invoke(block_, Target1.new(hash_))
212
212
  assert_equal(1, hash_['a1'])
213
213
  assert_equal(2, hash_['b2'])
214
214
  assert_nil(hash_['c3'])
@@ -222,13 +222,13 @@ module Blockenspiel
222
222
  # * Asserts that underscore methods are added in dsl_methods true mode.
223
223
 
224
224
  def test_onoff_switching
225
- hash_ = Hash.new
225
+ hash_ = ::Hash.new
226
226
  block_ = proc do
227
- assert_raise(NoMethodError){ _set_value1('a', 1) }
227
+ assert_raise(::NoMethodError){ _set_value1('a', 1) }
228
228
  set_value2('b'){ 2 }
229
229
  _set_value3('c', 3)
230
230
  end
231
- Blockenspiel.invoke(block_, Target2.new(hash_))
231
+ ::Blockenspiel.invoke(block_, Target2.new(hash_))
232
232
  assert_nil(hash_['a1'])
233
233
  assert_equal(2, hash_['b2'])
234
234
  assert_equal(3, hash_['c3'])
@@ -241,14 +241,14 @@ module Blockenspiel
241
241
  # * Asserts that adding an explicit dsl method with a different name works.
242
242
 
243
243
  def test_explicit_add
244
- hash_ = Hash.new
244
+ hash_ = ::Hash.new
245
245
  block_ = proc do
246
246
  set_value1('a', 1)
247
- assert_raise(NoMethodError){ set_value2('b'){ 2 } }
247
+ assert_raise(::NoMethodError){ set_value2('b'){ 2 } }
248
248
  renamed_set_value2('c'){ 3 }
249
249
  another_set_value2('d'){ 4 }
250
250
  end
251
- Blockenspiel.invoke(block_, Target3.new(hash_))
251
+ ::Blockenspiel.invoke(block_, Target3.new(hash_))
252
252
  assert_equal(1, hash_['a1'])
253
253
  assert_nil(hash_['b2'])
254
254
  assert_equal(3, hash_['c2'])
@@ -262,13 +262,13 @@ module Blockenspiel
262
262
  # * Asserts that re-adding a removed method with a different name works.
263
263
 
264
264
  def test_explicit_removing
265
- hash_ = Hash.new
265
+ hash_ = ::Hash.new
266
266
  block_ = proc do
267
- assert_raise(NoMethodError){ set_value1('a', 1) }
268
- assert_raise(NoMethodError){ set_value2('b'){ 2 } }
267
+ assert_raise(::NoMethodError){ set_value1('a', 1) }
268
+ assert_raise(::NoMethodError){ set_value2('b'){ 2 } }
269
269
  renamed_set_value2('c'){ 3 }
270
270
  end
271
- Blockenspiel.invoke(block_, Target4.new(hash_))
271
+ ::Blockenspiel.invoke(block_, Target4.new(hash_))
272
272
  assert_nil(hash_['a1'])
273
273
  assert_nil(hash_['b2'])
274
274
  assert_equal(3, hash_['c2'])
@@ -281,16 +281,16 @@ module Blockenspiel
281
281
  # * Asserts that method overriding is done correctly.
282
282
 
283
283
  def test_subclassing
284
- hash_ = Hash.new
284
+ hash_ = ::Hash.new
285
285
  block_ = proc do
286
286
  set_value1('a', 1)
287
287
  set_value2('b'){ 2 }
288
- assert_raise(NoMethodError){ set_value3('c', 3) }
289
- assert_raise(NoMethodError){ set_value4('d', 4) }
288
+ assert_raise(::NoMethodError){ set_value3('c', 3) }
289
+ assert_raise(::NoMethodError){ set_value4('d', 4) }
290
290
  renamed_set_value4('e', 5)
291
291
  set_value5('f', 6)
292
292
  end
293
- Blockenspiel.invoke(block_, Target5b.new(hash_))
293
+ ::Blockenspiel.invoke(block_, Target5b.new(hash_))
294
294
  assert_equal(1, hash_['a1sub'])
295
295
  assert_equal(2, hash_['b2'])
296
296
  assert_nil(hash_['c3'])
@@ -306,13 +306,13 @@ module Blockenspiel
306
306
  # * Asserts that combined array and hash parameters works.
307
307
 
308
308
  def test_multiple_dsl_methods
309
- hash_ = Hash.new
309
+ hash_ = ::Hash.new
310
310
  block_ = proc do
311
311
  set_value1('a', 1)
312
312
  renamed_set_value2('b'){ 2 }
313
- assert_raise(NoMethodError){ set_value2('c', 3) }
313
+ assert_raise(::NoMethodError){ set_value2('c', 3) }
314
314
  end
315
- Blockenspiel.invoke(block_, Target6.new(hash_))
315
+ ::Blockenspiel.invoke(block_, Target6.new(hash_))
316
316
  assert_equal(1, hash_['a1'])
317
317
  assert_equal(2, hash_['b2'])
318
318
  end
@@ -37,13 +37,13 @@
37
37
 
38
38
 
39
39
  require 'test/unit'
40
- require File.expand_path("#{File.dirname(__FILE__)}/../lib/blockenspiel.rb")
40
+ require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/blockenspiel.rb")
41
41
 
42
42
 
43
43
  module Blockenspiel
44
44
  module Tests # :nodoc:
45
45
 
46
- class TestDynamic < Test::Unit::TestCase # :nodoc:
46
+ class TestDynamic < ::Test::Unit::TestCase # :nodoc:
47
47
 
48
48
 
49
49
  # Test the simple case.
@@ -54,8 +54,8 @@ module Blockenspiel
54
54
  block_ = proc do
55
55
  set_value(:a, 1)
56
56
  end
57
- hash_ = Hash.new
58
- Blockenspiel.invoke(block_) do
57
+ hash_ = ::Hash.new
58
+ ::Blockenspiel.invoke(block_) do
59
59
  add_method(:set_value) do |key_, value_|
60
60
  hash_[key_] = value_
61
61
  end
@@ -70,7 +70,7 @@ module Blockenspiel
70
70
  # * Asserts that the method appears in its original name in a parametered block.
71
71
 
72
72
  def test_renaming
73
- hash_ = Hash.new
73
+ hash_ = ::Hash.new
74
74
  dsl_definition_ = proc do
75
75
  add_method(:set_value, :dsl_method => :renamed_set_value) do |key_, value_|
76
76
  hash_[key_] = value_
@@ -78,14 +78,14 @@ module Blockenspiel
78
78
  end
79
79
  block1_ = proc do
80
80
  renamed_set_value(:a, 1)
81
- assert_raise(NoMethodError){ set_value(:b, 2) }
81
+ assert_raise(::NoMethodError){ set_value(:b, 2) }
82
82
  end
83
- Blockenspiel.invoke(block1_, &dsl_definition_)
83
+ ::Blockenspiel.invoke(block1_, &dsl_definition_)
84
84
  block2_ = proc do |dsl_|
85
85
  dsl_.set_value(:c, 3)
86
- assert_raise(NoMethodError){ renamed_set_value(:d, 4) }
86
+ assert_raise(::NoMethodError){ renamed_set_value(:d, 4) }
87
87
  end
88
- Blockenspiel.invoke(block2_, &dsl_definition_)
88
+ ::Blockenspiel.invoke(block2_, &dsl_definition_)
89
89
  assert_equal(1, hash_[:a])
90
90
  assert_nil(hash_[:b])
91
91
  assert_equal(3, hash_[:c])
@@ -100,7 +100,7 @@ module Blockenspiel
100
100
  # * Asserts that a block passed "last" works.
101
101
 
102
102
  def test_blocks_first_and_last
103
- hash_ = Hash.new
103
+ hash_ = ::Hash.new
104
104
  dsl_definition_ = proc do
105
105
  add_method(:set_value1, :block => :first) do |bl_, key_|
106
106
  hash_[key_] = bl_.call
@@ -117,7 +117,7 @@ module Blockenspiel
117
117
  set_value2(:b){ 2 }
118
118
  set_value2(:c){ 3 }
119
119
  end
120
- Blockenspiel.invoke(block_, &dsl_definition_)
120
+ ::Blockenspiel.invoke(block_, &dsl_definition_)
121
121
  assert_equal(1, hash_[:a])
122
122
  assert_equal(2, hash_[:b])
123
123
  assert_equal(3, hash_[:c])
@@ -129,7 +129,7 @@ module Blockenspiel
129
129
  # * Asserts that if a block isn't given, it is set to nil.
130
130
 
131
131
  def test_blocks_nil
132
- hash_ = Hash.new
132
+ hash_ = ::Hash.new
133
133
  dsl_definition_ = proc do
134
134
  add_method(:set_value1, :block => :first) do |bl_, key_|
135
135
  assert_nil(bl_)
@@ -142,7 +142,7 @@ module Blockenspiel
142
142
  set_value1(:a)
143
143
  set_value2(:b)
144
144
  end
145
- Blockenspiel.invoke(block_, &dsl_definition_)
145
+ ::Blockenspiel.invoke(block_, &dsl_definition_)
146
146
  assert_nil(hash_[:a])
147
147
  assert_nil(hash_[:b])
148
148
  end
@@ -155,7 +155,7 @@ module Blockenspiel
155
155
  # * Asserts that a block passed "last" works.
156
156
 
157
157
  def test_blocks_legacy
158
- hash_ = Hash.new
158
+ hash_ = ::Hash.new
159
159
  dsl_definition_ = proc do
160
160
  add_method(:set_value, :receive_block => true) do |key_, bl_|
161
161
  hash_[key_] = bl_.call
@@ -164,7 +164,7 @@ module Blockenspiel
164
164
  block_ = proc do
165
165
  set_value(:a){ 1 }
166
166
  end
167
- Blockenspiel.invoke(block_, &dsl_definition_)
167
+ ::Blockenspiel.invoke(block_, &dsl_definition_)
168
168
  assert_equal(1, hash_[:a])
169
169
  end
170
170