Browse files

Refactored version bumping stuff.

  • Loading branch information...
1 parent f1248cb commit 7e2ff34729a9ecc50873e2620b194e25e3f73ebf @technicalpickles technicalpickles committed Oct 11, 2008
Showing with 34 additions and 47 deletions.
  1. +34 −47 Rakefile
View
81 Rakefile
@@ -15,9 +15,7 @@ task :default => :test
spec = Gem::Specification.new do |s|
s.name = "clearance"
- s.version = "#{Clearance::Version::MAJOR}.#{Clearance::Version::MINOR}.#{Clearance::Version::PATCH}"
- date = DateTime.now
- s.date = "#{date.year}-#{date.month}-#{date.day}"
+
s.summary = "Simple, complete Rails authentication."
s.email = "dcroak@thoughtbot.com"
s.homepage = "http://github.com/thoughtbot/clearance"
@@ -26,73 +24,62 @@ spec = Gem::Specification.new do |s|
s.files = FileList["[A-Z]*", "{generators,lib,test}/**/*"]
end
-namespace :gemspec do
- desc "Generate a gemspec file for GitHub"
- task :write do
- File.open("#{spec.name}.gemspec", 'w') do |f|
- f.write spec.to_ruby
- end
+desc "Generate a gemspec file for GitHub"
+task :gemspec => 'version:calculate' do
+ date = DateTime.now
+ spec.date = "#{date.year}-#{date.month}-#{date.day}"
+
+ File.open("#{spec.name}.gemspec", 'w') do |f|
+ f.write spec.to_ruby
+ end
+end
+
+desc "Displays the current version"
+task :version => 'version:calculate' do
+ puts spec.version
+end
+
+namespace :version do
+ desc "Determine's the version based on Clearance::Version"
+ task :calculate do
+ spec.version ||= "#{Clearance::Version::MAJOR}.#{Clearance::Version::MINOR}.#{Clearance::Version::PATCH}"
end
namespace :bump do
- desc "Bump the gemspec a major version."
- task :major do
- major = Clearance::Version::MAJOR + 1
+ def bump_gemspec(spec, major, minor, patch)
File.open("lib/clearance/version.rb", 'w') do |file|
file.write <<-END
module Clearance
module Version
MAJOR = #{major}
- MINOR = 0
- PATCH = 0
+ MINOR = #{minor}
+ PATCH = #{patch}
end
end
END
end
-
- spec.version = "#{major}.0.0"
- Rake::Task["gemspec:write"].invoke
+
+ spec.version = "#{major}.#{minor}.#{patch}"
+ Rake::Task["gemspec"].invoke
puts "Gem bumped to #{spec.version}"
end
+ desc "Bump the gemspec a major version."
+ task :major do
+ major = Clearance::Version::MAJOR + 1
+ bump_gemspec(spec, major, 0, 0)
+ end
+
desc "Bump the gemspec a minor version."
task :minor do
minor = Clearance::Version::MINOR + 1
- File.open("lib/clearance/version.rb", 'w') do |file|
- file.write <<-END
-module Clearance
- module Version
- MAJOR = #{Clearance::Version::MAJOR}
- MINOR = #{minor}
- PATCH = 0
- end
-end
- END
- end
-
- spec.version = "#{Clearance::Version::MAJOR}.#{minor}.0"
- Rake::Task["gemspec:write"].invoke
- puts "Gem bumped to #{spec.version}"
+ bump_gemspec(spec, Clearance::Version::MAJOR, minor, 0)
end
desc "Bump the gemspec a patch version."
task :patch do
patch = Clearance::Version::PATCH + 1
- File.open("lib/clearance/version.rb", 'w') do |file|
- file.write <<-END
-module Clearance
- module Version
- MAJOR = #{Clearance::Version::MAJOR}
- MINOR = #{Clearance::Version::MINOR}
- PATCH = #{patch}
- end
-end
- END
- end
-
- spec.version = "#{Clearance::Version::MAJOR}.#{Clearance::Version::MINOR}.#{patch}"
- Rake::Task["gemspec:write"].invoke
- puts "Gem bumped to #{spec.version}"
+ bump_gemspec(spec, Clearance::Version::MAJOR, Clearance::Version::MINOR, patch)
end
end
end

0 comments on commit 7e2ff34

Please sign in to comment.