refactored Ruby version tokens handling
This commit is contained in:
parent
48007e519c
commit
a988abd1b9
|
@ -22,7 +22,12 @@ module RedStorm
|
||||||
$1
|
$1
|
||||||
end
|
end
|
||||||
|
|
||||||
module_function :current_ruby_mode
|
def jruby_mode_token(ruby_version = nil)
|
||||||
|
version_map = {"1.8" => "RUBY1_8", "--1.8" => "RUBY1_8", "1.9" => "RUBY1_9", "--1.9" => "RUBY1_9"}
|
||||||
|
version_map[ruby_version.to_s] || version_map[RedStorm.current_ruby_mode]
|
||||||
|
end
|
||||||
|
|
||||||
|
module_function :current_ruby_mode, :jruby_mode_token
|
||||||
|
|
||||||
# puts("*** LAUNCH_PATH=#{LAUNCH_PATH}")
|
# puts("*** LAUNCH_PATH=#{LAUNCH_PATH}")
|
||||||
# puts("*** JAR_CONTEXT=#{JAR_CONTEXT}")
|
# puts("*** JAR_CONTEXT=#{JAR_CONTEXT}")
|
||||||
|
|
|
@ -29,8 +29,7 @@ end
|
||||||
|
|
||||||
task :launch, :env, :ruby_mode, :class_file do |t, args|
|
task :launch, :env, :ruby_mode, :class_file do |t, args|
|
||||||
# use ruby mode parameter or default to current interpreter version
|
# use ruby mode parameter or default to current interpreter version
|
||||||
version_map = {"--1.8" => "RUBY1_8", "--1.9" => "RUBY1_9"}
|
version_token = RedStorm.jruby_mode_token(args[:ruby_mode])
|
||||||
version_token = version_map[args[:ruby_mode] || "--#{RedStorm.current_ruby_mode}"]
|
|
||||||
|
|
||||||
command = case args[:env]
|
command = case args[:env]
|
||||||
when "local"
|
when "local"
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
require 'red_storm/environment'
|
||||||
|
|
||||||
|
describe RedStorm do
|
||||||
|
|
||||||
|
describe "jruby_mode_token" do
|
||||||
|
|
||||||
|
it "should default to current JRuby mode" do
|
||||||
|
RedStorm.should_receive(:current_ruby_mode).and_return("1.8")
|
||||||
|
RedStorm.jruby_mode_token.should == "RUBY1_8"
|
||||||
|
|
||||||
|
RedStorm.should_receive(:current_ruby_mode).and_return("1.9")
|
||||||
|
RedStorm.jruby_mode_token.should == "RUBY1_9"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should use provided version" do
|
||||||
|
RedStorm.should_receive(:current_ruby_mode).never
|
||||||
|
|
||||||
|
RedStorm.jruby_mode_token("1.8").should == "RUBY1_8"
|
||||||
|
RedStorm.jruby_mode_token("--1.8").should == "RUBY1_8"
|
||||||
|
|
||||||
|
RedStorm.jruby_mode_token("1.9").should == "RUBY1_9"
|
||||||
|
RedStorm.jruby_mode_token("--1.9").should == "RUBY1_9"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should default to current JRuby mode on invalid version" do
|
||||||
|
RedStorm.should_receive(:current_ruby_mode).and_return("1.9")
|
||||||
|
RedStorm.jruby_mode_token("foobar").should == "RUBY1_9"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue