Class: Gem::Commands::InaboxCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::InaboxCommand
- Defined in:
- lib/rubygems/commands/inabox_command.rb
Instance Method Summary collapse
- #arguments ⇒ Object
- #config_path ⇒ Object
- #configure ⇒ Object
- #description ⇒ Object
- #execute ⇒ Object
- #geminabox_host ⇒ Object
- #geminabox_host=(host) ⇒ Object
-
#initialize ⇒ InaboxCommand
constructor
A new instance of InaboxCommand.
- #last_minute_requires! ⇒ Object
- #send_gems(gemfiles) ⇒ Object
- #usage ⇒ Object
Constructor Details
#initialize ⇒ InaboxCommand
Returns a new instance of InaboxCommand.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rubygems/commands/inabox_command.rb', line 18 def initialize super 'inabox', description add_option('-c', '--configure', "Configure GemInABox") do |value, | [:configure] = true end add_option('-g', '--host HOST', "Host to upload to.") do |value, | [:host] = value end add_option('-o', '--overwrite', "Overwrite Gem.") do |value, | [:overwrite] = true end add_option('-p', '--port', "Sets port") do |value, | [:port] = value end end |
Instance Method Details
#arguments ⇒ Object
10 11 12 |
# File 'lib/rubygems/commands/inabox_command.rb', line 10 def arguments "GEM built gem to push up" end |
#config_path ⇒ Object
72 73 74 |
# File 'lib/rubygems/commands/inabox_command.rb', line 72 def config_path File.join(Gem.user_home, '.gem', 'geminabox') end |
#configure ⇒ Object
76 77 78 79 80 |
# File 'lib/rubygems/commands/inabox_command.rb', line 76 def configure say "Enter the root url for your personal geminabox instance (e.g. http://gems/)." host = ask("Host:") self.geminabox_host = host end |
#description ⇒ Object
6 7 8 |
# File 'lib/rubygems/commands/inabox_command.rb', line 6 def description 'Push a gem up to your GemInABox' end |
#execute ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rubygems/commands/inabox_command.rb', line 43 def execute last_minute_requires! return configure if [:configure] configure unless geminabox_host if [:args].size == 0 say "You didn't specify a gem, looking for one in . and in ./pkg/..." gemfiles = [GeminaboxClient::GemLocator.find_gem(Dir.pwd)] else gemfiles = get_all_gem_names end send_gems(gemfiles) end |
#geminabox_host ⇒ Object
82 83 84 |
# File 'lib/rubygems/commands/inabox_command.rb', line 82 def geminabox_host @geminabox_host ||= [:host] || Gem.configuration.load_file(config_path)[:host] end |
#geminabox_host=(host) ⇒ Object
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/rubygems/commands/inabox_command.rb', line 86 def geminabox_host=(host) config = Gem.configuration.load_file(config_path).merge(:host => host) dirname = File.dirname(config_path) Dir.mkdir(dirname) unless File.exist?(dirname) File.open(config_path, 'w') do |f| f.write config.to_yaml end end |
#last_minute_requires! ⇒ Object
38 39 40 41 |
# File 'lib/rubygems/commands/inabox_command.rb', line 38 def last_minute_requires! require 'yaml' require File.("../../../geminabox_client.rb", __FILE__) end |
#send_gems(gemfiles) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rubygems/commands/inabox_command.rb', line 58 def send_gems(gemfiles) client = GeminaboxClient.new(geminabox_host) gemfiles.each do |gemfile| say "Pushing #{File.basename(gemfile)} to #{client.url}..." begin say client.push(gemfile, ) rescue GeminaboxClient::Error => e alert_error e. terminate_interaction(1) end end end |
#usage ⇒ Object
14 15 16 |
# File 'lib/rubygems/commands/inabox_command.rb', line 14 def usage "#{program_name} GEM" end |