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

Commit

Permalink
Remove the --cedar option, detect cedar automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Yurek committed Sep 7, 2011
1 parent 4d2b13e commit 6bd53af
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
12 changes: 9 additions & 3 deletions lib/kumade/deployer.rb
Expand Up @@ -3,11 +3,10 @@ class Deployer < Base
DEPLOY_BRANCH = "deploy"
attr_reader :environment, :pretending, :git

def initialize(environment = 'staging', pretending = false, cedar = false)
def initialize(environment = 'staging', pretending = false)
super()
@environment = environment
@pretending = pretending
@cedar = cedar
@git = Git.new(pretending, environment)
@branch = @git.current_branch
end
Expand Down Expand Up @@ -45,7 +44,7 @@ def post_deploy
end

def heroku(command)
heroku_command = if @cedar
heroku_command = if cedar?
"bundle exec heroku run"
else
"bundle exec heroku"
Expand All @@ -54,6 +53,13 @@ def heroku(command)
"Failed to run #{command} on Heroku")
end

def cedar?
return @cedar unless @cedar.nil?
heroku("stack").split("\n").grep(/\*/).any? do |line|

This comment has been minimized.

Copy link
@tapajos

tapajos Sep 9, 2011

Contributor

Infinite loop here. Issue #38

line.include?("cedar")
end
end

def ensure_clean_git
git.ensure_clean_git
end
Expand Down
6 changes: 1 addition & 5 deletions lib/kumade/runner.rb
Expand Up @@ -21,7 +21,7 @@ def self.deploy
puts "==> In Pretend Mode"
end
puts "==> Deploying to: #{environment}"
Deployer.new(environment, pretending?, @options[:cedar]).deploy
Deployer.new(environment, pretending?).deploy
puts "==> Deployed to: #{environment}"
end

Expand All @@ -34,10 +34,6 @@ 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
puts "kumade #{Kumade::VERSION}"
exit
Expand Down
22 changes: 18 additions & 4 deletions spec/kumade/deployer_spec.rb
Expand Up @@ -435,19 +435,33 @@ class More
end
end

describe Kumade::Deployer, "#heroku" do
describe Kumade::Deployer, "#cedar?" do
context "when on Cedar" do
subject { Kumade::Deployer.new('staging', false, cedar = true) }
subject { Kumade::Deployer.new('staging', false) }
before { subject.stub(:heroku).and_return(" bamboo\n* cedar\n") }
its(:cedar?) { should be_true }
end

context "when not on Cedar" do
subject { Kumade::Deployer.new('staging', false) }
before { subject.stub(:heroku).and_return("* bamboo\n cedar\n") }
its(:cedar?) { should be_false }
end
end

describe Kumade::Deployer, "#heroku" do
context "when on Cedar" do
subject { Kumade::Deployer.new('staging', false) }
before { subject.stub(:cedar?).and_return(true) }
it "runs commands with `run`" do
subject.should_receive(:run_or_error).with("bundle exec heroku run rake --remote staging", //)
subject.heroku("rake")
end
end

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

subject { Kumade::Deployer.new('staging', false) }
before { subject.stub(:cedar?).and_return(false) }
it "runs commands without `run`" do
subject.should_receive(:run_or_error).with("bundle exec heroku rake --remote staging", //)
subject.heroku("rake")
Expand Down
10 changes: 0 additions & 10 deletions spec/kumade/runner_spec.rb
Expand Up @@ -26,16 +26,6 @@
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

describe Kumade::Runner do
Expand Down

0 comments on commit 6bd53af

Please sign in to comment.