Sha256: d0f492461db9159ee47e0dc979e07cc4dc776fee55a006b1bfd51e0382bdc2a6

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

#!/usr/bin/env ruby
require 'rubygems'
require 'trollop'
require 'bumpy'

opts = Trollop::options do
  version "bumpy #{Bumpy::VERSION} by Hendrik Mans"
  banner <<-EOS
Bumpy bumps your gem's version number.

Usage: bumpy [options] [version]

Available Options:
EOS

  opt :dryrun, "Dry run (no writing or committing)"
  opt :no_git, "Don't automatically create git commit"
end

EXPR = %r{VERSION = ['"](.+)['"]}
opts[:new_version] = ARGV.shift

Dir['./lib/**/version.rb'].each do |name|
  contents = File.read(name)
  if contents =~ EXPR
    opts[:new_version] ||= begin
      parts = $1.split('.')
      parts[-1] = parts[-1].to_i + 1
      parts.join '.'
    end

    puts "Bumping version number found in #{name} to #{opts[:new_version]}"
    contents.sub!(EXPR, "VERSION = \"#{opts[:new_version]}\"")

    unless opts[:dryrun]
      File.open(name, 'w+') do |f|
        f.write(contents)
      end

      # create git commit
      if File.exists?('./.git') && !opts[:no_git]
        puts "Creating git commit"
        system "git add #{name} && git commit -m 'Bump version to #{opts[:new_version]}'"
      end
    end

    # done!
    exit 0
  end
end

puts "No version file found. :("

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bumpy-0.1.2 bin/bumpy