-
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from bundler/various-fixes-2
Various fixes 2
- Loading branch information
Showing
9 changed files
with
164 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Run a JRuby program in process. | ||
class InProcessExec | ||
attr_reader :status, :output | ||
|
||
def initialize(env, dir, args) | ||
raise "InProcessExec is only valid on JRuby!" unless RUBY_PLATFORM == "java" | ||
@env = env | ||
@dir = dir | ||
@args = args | ||
exec | ||
end | ||
|
||
private | ||
|
||
def exec | ||
prepare_streams | ||
prepare_config | ||
@status = org.jruby.Main.new(@config).run(@args.to_java(:String)).status | ||
@output = @output_stream.to_string | ||
end | ||
|
||
def prepare_streams | ||
@input_stream = java.io.ByteArrayInputStream.new([].to_java(:byte)) | ||
@output_stream = java.io.ByteArrayOutputStream.new | ||
@output_print_stream = java.io.PrintStream.new(@output_stream) | ||
end | ||
|
||
def prepare_config | ||
@config = org.jruby.RubyInstanceConfig.new(JRuby.runtime.instance_config) | ||
@config.environment = @env | ||
@config.current_directory = @dir | ||
@config.input = @input_stream | ||
@config.output = @output_print_stream | ||
@config.error = @output_print_stream | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require "rubygems" | ||
gem "bundler" | ||
require "bundler" | ||
require "bundler/fetcher" | ||
require_relative "../in_process_exec.rb" | ||
|
||
module Bundler | ||
#:nodoc: | ||
class Fetcher | ||
# The Bundler user_agent uses SecureRandom, which causes the specs | ||
# to run out of entropy and run a lot longer than they need to. | ||
def user_agent | ||
"gemstash spec" | ||
end | ||
end | ||
end | ||
|
||
def Kernel.exec(*args) | ||
args.pop if args.last.kind_of?(Hash) | ||
process = InProcessExec.new(ENV, File.expand_path("."), args) | ||
puts process.output | ||
exit process.status | ||
end | ||
|
||
load Gem.bin_path("bundler", "bundle") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Based on jgem | ||
require "rubygems" | ||
require "rubygems/gem_runner" | ||
require "rubygems/exceptions" | ||
|
||
begin | ||
Gem::GemRunner.new.run ARGV.clone | ||
rescue Gem::SystemExitException => e | ||
exit e.exit_code | ||
end |