blockenspiel 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Blockenspiel unmixer for Rubinius
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2011 Daniel Azuma
7
- #
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,24 +35,24 @@
35
35
 
36
36
 
37
37
  module Blockenspiel
38
-
39
-
38
+
39
+
40
40
  # :stopdoc:
41
-
41
+
42
42
  module Unmixer
43
-
43
+
44
44
  @old_metaclass = ''.respond_to?(:metaclass)
45
-
46
-
45
+
46
+
47
47
  # Unmix a module from an object in Rubinius.
48
- #
48
+ #
49
49
  # This implementation is based on unreleased code from the Mixology
50
50
  # source, written by Dan Manges.
51
51
  # See http://github.com/dan-manges/mixology
52
- #
52
+ #
53
53
  # It has been stripped down and modified for compatibility with the
54
54
  # Rubinius 1.0 release.
55
-
55
+
56
56
  def self.unmix(obj_, mod_) # :nodoc:
57
57
  last_super_ = @old_metaclass ? obj_.metaclass : obj_.singleton_class
58
58
  this_super_ = last_super_.direct_superclass
@@ -69,18 +69,18 @@ module Blockenspiel
69
69
  end
70
70
  nil
71
71
  end
72
-
73
-
72
+
73
+
74
74
  def self._reset_method_cache(obj_) # :nodoc:
75
75
  obj_.methods.each do |name_|
76
76
  ::Rubinius::VM.reset_method_cache(name_.to_sym)
77
77
  end
78
78
  end
79
-
80
-
79
+
80
+
81
81
  end
82
-
82
+
83
83
  # :startdoc:
84
-
85
-
84
+
85
+
86
86
  end
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Blockenspiel unmixer module when unmixer is not implemented
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2010-2011 Daniel Azuma
7
- #
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,24 +35,24 @@
35
35
 
36
36
 
37
37
  module Blockenspiel
38
-
39
-
38
+
39
+
40
40
  # :stopdoc:
41
-
41
+
42
42
  module Unmixer
43
-
44
-
43
+
44
+
45
45
  # Unmixer stub.
46
46
  # This throws an exception indicating the unmixer is not implemented.
47
-
47
+
48
48
  def self.unmix(obj_, mod_) # :nodoc:
49
49
  raise "Blockenspiel's mixin behavior is not implemented on this ruby platform."
50
50
  end
51
-
52
-
51
+
52
+
53
53
  end
54
-
54
+
55
55
  # :startdoc:
56
-
57
-
56
+
57
+
58
58
  end
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Blockenspiel version
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2008-2011 Daniel Azuma
7
- #
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,10 +35,10 @@
35
35
 
36
36
 
37
37
  module Blockenspiel
38
-
38
+
39
39
  # Current gem version, as a frozen string.
40
40
  VERSION_STRING = ::File.read(::File.dirname(__FILE__)+'/../../Version').strip.freeze
41
-
41
+
42
42
  autoload(:VERSION, ::File.dirname(__FILE__)+'/versionomy.rb')
43
-
43
+
44
44
  end
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Blockenspiel version
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2008-2011 Daniel Azuma
7
- #
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -41,11 +41,9 @@ end
41
41
 
42
42
 
43
43
  module Blockenspiel
44
-
45
- unless const_defined?(:VERSION)
46
- # Current gem version, as a Versionomy::Value if the versionomy library
47
- # is available, or as a frozen string if not.
48
- VERSION = defined?(::Versionomy) ? ::Versionomy.parse(VERSION_STRING, :standard) : VERSION_STRING
49
- end
50
-
44
+
45
+ # Current gem version, as a Versionomy::Value if the versionomy library
46
+ # is available, or as a frozen string if not.
47
+ VERSION = defined?(::Versionomy) ? ::Versionomy.parse(VERSION_STRING, :standard) : VERSION_STRING
48
+
51
49
  end
@@ -1,17 +1,17 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Blockenspiel basic tests
4
- #
4
+ #
5
5
  # This file contains tests for the simple use cases.
6
- #
6
+ #
7
7
  # -----------------------------------------------------------------------------
8
8
  # Copyright 2008-2011 Daniel Azuma
9
- #
9
+ #
10
10
  # All rights reserved.
11
- #
11
+ #
12
12
  # Redistribution and use in source and binary forms, with or without
13
13
  # modification, are permitted provided that the following conditions are met:
14
- #
14
+ #
15
15
  # * Redistributions of source code must retain the above copyright notice,
16
16
  # this list of conditions and the following disclaimer.
