Rakefile in expandsync-0.1.3 vs Rakefile in expandsync-0.2.0

- old
+ new

@@ -1,39 +1,51 @@ require 'rake/clean' require 'rubygems' -require 'rubygems/package_task' -require 'cucumber' -require 'cucumber/rake/task' + +def version + contents = File.read File.expand_path('../lib/expandsync/constants.rb', __FILE__) + contents[/\sVERSION = '([^']+)'/, 1] +end + spec = eval(File.read('expandsync.gemspec')) -Gem::PackageTask.new(spec) do |pkg| +require 'rake/testtask' +desc 'Run unit tests' +Rake::TestTask.new do |t| + t.libs << "test" + t.test_files = FileList['test/*_test.rb'] end +require 'cucumber' +require 'cucumber/rake/task' CUKE_RESULTS = 'results.html' CLEAN << CUKE_RESULTS - -desc 'Run features' +desc 'Run Cucumber features' Cucumber::Rake::Task.new(:features) do |t| - opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x" + opts = "features --format html -o #{CUKE_RESULTS} --format progress -x" opts += " --tags #{ENV['TAGS']}" if ENV['TAGS'] t.cucumber_opts = opts t.fork = false end -desc 'Run features tagged as work-in-progress (@wip)' -Cucumber::Rake::Task.new('features:wip') do |t| - tag_opts = ' --tags ~@pending' - tag_opts = ' --tags @wip' - t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}" - t.fork = false +desc "Release ExpandSync version #{ version }" +task :release => :build do + unless `git branch` =~ /^\* master$/ + puts "You must be on the master branch to release!" + exit! + end + + sh "git commit --allow-empty -a -m 'Release #{ version }'" + sh "git tag v#{ version }" + sh "git push origin master" + sh "git push origin v#{ version }" + sh "gem push pkg/expandsync-#{ version }.gem" end -task :cucumber => :features -task 'cucumber:wip' => 'features:wip' -task :wip => 'features:wip' -require 'rake/testtask' -Rake::TestTask.new do |t| - t.libs << "test" - t.test_files = FileList['test/*_test.rb'] +desc "Build the gem" +task :build do + FileUtils.mkdir_p "pkg" + sh "gem build expandsync.gemspec" + FileUtils.mv("./expandsync-#{ version }.gem", "pkg") end -task :default => [:test,:features] +task :default => [:test, :features]