Skip to content

Commit

Permalink
Create an #alias_task method;
Browse files Browse the repository at this point in the history
Makes these task match arg lists as originals
Closes #78
  • Loading branch information
kmayer committed Mar 31, 2012
1 parent aadd88f commit 2c2ff9b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
32 changes: 20 additions & 12 deletions lib/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions spec/heroku_san/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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')
Expand Down

0 comments on commit 2c2ff9b

Please sign in to comment.