17
17
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -20,7 +20,7 @@
20
20
  # * Neither the name of the copyright holder, nor the names of any other
21
21
  # contributors to this software, may be used to endorse or promote products
22
22
  # derived from this software without specific prior written permission.
23
- #
23
+ #
24
24
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
25
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
26
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -42,37 +42,37 @@ require 'blockenspiel'
42
42
 
43
43
  module Blockenspiel
44
44
  module Tests # :nodoc:
45
-
45
+
46
46
  class TestBasic < ::Test::Unit::TestCase # :nodoc:
47
-
48
-
47
+
48
+
49
49
  class SimpleTarget < ::Blockenspiel::Base
50
-
50
+
51
51
  def initialize
52
52
  @hash = ::Hash.new
53
53
  end
54
-
54
+
55
55
  def set_value(key_, value_)
56
56
  @hash[key_] = value_
57
57
  end
58
-
58
+
59
59
  def set_value_by_block(key_)
60
60
  @hash[key_] = yield
61
61
  end
62
-
62
+
63
63
  def get_value(key_)
64
64
  @hash[key_]
65
65
  end
66
66
  dsl_method :get_value, false
67
-
67
+
68
68
  end
69
-
70
-
69
+
70
+
71
71
  # Test basic usage with a parameter object.
72
- #
72
+ #
73
73
  # * Asserts that methods are not mixed in to self.
74
74
  # * Asserts that the specified target object does in fact receive the block messages.
75
-
75
+
76
76
  def test_basic_param
77
77
  block_ = ::Proc.new do |t_|
78
78
  t_.set_value(:a, 1)
@@ -85,14 +85,14 @@ module Blockenspiel
85
85
  assert_equal(1, target_.get_value(:a))
86
86
  assert_equal(2, target_.get_value(:b))
87
87
  end
88
-
89
-
88
+
89
+
90
90
  # Test basic usage with a mixin.
91
- #
91
+ #
92
92
  # * Asserts that methods are mixed in to self.
93
93
  # * Asserts that methods are removed from self afterward.
94
94
  # * Asserts that the specified target object still receives the messages.
95
-
95
+
96
96
  def test_basic_mixin
97
97
  block_ = ::Proc.new do
98
98
  set_value(:a, 1)
@@ -105,13 +105,13 @@ module Blockenspiel
105
105
  assert_equal(1, target_.get_value(:a))
106
106
  assert_equal(2, target_.get_value(:b))
107
107
  end
108
-
109
-
108
+
109
+
110
110
  # Test basic usage with a builder.
111
- #
111
+ #
112
112
  # * Asserts that the receivers are called.
113
113
  # * Asserts that receivers with blocks are handled properly.
114
-
114
+
115
115
  def test_basic_builder
116
116
  block_ = ::Proc.new do
117
117
  set_value(:a, 1)
@@ -129,12 +129,12 @@ module Blockenspiel
129
129
  assert_equal(1, hash_[:a])
130
130
  assert_equal(2, hash_[:b])
131
131
  end
132
-
133
-
132
+
133
+
134
134
  # Test basic usage with a string.
135
- #
135
+ #
136
136
  # * Asserts that the specified target object receives the messages.
137
-
137
+
138
138
  def test_basic_string
139
139
  string_ = <<-STR
140
140
  set_value(:a, 1)
@@ -146,12 +146,12 @@ module Blockenspiel
146
146
  assert_equal(1, target_.get_value(:a))
147
147
  assert_equal(2, target_.get_value(:b))
148
148
  end
149
-
150
-
149
+
150
+
151
151
  # Test basic usage with a file.
152
- #
152
+ #
153
153
  # * Asserts that the specified target object receives the messages.
154
-
154
+
155
155
  def test_basic_file
156
156
  target_ = SimpleTarget.new
157
157
  ::Blockenspiel.invoke(target_, :file => "#{File.dirname(__FILE__)}/files/file1.rb")
@@ -159,9 +159,9 @@ module Blockenspiel
159
159
  assert_equal(1, target_.get_value(:a))
160
160
  assert_equal(2, target_.get_value(:b))
161
161
  end
162
-
163
-
162
+
163
+
164
164
  end
165
-
165
+
166
166
  end
167
167
  end
@@ -1,17 +1,17 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Blockenspiel behavior tests
4
- #
4
+ #
5
5
  # This file contains tests for behavior settings.
6
- #
6
+ #
7
7
  # -----------------------------------------------------------------------------
8
8
  # Copyright 2008-2011 Daniel Azuma
9
- #
9
+ #
10
10
  # All rights reserved.
