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:     add_key_option
25: 
26:     add_option(
27:       '--host HOST',
28:       'Push to another gemcutter-compatible host'
29:     ) do |value, options|
30:       options[:host] = value
31:     end
32:   end

Public Instance methods

[Source]

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

[Source]

    # File lib/rubygems/commands/push_command.rb, line 39
39:   def send_gem name
40:     args = [:post, "api/v1/gems"]
41: 
42:     args << options[:host] if options[:host]
43: 
44:     if Gem.latest_rubygems_version < Gem::Version.new(Gem::VERSION) then
45:       alert_error "Using beta/unreleased version of rubygems. Not pushing."
46:       terminate_interaction 1
47:     end
48: 
49:     response = rubygems_api_request(*args) do |request|
50:       request.body = Gem.read_binary name
51:       request.add_field "Content-Length", request.body.size
52:       request.add_field "Content-Type",   "application/octet-stream"
53:       request.add_field "Authorization",  api_key
54:     end
55: 
56:     with_response response
57:   end

[Validate]