Class: Gem::Commands::GitinstallCommand

Inherits:
Gem::Command
  • Object
show all
Defined in:
lib/rubygems/commands/gitinstall_command.rb

Instance Method Summary collapse

Constructor Details

#initializeGitinstallCommand

Returns a new instance of GitinstallCommand.



5
6
7
8
9
10
# File 'lib/rubygems/commands/gitinstall_command.rb', line 5

def initialize
  super 'gitinstall', "Install gem from a git repo"
  add_option '--force', 'skip validation of the gemspec' do |value, options|
    options[:force] = true
  end
end

Instance Method Details

#argumentsObject

:nodoc:



40
41
42
# File 'lib/rubygems/commands/gitinstall_command.rb', line 40

def arguments # :nodoc:
  "GEMNAME       name of gem to install"
end

#build_gem(dir) ⇒ Object



25
26
27
28
29
# File 'lib/rubygems/commands/gitinstall_command.rb', line 25

def build_gem(dir)
  force = options[:force] ? " --force" : ""
  run "cd #{dir} && rm -rf *.gem"
  run "cd #{dir} && gem build *.gemspec#{force}"
end

#clone_repo(url, dir) ⇒ Object



21
22
23
# File 'lib/rubygems/commands/gitinstall_command.rb', line 21

def clone_repo(url, dir)
  run "git clone #{url} #{dir}"
end

#executeObject



12
13
14
15
16
17
18
19
# File 'lib/rubygems/commands/gitinstall_command.rb', line 12

def execute
  url = get_one_gem_name
  Dir.mktmpdir "gemgitinstall" do |dir|
    clone_repo(url, dir)
    build_gem(dir)
    install_gem(dir)
  end
end

#install_gem(dir) ⇒ Object



31
32
33
# File 'lib/rubygems/commands/gitinstall_command.rb', line 31

def install_gem(dir)
  run "cd #{dir} && gem install *.gem"
end

#run(cmd) ⇒ Object



35
36
37
38
# File 'lib/rubygems/commands/gitinstall_command.rb', line 35

def run(cmd)
  puts "Executing: #{cmd}"
  system cmd
end

#usageObject

:nodoc:



44
45
46
# File 'lib/rubygems/commands/gitinstall_command.rb', line 44

def usage # :nodoc:
  "#{program_name} GEMNAME"
end