| Class | Sprout::User |
| In: |
sprout/lib/sprout/user.rb
|
| Parent: | Object |
Returns the home path for a named application based on the currently logged in user and operating system. If the user name is lbayes and the application name is Sprouts, this path will be:
| Windows XP: | C:\Documents And Settings\lbayes\Local Settings\Application Data\Sprouts |
| Cygwin: | /cygdrive/c/Documents And Settings/Local Settings/Application Data/Sprouts |
| OS X: | /Users/lbayes/Library/Sprouts |
| Linux: | ~/.sprouts |
# File sprout/lib/sprout/user.rb, line 83 def User.application_home(name) return User.new().application_home(name) end
Clean a path string in such a way that works for each platform. For example, Windows doesn‘t like it when we backslash to escape spaces in a path because that is the character they use as a delimiter. And OS X doesn‘t really like it when we wrap paths in quotes.
# File sprout/lib/sprout/user.rb, line 120 def User.clean_path(path) return User.new().clean_path(path) end
Execute a named tool sprout. The full sprout name should be provided to the tool parameter, and a string of shell parameters that will be sent to the tool itself.
# File sprout/lib/sprout/user.rb, line 100 def User.execute(tool, options='') return User.new().execute(tool, options) end
# File sprout/lib/sprout/user.rb, line 104 def User.execute_silent(tool, options='') return User.new().execute_silent(tool, options) end
Retrieve the full path to an executable that exists in the user path
# File sprout/lib/sprout/user.rb, line 62 def User.get_exe_path(executable) return User.new().get_exe_path(executable) end
Return the home path for the currently logged in user. If the user name is lbayes, this should be:
| Windows XP: | C:\Documents And Settings\lbayes |
| Cygwin: | /cygdrive/c/Documents And Settings/lbayes |
| OS X: | /Users/lbayes |
| Linux: | ~/ |
# File sprout/lib/sprout/user.rb, line 72 def User.home User.new().home end
Pass an executable or binary file name and find out if that file exists in the system path or not
# File sprout/lib/sprout/user.rb, line 57 def User.in_path?(executable) User.new().in_path?(executable) end
Returns the library path on the current system. This is the general path where all applications should store configuration or session data.
| Windows XP: | C:\Documents And Settings\lbayes\Local Settings\Application Data |
| Cygwin: | /cygdrive/c/Documents And Settings/lbayes/Local Settings/Application Data |
| OS X: | /Users/lbayes/Library |
| Linux: | ~/ |
# File sprout/lib/sprout/user.rb, line 94 def User.library return User.new().library end
Retrieve a user instance that represents the currently logged in user on this system.
# File sprout/lib/sprout/user.rb, line 18 def User.new(os=nil, impl=nil) if(os.nil? && impl.nil? && @@user) return @@user end if(os.nil?) os = Platform::OS end if(impl.nil?) impl = Platform::IMPL end if(os == :win32 && impl == :vista) @@user = VistaUser.new elsif(os == :win32 && impl == :cygwin) @@user = CygwinUser.new elsif(os == :win32) @@user = WinUser.new elsif(os == :unix && impl == :macosx) @@user = OSXUser.new # elsif(os == :unix && impl == :linux) # @@user = UnixUser.new else @@user = UnixUser.new end end