Class Gem::Commands::PushCommand
In: lib/rubygems/commands/push_command.rb
Parent: Gem::Command

Methods

execute   new   send_gem  

Included Modules

Gem::LocalRemoteOptions Gem::GemcutterUtilities

Public Class methods

[Source]

    # File lib/rubygems/commands/push_command.rb, line 21
21:   def initialize
22:     super 'push', description
23:     add_proxy_option
24:     
25:     add_option(
26:       '--host HOST',
27:       'Push to another gemcutter-compatible host'
28:     ) do |value, options|
29:       options[:host] = value
30:     end
31:   end

Public Instance methods

[Source]

    # File lib/rubygems/commands/push_command.rb, line 33
33:   def execute
34:     sign_in
35:     send_gem get_one_gem_name
36:   end

[Source]

    # File lib/rubygems/commands/push_command.rb, line 38
38:   def send_gem name
39:     say "Pushing gem to #{options[:host] || Gem.host}..."
40: 
41:     args = [:post, "api/v1/gems"]
42: 
43:     args << options[:host] if options[:host]
44: 
45:     response = rubygems_api_request(*args) do |request|
46:       request.body = Gem.read_binary name
47:       request.add_field "Content-Length", request.body.size
48:       request.add_field "Content-Type",   "application/octet-stream"
49:       request.add_field "Authorization",  Gem.configuration.rubygems_api_key
50:     end
51: 
52:     with_response response
53:   end

[Validate]