class BitGirder::Ops::Ruby::RubyContext
Public Class Methods
from_mingle_struct( s )
click to toggle source
# File lib/bitgirder/ops/ruby.rb, line 166 def self.from_mingle_struct( s ) self.new( id: s.expect_string( :id ), ruby_home: s.expect_string( :ruby_home ), gem_home: s.expect_string( :gem_home ), ruby_flavor: s.get_string( :ruby_flavor ), env: read_env_in( s ) ) end
read_env_in( s )
click to toggle source
# File lib/bitgirder/ops/ruby.rb, line 150 def self.read_env_in( s ) ( s[ :env ] || [] ).inject( {} ) do |env, pair| nm, val = pair[ 0 ], pair[ 1 ] if env.key?( nm ) raise "Multiple definitions of env var #{nm}" else env[ nm ] = val end env end end
Public Instance Methods
get_env_var_rubylib()
click to toggle source
# File lib/bitgirder/ops/ruby.rb, line 125 def get_env_var_rubylib res = get_ruby_include_dirs.join( ":" ) if prev = ENV[ ENV_RUBYLIB ] res << ":#{prev}" end res end
get_ruby_include_dirs()
click to toggle source
# File lib/bitgirder/ops/ruby.rb, line 116 def get_ruby_include_dirs if @ruby_flavor == "jruby" [] else RubyIncludes.get_ruby_include_dirs( ruby_home: @ruby_home ) end end
prepend_path_ruby_home()
click to toggle source
# File lib/bitgirder/ops/ruby.rb, line 112 def prepend_path_ruby_home "#@gem_home/bin:#@ruby_home/bin:#{ENV[ ENV_PATH ]}" end
proc_builder_opts( cmd = nil )
click to toggle source
# File lib/bitgirder/ops/ruby.rb, line 136 def proc_builder_opts( cmd = nil ) opts = { opts: {}, argv: [] } opts[ :env ] = @env.merge( ENV_GEM_HOME => @gem_home, ENV_PATH => prepend_path_ruby_home, ) opts[ :cmd ] = rcmd( cmd ) if cmd opts end
rcmd( cmd, alts = true )
click to toggle source
# File lib/bitgirder/ops/ruby.rb, line 98 def rcmd( cmd, alts = true ) not_nil( cmd, :cmd ) cmds = [ cmd ] cmds << "j#{cmd}" if alts bin_dirs = [ @gem_home, @ruby_home ].map { |dir| "#{dir}/bin" } files = bin_dirs.map { |bd| cmds.map { |cmd| "#{bd}/#{cmd}" } }.flatten files.find { |f| File.exist?( f ) } or raise "No #{cmd} in #{bin_dirs.join( " or " )}" end