You can clone with
HTTPS or Subversion.
Building native extensions. This could take a while...
/custom/jruby/lib/ruby/1.8/mkmf.rb:7: JRuby does not support native extensions. Check wiki.jruby.org for alternatives. (NotImplementedError)
from /custom/jruby/lib/ruby/1.8/mkmf.rb:1:in `require'
ERROR: Error installing algorithms:
ERROR: Failed to build gem native extension.
Will investigate this weekend.
JRuby does not support extensions, to build a jruby gem, simply:
spec.extensions = nil
spec.platform = 'java'
and you'll get a (pure-ruby) jruby compatible algorithms-0.2.0-java.gem
Any way to automate this so jruby users get the extension-less gem while everyone else gets extensions?
I think you have to generate separate gems, but you can put if RUBY_PLATFORM =~ /java/ checks in the gemspec so jruby -S gem build algorithms.gemspec builds the jruby version.
If I generate the separate gem, will pushing that onto rubyforge automatically result in the selection choices when installing gems?
If you set .platform='java', jgem and gem will pick and install the appropriate gems correctly.
I use rvm and jruby 1.5.6. I followed the above procedure. Gem was packaged and installed nicely. However, I get the following error when I try to run my code:
/home/vatikiot/.rvm/rubies/jruby-1.5.6/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require': no such file to load -- CString (LoadError)
This is due to the addition of Algorithm::String in fb40819
You could add a java version of the Levenshtein distance algorithm, or simply wrap the following code in a unless RUBY_PLATFORM =~ /java/ to disable it: https://github.com/kanwei/algorithms/blob/master/lib/algorithms/string.rb#L7
unless RUBY_PLATFORM =~ /java/
gem stakach-algorithms fixes the CString issue
Fixed for 0.6.1