blockenspiel 0.4.0-java → 0.4.1-java

Sign up to get free protection for your applications and to get access to all the features.
data/Blockenspiel.rdoc CHANGED
@@ -307,20 +307,19 @@ multiple threads trying to mix methods into the same object concurrently.
307
307
 
308
308
  === Requirements
309
309
 
310
- * Ruby 1.8.7, Ruby 1.9.1 or later, or JRuby 1.5 or later.
310
+ * Ruby 1.8.7, Ruby 1.9.1 or later, JRuby 1.5 or later, or Rubinius 1.0 or later.
311
311
 
312
312
  === Installation
313
313
 
314
314
  gem install blockenspiel
315
315
 
316
- === Known issues and limitations
316
+ === Known issues and to-do items
317
317
 
318
318
  * Implementing wildcard DSL methods using <tt>method_missing</tt> doesn't
319
319
  work. I haven't yet decided on the right semantics for this case, or
320
320
  whether it is even a reasonable feature at all.
321
321
  * Including Blockenspiel::DSL in a module (rather than a class) is not yet
322
322
  supported, but this is planned for a future release.
323
- * Rubinius support is not yet present, but on the to-do list.
324
323
  * Installing on Windows may be a challenge because blockenspiel includes a
325
324
  native extension. I'm considering evaluating Luis Lavena's rake-compiler
326
325
  to simplify this process.
@@ -345,10 +344,13 @@ Way Out Of Instance Eval?". The original link is gone, but you may find
345
344
  copies or mirrors out there.
346
345
 
