jruby

Selectively silence JRuby warnings

北战南征 提交于 2019-12-10 11:17:25
问题 I'm using the ruby-mysql library under JRuby and get the following warnings: /mysql/protocol.rb:530 warning: GC.disable does nothing on JRuby Is there any way to get JRuby to stop complaining about this? 回答1: You have a couple options. First, you can run your program with the -W0 option which will disable all warnings. That's probably not what you want. However, applying -W0 is the same as setting $VERBOSE to nil -- so we can simply do that around the code where we want to suppress warnings.

Understanding the source code for Ruby's repeated_permutation method

大城市里の小女人 提交于 2019-12-10 10:29:32
问题 I've been building an intelligent Mastermind game in Ruby. In my game, if you select the option of having the computer play the role of code breaker, the computer makes educated guesses at what the code maker's code is. As part of my algorithm, the computer first looks at the entire list of ALL POSSIBLE CODES. For example, if there are 6 colors to choose from (red orange blue green purple yellow) and the code is made up of 4 colors (repeats are allowed), then to view all possible codes, you

JRuby/Windows and (native) extensions how do I distinguish them?

巧了我就是萌 提交于 2019-12-10 10:16:53
问题 I've tried to use EventMachine etc., with JRuby. I get errors about native extensions. I believe this is due to Java limitations. I think the fact that I am on Windows further complicates the issue. Some clarification would be appreciated. What extensions can/can't be used with JRuby? How can I tell? Thanks. 回答1: there is no really easy way to use native extensions in jruby. native extensions are calling c code that cant be called in jruby without implementing it in java. aside from that a

pik Error: private method `gsub' called for nil:NilClass

情到浓时终转凉″ 提交于 2019-12-10 09:26:35
问题 I´m getting an error when adding JRuby 1.3.1 to pik. Error: Error: private method `gsub' called for nil:NilClass this is my path environment variable: C:\Users\Owner>echo %path% C:\Program Files\Java\jdk1.7.0_05\bin;c:\jruby-1.7.0.preview1\bin;C:\jruby-1.3.1\bin;c:\pik this is when trying to add 1.3.1 version: C:\Users\Owner>pik add C:\jruby-1.3.1\bin There was an error. Error: private method `gsub' called for nil:NilClass in: pik/commands/command.rb:124:in `get_version' in: pik/commands/add

I am familiar with Ruby /DL but not sure how to use the C function calls that have pointers for return parameters

半腔热情 提交于 2019-12-10 07:53:05
问题 I have this function in this Module require 'dl' require 'dl/import' module LibCalendars extend DL::Importer dlload './cal2jd.o' extern 'int iauCal2jd(int, int, int, double *, double *)' end How do I set this up in a Module to get access to the pointers? Is what I need partly in there? I'm just not sure. How is this done correctly? The exact code is at http://www.iausofa.org/2013_1202_C/sofa/cal2jd.c I need to know how to access those address pointers. The validation tests are here http://www

JRuby Heroku Gem

不问归期 提交于 2019-12-10 05:55:05
问题 Is it possible to use Heroku client with JRuby? I have installed heroku gem successfully with all dependencies, but I can't login. PS D:\Projects\myproject> heroku login Enter your Heroku credentials. Email: myname@mydomain.com Password (typing will be hidden): mypassword ! Heroku client internal error. ! Search for help at: https://help.heroku.com ! Or report a bug at: https://github.com/heroku/heroku/issues/new Error: write would raise (OpenSSL::SSL::SSLError) (Excon::Errors::SocketError)

How do I cleanly shut down an embedded JRuby in response to a SIGTERM to the JVM process?

痞子三分冷 提交于 2019-12-09 14:06:02
问题 I am running a Middleman (which uses Webrick) server on JRuby inside a JVM process using the org.jruby.embed.ScriptingContainer API. If I shutdown cleanly and stop the server from inside the JVM, everything works as expected. But if I send a SIGTERM to the JVM process (for example, by hitting ctrl+C at the command line), the console returns but the JVM process does not terminate - it hangs around indefinitely until I send it a SIGKILL. I tried registering a JVM shutdown hook to terminate the

Using a self-signed certificate

走远了吗. 提交于 2019-12-09 11:59:30
问题 I am just trying to get my head around SSL. I have set up a Jetty server on my localhost, and generated my own certificate using Keytool. Now when I go to https://localhost:8443/ I get the can't trust this certificate error. I use keytool -export -alias pongus -keystore keystore -file certfile.cer To create the certificate which I think is what the client needs to authenticate with the server. (This is where I could be very wrong!) I have the following ruby code : require 'net/https' require

How can I tell if I'm running from JRuby vs. Ruby?

百般思念 提交于 2019-12-09 04:16:54
问题 I have a script with a factory method that I would like to return a different implementation of some class depending on whether or not the script is running from JRuby or Ruby. Anyone have any ideas on how I could tell the difference from inside my script? Some initial thoughts I had were: Attempt to 'include Java' and rescue back to the Ruby implementation if it fails. This method doesn't work. Ruby's smart enough to error out regardless of my begin/rescue/end. Do something goofy with

What is the significance for Ruby programmers of SAP's new implementation of Ruby?

老子叫甜甜 提交于 2019-12-08 16:57:25
问题 SAP announced Blue Ruby, a version of Ruby that runs inside the ABAP Virtual Machine. This seems to lend additional credibility to the Ruby language but, except for SAP developers, does this have any applicability to the rest of the Ruby community? I'm just wondering what other significance this may have. Additional job opportunities, perhaps, for Ruby developers to be hired to work on SAP projects? Any other potential benefits for Ruby programmers? Also, something I'm not clear about: