Sha256: f6d9a148d089a12b4828cd484b34d365bfd3b93510ef3bbc85a49a26ce6a3e4c

Contents?: true

Size: 1.5 KB

Versions: 6

Compression:

Stored size: 1.5 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
              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 successfull or not.
      #
      def push(path)
        arguments = ['gem', 'push', path]
        arguments.push('--host', @host) if @host

        return run(*arguments)
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubygems-tasks-0.2.0 lib/rubygems/tasks/push.rb
rubygems-tasks-0.1.2 lib/rubygems/tasks/push.rb
rubygems-tasks-0.1.1 lib/rubygems/tasks/push.rb
rubygems-tasks-0.1.0 lib/rubygems/tasks/push.rb
rubygems-tasks-0.1.0.pre3 lib/rubygems/tasks/push.rb
rubygems-tasks-0.1.0.pre2 lib/rubygems/tasks/push.rb