347
346
  The unmixer code is based on {Mixology}[http://rubyforge.org/projects/mixology],
348
- version 0.1 by Patrick Farley, anonymous z, Dan Manges, and Clint Bishop.
349
- The code has been stripped down and modified to support MRI 1.9 and JRuby 1.2.
350
- I know Mixology 0.2 is available, but I'm keeping the unmixer bundled with
351
- Blockenspiel for now, to reduce dependencies.
347
+ version by Patrick Farley, anonymous z, Dan Manges, and Clint Bishop.
348
+ The MRI C extension and the JRuby code were adapted from Mixology 0.1, and
349
+ have been stripped down and modified to support Ruby 1.9 and JRuby >= 1.2.
350
+ The Rubinius code was adapted from unreleased code in the Mixology source
351
+ tree and modified to support Rubinius 1.0. I know Mixology 0.2 is now
352
+ available, but its Rubinius support is not active, and I'd rather keep the
353
+ unmixer bundled with Blockenspiel for now to reduce dependencies.
352
354
 
353
355
  The dsl_attr_writer and dsl_attr_accessor feature came from a suggestion by
354
356
  Luis Lavena.
data/History.rdoc CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.4.1 / 2010-06-23
2
+
3
+ * Support for rubinius 1.0.
4
+
1
5
  === 0.4.0 / 2010-06-21
2
6
 
3
7
  * Implemented string- and file-based DSLs (in addition to block-based).
data/README.rdoc CHANGED
@@ -55,20 +55,19 @@ For an extended analysis of different ways to implement DSL blocks, see
55
55
 
56
56
  === Requirements
57
57
 
58
- * Ruby 1.8.7, Ruby 1.9.1 or later, or JRuby 1.5 or later.
58
+ * Ruby 1.8.7, Ruby 1.9.1 or later, JRuby 1.5 or later, or Rubinius 1.0 or later.
59
59
 
60
60
  === Installation
61
61
 
62
62
  gem install blockenspiel
63
63
 
64
- === Known issues and limitations
64
+ === Known issues and to-do items
65
65
 
66
66
  * Implementing wildcard DSL methods using <tt>method_missing</tt> doesn't
67
67
  work. I haven't yet decided on the right semantics for this case, or
68
68
  whether it is even a reasonable feature at all.
69
69
  * Including Blockenspiel::DSL in a module (rather than a class) is not yet
70
70
  supported, but this is planned for a future release.
71
- * Rubinius support is not yet present, but on the to-do list.
72
71
  * Installing on Windows may be a challenge because blockenspiel includes a
73
72
  native extension. I'm considering evaluating Luis Lavena's rake-compiler
74
73
  to simplify this process.
@@ -93,10 +92,16 @@ Way Out Of Instance Eval?". The original link has disappeared along with
93
92
  its author, but you may find copies or mirrors out there.
94
93
 
95
94
  The unmixer code is based on {Mixology}[http://rubyforge.org/projects/mixology],
96
- version 0.1 by Patrick Farley, anonymous z, Dan Manges, and Clint Bishop.
97
- The code has been stripped down and modified to support MRI 1.9 and JRuby 1.2.
98
- I know Mixology 0.2 is available, but I'm keeping the unmixer bundled with
99
- Blockenspiel for now, to reduce dependencies.
95
+ version by Patrick Farley, anonymous z, Dan Manges, and Clint Bishop.
96
+ The MRI C extension and the JRuby code were adapted from Mixology 0.1, and
97
+ have been stripped down and modified to support Ruby 1.9 and JRuby >= 1.2.
98
+ The Rubinius code was adapted from unreleased code in the Mixology source
99
+ tree and modified to support Rubinius 1.0. I know Mixology 0.2 is now
100
+ available, but its Rubinius support is not active, and I'd rather keep the
101
+ unmixer bundled with Blockenspiel for now to reduce dependencies.
102
+
103
+ The dsl_attr_writer and dsl_attr_accessor feature came from a suggestion by
104
+ Luis Lavena.
100
105
 
101
106
  === License
102
107
 
data/Rakefile CHANGED
@@ -31,6 +31,8 @@
31
31
  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
32
  # POSSIBILITY OF SUCH DAMAGE.
33
33
  # -----------------------------------------------------------------------------
34
+ ;
35
+
34
36
 
35
37
  require 'rubygems'
36
38
  require 'rake'
@@ -45,35 +47,34 @@ require ::File.expand_path("#{::File.dirname(__FILE__)}/lib/blockenspiel/version
45
47
 
46
48
 
47
49
  # Configuration
50
+
48
51
  EXTRA_RDOC_FILES = ['README.rdoc', 'Blockenspiel.rdoc', 'History.rdoc', 'ImplementingDSLblocks.rdoc']
49
52
 
50
53
 
51
54
  # Environment configuration
55
+
52
56
  dlext_ = Config::CONFIG['DLEXT']
53
- if ::RUBY_PLATFORM =~ /java/
54
- platform_suffix_ = 'java'
55
- elsif ::RUBY_COPYRIGHT =~ /Yukihiro\sMatsumoto/i
56
- if ::RUBY_VERSION =~ /^1\.8(\..*)?$/
57
- platform_suffix_ = 'mri18'
58
- elsif ::RUBY_VERSION =~ /^1\.9(\..*)?$/
59
- platform_suffix_ = 'mri19'
60
- else
61
- raise "Unknown version of Matz Ruby Interpreter (#{::RUBY_VERSION})"
57
+ platform_ =
58
+ case ::RUBY_DESCRIPTION
59
+ when /^jruby\s/ then :jruby
60
+ when /^ruby\s/ then :mri
61
+ when /^rubinius\s/ then :rubinius
62
+ else :unknown
62
63
  end
63
- else
64
- raise "Could not identify the ruby runtime"
65
- end
66
64
 
67
65
 
68
66
  # Default task
67
+
69
68
  task :default => [:clean, :rdoc, :package, :test]
70
69
 
71
70
 
72
71
  # Clean task
73
- CLEAN.include(['ext/blockenspiel/Makefile*', "**/*.#{dlext_}", 'ext/blockenspiel/unmixer.o', '**/blockenspiel_unmixer.jar', 'ext/blockenspiel/BlockenspielUnmixerService.class', 'idslb_markdown.txt', 'doc', 'pkg'])
72
+
73
+ CLEAN.include(['ext/blockenspiel/Makefile*', "**/*.#{dlext_}", "**/*.rbc", 'ext/blockenspiel/*.o', '**/*.jar', 'ext/blockenspiel/*.class', 'idslb_markdown.txt', 'doc', 'pkg'])
74
74
 
75
75
 
76
76
  # Test task
77
+
77
78
  task :test => :build
78
79
  ::Rake::TestTask.new('test') do |task_|
79
80
  task_.pattern = 'tests/tc_*.rb'
@@ -81,10 +82,11 @@ end
81
82
 
82
83
 
83
84
  # RDoc task
85
+
84
86
  ::Rake::RDocTask.new do |task_|
85
87
  task_.main = 'README.rdoc'
86
88
  task_.rdoc_files.include(*EXTRA_RDOC_FILES)
87
- task_.rdoc_files.include('lib/blockenspiel/*.rb')
89
+ task_.rdoc_files.include(['lib/blockenspiel.rb', 'lib/blockenspiel/*.rb'])
88
90
  task_.rdoc_dir = 'doc'
89
91
  task_.title = "Blockenspiel #{::Blockenspiel::VERSION_STRING} documentation"
90
92
  task_.options << '--format=darkfish'
@@ -92,7 +94,8 @@ end
92
94
 
93
95
 
94
96
  # Gem package task
95
- task :package => [:build_java] do
97
+
98
+ task :package => [:build_jruby] do
96
99
  mkdir_p('pkg')
97
100
 
98
101
  # Common gemspec
@@ -126,7 +129,7 @@ task :package => [:build_java] do
126
129
  # JRuby gemspec
127
130
  gemspec_ = create_gemspec do |s_|
128
131
  s_.platform = 'java'
129
- s_.files += ['lib/blockenspiel_unmixer.jar']
132
+ s_.files += ['lib/blockenspiel_unmixer_jruby.jar']
130
133
  end
131
134
  ::Gem::Builder.new(gemspec_).build
132
135
  mv "blockenspiel-#{::Blockenspiel::VERSION_STRING}-java.gem", 'pkg'
@@ -134,51 +137,78 @@ end
134
137
 
135
138
 
136
139
  # General build task
137
- task :build => ::RUBY_PLATFORM =~ /java/ ? [:build_java] : [:build_c]
138
140
 
141
+ case platform_
142
+ when :jruby
143
+ task :build => [:build_jruby]
144
+ when :mri
145
+ task :build => [:build_mri]
146
+ else
147
+ task :build
148
+ end
139
149
 
140
- # Build tasks for MRI
141
-
142
- makefile_name_ = "Makefile_#{platform_suffix_}"
143
- unmixer_general_name_ = "unmixer.#{dlext_}"
144
- unmixer_name_ = "unmixer_#{platform_suffix_}.#{dlext_}"
145
150
 
146
- desc 'Ensures the C extension appropriate to the current platform is present'
147
- task :build_c => ["ext/blockenspiel/#{unmixer_name_}"] do
148
- cp "ext/blockenspiel/#{unmixer_name_}", "lib/blockenspiel/#{unmixer_general_name_}"
149
- end
151
+ # Build tasks for MRI.
152
+ # These are available only if the current rake is running under MRI.
153
+ # They build the C extension for the current MRI.
150
154
 
151
- file "ext/blockenspiel/#{unmixer_name_}" => ["ext/blockenspiel/#{makefile_name_}"] do
152
- ::Dir.chdir('ext/blockenspiel') do
153
- cp makefile_name_, 'Makefile'
154
- sh 'make'
155
- rm 'unmixer.o'
156
- mv unmixer_general_name_, unmixer_name_
155
+ if platform_ == :mri
156
+
157
+ if ::RUBY_VERSION =~ /^1\.8\..*$/
158
+ mri_version_suffix_ = '18'
159
+ elsif ::RUBY_VERSION =~ /^1\.9\..*$/
160
+ mri_version_suffix_ = '19'
161
+ else
162
+ raise "Unknown version of Matz Ruby Interpreter (#{::RUBY_VERSION})"
163
+ end
164
+
165
+ makefile_name_ = "Makefile#{mri_version_suffix_}"
166
+ unmixer_general_name_ = "unmixer_mri.#{dlext_}"
167
+ unmixer_name_ = "unmixer_mri#{mri_version_suffix_}.#{dlext_}"
168
+
169
+ desc 'Ensures the MRI C extension appropriate to the current platform is present'
170
+ task :build_mri => ["ext/blockenspiel/#{unmixer_name_}"] do
171
+ cp "ext/blockenspiel/#{unmixer_name_}", "lib/blockenspiel/#{unmixer_general_name_}"
157
172
  end
173
+
174
+ file "ext/blockenspiel/#{unmixer_name_}" => ["ext/blockenspiel/#{makefile_name_}"] do
175
+ ::Dir.chdir('ext/blockenspiel') do
176
+ cp makefile_name_, 'Makefile'
177
+ sh 'make'
178
+ rm 'unmixer_mri.o'
179
+ mv unmixer_general_name_, unmixer_name_
180
+ end
181
+ end
182
+
183
+ file "ext/blockenspiel/#{makefile_name_}" do
184
+ ::Dir.chdir('ext/blockenspiel') do
185
+ ruby 'extconf.rb'
186
+ mv 'Makefile', makefile_name_
187
+ end
188
+ end
189
+
158
190
  end
159
191
 
160
- file "ext/blockenspiel/#{makefile_name_}" do
161
- ::Dir.chdir('ext/blockenspiel') do
162
- ruby 'extconf.rb'
163
- mv 'Makefile', makefile_name_
164
- end
165
- end
166
192
 
193
+ # Build tasks for JRuby.
194
+ # These are available under any ruby.
195
+ # They assume that $JRUBY_HOME is set, and that the javac and jar
196
+ # binaries are in the current path.
167
197
 
168
- # Build tasks for JRuby
169
198
  desc 'Builds the JRuby extension'
170
- task :build_java => ['lib/blockenspiel_unmixer.jar']
199
+ task :build_jruby => ['lib/blockenspiel_unmixer_jruby.jar']
171
200
 
172
- file 'lib/blockenspiel_unmixer.jar' do
201
+ file 'lib/blockenspiel_unmixer_jruby.jar' do
173
202
  ::Dir.chdir('ext/blockenspiel') do
174
- sh 'javac -source 1.5 -target 1.5 -classpath $JRUBY_HOME/lib/jruby.jar BlockenspielUnmixerService.java'
175
- sh 'jar cf blockenspiel_unmixer.jar BlockenspielUnmixerService.class'
203
+ sh 'javac -source 1.5 -target 1.5 -classpath $JRUBY_HOME/lib/jruby.jar BlockenspielUnmixerJrubyService.java'
204
+ sh 'jar cf blockenspiel_unmixer_jruby.jar BlockenspielUnmixerJrubyService.class'
176
205
  end
177
- mv 'ext/blockenspiel/blockenspiel_unmixer.jar', 'lib'
206
+ mv 'ext/blockenspiel/blockenspiel_unmixer_jruby.jar', 'lib'
178
207
  end
179
208
 
180
209
 
181
210
  # Publish RDocs
211
+
182
212
  desc 'Publishes RDocs to RubyForge'
183
213
  task :publish_rdoc_to_rubyforge => [:rerdoc] do
184
214
  config_ = ::YAML.load(::File.read(::File.expand_path("~/.rubyforge/user-config.yml")))
@@ -188,6 +218,7 @@ end
188
218
 
189
219
 
190
220
  # Publish gem
221
+
191
222
  task :release_gem => [:package] do |t_|
192
223
  v_ = ::ENV["VERSION"]
193
224
  abort "Must supply VERSION=x.y.z" unless v_
@@ -203,11 +234,13 @@ end
203
234
 
204
235
 
205
236
  # Publish everything
237
+
206
238
  task :release => [:release_gem, :publish_rdoc_to_rubyforge]
207
239
 
208
240
 
209
241
  # Custom task that takes the implementing dsl blocks paper
210
242
  # and converts it from RDoc format to Markdown
243
+
211
244
  task :idslb_markdown do
212
245
  ::File.open('ImplementingDSLblocks.rdoc') do |read_|
213
246
  ::File.open('idslb_markdown.txt', 'w') do |write_|
@@ -36,10 +36,10 @@
36
36
 
37
37
 
38
38
  /*
39
- This implementation based on Mixology,
39
+ This implementation based on Mixology 0.1,
40
40
  written by Patrick Farley, anonymous z, Dan Manges, and Clint Bishop.
41
41
  http://rubyforge.org/projects/mixology
42
- http://github.com/dan-manges/mixology/tree/master
42
+ http://github.com/dan-manges/mixology
43
43
 
44
44
  It has been stripped down and modified for JRuby 1.2 compatibility.
45
45
  */
@@ -63,14 +63,14 @@ import org.jruby.exceptions.RaiseException;
63
63
  import org.jruby.runtime.load.BasicLibraryService;
64
64
 
65
65
 
66
- public class BlockenspielUnmixerService implements BasicLibraryService
66
+ public class BlockenspielUnmixerJrubyService implements BasicLibraryService
67
67
  {
68
68
 
69
69
  public boolean basicLoad(final Ruby runtime) throws IOException
70
70
  {
71
71
  RubyModule blockenspielModule = runtime.getOrCreateModule("Blockenspiel");
72
72
  RubyModule unmixerModule = runtime.defineModuleUnder("Unmixer", blockenspielModule);
73
- unmixerModule.getSingletonClass().defineAnnotatedMethods(BlockenspielUnmixerService.class);
73
+ unmixerModule.getSingletonClass().defineAnnotatedMethods(BlockenspielUnmixerJrubyService.class);
74
74
  return true;
75
75
  }
76
76
 
@@ -1,2 +1,38 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Blockenspiel native library builder
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2010 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
1
37
  require 'mkmf'
2
- create_makefile 'blockenspiel/unmixer'
38
+ create_makefile 'blockenspiel/unmixer_mri'
@@ -4,7 +4,7 @@
4
4
  Blockenspiel unmixer (MRI implementation)
5
5
 
6
6
  -----------------------------------------------------------------------------
7
- Copyright 2008-2009 Daniel Azuma
7
+ Copyright 2008-2010 Daniel Azuma
8
8
 
9
9
  All rights reserved.
10
10
 
@@ -36,12 +36,14 @@
36
36
 
37
37
 
38
38
  /*
39
- This implementation based on Mixology,
39
+ This implementation based on Mixology 0.1,
40
40
  written by Patrick Farley, anonymous z, Dan Manges, and Clint Bishop.
41
41
  http://rubyforge.org/projects/mixology
42
42
  http://github.com/dan-manges/mixology/tree/master
43
43
 
44
44
  It has been stripped down and modified for compatibility with Ruby 1.9.
45
+
46
+ Note that this C extension is specific to MRI.
45
47
  */
46
48
 
47
49
 
@@ -53,8 +55,11 @@
53
55
  #endif
54
56
 
55
57
 
58
+ #ifndef RUBINIUS
59
+
60
+
56
61
  static void remove_nested_module(VALUE klass, VALUE module) {
57
- if (RBASIC(RCLASS_SUPER(klass))->klass == RBASIC(RCLASS_SUPER(module))->klass) {
62
+ if (CLASS_OF(RCLASS_SUPER(klass)) == CLASS_OF(RCLASS_SUPER(module))) {
58
63
  if (RCLASS_SUPER(RCLASS_SUPER(module)) && BUILTIN_TYPE(RCLASS_SUPER(module)) == T_ICLASS) {
59
64
  remove_nested_module(RCLASS_SUPER(klass), RCLASS_SUPER(module));
60
65
  }
@@ -64,10 +69,10 @@ static void remove_nested_module(VALUE klass, VALUE module) {
64
69
 
65
70
 
66
71
  static VALUE do_unmix(VALUE self, VALUE receiver, VALUE module) {
67
- VALUE klass = RBASIC(receiver)->klass;
72
+ VALUE klass = CLASS_OF(receiver);
68
73
  while (klass != rb_class_real(klass)) {
69
74
  VALUE super = RCLASS_SUPER(klass);
70
- if (BUILTIN_TYPE(super) == T_ICLASS && RBASIC(super)->klass == module) {
75
+ if (BUILTIN_TYPE(super) == T_ICLASS && CLASS_OF(super) == module) {
71
76
  if (RCLASS_SUPER(module) && BUILTIN_TYPE(RCLASS_SUPER(module)) == T_ICLASS) {
72
77
  remove_nested_module(super, module);
73
78
  }
@@ -80,7 +85,14 @@ static VALUE do_unmix(VALUE self, VALUE receiver, VALUE module) {
80
85
  }
81
86
 
82
87
 
83
- void Init_unmixer() {
88
+ #endif
89
+
90
+
91
+ void Init_unmixer_mri() {
92
+ #ifndef RUBINIUS
93
+
84
94
  VALUE container = rb_singleton_class(rb_define_module_under(rb_define_module("Blockenspiel"), "Unmixer"));
85
95
  rb_define_method(container, "unmix", do_unmix, 2);
96
+
97
+ #endif
86
98
  }
@@ -0,0 +1,84 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Blockenspiel unmixer for Rubinius
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2010 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
37
+ module Blockenspiel
38
+
39
+
40
+ # :stopdoc:
41
+
42
+ module Unmixer
43
+
44
+
45
+ # Unmix a module from an object in Rubinius.
46
+ #
47
+ # This implementation is based on unreleased code from the Mixology
48
+ # source, written by Dan Manges.
49
+ # See http://github.com/dan-manges/mixology
50
+ #
51
+ # It has been stripped down and modified for compatibility with the
52
+ # Rubinius 1.0 release.
53
+
54
+ def self.unmix(obj_, mod_) # :nodoc:
55
+ last_super_ = obj_.metaclass
56
+ this_super_ = last_super_.direct_superclass
57
+ while this_super_
58
+ if (this_super_ == mod_ || this_super_.respond_to?(:module) && this_super_.module == mod_)
59
+ _reset_method_cache(obj_)
60
+ last_super_.superclass = this_super_.direct_superclass
61
+ _reset_method_cache(obj_)
62
+ return
63
+ else
64
+ last_super_ = this_super_
65
+ this_super_ = this_super_.direct_superclass
66
+ end
67
+ end
68
+ nil
69
+ end
70
+
71
+
72
+ def self._reset_method_cache(obj_) # :nodoc:
73
+ obj_.methods.each do |name_|
74
+ ::Rubinius::VM.reset_method_cache(name_.to_sym)
75
+ end
76
+ end
77
+
78
+
79
+ end
80
+
81
+ # :startdoc:
82
+
83
+
84
+ end
@@ -0,0 +1,58 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Blockenspiel unmixer module when unmixer is not implemented
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2010 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
37
+ module Blockenspiel
38
+
39
+
40
+ # :stopdoc:
41
+
42
+ module Unmixer
43
+
44
+
45
+ # Unmixer stub.
46
+ # This throws an exception indicating the unmixer is not implemented.
47
+
48
+ def self.unmix(obj_, mod_) # :nodoc:
49
+ raise "Blockenspiel's mixin behavior is not implemented on this ruby platform."
50
+ end
51
+
52
+
53
+ end
54
+
55
+ # :startdoc:
56
+
57
+
58
+ end
@@ -37,7 +37,7 @@
37
37
  module Blockenspiel
38
38
 
39
39
  # Current gem version, as a frozen string.
40
- VERSION_STRING = '0.4.0'.freeze
40
+ VERSION_STRING = '0.4.1'.freeze
41
41
 
42
42
  autoload(:VERSION, ::File.dirname(__FILE__)+'/versionomy.rb')
43
43
 
data/lib/blockenspiel.rb CHANGED
@@ -53,9 +53,14 @@ includes_ = [
53
53
 
54
54
 
55
55
  dir_ = ::File.expand_path('blockenspiel', ::File.dirname(__FILE__))
56
- if ::RUBY_PLATFORM =~ /java/
57
- require "blockenspiel_unmixer"
56
+ case ::RUBY_DESCRIPTION
57
+ when /^ruby\s/
58
+ includes_.unshift('unmixer_mri')
59
+ when /^jruby\s/
60
+ require "blockenspiel_unmixer_jruby"
61
+ when /^rubinius\s/
62
+ includes_.unshift('unmixer_rubinius')
58
63
  else
59
- includes_.unshift('unmixer')
64
+ includes_.unshift('unmixer_unimplemented')
60
65
  end
61
66
  includes_.each{ |file_| require "#{dir_}/#{file_}" }
Binary file
data/tests/tc_mixins.rb CHANGED
@@ -339,67 +339,70 @@ module Blockenspiel
339
339
  # multiple mixins add the same method name, multiple times from different
340
340
  # fibers.
341
341
 
342
- def test_nested_two_fibers
343
- return unless defined?(::Fiber)
344
- hash_ = {}
345
- target1_ = Target1.new(hash_)
346
- target2_ = Target2.new(hash_)
347
- assert(!self.respond_to?(:set_value))
348
- assert(!self.respond_to?(:set_value2))
349
- assert(!self.respond_to?(:set_value2_inmixin))
350
- f1_ = ::Fiber.new do
351
- ::Blockenspiel.invoke(::Proc.new do
352
- ::Fiber.yield
353
- set_value('a', 1)
354
- set_value2('b'){ 2 }
342
+ if defined?(::Fiber)
343
+
344
+ def test_nested_two_fibers
345
+ hash_ = {}
346
+ target1_ = Target1.new(hash_)
347
+ target2_ = Target2.new(hash_)
348
+ assert(!self.respond_to?(:set_value))
349
+ assert(!self.respond_to?(:set_value2))
350
+ assert(!self.respond_to?(:set_value2_inmixin))
351
+ f1_ = ::Fiber.new do
355
352
  ::Blockenspiel.invoke(::Proc.new do
356
353
  ::Fiber.yield
357
- set_value('c', 3)
358
- set_value2_inmixin('d'){ 4 }
359
- end, target2_)
360
- ::Fiber.yield
361
- set_value('e', 5)
362
- set_value2('f'){ 6 }
363
- end, target1_)
364
- end
365
- f2_ = ::Fiber.new do
366
- ::Blockenspiel.invoke(::Proc.new do
367
- ::Fiber.yield
368
- set_value('A', 11)
369
- set_value2_inmixin('B'){ 12 }
370
- ::Blockenspiel.invoke(::Proc.new do
354
+ set_value('a', 1)
355
+ set_value2('b'){ 2 }
356
+ ::Blockenspiel.invoke(::Proc.new do
357
+ ::Fiber.yield
358
+ set_value('c', 3)
359
+ set_value2_inmixin('d'){ 4 }
360
+ end, target2_)
371
361
  ::Fiber.yield
372
- set_value('C', 13)
373
- set_value2('D'){ 14 }
362
+ set_value('e', 5)
363
+ set_value2('f'){ 6 }
374
364
  end, target1_)
375
- ::Fiber.yield
376
- set_value('E', 15)
377
- set_value2_inmixin('F'){ 16 }
378
- end, target2_)
365
+ end
366
+ f2_ = ::Fiber.new do
367
+ ::Blockenspiel.invoke(::Proc.new do
368
+ ::Fiber.yield
369
+ set_value('A', 11)
370
+ set_value2_inmixin('B'){ 12 }
371
+ ::Blockenspiel.invoke(::Proc.new do
372
+ ::Fiber.yield
373
+ set_value('C', 13)
374
+ set_value2('D'){ 14 }
375
+ end, target1_)
376
+ ::Fiber.yield
377
+ set_value('E', 15)
378
+ set_value2_inmixin('F'){ 16 }
379
+ end, target2_)
380
+ end
381
+ f1_.resume
382
+ f2_.resume
383
+ f1_.resume
384
+ f2_.resume
385
+ f1_.resume
386
+ f2_.resume
387
+ f1_.resume
388
+ f2_.resume
389
+ assert(!self.respond_to?(:set_value))
390
+ assert(!self.respond_to?(:set_value2))
391
+ assert(!self.respond_to?(:set_value2_inmixin))
392
+ assert_equal(1, hash_['a1'])
393
+ assert_equal(2, hash_['b1'])
394
+ assert_equal(3, hash_['c2'])
395
+ assert_equal(4, hash_['d2'])
396
+ assert_equal(5, hash_['e1'])
397
+ assert_equal(6, hash_['f1'])
398
+ assert_equal(11, hash_['A2'])
399
+ assert_equal(12, hash_['B2'])
400
+ assert_equal(13, hash_['C1'])
401
+ assert_equal(14, hash_['D1'])
402
+ assert_equal(15, hash_['E2'])
403
+ assert_equal(16, hash_['F2'])
379
404
  end
380
- f1_.resume
381
- f2_.resume
382
- f1_.resume
383
- f2_.resume
384
- f1_.resume
385
- f2_.resume
386
- f1_.resume
387
- f2_.resume
388
- assert(!self.respond_to?(:set_value))
389
- assert(!self.respond_to?(:set_value2))
390
- assert(!self.respond_to?(:set_value2_inmixin))
391
- assert_equal(1, hash_['a1'])
392
- assert_equal(2, hash_['b1'])
393
- assert_equal(3, hash_['c2'])
394
- assert_equal(4, hash_['d2'])
395
- assert_equal(5, hash_['e1'])
396
- assert_equal(6, hash_['f1'])
397
- assert_equal(11, hash_['A2'])
398
- assert_equal(12, hash_['B2'])
399
- assert_equal(13, hash_['C1'])
400
- assert_equal(14, hash_['D1'])
401
- assert_equal(15, hash_['E2'])
402
- assert_equal(16, hash_['F2'])
405
+
403
406
  end
404
407
 
405
408
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blockenspiel
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 0
10
- version: 0.4.0
9
+ - 1
10
+ version: 0.4.1
11
11
  platform: java
12
12
  authors:
13
13
  - Daniel Azuma
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-21 00:00:00 -07:00
18
+ date: 2010-06-23 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -31,17 +31,19 @@ extra_rdoc_files:
31
31
  - History.rdoc
32
32
  - ImplementingDSLblocks.rdoc
33
33
  files:
34
- - ext/blockenspiel/unmixer.c
34
+ - ext/blockenspiel/unmixer_mri.c
35
35
  - ext/blockenspiel/extconf.rb
36
- - ext/blockenspiel/BlockenspielUnmixerService.java
36
+ - ext/blockenspiel/BlockenspielUnmixerJrubyService.java
37
37
  - lib/blockenspiel/builder.rb
38
38
  - lib/blockenspiel/dsl_setup.rb
39
39
  - lib/blockenspiel/errors.rb
40
40
  - lib/blockenspiel/impl.rb
41
+ - lib/blockenspiel/unmixer_rubinius.rb
42
+ - lib/blockenspiel/unmixer_unimplemented.rb
41
43
  - lib/blockenspiel/version.rb
42
44
  - lib/blockenspiel/versionomy.rb
43
45
  - lib/blockenspiel.rb
44
- - lib/blockenspiel_unmixer.jar
46
+ - lib/blockenspiel_unmixer_jruby.jar
45
47
  - tests/files/file1.rb
46
48
  - tests/tc_basic.rb
47
49
  - tests/tc_behaviors.rb
Binary file