Class: Gem::Tasks::Push

Inherits:
Task
  • Object
show all
Defined in:
lib/rubygems/tasks/push.rb

Overview

The push task.

Constant Summary

Constants included from Printing

Gem::Tasks::Printing::ANSI_BRIGHT, Gem::Tasks::Printing::ANSI_CLEAR, Gem::Tasks::Printing::ANSI_GREEN, Gem::Tasks::Printing::ANSI_RED, Gem::Tasks::Printing::ANSI_YELLOW, Gem::Tasks::Printing::DEBUG_PREFIX, Gem::Tasks::Printing::ERROR_PREFIX, Gem::Tasks::Printing::STATUS_PREFIX

Instance Attribute Summary collapse

Attributes inherited from Task

#project

Instance Method Summary collapse

Methods inherited from Task

#bundle, #gem, #gemspec_tasks, #invoke, #namespaced_tasks, #run, #task?

Methods included from Printing

#debug, #error, #status

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ Push

Initializes the push task.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Options Hash (options):

  • :host (String)

    The rubygems host to push gems to.

Yields:

  • (_self)

Yield Parameters:


22
23
24
25
26
27
28
29
# File 'lib/rubygems/tasks/push.rb', line 22

def initialize(options={})
  super()

  @host = options[:host]

  yield self if block_given?
  define
end

Instance Attribute Details

#hostObject

The rubygems host to push gems to.


11
12
13
# File 'lib/rubygems/tasks/push.rb', line 11

def host
  @host
end

Instance Method Details

#defineObject

Defines the push task.


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rubygems/tasks/push.rb', line 34

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

#push(path) ⇒ Boolean

Pushes the gem by running gem push.

Parameters:

  • path (String)

    The path to the .gem file.

Returns:

  • (Boolean)

    Specifies whether gem push was successful or not.


70
71
72
73
74
75
# File 'lib/rubygems/tasks/push.rb', line 70

def push(path)
  arguments = ['gem', 'push', path]
  arguments.push('--host', @host) if @host

  return run(*arguments)
end