From ac432aad78e8c08f777a293483c4ff9832f9ad0d Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Wed, 10 Oct 2012 19:35:04 -0600 Subject: [PATCH] Add bump task to Rakefile --- Rakefile | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 13fd22cd..1fd5a185 100644 --- a/Rakefile +++ b/Rakefile @@ -17,6 +17,27 @@ def version line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1] end +# assumes x.y.z all digit version +def next_version + # x.y.z + v = version.split '.' + # bump z + v[-1] = v[-1].to_i + 1 + v.join '.' +end + +def bump_version + old_file = File.read("lib/#{name}.rb") + old_version_line = old_file[/^\s*VERSION\s*=\s*.*/] + new_version = next_version + # replace first match of old vesion with new version + old_file.sub!(old_version_line, " VERSION = '#{new_version}'") + + File.write("lib/#{name}.rb", old_file) + + new_version +end + def date Date.today.to_s end @@ -71,7 +92,14 @@ end # ############################################################################# - +desc "Update version number and gemspec" +task :bump do + puts "Updated version to #{bump_version}" + # Execute does not invoke dependencies. + # Manually invoke gemspec then validate. + Rake::Task[:gemspec].execute + Rake::Task[:validate].execute +end ############################################################################# #