kumade 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -6,3 +6,4 @@ tmp/
6
6
  .rake_tasks
7
7
  *.sw[op]
8
8
  .rvmrc
9
+ coverage/
@@ -0,0 +1,7 @@
1
+ # vim: syntax=ruby ft=ruby
2
+ if ENV['COVERAGE']
3
+ SimpleCov.start do
4
+ add_filter "/spec/"
5
+ add_filter "/features/"
6
+ end
7
+ end
@@ -1,3 +1,6 @@
1
+ ## 0.7.0 (2011-10-15)
2
+ * Kumade now has a working check for the Cedar stack.
3
+
1
4
  ## 0.6.0 (2011-10-15)
2
5
  * Remove thor dependency, since Thor is no longer in the gem.
3
6
 
data/README.md CHANGED
@@ -13,8 +13,8 @@ Before deploying, Kumade ensures the git repo is clean.
13
13
  After that, it packages assets using
14
14
  [Jammit](http://documentcloud.github.com/jammit/) and/or
15
15
  [More](https://github.com/cloudhead/more), commits them, and pushes to origin.
16
- Then it force pushes to the correct Heroku remote and runs `rake db:migrate` on the
17
- Heroku app.
16
+ Then it force pushes to the correct Heroku remote, runs `rake db:migrate` on the
17
+ Heroku app, and then restarts the app.
18
18
 
19
19
  If any step fails, it immediately prints an error and stops the deploy
20
20
  process.
@@ -22,9 +22,7 @@ process.
22
22
  ## Install
23
23
  In your Gemfile:
24
24
 
25
- ```ruby
26
- gem 'kumade'
27
- ```
25
+ gem 'kumade'
28
26
 
29
27
  ## Usage
30
28
 
@@ -70,16 +68,19 @@ Tested against:
70
68
 
71
69
  Want to run a task before bundling your assets on deploy? In your Rails app's rake tasks, drop in:
72
70
 
73
- ``` ruby
74
- namespace :kumade do
75
- task :before_asset_compilation do
76
- puts "This runs before assets are committed and pushed to the remote"
77
- end
78
- end
79
- ```
71
+ namespace :kumade do
72
+ task :before_asset_compilation do
73
+ puts "This runs before assets are committed and pushed to the remote"
74
+ end
75
+ end
80
76
 
81
77
  You can hook in any custom code you want to run there before deploying!
82
78
 
79
+ ## Development
80
+ To generate coverage (only on 1.9.x), run rake with COVERAGE set:
81
+
82
+ COVERAGE=1 rake
83
+
83
84
  ## What's with the name?
84
85
 
85
86
  Kumade ([pronunciation here](http://translate.google.com/#ja|en|熊手)) means
@@ -28,6 +28,7 @@ Feature: Kumade executable
28
28
  git push -f pretend-staging deploy:master
29
29
  ==> Pushed deploy:master -> pretend-staging
30
30
  ==> Migrated pretend-staging
31
+ ==> Restarted pretend-staging
31
32
  ==> Deployed to: pretend-staging
32
33
  """
33
34
  But the output should not contain "==> Packaged with Kumade::MorePackager"
@@ -58,6 +59,7 @@ Feature: Kumade executable
58
59
  git push -f pretend-staging deploy:master
59
60
  ==> Pushed deploy:master -> pretend-staging
60
61
  ==> Migrated pretend-staging
62
+ ==> Restarted pretend-staging
61
63
  ==> Deployed to: pretend-staging
62
64
  """
63
65
 
@@ -1,3 +1,8 @@
1
+ begin
2
+ require 'simplecov'
3
+ rescue LoadError
4
+ # Probably on 1.8.7, ignore.
5
+ end
1
6
  require 'aruba/cucumber'
2
7
  require 'kumade'
3
8
 
@@ -27,4 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.add_development_dependency('jammit', '~> 0.6.3')
28
28
  s.add_development_dependency('less', '~> 2.0')
29
29
  s.add_development_dependency('bourne')
30
+ if RUBY_VERSION >= '1.9.0'
31
+ s.add_development_dependency('simplecov')
32
+ end
30
33
  end
@@ -18,7 +18,6 @@ module Kumade
18
18
  def run
19
19
  begin
20
20
  @command_line.run
21
- true
22
21
  rescue Cocaine::ExitStatusError, Cocaine::CommandNotFoundError
23
22
  false
24
23
  end
@@ -18,6 +18,7 @@ module Kumade
18
18
  pre_deploy
19
19
  heroku.sync
20
20
  heroku.migrate_database
21
+ heroku.restart_app
21
22
  rescue => deploying_error
22
23
  Kumade.configuration.outputter.error("#{deploying_error.class}: #{deploying_error.message}")
23
24
  ensure
@@ -20,6 +20,11 @@ module Kumade
20
20
  Kumade.configuration.outputter.success("Migrated #{Kumade.configuration.environment}")
21
21
  end
22
22
 
23
+ def restart_app
24
+ heroku("restart") unless Kumade.configuration.pretending?
25
+ Kumade.configuration.outputter.success("Restarted #{Kumade.configuration.environment}")
26
+ end
27
+
23
28
  def delete_deploy_branch
24
29
  git.delete(DEPLOY_BRANCH, @branch)
25
30
  end
@@ -1,21 +1,21 @@
1
1
  module Kumade
2
2
  class Outputter
3
3
  def success(message)
4
- puts "==> #{message}"
4
+ STDOUT.puts "==> #{message}"
5
5
  end
6
6
 
7
7
  def info(message)
8
- puts "==> #{message}"
8
+ STDOUT.puts "==> #{message}"
9
9
  end
10
10
 
11
11
  def error(message)
12
- puts "==> ! #{message}"
12
+ STDOUT.puts "==> ! #{message}"
13
13
  raise Kumade::DeploymentError, message
14
14
  end
15
15
 
16
16
  def say_command(command)
17
17
  prefix = " " * 8
18
- puts "#{prefix}#{command}"
18
+ STDOUT.puts "#{prefix}#{command}"
19
19
  end
20
20
  end
21
21
  end
@@ -1,3 +1,3 @@
1
1
  module Kumade
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -70,8 +70,8 @@ describe Kumade::CLI, ".deployer" do
70
70
  end
71
71
 
72
72
  describe Kumade::CLI, ".swapping_stdout_for" do
73
- let(:stdout) { $stdout }
74
- let(:output) { StringIO.new }
73
+ let!(:stdout) { $stdout }
74
+ let(:output) { StringIO.new }
75
75
 
76
76
  before do
77
77
  stdout.stubs(:print => nil, :puts => nil)
@@ -83,6 +83,7 @@ describe Kumade::CLI, ".swapping_stdout_for" do
83
83
  end
84
84
 
85
85
  stdout.should have_received(:print).never
86
+ stdout.should have_received(:puts).never
86
87
 
87
88
  output.rewind
88
89
  output.read.should == "Hello, you can't see me.\n"
@@ -94,7 +95,7 @@ describe Kumade::CLI, ".swapping_stdout_for" do
94
95
  raise Kumade::DeploymentError.new("error")
95
96
  end
96
97
 
97
- stdout.should have_received(:print)
98
+ stdout.should have_received(:print).with("Hello, you can see me!\n")
98
99
  end
99
100
 
100
101
  context "in print output mode" do
@@ -103,7 +104,7 @@ describe Kumade::CLI, ".swapping_stdout_for" do
103
104
  $stdout.puts "Hello, you can see me!"
104
105
  end
105
106
 
106
- stdout.should have_received(:puts)
107
+ stdout.should have_received(:puts).with("Hello, you can see me!")
107
108
  end
108
109
  end
109
110
  end
@@ -4,7 +4,7 @@ describe Kumade::CommandLine, "#run_or_error", :with_mock_outputter do
4
4
  subject { Kumade::CommandLine.new("echo") }
5
5
 
6
6
  context "when pretending" do
7
- let(:command_line) { stub("Cocaine::CommandLine instance", :run => nil, :command => 'command') }
7
+ let(:command_line) { stub("Cocaine::CommandLine instance", :run => "does-not-matter", :command => 'command') }
8
8
 
9
9
  before do
10
10
  Cocaine::CommandLine.stubs(:new).returns(command_line)
@@ -24,12 +24,16 @@ describe Kumade::CommandLine, "#run_or_error", :with_mock_outputter do
24
24
  end
25
25
 
26
26
  context "when successful" do
27
+ let(:command_line) { stub("Cocaine::CommandLine instance", :run => command_line_result, :command => 'command') }
28
+ let(:command_line_result) { "result" }
29
+
27
30
  before do
31
+ Cocaine::CommandLine.stubs(:new).returns(command_line)
28
32
  Kumade.configuration.pretending = false
29
33
  end
30
34
 
31
- it "returns true" do
32
- subject.run_or_error.should be_true
35
+ it "returns the result of running the command" do
36
+ subject.run_or_error.should == command_line_result
33
37
  end
34
38
  end
35
39
 
@@ -48,8 +52,9 @@ describe Kumade::CommandLine, "#run_or_error", :with_mock_outputter do
48
52
  end
49
53
 
50
54
  describe Kumade::CommandLine, "#run_with_status", :with_mock_outputter do
51
- let(:command) { "echo" }
52
- let(:command_line) { stub("Cocaine::CommandLine instance", :run => nil, :command => command) }
55
+ let(:command) { "echo blah" }
56
+ let(:command_line_result) { "blah\n" }
57
+ let(:command_line) { stub("Cocaine::CommandLine instance", :run => command_line_result, :command => command) }
53
58
  subject { Kumade::CommandLine.new(command) }
54
59
 
55
60
  before do
@@ -72,7 +77,7 @@ describe Kumade::CommandLine, "#run_with_status", :with_mock_outputter do
72
77
  end
73
78
 
74
79
  it "returns true" do
75
- subject.run_with_status.should be_true
80
+ subject.run_with_status.should == true
76
81
  end
77
82
  end
78
83
 
@@ -84,15 +89,19 @@ describe Kumade::CommandLine, "#run_with_status", :with_mock_outputter do
84
89
 
85
90
  command_line.should have_received(:run).once
86
91
  end
92
+
93
+ it "returns the result of running the command" do
94
+ subject.run_with_status.should == command_line_result
95
+ end
87
96
  end
88
97
  end
89
98
 
90
99
  describe Kumade::CommandLine, "#run", :with_mock_outputter do
91
100
  context "when successful" do
92
- subject { Kumade::CommandLine.new("echo") }
101
+ subject { Kumade::CommandLine.new("echo -n blah") }
93
102
 
94
- it "returns true" do
95
- subject.run.should == true
103
+ it "returns the result of running the command" do
104
+ subject.run.should == "blah"
96
105
  end
97
106
  end
98
107
 
@@ -23,6 +23,7 @@ describe Kumade::Deployer, "#deploy", :with_mock_outputter do
23
23
  subject.expects(:pre_deploy)
24
24
  subject.heroku.expects(:sync)
25
25
  subject.heroku.expects(:migrate_database)
26
+ subject.heroku.expects(:restart_app)
26
27
  subject.expects(:post_deploy)
27
28
 
28
29
  subject.deploy
@@ -56,6 +56,39 @@ describe Kumade::Heroku, "#migrate_database", :with_mock_outputter do
56
56
  end
57
57
  end
58
58
 
59
+ describe Kumade::Heroku, "#restart_app", :with_mock_outputter do
60
+ let(:environment) { 'staging' }
61
+
62
+ before do
63
+ subject.stubs(:heroku)
64
+ force_add_heroku_remote(environment)
65
+ end
66
+
67
+ it "runs the heroku restart command" do
68
+ subject.restart_app
69
+
70
+ subject.should have_received(:heroku).with("restart")
71
+ end
72
+
73
+ it "prints a message" do
74
+ subject.restart_app
75
+
76
+ Kumade.configuration.outputter.should have_received(:success).with(regexp_matches(/Restarted #{environment}/))
77
+ end
78
+
79
+ context "when pretending" do
80
+ before do
81
+ Kumade.configuration.pretending = true
82
+ end
83
+
84
+ it "does not run the command" do
85
+ subject.restart_app
86
+
87
+ subject.should have_received(:heroku).never
88
+ end
89
+ end
90
+ end
91
+
59
92
  describe Kumade::Heroku, "#heroku", :with_mock_outputter do
60
93
  let(:command_instance) { stub("Kumade::CommandLine instance", :run_or_error => true) }
61
94
 
@@ -1,9 +1,11 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Kumade::NoopPackager, :with_mock_outputter do
3
+ describe Kumade::NoopPackager do
4
4
  subject { Kumade::NoopPackager }
5
5
 
6
6
  it_should_behave_like "packager"
7
7
 
8
8
  its(:assets_path) { should == "" }
9
+
10
+ it { should_not be_installed }
9
11
  end
@@ -1,3 +1,9 @@
1
+ begin
2
+ require 'simplecov'
3
+ rescue LoadError
4
+ # Probably on 1.8.7, ignore.
5
+ end
6
+
1
7
  require 'rspec'
2
8
  require 'aruba/api'
3
9
  require 'bourne'
@@ -1,33 +1,23 @@
1
1
  shared_context "when on Cedar" do
2
- let(:command_line) { mock("Kumade::CommandLine instance") }
2
+ let(:command_line) { mock("Kumade::CommandLine") }
3
+ let(:stack_command) { "bundle exec heroku stack --remote staging" }
4
+ let(:heroku_output) { ["aspen-mri-1.8.6", "bamboo-mri-1.9.2", "bamboo-ree-1.8.7", "* cedar (beta)"].join("\n") }
3
5
 
4
6
  before do
5
- Kumade::CommandLine.expects(:new).
6
- with("bundle exec heroku stack --remote staging").
7
- returns(command_line)
7
+ Kumade::CommandLine.expects(:new).with(stack_command).returns(command_line)
8
8
 
9
- command_line.expects(:run_or_error).returns(%{
10
- aspen-mri-1.8.6
11
- bamboo-mri-1.9.2
12
- bamboo-ree-1.8.7
13
- * cedar (beta)
14
- })
9
+ command_line.expects(:run_or_error).returns(heroku_output)
15
10
  end
16
11
  end
17
12
 
18
13
  shared_context "when not on Cedar" do
19
- let(:command_line) { mock("Kumade::CommandLine") }
14
+ let(:command_line) { mock("Kumade::CommandLine") }
15
+ let(:stack_command) { "bundle exec heroku stack --remote staging" }
16
+ let(:heroku_output) { ["aspen-mri-1.8.6", "* bamboo-mri-1.9.2", "bamboo-ree-1.8.7", "cedar (beta)"].join("\n") }
20
17
 
21
18
  before do
22
- Kumade::CommandLine.expects(:new).
23
- with("bundle exec heroku stack --remote staging").
24
- returns(command_line)
19
+ Kumade::CommandLine.expects(:new).with(stack_command).returns(command_line)
25
20
 
26
- command_line.expects(:run_or_error).returns(%{
27
- aspen-mri-1.8.6
28
- * bamboo-mri-1.9.2
29
- bamboo-ree-1.8.7
30
- cedar (beta)
31
- })
21
+ command_line.expects(:run_or_error).returns(heroku_output)
32
22
  end
33
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kumade
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-10-15 00:00:00.000000000Z
13
+ date: 2011-10-21 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: heroku
17
- requirement: &2153892060 !ruby/object:Gem::Requirement
17
+ requirement: &70180072865600 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '2.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2153892060
25
+ version_requirements: *70180072865600
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rake
28
- requirement: &2153891080 !ruby/object:Gem::Requirement
28
+ requirement: &70180072864740 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 0.8.7
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2153891080
36
+ version_requirements: *70180072864740
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: cocaine
39
- requirement: &2153890460 !ruby/object:Gem::Requirement
39
+ requirement: &70180072862960 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 0.2.0
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *2153890460
47
+ version_requirements: *70180072862960
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rake
50
- requirement: &2153889820 !ruby/object:Gem::Requirement
50
+ requirement: &70180072854560 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 0.8.7
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2153889820
58
+ version_requirements: *70180072854560
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rspec
61
- requirement: &2153889040 !ruby/object:Gem::Requirement
61
+ requirement: &70180072853060 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 2.6.0
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *2153889040
69
+ version_requirements: *70180072853060
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: cucumber
72
- requirement: &2153888380 !ruby/object:Gem::Requirement
72
+ requirement: &70180072851460 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ~>
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: 1.0.2
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *2153888380
80
+ version_requirements: *70180072851460
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: aruba
83
- requirement: &2153887700 !ruby/object:Gem::Requirement
83
+ requirement: &70180072850160 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ~>
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: 0.4.3
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *2153887700
91
+ version_requirements: *70180072850160
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: jammit
94
- requirement: &2153887040 !ruby/object:Gem::Requirement
94
+ requirement: &70180072849500 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ~>
@@ -99,10 +99,10 @@ dependencies:
99
99
  version: 0.6.3
100
100
  type: :development
101
101
  prerelease: false
102
- version_requirements: *2153887040
102
+ version_requirements: *70180072849500
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: less
105
- requirement: &2153886240 !ruby/object:Gem::Requirement
105
+ requirement: &70180072848760 !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
108
108
  - - ~>
@@ -110,10 +110,10 @@ dependencies:
110
110
  version: '2.0'
111
111
  type: :development
112
112
  prerelease: false
113
- version_requirements: *2153886240
113
+ version_requirements: *70180072848760
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: bourne
116
- requirement: &2153885660 !ruby/object:Gem::Requirement
116
+ requirement: &70180072848100 !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements:
119
119
  - - ! '>='
@@ -121,7 +121,18 @@ dependencies:
121
121
  version: '0'
122
122
  type: :development
123
123
  prerelease: false
124
- version_requirements: *2153885660
124
+ version_requirements: *70180072848100
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov
127
+ requirement: &70180072840840 !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: *70180072840840
125
136
  description: A well-tested script for easy deploying to Heroku
126
137
  email:
127
138
  - gabe@thoughtbot.com
@@ -132,6 +143,7 @@ extensions: []
132
143
  extra_rdoc_files: []
133
144
  files:
134
145
  - .gitignore
146
+ - .simplecov
135
147
  - .travis.yml
136
148
  - Changelog.md
137
149
  - Gemfile
@@ -199,7 +211,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
199
211
  version: '0'
200
212
  segments:
201
213
  - 0
202
- hash: 1939713887165989663
214
+ hash: -2390276882750566623
203
215
  required_rubygems_version: !ruby/object:Gem::Requirement
204
216
  none: false
205
217
  requirements:
@@ -208,10 +220,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
220
  version: '0'
209
221
  segments:
210
222
  - 0
211
- hash: 1939713887165989663
223
+ hash: -2390276882750566623
212
224
  requirements: []
213
225
  rubyforge_project:
214
- rubygems_version: 1.8.10
226
+ rubygems_version: 1.8.11
215
227
  signing_key:
216
228
  specification_version: 3
217
229
  summary: A well-tested script for easy deploying to Heroku