GemInstaller

Public Class Methods

autogem(args = []) click to toggle source
    # File lib/geminstaller.rb, line 27
27:   def self.autogem(args = [])
28:     args_copy = args.dup
29:     args_copy = args_copy.split(' ') unless args.respond_to? :join
30:     # TODO: should explicitly remove all args not applicable to autogem (anything but config, silent, and geminstaller_output)

31:     args_without_sudo = strip_sudo(args_copy)
32:     app = create_application(args_without_sudo)
33:     app.autogem
34:   end
create_application(args = [], registry = nil) click to toggle source
    # File lib/geminstaller.rb, line 40
40:   def self.create_application(args = [], registry = nil)
41:     registry ||= create_registry
42:     app = registry.app
43:     app.args = args
44:     app
45:   end
create_registry() click to toggle source
    # File lib/geminstaller.rb, line 47
47:   def self.create_registry
48:     GemInstaller::Registry.new
49:   end
find_geminstaller_executable() click to toggle source
     # File lib/geminstaller.rb, line 80
 80:   def self.find_geminstaller_executable
 81:     possible_locations = [
 82:       'ruby -S geminstaller',
 83:       'ruby /usr/local/bin/geminstaller',
 84:       'ruby /usr/bin/geminstaller',
 85:       'ruby ./bin/geminstaller'
 86:       ]
 87:     path_key = 'geminstaller_exec_path='
 88:     possible_locations.each do |possible_location|
 89:       cmd = "#{possible_location} --geminstaller-exec-path"
 90: 
 91:       $stderr_backup = $stderr.dup
 92:       $stderr.reopen("/dev/null", "w")
 93:       io = IO.popen(cmd)
 94:       $stderr.reopen($stderr_backup)
 95:       STDERR.reopen($stderr_backup) # Why are these not the same?  It is an old question: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/47596

 96:       output = io.read
 97:       next unless output =~ /#{path_key}/
 98:       path = output.sub(path_key,'')
 99:       return path
100:     end
101:     raise GemInstaller::GemInstallerError.new("Error: Unable to locate the geminstaller executable.  Specify it explicitly, or don't use the sudo option.")
102:   end
install(args = [], geminstaller_executable = nil) click to toggle source
    # File lib/geminstaller.rb, line 5
 5:   def self.install(args = [], geminstaller_executable = nil)
 6:     args_copy = args.dup
 7:     args_copy = args_copy.split(' ') unless args.respond_to? :join
 8:     # recursively call script with sudo, if --sudo option is specified

 9:     if platform_supports_sudo? and (args_copy.include?("-s") or args_copy.include?("--sudo"))
10:       result = reinvoke_with_sudo(args_copy, geminstaller_executable)
11:       if result != 0 and (args_copy.include?("-e") or args_copy.include?("--exceptions"))
12:         message = "Error: GemInstaller failed while being invoked with --sudo option.  See prior output for error, and use '--geminstaller-output=all --rubygems-output=all' options to get more details."
13:         raise GemInstaller::GemInstallerError.new(message)
14:       end
15:       return result
16:     else
17:       app = create_application(args_copy)
18:       app.install
19:     end
20:   end
parse_config_paths(config_paths) click to toggle source
    # File lib/geminstaller.rb, line 51
51:   def self.parse_config_paths(config_paths)
52:     return nil unless config_paths
53:     return config_paths unless config_paths.respond_to? :join
54:     return config_paths.join(',')
55:   end
platform_supports_sudo?() click to toggle source
    # File lib/geminstaller.rb, line 57
57:   def self.platform_supports_sudo?
58:     return true unless RUBY_PLATFORM =~ /mswin/
59:     return false
60:   end
reinvoke_with_sudo(args, geminstaller_executable) click to toggle source
    # File lib/geminstaller.rb, line 62
62:   def self.reinvoke_with_sudo(args, geminstaller_executable)
63:     # Sudo support is a hack, better to use other alternatives.

64:     geminstaller_executable ||= find_geminstaller_executable
65:     args_without_sudo = strip_sudo(args)
66:     args_without_sudo << '--redirect-stderr-to-stdout'
67:     cmd = "sudo ruby #{geminstaller_executable} #{args_without_sudo.join(' ')}"
68:     # TODO: this eats any output.  There currently is no standard way to get a return code AND stdin AND stdout.

69:     # Some non-standard packages like Open4 handle this, but not synchronously.  The Simplest Thing That Could

70:     # Possibly Work is to have a command line option which will cause all stderr output to be redirected to stdout.

71:     result = system(cmd)
72:     return 1 unless result
73:     return $?.exitstatus
74:   end
run(args = [], geminstaller_executable = nil) click to toggle source
    # File lib/geminstaller.rb, line 22
22:   def self.run(args = [], geminstaller_executable = nil)
23:     # run is now an alias for install

24:     install(args, geminstaller_executable)
25:   end
strip_sudo(args) click to toggle source
    # File lib/geminstaller.rb, line 76
76:   def self.strip_sudo(args)
77:     return args.reject {|arg| arg == "-s" || arg == "--sudo"}
78:   end
version() click to toggle source
    # File lib/geminstaller.rb, line 36
36:   def self.version
37:     "0.5.6"
38:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.