Sha256: 8ff7972b698be275851f287172f3d33f4db0f99b47c6ccc4dcb5c0ad5e245950

Contents?: true

Size: 995 Bytes

Versions: 1

Compression:

Stored size: 995 Bytes

Contents

class Gem::Commands::NexusCommand < Gem::AbstractCommand

  def description
    'Push a gem up to Nexus server'
  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 Nexus..."

    path = get_one_gem_name

    response = make_request(:post, "gems/#{File.basename(path)}") do |request|
      request.body = Gem.read_binary(path)
      request.add_field("Content-Length", request.body.size)
      request.add_field("Content-Type", "application/octet-stream")
      request.add_field("Authorization", authorization.strip)
    end

    case response.code
    when "401"
      say "Unauthorized"
    when "400"
      say "something went wrong - maybe (re)deployment is not allowed"
    when "500"
      say "something went wrong"
    else
      say response.message
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nexus-0.1.0 lib/commands/nexus.rb