Sha256: 6702468397e6ed02565e40e8704ae1a60476f35608f740294cc74a83e1e39557

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require 'rubygems/tasks/task'

module Gem
  class Tasks
    #
    # The `push` task.
    #
    class Push < Task

      # The Gemcutter host to push gems to.
      attr_accessor :host

      #
      # Initializes the `push` task.
      #
      # @param [Hash] options
      #   Additional options.
      #
      # @option options [String] :host
      #   The Gemcutter host to push gems to.
      #
      def initialize(options={})
        super()

        @host = options[:host]

        yield self if block_given?
        define
      end

      #
      # Defines the `push` task.
      #
      def define
        namespace :push do
          @project.builds.each do |build,packages|
            path = packages[:gem]

            task build => path do
              arguments = []

              if @host
                arguments << '--host' << @host

                status "Pushing #{File.basename(path)} to #{@host} ..."
              else
                status "Pushing #{File.basename(path)} ..."
              end

              run 'gem', 'push', path, *arguments
            end
          end
        end

        gemspec_tasks :push

        # backwards compatibility for Hoe
        task :publish => :push
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubygems-tasks-0.1.0.pre1 lib/rubygems/tasks/push.rb