diff options
author | Aman Gupta <aman@tmm1.net> | 2015-02-11 17:56:18 -0800 |
---|---|---|
committer | Aman Gupta <aman@tmm1.net> | 2015-02-11 17:56:18 -0800 |
commit | 0e2073b4300d6e6c880c1788300a5c2c1ad7ec65 (patch) | |
tree | 0629bcdaac4f2bad4018ed5ca27bb691bf3a5e6a | |
parent | 35340f1e91941af47988b1b9d77705493b96d3db (diff) | |
download | systemu-0e2073b4300d6e6c880c1788300a5c2c1ad7ec65.tar.gz |
make ruby_exe resolution lazy
-rw-r--r-- | lib/systemu.rb | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/systemu.rb b/lib/systemu.rb index c32b9bc..bc5b577 100644 --- a/lib/systemu.rb +++ b/lib/systemu.rb @@ -29,16 +29,20 @@ class SystemUniversal @pid = Process.pid @turd = ENV['SYSTEMU_TURD'] - c = begin; ::RbConfig::CONFIG; rescue NameError; ::Config::CONFIG; end - ruby = File.join(c['bindir'], c['ruby_install_name']) << c['EXEEXT'] - @ruby = if system('%s -e 42' % ruby) - ruby - else - system('%s -e 42' % 'ruby') ? 'ruby' : warn('no ruby in PATH/CONFIG') + def self.ruby + return @ruby if @ruby + + c = begin; ::RbConfig::CONFIG; rescue NameError; ::Config::CONFIG; end + ruby = File.join(c['bindir'], c['ruby_install_name']) << c['EXEEXT'] + @ruby = if system('%s -e 42' % ruby) + ruby + else + system('%s -e 42' % 'ruby') ? 'ruby' : warn('no ruby in PATH/CONFIG') + end end class << SystemUniversal - %w( host ppid pid ruby turd ).each{|a| attr_accessor a} + %w( host ppid pid turd ).each{|a| attr_accessor a} def quote(*words) words.map{|word| word.inspect}.join(' ') |