diff options
author | Vassilis Rizopoulos <vassilisrizopoulos@gmail.com> | 2015-03-19 12:56:23 +0100 |
---|---|---|
committer | Vassilis Rizopoulos <vassilisrizopoulos@gmail.com> | 2015-03-19 12:56:23 +0100 |
commit | 47f55145454c702bfad999ca81e5ffeabd828527 (patch) | |
tree | 7f2e61755e0c93d99d888bdc155e02e3dbcf72be | |
parent | 56241a5899c89fedd78060e6ba96b75e6b736639 (diff) | |
parent | b8f8b78a3e72a9dc4ce2ac885cc5cdb742f81d3b (diff) | |
download | systemu-47f55145454c702bfad999ca81e5ffeabd828527.tar.gz |
Merge pull request #38 from tmm1/lazy-ruby-lookup
Make ruby exe resolution lazy
-rw-r--r-- | lib/systemu.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/systemu.rb b/lib/systemu.rb index 2f045d2..3812d4e 100644 --- a/lib/systemu.rb +++ b/lib/systemu.rb @@ -28,17 +28,22 @@ class SystemUniversal @ppid = Process.ppid @pid = Process.pid @turd = ENV['SYSTEMU_TURD'] + @ruby = nil - 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(' ') |