Skip to content

Commit

Permalink
lib/nuggets/ruby.rb (Process.ruby): Added JRuby variant.
Browse files Browse the repository at this point in the history
  • Loading branch information
blackwinter committed Nov 26, 2014
1 parent b382361 commit 67be07d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
3 changes: 2 additions & 1 deletion ChangeLog
Expand Up @@ -2,12 +2,13 @@

= Revision history for nuggets

== 1.0.2 [unreleased]
== 1.1.0 [unreleased]

* Nuggets::LogParser::Rails no longer <tt>eval</tt>s the params hash; set the
environment variable +NUGGETS_LOG_PARSER_RAILS_EVAL_PARAMS+ to restore this
behaviour.
* Added Object#rescue_if and Object#rescue_unless.
* Added JRuby variant of Process.ruby.

== 1.0.1 [2014-08-27]

Expand Down
27 changes: 17 additions & 10 deletions lib/nuggets/ruby.rb
Expand Up @@ -216,20 +216,27 @@ def shebang_command(filename)

def File.ruby; ::Nuggets::Ruby.ruby_command; end

begin
require 'open4'

if RUBY_PLATFORM == 'java'
def Process.ruby(*args, &block)
argv = ::Nuggets::Ruby.ruby_options_to_argv(args)
::Open4.popen4(*argv, &block)
::IO.popen4(*argv, &block); $?
end
else
begin
require 'open4'

def Process.ruby(*args, &block)
argv = ::Nuggets::Ruby.ruby_options_to_argv(args)
::Open4.popen4(*argv, &block)
end

require 'nuggets/io/interact'
require 'nuggets/io/interact'

def Process.interact_ruby(input, *args)
ruby(*args) { |_, i, o, e|
::IO.interact({ input => i }, { o => $stdout, e => $stderr })
}
def Process.interact_ruby(input, *args)
ruby(*args) { |_, i, o, e|
::IO.interact({ input => i }, { o => $stdout, e => $stderr })
}
end
rescue ::LoadError
end
rescue ::LoadError
end

0 comments on commit 67be07d

Please sign in to comment.