Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
Pass in -c to use Cedar. Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabe Berke-Williams committed Aug 12, 2011
1 parent 3e7ba9a commit bce4682
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 17 deletions.
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,34 @@ gem 'kumade'
```

## Usage
kumade will deploy to any remote in the repo.
kumade will deploy to any Heroku remote in the repo.
For example, if you have a remote named "bamboo":

$ kumade deploy bamboo
$ kumade bamboo

which will autodetect the name of the Heroku app that the bamboo remote points
to, and deploy to it.
to and deploy to it.

To run in pretend mode, which just prints what would be done:
To run in pretend mode, which prints what would be done without actually doing
any of it:

$ kumade deploy bamboo -p
$ kumade bamboo -p

The default task is to deploy to staging:
The default is to deploy to staging:

$ kumade # equivalent to "kumade deploy staging"
$ kumade # equivalent to "kumade staging"

## Does it support the Cedar stack?

Yes. To indicate that a particular app is using Cedar, do this:
Yes. To indicate that a particular app is using Cedar, run with the -c flag:

Kumade.on_cedar("my-app-name")
kumade bamboo -c

## Sample Output

### Normal mode

$ kumade deploy heroku-staging
$ kumade heroku-staging
==> Deploying to: heroku-staging
==> heroku-staging is a Heroku remote
==> Git repo is clean
Expand Down Expand Up @@ -106,7 +107,7 @@ Yes. To indicate that a particular app is using Cedar, do this:

### Pretend mode

$ kumade deploy heroku-staging -p
$ kumade heroku-staging -p
==> In Pretend Mode
==> Deploying to: heroku-staging
==> heroku-staging is a Heroku remote
Expand All @@ -120,7 +121,7 @@ Yes. To indicate that a particular app is using Cedar, do this:

### Pretend Mode with a non-Heroku remote

$ kumade deploy origin -p
$ kumade origin -p
==> In Pretend Mode
==> Deploying to: origin
==> ! Cannot deploy: "origin" remote does not point to Heroku
Expand Down
5 changes: 3 additions & 2 deletions lib/kumade/deployer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ class Deployer < Thor::Shell::Color
DEPLOY_BRANCH = "deploy"
attr_reader :environment, :pretending

def initialize(environment = 'staging', pretending = false)
def initialize(environment = 'staging', pretending = false, cedar = false)
super()
@environment = environment
@pretending = pretending
@branch = current_branch
@cedar = cedar
end

def deploy
Expand Down Expand Up @@ -49,7 +50,7 @@ def post_deploy
end

def heroku(command, app)
heroku_command = if Kumade.cedar?(app)
heroku_command = if @cedar
"bundle exec heroku run"
else
"bundle exec heroku"
Expand Down
6 changes: 5 additions & 1 deletion lib/kumade/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def self.deploy
@out.puts "==> In Pretend Mode"
end
@out.puts "==> Deploying to: #{environment}"
Deployer.new(environment, pretending?).deploy
Deployer.new(environment, pretending?, @options[:cedar]).deploy
@out.puts "==> Deployed to: #{environment}"
end

Expand All @@ -32,6 +32,10 @@ def self.parse_arguments!(args)
options[:pretend] = p
end

opts.on("-c", "--cedar", "Use this if your app is on cedar") do |cedar|
options[:cedar] = cedar
end

opts.on_tail('-v', '--version', 'Show version') do
@out.puts "kumade #{Kumade::VERSION}"
exit
Expand Down
4 changes: 2 additions & 2 deletions spec/kumade/deployer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ class More
let(:app_name){ 'sushi' }

context "when on Cedar" do
before { Kumade.stub(:cedar?).and_return(true) }
subject { Kumade::Deployer.new('staging', false, cedar = true) }

it "runs commands with `run`" do
subject.should_receive(:run_or_error).with("bundle exec heroku run rake --app #{app_name}", //)
Expand All @@ -485,7 +485,7 @@ class More
end

context "when not on Cedar" do
before { Kumade.stub(:cedar?).and_return(false) }
subject { Kumade::Deployer.new('staging', false, cedar = false) }

it "runs commands without `run`" do
subject.should_receive(:run_or_error).with("bundle exec heroku rake --app #{app_name}", //)
Expand Down
11 changes: 11 additions & 0 deletions spec/kumade/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,15 @@

subject.run([environment], out)
end

%w(-c --cedar).each do |cedar_arg|
it "uses cedar when run with #{cedar_arg}" do
deployer = double("deployer").as_null_object
Kumade::Deployer.should_receive(:new).
with(anything, anything, true).
and_return(deployer)

subject.run([environment, cedar_arg], out)
end
end
end

0 comments on commit bce4682

Please sign in to comment.