From 2763c4f355de294771f8ec6978b29f4ab4955b22 Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Tue, 28 Feb 2012 12:05:08 -0500 Subject: [PATCH] Rake task for updating gem versions. --- Rakefile | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Rakefile b/Rakefile index 60ffd69..6226046 100644 --- a/Rakefile +++ b/Rakefile @@ -226,6 +226,36 @@ namespace :ci do end end +# Deployment +VERSION_FILES = %w(lib/bson/version.rb lib/mongo/version.rb ext/cbson/version.h) + +def current_version + f = File.open("lib/mongo/version.rb") + str = f.read + str =~ /VERSION\s+=\s+([.\d"]+)$/ + return $1 +end + +def change_version(new_version) + version = current_version + VERSION_FILES.each do |filename| + f = File.open(filename) + str = f.read + f.close + str.gsub!(version, "\"#{new_version}\"") + File.open(filename, 'w') do |f| + f.write(str) + end + end +end + +namespace :deploy do + task :version, [:version] do |t, args| + puts args[:version] + change_version(args[:version]) + end +end + task :default => :list task :list do