Skip to content

Commit

Permalink
switch to bump
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser committed Nov 30, 2012
1 parent a0638a6 commit b1da3b6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -3,6 +3,7 @@ source :rubygems
gemspec gemspec


gem 'appraisal' gem 'appraisal'
gem 'bump'
gem 'rake' gem 'rake'
gem 'rspec', '~>2' gem 'rspec', '~>2'
gem 'sqlite3' gem 'sqlite3'
2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -23,6 +23,7 @@ GEM
rake rake
arel (3.0.2) arel (3.0.2)
builder (3.0.4) builder (3.0.4)
bump (0.3.5)
diff-lcs (1.1.3) diff-lcs (1.1.3)
i18n (0.6.1) i18n (0.6.1)
multi_json (1.3.7) multi_json (1.3.7)
Expand All @@ -44,6 +45,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
appraisal appraisal
ar_after_transaction! ar_after_transaction!
bump
rake rake
rspec (~> 2) rspec (~> 2)
sqlite3 sqlite3
18 changes: 1 addition & 17 deletions Rakefile
@@ -1,6 +1,7 @@
require "bundler/setup" require "bundler/setup"
require "bundler/gem_tasks" require "bundler/gem_tasks"
require "appraisal" require "appraisal"
require "bump/tasks"




task :spec do task :spec do
Expand All @@ -10,20 +11,3 @@ end
task :default do task :default do
sh "bundle exec rake appraisal:install && bundle exec rake appraisal spec" sh "bundle exec rake appraisal:install && bundle exec rake appraisal spec"
end end

# extracted from https://github.com/grosser/project_template
rule /^version:bump:.*/ do |t|
sh "git status | grep 'nothing to commit'" # ensure we are not dirty
index = ['major', 'minor','patch'].index(t.name.split(':').last)
file = 'lib/ar_after_transaction/version.rb'

version_file = File.read(file)
old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
version_parts[index] = version_parts[index].to_i + 1
version_parts[2] = 0 if index < 2 # remove patch for minor
version_parts[1] = 0 if index < 1 # remove minor for major
new_version = version_parts * '.'
File.open(file,'w'){|f| f.write(version_file.sub(old_version, new_version)) }

sh "bundle && git add #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}'"
end

0 comments on commit b1da3b6

Please sign in to comment.