Class: Gem::Commands::MultirepCommand

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

Overview

new, #execute, #arguments, #defaults_str, #description and #usage Gem.ensure_gem_subdirectories @gem_home

Constant Summary collapse

DEFAULT_CONFIG_FILE =
File.join system_config_path, 'repositories_gemrc'

Instance Method Summary collapse

Constructor Details

#initializeMultirepCommand

Returns a new instance of MultirepCommand.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rubygems/commands/multirep_command.rb', line 26

def initialize
  @repositories = []
  
  super 'multirep', "Add capability to have multiple local GEM repositories"

  add_option('-a', '--add PATH', 'Add new repository to list') do |value, options|
    options[:add] = value
  end

  add_option('-r', '--remove PATH', 'Remove repository from list') do |value, options|
    options[:remove] = value
  end
  
  remove_option '--config-file'
end

Instance Method Details

#descriptionObject

:nodoc:



46
47
48
# File 'lib/rubygems/commands/multirep_command.rb', line 46

def description # :nodoc:
  ""
end

#executeObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/rubygems/commands/multirep_command.rb', line 50

def execute
  @repositories = load_file(DEFAULT_CONFIG_FILE)
  
  if options[:add] || options[:remove]
    if options[:add]
      require 'ruby-debug'
      debugger
      
      @repositories << options[:add]
    elsif options[:remove]
      @repositories.delete(options[:remove])
    end
    
    save_file(DEFAULT_CONFIG_FILE)
  end
  
  say "List of repositories:"
  say @repositories
end

#usageObject

:nodoc:



42
43
44
# File 'lib/rubygems/commands/multirep_command.rb', line 42

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