Skip to content
Browse files

make version:bump:minor 0 out patch

  • Loading branch information...
1 parent c01f3f5 commit fc8aeec6d8cf6465fa7460e04e0b09aa63663236 @grosser committed Feb 8, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 Rakefile
View
6 Rakefile
@@ -4,13 +4,17 @@ task :default do
sh "rspec spec/"
end
+# extracted from https://github.com/grosser/project_template
rule /^version:bump:.*/ do |t|
- file = 'lib/GEM_NAME/version.rb'
sh "git status | grep 'nothing to commit'" # ensure we are not dirty
index = ['major', 'minor','patch'].index(t.name.split(':').last)
+ file = 'lib/GEM_NAME/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)) }

0 comments on commit fc8aeec

Please sign in to comment.
Something went wrong with that request. Please try again.