Class: Gem::Tasks::SCM::Push

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

Overview

The scm:push task.

Constant Summary

Constants included from Printing

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

Instance Attribute Summary

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 scm:push task.

Parameters:

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

    Additional options.

Yields:

  • (_self)

Yield Parameters:



17
18
19
20
21
22
# File 'lib/rubygems/tasks/scm/push.rb', line 17

def initialize(options={})
  super()

  yield self if block_given?
  define
end

Instance Method Details

#defineObject

Defines the scm:push task.



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rubygems/tasks/scm/push.rb', line 27

def define
  task :validate

  namespace :scm do
    task :push => :validate do
      status "Pushing commits ..."

      unless push!
        error "Could not push commits"
      end
    end
  end
end

#push!Boolean

Pushes commits.

Returns:

  • (Boolean)

    Specifies whether the commits were successfully pushed.



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/rubygems/tasks/scm/push.rb', line 49

def push!
  case @project.scm
  when :git
    run 'git', 'push'
    run 'git', 'push', '--tags'
  when :hg 
    run 'hg', 'push'
  else
    true
  end
end