lib/knj/os.rb in knjrbfw-0.0.103 vs lib/knj/os.rb in knjrbfw-0.0.104
- old
+ new
@@ -52,21 +52,22 @@
#===Examples
# print "Can I please move to another machine?" if Knj::Os.os == "windows"
# print "I like it better now." if Knj::Os.os == "linux"
def self.os
if ENV["OS"]
- teststring = ENV["OS"].to_s
+ teststring = ENV["OS"].to_s.downcase
elsif RUBY_PLATFORM
- teststring = RUBY_PLATFORM.to_s
+ teststring = RUBY_PLATFORM.to_s.downcase
end
- if teststring.downcase.index("windows") != nil
+ if teststring.include?("windows")
return "windows"
- elsif teststring.downcase.index("linux") != nil
+ elsif teststring.include?("linux")
return "linux"
+ elsif teststring.include?("darwin")
else
- raise "Could not figure out OS."
+ raise "Could not figure out OS: '#{teststring}'."
end
end
#Returns the current graphical toolkit running.
#===Examples
@@ -219,10 +220,15 @@
#Returns the Ruby executable that is running the current process if possible.
def self.executed_executable
return ENV["rvm_ruby_string"] if !ENV["rvm_ruby_string"].to_s.empty?
+ if ENV["MY_RUBY_HOME"]
+ ruby_bin_path = "#{ENV["MY_RUBY_HOME"]}/bin/ruby"
+ return ruby_bin_path if File.exists?(ruby_bin_path)
+ end
+
#Try to look the executeable up by command.
if self.os == "linux"
unix_proc = Knj::Unix_proc.find_self
if unix_proc
if match_cmd = unix_proc["cmd"].match(/^(\/usr\/bin\/|)((j|iron|)ruby([\d\.-]*))(\s+|$)/)
@@ -232,9 +238,11 @@
end
else
raise "Could not find the self-process."
end
end
+
+ puts ENV.to_hash
raise "Could not figure out the executed executable."
end
end
\ No newline at end of file