Class: Gem::Commands::PushCommand

Inherits:
AbstractCommand
  • Object
show all
Defined in:
lib/commands/push.rb

Instance Method Summary collapse

Constructor Details

#initializePushCommand

Returns a new instance of PushCommand.



15
16
17
18
# File 'lib/commands/push.rb', line 15

def initialize
  super 'push', description
  add_proxy_option
end

Instance Method Details

#argumentsObject



7
8
9
# File 'lib/commands/push.rb', line 7

def arguments
  "GEM       built gem to push up"
end

#descriptionObject



3
4
5
# File 'lib/commands/push.rb', line 3

def description
  'Push a gem up to Gemcutter'
end

#executeObject



20
21
22
23
# File 'lib/commands/push.rb', line 20

def execute
  setup
  send_gem
end

#send_gemObject



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/commands/push.rb', line 25

def send_gem
  say "Pushing gem to Gemcutter..."

  name = get_one_gem_name
  response = make_request(:post, "gems") do |request|
    request.body = File.open(name).read
    request.add_field("Content-Length", request.body.size)
    request.add_field("Content-Type", "application/octet-stream")
    request.add_field("Authorization", api_key)
  end

  say response.body
end

#usageObject



11
12
13
# File 'lib/commands/push.rb', line 11

def usage
  "#{program_name} GEM"
end