Class Sprout::User
In: sprout/lib/sprout/user.rb
Parent: Object

The User class provides a single and consistent interface to User based paths and features so that Sprout implementation code doesn‘t need to be concerned with which Operating system it is running on.

Methods

Public Class methods

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

[Source]

# 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.

[Source]

# 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.

[Source]

# File sprout/lib/sprout/user.rb, line 100
    def User.execute(tool, options='')
      return User.new().execute(tool, options)
    end

[Source]

# File sprout/lib/sprout/user.rb, line 104
    def User.execute_silent(tool, options='')
      return User.new().execute_silent(tool, options)
    end

Execute a named tool sprout as a new thread and return that thread

[Source]

# File sprout/lib/sprout/user.rb, line 109
    def User.execute_thread(tool, options='')
      if(Log.debug)
         return ThreadMock.new
      else
         return User.new().execute_thread(tool, options)
      end
    end

Retrieve the full path to an executable that exists in the user path

[Source]

# 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:~/

[Source]

# 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

[Source]

# File sprout/lib/sprout/user.rb, line 57
    def User.in_path?(executable)
      User.new().in_path?(executable)
    end

[Source]

# File sprout/lib/sprout/user.rb, line 51
    def User.is_a?(type)
      User.new().is_a?(type)
    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:~/

[Source]

# 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.

[Source]

# 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

[Validate]