lib/user.rb in sprout-0.5.19 vs lib/user.rb in sprout-0.5.23
- old
+ new
@@ -39,10 +39,14 @@
def User.home=(path)
User.new().home = path
end
+ def User.in_path?(executable)
+ User.new().in_path?(executable)
+ end
+
def User.home
User.new().home
end
def User.application_home(name)
@@ -111,10 +115,28 @@
return @home = "/"
end
end
end
+ def get_exe_path(executable)
+ paths = get_paths
+ paths.each do |path|
+ if(File.exists?(File.join(path, executable)))
+ return File.join(path, executable)
+ end
+ end
+ return nil
+ end
+
+ def in_path?(executable)
+ return !get_exe_path(executable).nil?
+ end
+
+ def get_paths
+ return ENV['PATH'].split(':')
+ end
+
def library
return home
end
def platform
@@ -131,11 +153,15 @@
return ProcessRunner.new(command)
end
def execute(tool, options='')
tool = Sprout.load(tool)
- target = tool.archive_path
+ if(tool.executable)
+ target = get_exe_path(tool.executable)
+ else
+ target = tool.archive_path
+ end
Log.puts(">> Execute: #{File.basename(target)} #{options}")
runner = get_process_runner("#{clean_path(target)} #{options}")
result = runner.read
error = runner.read_err
if(result.size > 0)
@@ -201,9 +227,13 @@
usr = super
if(usr.index "My Documents")
usr = File.dirname(usr)
end
return usr
+ end
+
+ def get_paths
+ return ENV['PATH'].split(';')
end
def library
# For some reason, my homepath returns inside 'My Documents'...
application_data = File.join(home, @@LOCAL_SETTINGS, @@APPLICATION_DATA)