Sha256: ca79a1fff7577c634c531fde4893e19071f73f8ab581260ebbe7669369d903c8

Contents?: true

Size: 1.57 KB

Versions: 4

Compression:

Stored size: 1.57 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
        task :validate

        namespace :push do
          @project.builds.each do |build,packages|
            path = packages[:gem]

            task build => [:validate, path] do
              if @host
                status "Pushing #{File.basename(path)} to #{@host} ..."
              else
                status "Pushing #{File.basename(path)} ..."
              end

              push(path)
            end
          end
        end

        gemspec_tasks :push

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

      #
      # Pushes the gem by running `gem push`.
      #
      # @param [String] path
      #   The path to the `.gem` file.
      #
      # @return [Boolean]
      #   Specifies whether `gem push` was successful or not.
      #
      # @api semipublic
      #
      def push(path)
        arguments = ['gem', 'push', path]
        arguments.push('--host', @host) if @host

        return run(*arguments)
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubygems-tasks-0.2.4 lib/rubygems/tasks/push.rb
rubygems-tasks-0.2.3 lib/rubygems/tasks/push.rb
rubygems-tasks-0.2.2 lib/rubygems/tasks/push.rb
rubygems-tasks-0.2.1 lib/rubygems/tasks/push.rb