11
- #
11
+ #
12
12
  # Redistribution and use in source and binary forms, with or without
13
13
  # modification, are permitted provided that the following conditions are met:
14
- #
14
+ #
15
15
  # * Redistributions of source code must retain the above copyright notice,
16
16
  # this list of conditions and the following disclaimer.
17
17
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -20,7 +20,7 @@
20
20
  # * Neither the name of the copyright holder, nor the names of any other
21
21
  # contributors to this software, may be used to endorse or promote products
22
22
  # derived from this software without specific prior written permission.
23
- #
23
+ #
24
24
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
25
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
26
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -42,49 +42,49 @@ require 'blockenspiel'
42
42
 
43
43
  module Blockenspiel
44
44
  module Tests # :nodoc:
45
-
45
+
46
46
  class TestBehaviors < ::Test::Unit::TestCase # :nodoc:
47
-
48
-
47
+
48
+
49
49
  class Target1 < ::Blockenspiel::Base
50
-
50
+
51
51
  dsl_methods false
52
-
52
+
53
53
  def initialize(hash_)
54
54
  @hash = hash_
55
55
  end
56
-
56
+
57
57
  def set_value1(key_, value_)
58
58
  @hash["#{key_}1"] = value_
59
59
  end
60
60
  dsl_method :set_value1
61
-
61
+
62
62
  def set_value2(key_)
63
63
  @hash["#{key_}2"] = yield
64
64
  end
65
65
  dsl_method :set_value2
66
-
66
+
67
67
  def set_value3(key_, value_)
68
68
  @hash["#{key_}3"] = value_
69
69
  end
70
70
  dsl_method :set_value3_dslversion, :set_value3
71
-
71
+
72
72
  end
73
-
74
-
73
+
74
+
75
75
  def helper_method
76
76
  true
77
77
  end
78
-
79
-
78
+
79
+
80
80
  # Test instance_eval behavior.
81
- #
81
+ #
82
82
  # * Asserts that self points at the target.
83
83
  # * Asserts that the target methods are available.
84
84
  # * Asserts that the target methods are not renamed by dsl_method directives.
85
85
  # * Asserts that the caller's instance variables are not available.
86
86
  # * Asserts that the caller's helper methods are not available.
87
-
87
+
88
88
  def test_instance_eval_behavior
89
89
  hash_ = ::Hash.new
90
90
  context_self_ = self
@@ -103,15 +103,15 @@ module Blockenspiel
103
103
  assert_equal(2, hash_['b2'])
104
104
  assert_equal(3, hash_['c3'])
105
105
  end
106
-
107
-
106
+
107
+
108
108
  # Test proxy behavior.
109
- #
109
+ #
110
110
  # * Asserts that self doesn't point at the Target nor the original context.
111
111
  # * Asserts that the target methods are available in their dsl renamed forms.
112
112
  # * Asserts that the caller's instance variables are not available.
113
113
  # * Asserts that the caller's helper methods *are* available.
114
-
114
+
115
115
  def test_proxy_behavior
116
116
  hash_ = ::Hash.new
117
117
  context_self_ = self
@@ -131,13 +131,13 @@ module Blockenspiel
131
131
  assert_equal(2, hash_['b2'])
132
132
  assert_equal(3, hash_['c3'])
133
133
  end
134
-
135
-
134
+
135
+
136
136
  # Test parameterless blocks disabled
137
- #
137
+ #
138
138
  # * Asserts that an error is raised if sending a no-parameter block in this case.
139
139
  # * Asserts that sending a one-parameter block still works.
140
-
140
+
141
141
  def test_disable_parameterless
142
142
  hash_ = ::Hash.new
143
143
  block1_ = ::Proc.new do ||
@@ -158,13 +158,13 @@ module Blockenspiel
158
158
  end
159
159
  assert_equal(2, hash_['b1'])
160
160
  end
161
-
162
-
161
+
162
+
163
163
  # Test parametered blocks disabled
164
- #
164
+ #
165
165
  # * Asserts that an error is raised if sending a one-parameter block in this case.
166
166
  # * Asserts that sending a no-parameter block still works.
167
-
167
+
168
168
  def test_disable_parametered
169
169
  hash_ = ::Hash.new
170
170
  block1_ = ::Proc.new do ||
@@ -184,8 +184,8 @@ module Blockenspiel
184
184
  assert_equal(1, hash_['a1'])
185
185
  assert_equal(3, hash_['c1'])
186
186
  end
187
-
187
+
188
188
  end
189
-
189
+
190
190
  end
191
191
  end