Sha256: e577b9aabc1f0049e72a16cf017af425473eaa9c5bb7ab90ed612a3bc85f3c97

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

require 'rubygems/commands/tag_command'
require 'rubygems/commands/release_command'

class Gem::Commands::BumpCommand < Gem::Command
  include GemRelease, Gem::Commands
  include Helpers, CommandOptions

  attr_reader :arguments, :usage

  OPTIONS = { :version => 'patch', :push => false, :tag => false, :release => false }

  def initialize
    super 'bump', 'Bump the gem version', OPTIONS

    option :version, '-v', 'Target version: next [major|minor|patch] or a given version number [x.x.x]'
    option :push,    '-p', 'Push to origin'
    option :tag,     '-t', 'Create a git tag and push --tags to origin'
    option :release, '-r', 'Build gem from a gemspec and push to rubygems.org'
  end

  def execute
    bump
    commit
    push    if options[:push] || options[:tag]
    release if options[:release]
    tag     if options[:tag]
  end

  protected

    def bump
      say "Bumping from #{version.old_number} to version #{version.new_number}"
      version.bump!
    end

    def commit
      say "Creating commit"
      `git add #{version.filename}`
      `git commit -m "Bump to #{version.new_number}"`
    end

    def push
      say "Pushing to origin"
      `git push`
    end

    def release
      ReleaseCommand.new.invoke
    end

    def tag
      TagCommand.new.invoke
    end

    def version
      @version ||= VersionFile.new(:target => options[:version])
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gem-release-0.0.16 lib/rubygems/commands/bump_command.rb
gem-release-0.0.15 lib/rubygems/commands/bump_command.rb
gem-release-0.0.14 lib/rubygems/commands/bump_command.rb