Class: Gem::Commands::CloneCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::CloneCommand
- Defined in:
- lib/rubygems/commands/clone_command.rb
Instance Method Summary collapse
-
#arguments ⇒ Object
:nodoc:.
-
#description ⇒ Object
:nodoc:.
- #execute ⇒ Object
-
#initialize ⇒ CloneCommand
constructor
A new instance of CloneCommand.
Constructor Details
#initialize ⇒ CloneCommand
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rubygems/commands/clone_command.rb', line 8 def initialize super 'clone', 'Clone a gem repository using git goget, ghq, or git' add_option('-v', '--verbose', 'Show verbose output') do |value, | [:verbose] = true end add_option('-u', '--show-url', 'Show repository URL without cloning') do |value, | [:show_url] = true end end |
Instance Method Details
#arguments ⇒ Object
:nodoc:
20 21 22 |
# File 'lib/rubygems/commands/clone_command.rb', line 20 def arguments # :nodoc: "GEM_NAME name of gem to clone" end |
#description ⇒ Object
:nodoc:
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rubygems/commands/clone_command.rb', line 24 def description # :nodoc: "The clone command fetches gem metadata from RubyGems.org and clones\nthe gem's source repository using git goget (preferred), ghq, or git\nbased on the homepage or source_code_uri from the gem's metadata.\n\nExamples:\ngem clone sinatra\ngem clone rails --verbose\ngem clone rails --show-url\n EOF\nend\n" |
#execute ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rubygems/commands/clone_command.rb', line 37 def execute gem_name = get_one_gem_name say "Fetching gem metadata for '#{gem_name}'..." if [:verbose] gem_info = fetch_gem_info(gem_name) if gem_info.nil? alert_error "Could not find gem '#{gem_name}'" terminate_interaction 1 end repository_url = extract_repository_url(gem_info) if repository_url.nil? alert_error "Could not find repository URL for gem '#{gem_name}'" terminate_interaction 1 end say "Found repository URL: #{repository_url}" if [:verbose] if [:show_url] say repository_url else clone_repository(repository_url) end end |