Class: Jeweler::Commands::InstallGem

Inherits:
Object
  • Object
show all
Defined in:
lib/jeweler/commands/install_gem.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInstallGem

Returns a new instance of InstallGem.



8
9
10
# File 'lib/jeweler/commands/install_gem.rb', line 8

def initialize
  self.output = $stdout
end

Instance Attribute Details

#gemspec_helperObject

Returns the value of attribute gemspec_helper.



6
7
8
# File 'lib/jeweler/commands/install_gem.rb', line 6

def gemspec_helper
  @gemspec_helper
end

#outputObject

Returns the value of attribute output.



6
7
8
# File 'lib/jeweler/commands/install_gem.rb', line 6

def output
  @output
end

Class Method Details

.build_for(jeweler) ⇒ Object



32
33
34
35
36
37
# File 'lib/jeweler/commands/install_gem.rb', line 32

def self.build_for(jeweler)
  command = new
  command.output = jeweler.output
  command.gemspec_helper = jeweler.gemspec_helper
  command
end

Instance Method Details

#host_osObject



28
29
30
# File 'lib/jeweler/commands/install_gem.rb', line 28

def host_os
  Config::CONFIG['host_os']
end

#runObject



13
14
15
16
17
18
# File 'lib/jeweler/commands/install_gem.rb', line 13

def run
  command = "gem install #{gemspec_helper.gem_path}"
  output.puts "Executing #{command.inspect}:"

  sh sudo_wrapper(command) # TODO where does sh actually come from!? - rake, apparently
end

#sudo_wrapper(command) ⇒ Object



20
21
22
# File 'lib/jeweler/commands/install_gem.rb', line 20

def sudo_wrapper(command)
  use_sudo? ? "sudo #{command}" : command
end

#use_sudo?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/jeweler/commands/install_gem.rb', line 24

def use_sudo?
  host_os !~ /mswin|windows|cygwin/i
end