Class: BitGirder::Ops::Ruby::RubyContext
- Inherits:
-
BitGirderClass
- Object
- BitGirderClass
- BitGirder::Ops::Ruby::RubyContext
- Defined in:
- lib/bitgirder/ops/ruby.rb
Class Method Summary collapse
Instance Method Summary collapse
- #get_env_var_rubylib ⇒ Object
- #get_ruby_include_dirs ⇒ Object
- #prepend_path_ruby_home ⇒ Object
- #proc_builder_opts(cmd = nil) ⇒ Object
- #rcmd(cmd, alts = true) ⇒ Object
Class Method Details
.from_mingle_struct(s) ⇒ Object
166 167 168 169 170 171 172 173 174 175 |
# 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) ⇒ Object
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# 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 |
Instance Method Details
#get_env_var_rubylib ⇒ Object
125 126 127 128 129 130 131 132 133 134 |
# 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 ⇒ Object
116 117 118 119 120 121 122 123 |
# 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 ⇒ Object
112 113 114 |
# 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) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 |
# 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) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 |
# 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 |