jruby

Using threadsafe initialization in a JRuby gem

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 06:55:38
问题 Wanting to be sure we're using the correct synchronization (and no more than necessary) when writing threadsafe code in JRuby; specifically, in a Puma instantiated Rails app. UPDATE: Extensively re-edited this question, to be very clear and use latest code we are implementing. This code uses the atomic gem written by @headius (Charles Nutter) for JRuby, but not sure it is totally necessary, or in which ways it's necessary, for what we're trying to do here. Here's what we've got, is this

Can a Rails plugin be packaged as a WAR/JAR file?

允我心安 提交于 2019-12-11 06:47:16
问题 Can a plugin be packaged as a JAR/WAR file similar to the way in which an entire Rails app can be packaged for deployment on JRuby? 回答1: either you want warbler or you want to make a jar. If you need an empty rails app with that plugin, create an empty project, install the plugin and, edit config/warble.rb to copy the gems you need If you need a jar with class files from that plugin; you need jrubyc to compile the rb files to class files that you can then turn into a jar with the java jar

Installing hpricot for JRuby

寵の児 提交于 2019-12-11 06:42:44
问题 I'm trying to look at cucumber for Jruby on Rails. One of the pre-requesites is webrat which has as pre-requisite hpricot. I've installed the gem with hpricot using: gem install hpricot --source http://code.whytheluckystiff.net --version 0.6.1 --platform java This installs the java version of hpricot. I add the hpricot_scan.jar to the CLASSPATH but when I run: cucumber features -n I get the following output: HpricotScanService.java:931:in `hpricot_scan': java.lang.NoSuchMethodError: org.jruby

How to convert org.jruby.RubyString to java.io.InputStream

廉价感情. 提交于 2019-12-11 06:27:43
问题 I am using JRuby with a Java library. The type of an input parameter of the Java method is InputStream, and I am using JRuby to call this method, how could I revert something like "/directory/item.txt" to InputStream for the Java method? Thank you. 回答1: Use RubyString#to_java_bytes to convert the string to bytes, then wrap it in a java.io.ByteArrayInputStream, which is a subclass of java.io.InputStream : >> "an arbitrary string" "an arbitrary string" >> _.to_java_bytes => byte[97, 110, 32, 97

How to upgrade to a newer version of jruby

谁说胖子不能爱 提交于 2019-12-11 06:25:24
问题 I used the jruby zip executable to install 1.6.2, but it looks like they have released 1.6.4. How should I migrate from 1.6.2 to 1.6.4, should I have to re-install or is there a different command. 回答1: Mostly all you need to do is reinstall gems on the newly-unpacked JRuby (recommended), or migrate your existing gem installs by copying the lib/ruby/gems/* over to the new location. There's no automated update tool for JRuby itself right now. 回答2: Unpack new Jruby export JRUBY_HOME=/path/to

JRuby on Rails vs. Ruby on Rails, what's difference?

两盒软妹~` 提交于 2019-12-11 04:44:42
问题 I'm looking to try out JRuby and JRuby on Rails. I'm having trouble finding information on what's difference between JRuby on Rails and Ruby on Rails. What's the differences I need to look out for? N.B. This questions is an exact duplicate of JRuby on Rails vs. Ruby on Rails, what's difference?, except the original question was answered 2.5 years ago. I'm hoping for an up-to-date answer. 回答1: The original answer still stands and isn't really time specific. JRuby is just a version of Ruby that

implementing custom java class in jruby

孤者浪人 提交于 2019-12-11 03:34:08
问题 I am trying to implement a collection of java classes from the Stanford NLP Parser in jRuby I am able to implement regular Java in jRuby, but not the Stanford Parser classes #my requires/imports/includes, included multiple versions to be safe require 'java' include Java require 'c:\\stanford-parser\\stanfordparser.jar' require 'C:\\Stanford-Parser\\Current\\stanford-parser.jar' require 'c:\\sun\\stanfordparser' require 'rubygems' include_class 'edu.stanford.nlp.parser.lexparser

Using JRuby with Rails 3.2

一笑奈何 提交于 2019-12-11 02:57:26
问题 Has anyone had any success with installing Rails 3.2 and JRuby 1.6.5 on Mac OSX Lion using RVM? I'm planning on using TorqueBox with NGINX on my production server and I'm trying to mimic as much of the development technology onto my development machine as possible. I haven't gotten to install TorqueBox on my production server, and so far with my OSX RVM install I'm getting a few errors from an existing Rails 3.2 app that works fine with 1.9.2 and REE. The problem that I'm experiencing is this

Thrift gem and JRuby

半世苍凉 提交于 2019-12-11 01:28:05
问题 I just recently installed JRuby and the Thrift gem after using it in MRI. I'm running into a problem where if I require 'thrift' I get the message "Unable to load thrift_native extension. Defaulting to pure Ruby libraries." If I then try and require the code thrift generated in ruby I'll get this error: "NameError: uninitialized constant Thrift::Struct_Union" Is the thrift gem currently not working with JRuby? Is there something I can do to use thrift with JRuby besides using the gem? EDIT:

Error while using PDF Kit

旧巷老猫 提交于 2019-12-10 23:10:05
问题 I am trying to use PDFKit using rails 3, I followed the railscast tutorial and found that I get the following error: : undefined method `wrap_parameters' for ActionController::Base:Class (NoMethodError) http://railscasts.com/episodes/220-pdfkit 回答1: Maybe you're accidentally loading Rails 3.0.x on a Rails 3.1 application? It won't work if you generate a Rails 3.1 application, which adds config/initializers/wrap_parameters.rb , and then try to boot it with Rails 3.0.x. If you want Rails 3.1: