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 @@ def SystemUniversal.description @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(' ')