Sha256: da753f359b081283ddcd795cfe30a9e982d18d62112af950ff9e25730a0936ef

Contents?: true

Size: 986 Bytes

Versions: 2

Compression:

Stored size: 986 Bytes

Contents

require 'net/http'
require 'net/https'
require 'rubygems/local_remote_options'

class Gem::Commands::PushCommand < Gem::AbstractCommand

  include Gem::LocalRemoteOptions

  def description
    'Push a gem up to Gemcutter'
  end

  def arguments
    "GEM       built gem to push up"
  end

  def usage
    "#{program_name} GEM"
  end

  def initialize
    super 'push', description
    add_proxy_option
  end

  def execute
    setup
    send_gem
  end

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

    name = get_one_gem_name
    url = URI.parse("#{gemcutter_url}/gems")

    http = proxy_class.new(url.host, url.port)
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
    http.use_ssl = (url.scheme == 'https')
    request = proxy_class::Post.new(url.path)
    request.body = File.open(name).read
    request.add_field("Content-Length", request.body.size)
    request.add_field("Authorization", api_key)

    response = http.request(request)

    say response.body
  end

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
qrush-gemcutter-0.0.7 lib/commands/push.rb
gemcutter-0.0.7 lib/commands/push.rb