Class: Gem::Commands::BumpCommand

Inherits:
Gem::Command
  • Object
show all
Includes:
CommandOptions, Gem::Commands, GemRelease, Helpers
Defined in:
lib/rubygems/commands/bump_command.rb

Constant Summary collapse

DEFAULTS =
{
  :version => '',
  :commit  => true,
  :push    => false,
  :tag     => false,
  :release => false,
  :key     => '',
  :host    => '',
  :quiet   => false,
  :destination  => "origin",
}

Constants included from GemRelease

GemRelease::VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ BumpCommand

Returns a new instance of BumpCommand.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rubygems/commands/bump_command.rb', line 24

def initialize(options = {})
  @name = 'bump'
  super @name, 'Bump the gem version', default_options_with(options)

  option :version,     '-v', 'Target version: next [major|minor|patch|pre|release] or a given version number [x.x.x]'
  option :commit,      '-c', 'Perform a commit after incrementing gem version'
  option :push,        '-p', 'Push to the git destination'
  option :destination, '-d', 'destination git repository'
  option :tag,         '-t', 'Create a git tag and push it to the git destination'
  option :release,     '-r', 'Build gem from a gemspec and push to rubygems.org'
  option :key,         '-k', 'When releasing: use the given API key from ~/.gem/credentials'
  option :host,        '-h', 'When releasing: push to a gemcutter-compatible host other than rubygems.org'
  option :quiet,       '-q', 'Do not output status messages'
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



10
11
12
# File 'lib/rubygems/commands/bump_command.rb', line 10

def arguments
  @arguments
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/rubygems/commands/bump_command.rb', line 10

def name
  @name
end

#usageObject (readonly)

Returns the value of attribute usage.



10
11
12
# File 'lib/rubygems/commands/bump_command.rb', line 10

def usage
  @usage
end

Instance Method Details

#executeObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/rubygems/commands/bump_command.rb', line 39

def execute
  @new_version_number = nil

  tasks = [:commit, :push, :release, :tag]

  # enforce option dependencies
  options[:push] = true if options[:tag]
  options[:commit] = options[:commit] || options[:push] || options[:tag] || options[:release]

  in_gemspec_dirs do
    run_cmd(:bump)
  end

  if @new_version_number == nil
    say "No version files could be found, so no actions were performed." unless quiet?
  else
    tasks.each do |task|
      run_cmd(task) if options[task]
    end

    success
  end
end