From 2c2ff9b09dd477b9d438e8822952a5ecd600e8c9 Mon Sep 17 00:00:00 2001 From: Kenneth Mayer Date: Sat, 31 Mar 2012 16:43:56 -0700 Subject: [PATCH] Create an #alias_task method; Makes these task match arg lists as originals Closes #78 --- lib/tasks.rb | 32 ++++++++++++++++++++------------ spec/heroku_san/project_spec.rb | 6 +++--- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/lib/tasks.rb b/lib/tasks.rb index bf1dddf..b589515 100644 --- a/lib/tasks.rb +++ b/lib/tasks.rb @@ -283,18 +283,26 @@ end end -task :all => 'heroku:stage:all' -task :deploy => 'heroku:deploy' -task 'deploy:force' => 'heroku:deploy:force' -task :before_deploy => 'heroku:deploy:before' -task :after_deploy => 'heroku:deploy:after' -task :console => 'heroku:console' -task :restart => 'heroku:restart' -task :migrate => 'heroku:db:migrate' -task :logs => 'heroku:logs:default' -task 'logs:tail' => 'heroku:logs:tail' -task 'heroku:rack_env' => 'heroku:config:rack_env' -task :shell => 'heroku:shell' + +def alias_task(hash) + hash.each_pair do |(new_task, original_task)| + the_task = Rake.application[original_task] + task new_task, {the_task.arg_names => [original_task]} + end +end + +alias_task :all => 'heroku:stage:all' +alias_task :deploy => 'heroku:deploy' +alias_task 'deploy:force' => 'heroku:deploy:force' +alias_task :before_deploy => 'heroku:deploy:before' +alias_task :after_deploy => 'heroku:deploy:after' +alias_task :console => 'heroku:console' +alias_task :restart => 'heroku:restart' +alias_task :migrate => 'heroku:db:migrate' +alias_task :logs => 'heroku:logs:default' +alias_task 'logs:tail' => 'heroku:logs:tail' +alias_task 'heroku:rack_env' => 'heroku:config:rack_env' +alias_task :shell => 'heroku:shell' def each_heroku_app(&block) @heroku_san.each_app(&block) diff --git a/spec/heroku_san/project_spec.rb b/spec/heroku_san/project_spec.rb index 6e0f8ad..6d96259 100644 --- a/spec/heroku_san/project_spec.rb +++ b/spec/heroku_san/project_spec.rb @@ -2,7 +2,7 @@ require 'tmpdir' describe HerokuSan::Project do - specify ".new with a missing config file" do + specify ".new with a missing config file has no stages" do heroku_san = HerokuSan::Project.new("/u/should/never/get/here") heroku_san.all.should == [] end @@ -42,7 +42,7 @@ heroku_san.apps.should == heroku_san.all end - describe "#apps extra default behaviors" do + describe "extra (default) behaviors" do specify "on a git branch that matches an app name" do heroku_san.should_receive(:git_active_branch) { "staging" } $stdout.should_receive(:puts).with("Defaulting to 'staging' as it matches the current branch") @@ -56,7 +56,7 @@ heroku_san.apps.should == %w[] end - context "but only a single configured app" do + context "with only a single configured app" do let(:heroku_san) { HerokuSan::Project.new(File.join(SPEC_ROOT, "fixtures", "single_app.yml")) } it "returns the app" do $stdout.should_receive(:puts).with('Defaulting to "production" since only one app is defined')