heroku_san 1.3.0 → 2.0.rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
metadata CHANGED
@@ -1,21 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku_san
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
5
- prerelease:
4
+ version: 2.0.rc.1
5
+ prerelease: 4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Elijah Miller
9
9
  - Glenn Roberts
10
10
  - Ryan Ahearn
11
+ - Ken Mayer
11
12
  autorequire:
12
13
  bindir: bin
13
14
  cert_chain: []
14
- date: 2011-11-07 00:00:00.000000000Z
15
+ date: 2012-02-29 00:00:00.000000000Z
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
18
  name: rails
18
- requirement: &70239580705520 !ruby/object:Gem::Requirement
19
+ requirement: &2152331240 !ruby/object:Gem::Requirement
19
20
  none: false
20
21
  requirements:
21
22
  - - ! '>='
@@ -23,10 +24,10 @@ dependencies:
23
24
  version: '2'
24
25
  type: :runtime
25
26
  prerelease: false
26
- version_requirements: *70239580705520
27
+ version_requirements: *2152331240
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: heroku
29
- requirement: &70239580704340 !ruby/object:Gem::Requirement
30
+ requirement: &2152330240 !ruby/object:Gem::Requirement
30
31
  none: false
31
32
  requirements:
32
33
  - - ! '>='
@@ -34,21 +35,21 @@ dependencies:
34
35
  version: '2'
35
36
  type: :runtime
36
37
  prerelease: false
37
- version_requirements: *70239580704340
38
+ version_requirements: *2152330240
38
39
  - !ruby/object:Gem::Dependency
39
- name: rails
40
- requirement: &70239580700620 !ruby/object:Gem::Requirement
40
+ name: rake
41
+ requirement: &2152329700 !ruby/object:Gem::Requirement
41
42
  none: false
42
43
  requirements:
43
44
  - - ! '>='
44
45
  - !ruby/object:Gem::Version
45
- version: '3'
46
- type: :development
46
+ version: '0'
47
+ type: :runtime
47
48
  prerelease: false
48
- version_requirements: *70239580700620
49
+ version_requirements: *2152329700
49
50
  - !ruby/object:Gem::Dependency
50
51
  name: aruba
51
- requirement: &70239580699940 !ruby/object:Gem::Requirement
52
+ requirement: &2152328620 !ruby/object:Gem::Requirement
52
53
  none: false
53
54
  requirements:
54
55
  - - ! '>='
@@ -56,10 +57,21 @@ dependencies:
56
57
  version: '0'
57
58
  type: :development
58
59
  prerelease: false
59
- version_requirements: *70239580699940
60
+ version_requirements: *2152328620
60
61
  - !ruby/object:Gem::Dependency
61
62
  name: cucumber
62
- requirement: &70239580654620 !ruby/object:Gem::Requirement
63
+ requirement: &2152327820 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: *2152327820
72
+ - !ruby/object:Gem::Dependency
73
+ name: rake
74
+ requirement: &2152327040 !ruby/object:Gem::Requirement
63
75
  none: false
64
76
  requirements:
65
77
  - - ! '>='
@@ -67,7 +79,18 @@ dependencies:
67
79
  version: '0'
68
80
  type: :development
69
81
  prerelease: false
70
- version_requirements: *70239580654620
82
+ version_requirements: *2152327040
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
85
+ requirement: &2152325960 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: '1.0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: *2152325960
71
94
  description: Manage multiple Heroku instances/apps for a single Rails app using Rake
72
95
  email: elijah.miller@gmail.com
73
96
  executables: []
@@ -82,16 +105,32 @@ files:
82
105
  - LICENSE
83
106
  - README.rdoc
84
107
  - Rakefile
85
- - features/command_line.feature
108
+ - autotest/discover.rb
109
+ - cucumber.yml
110
+ - examples/auto_tagger.rake
111
+ - features/config.feature
86
112
  - features/extended-config.feature
113
+ - features/remote.feature
87
114
  - features/support/env.rb
88
115
  - heroku_san.gemspec
116
+ - lib/git.rb
89
117
  - lib/heroku_san.rb
90
- - lib/heroku_san/railtie.rb
91
- - lib/heroku_san/tasks.rb
118
+ - lib/heroku_san/project.rb
119
+ - lib/heroku_san/stage.rb
120
+ - lib/heroku_san/version.rb
121
+ - lib/railtie.rb
122
+ - lib/tasks.rb
92
123
  - lib/tasks/heroku.rake
93
124
  - lib/templates/heroku.example.yml
94
- homepage: http://github.com/glennr/heroku_san
125
+ - spec/fixtures/example.yml
126
+ - spec/fixtures/extended_config.yml
127
+ - spec/fixtures/old_format.yml
128
+ - spec/fixtures/single_app.yml
129
+ - spec/git_spec.rb
130
+ - spec/heroku_san/project_spec.rb
131
+ - spec/heroku_san/stage_spec.rb
132
+ - spec/spec_helper.rb
133
+ homepage: http://github.com/fastestforward/heroku_san
95
134
  licenses: []
96
135
  post_install_message:
97
136
  rdoc_options: []
@@ -103,9 +142,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
142
  - - ! '>='
104
143
  - !ruby/object:Gem::Version
105
144
  version: '0'
106
- segments:
107
- - 0
108
- hash: -81552674531593559
109
145
  required_rubygems_version: !ruby/object:Gem::Requirement
110
146
  none: false
111
147
  requirements:
@@ -119,6 +155,15 @@ signing_key:
119
155
  specification_version: 3
120
156
  summary: A bunch of useful Rake tasks for managing your Heroku apps
121
157
  test_files:
122
- - features/command_line.feature
158
+ - features/config.feature
123
159
  - features/extended-config.feature
160
+ - features/remote.feature
124
161
  - features/support/env.rb
162
+ - spec/fixtures/example.yml
163
+ - spec/fixtures/extended_config.yml
164
+ - spec/fixtures/old_format.yml
165
+ - spec/fixtures/single_app.yml
166
+ - spec/git_spec.rb
167
+ - spec/heroku_san/project_spec.rb
168
+ - spec/heroku_san/stage_spec.rb
169
+ - spec/spec_helper.rb
@@ -1,419 +0,0 @@
1
- HEROKU_CONFIG_FILE = Rails.root.join('config', 'heroku.yml')
2
-
3
- @app_settings =
4
- if File.exists?(HEROKU_CONFIG_FILE)
5
- if defined?(ERB)
6
- YAML.load(ERB.new(File.read(HEROKU_CONFIG_FILE)).result)
7
- else
8
- YAML.load_file(HEROKU_CONFIG_FILE)
9
- end
10
- else
11
- {}
12
- end
13
-
14
- if @app_settings.has_key? 'apps'
15
- @app_settings = @app_settings['apps']
16
- @app_settings.each_pair do |shorthand, app_name|
17
- @app_settings[shorthand] = {'app' => app_name}
18
- end
19
- end
20
-
21
- @config_repo = @app_settings.delete('config_repo')
22
- def retrieve_configuration
23
- unless @config_repo.nil?
24
- #load external config
25
- require 'tmpdir'
26
- tmp_config_dir = Dir.mktmpdir
27
- tmp_config_file = File.join tmp_config_dir, 'config.yml'
28
- sh "git clone #{@config_repo} #{tmp_config_dir}"
29
- @extra_config =
30
- if File.exists?(tmp_config_file)
31
- if defined?(ERB)
32
- YAML.load(ERB.new(File.read(tmp_config_file)).result)
33
- else
34
- YAML.load_file(tmp_config_file)
35
- end
36
- else
37
- {}
38
- end
39
- end
40
- end
41
-
42
- (@app_settings.keys || []).each do |name|
43
- desc "Select #{name} Heroku app for later commands"
44
- task name do
45
- @heroku_apps ||= []
46
- @heroku_apps << name
47
- end
48
- end
49
-
50
- desc 'Select all Heroku apps for later command'
51
- task :all do
52
- @heroku_apps = @app_settings.keys
53
- end
54
-
55
- namespace :heroku do
56
- desc "Creates the Heroku app"
57
- task :create do
58
- each_heroku_app do |name, app, repo|
59
- sh "heroku create #{app} #{("--stack " + stack(app)) if stack(app)}"
60
- end
61
- end
62
-
63
- desc "Generate the Heroku gems manifest from gem dependencies"
64
- task :gems => 'gems:base' do
65
- RAILS_ENV='production'
66
- Rake::Task[:environment].invoke
67
- gems = Rails.configuration.gems.reject { |g| g.frozen? && !g.framework_gem? }
68
- list = gems.collect do |g|
69
- command, *options = g.send(:install_command)
70
- options.join(" ")
71
- end
72
-
73
- list.unshift(%Q{rails --version "= #{Rails.version}"})
74
-
75
- File.open(Rails.root.join('.gems'), 'w') do |f|
76
- f.write(list.join("\n"))
77
- end
78
- end
79
-
80
- desc 'Add git remotes for all apps in this project'
81
- task :remotes do
82
- each_heroku_app do |name, app, repo|
83
- system("git remote add #{name} #{repo}")
84
- end
85
- end
86
-
87
- desc 'Adds a collaborator'
88
- task :share do
89
- print "Email address of collaborator to add: "
90
- $stdout.flush
91
- email = $stdin.gets
92
- each_heroku_app do |name, app, repo|
93
- sh "heroku sharing:add --app #{app} #{email}"
94
- end
95
- end
96
-
97
- desc 'Removes a collaborator'
98
- task :unshare do
99
- print "Email address of collaborator to remove: "
100
- $stdout.flush
101
- email = $stdin.gets
102
- each_heroku_app do |name, app, repo|
103
- sh "heroku sharing:remove --app #{app} #{email}"
104
- end
105
- end
106
-
107
- desc 'Lists configured apps'
108
- task :apps => :all do
109
- each_heroku_app do |name, app, repo|
110
- puts "#{name} is shorthand for the Heroku app #{app} located at:"
111
- puts " #{repo}"
112
- print " @ "
113
- rev = `git ls-remote -h #{repo}`.split(' ').first
114
- if rev.blank?
115
- puts 'not deployed'
116
- else
117
- puts `git name-rev #{rev}`
118
- end
119
- puts
120
- end
121
- end
122
-
123
- namespace :apps do
124
- desc 'Lists configured apps without hitting Heroku'
125
- task :local => :all do
126
- each_heroku_app do |name, app, repo|
127
- puts "#{name} is shorthand for the Heroku app #{app} located at:"
128
- puts " #{repo}"
129
- puts
130
- end
131
- end
132
- end
133
-
134
- desc 'Add proper RACK_ENV to each application'
135
- task :rack_env => :all do
136
- each_heroku_app do |name, app, repo|
137
- command = "heroku config --app #{app}"
138
- puts command
139
- config = Hash[`#{command}`.scan(/^(.+?)\s*=>\s*(.+)$/)]
140
- if config['RACK_ENV'] != name
141
- sh "heroku config:add --app #{app} RACK_ENV=#{name}"
142
- end
143
- end
144
- end
145
-
146
- desc 'Creates an example configuration file'
147
- task :create_config do
148
- example = File.join(File.dirname(__FILE__), '..', 'templates', 'heroku.example.yml')
149
- if File.exists?(HEROKU_CONFIG_FILE)
150
- puts "config/heroku.yml already exists"
151
- else
152
- puts "Copied example config to config/heroku.yml"
153
- FileUtils.cp(example, HEROKU_CONFIG_FILE)
154
- if ENV['EDITOR'].present?
155
- sh("#{ENV['EDITOR']} #{HEROKU_CONFIG_FILE}")
156
- else
157
- puts "Please edit config/heroku.yml with your application's settings."
158
- end
159
- end
160
- end
161
-
162
- desc 'Add config:vars to each application'
163
- task :config do
164
- retrieve_configuration
165
- each_heroku_app do |name, app, repo, config|
166
- command = "heroku config:add --app #{app}"
167
- config.each do |var, value|
168
- command += " #{var}=#{value}"
169
- end
170
- sh(command)
171
- end
172
- end
173
-
174
- namespace :config do
175
- desc "Lists config variables as set on Heroku"
176
- task :list do
177
- each_heroku_app do |name, app|
178
- puts "#{name}:"
179
- sh "heroku config --app #{app} --long"
180
- end
181
- end
182
-
183
- namespace :list do
184
- desc "Lists local config variables without setting them"
185
- task :local do
186
- retrieve_configuration
187
- each_heroku_app do |name, app, repo, config|
188
- (config).each do |var, value|
189
- puts "#{name} #{var}: '#{value}'"
190
- end
191
- end
192
- end
193
- end
194
- end
195
-
196
- desc 'Runs a rake task remotely'
197
- task :rake, :task do |t, args|
198
- each_heroku_app do |name, app, repo|
199
- sh "heroku #{run_or_rake(app)} #{args[:task]}"
200
- end
201
- end
202
-
203
- desc "Pushes the given commit (default: HEAD)"
204
- task :push, :commit do |t, args|
205
- each_heroku_app do |name, app, repo|
206
- push(args[:commit], repo)
207
- end
208
- end
209
-
210
- namespace :push do
211
- desc "Force-pushes the given commit (default: HEAD)"
212
- task :force, :commit do |t, args|
213
- @git_push_arguments ||= []
214
- @git_push_arguments << '--force'
215
- Rake::Task[:'heroku:push'].execute(args)
216
- end
217
- end
218
-
219
- desc "Enable maintenance mode"
220
- task :maintenance do
221
- each_heroku_app do |name, app, repo|
222
- maintenance(app, 'on')
223
- end
224
- end
225
-
226
- desc "Disable maintenance mode"
227
- task :maintenance_off do
228
- each_heroku_app do |name, app, repo|
229
- maintenance(app, 'off')
230
- end
231
- end
232
- end
233
-
234
- desc "Pushes the given commit, migrates and restarts (default: HEAD)"
235
- task :deploy, [:commit] => [:before_deploy] do |t, args|
236
- each_heroku_app do |name, app, repo|
237
- push(args[:commit], repo)
238
- migrate(app)
239
- end
240
- Rake::Task[:after_deploy].execute
241
- end
242
-
243
- namespace :deploy do
244
- desc "Force-pushes the given commit, migrates and restarts (default: HEAD)"
245
- task :force, :commit do |t, args|
246
- @git_push_arguments ||= []
247
- @git_push_arguments << '--force'
248
- Rake::Task[:deploy].invoke(args[:commit])
249
- end
250
- end
251
-
252
- # Deprecated.
253
- task :force_deploy do
254
- Rake::Task[:'deploy:force'].invoke
255
- end
256
-
257
- desc "Callback before deploys"
258
- task :before_deploy do
259
- end
260
-
261
- desc "Callback after deploys"
262
- task :after_deploy do
263
- end
264
-
265
- desc "Captures a bundle on Heroku"
266
- task :capture do
267
- each_heroku_app do |name, app, repo|
268
- sh "heroku bundles:capture --app #{app}"
269
- end
270
- end
271
-
272
- desc "Opens a remote console"
273
- task :console do
274
- each_heroku_app do |name, app, repo|
275
- if stack_is_cedar?(app)
276
- sh "heroku run --app #{app} console"
277
- else
278
- sh "heroku console --app #{app}"
279
- end
280
- end
281
- end
282
-
283
- desc "Restarts remote servers"
284
- task :restart do
285
- each_heroku_app do |name, app, repo|
286
- sh "heroku restart --app #{app}"
287
- end
288
- end
289
-
290
- desc "Migrates and restarts remote servers"
291
- task :migrate do
292
- each_heroku_app do |name, app, repo|
293
- migrate(app)
294
- end
295
- end
296
-
297
- desc "Shows the Heroku logs"
298
- task :logs do
299
- each_heroku_app do |name, app, repo|
300
- sh "heroku logs --app #{app}"
301
- end
302
- end
303
-
304
- namespace :db do
305
- desc 'Pull the Heroku database'
306
- task :pull do
307
- dbconfig = YAML.load(ERB.new(File.read(Rails.root.join('config/database.yml'))).result)[Rails.env]
308
- return if dbconfig['adapter'] != 'postgresql'
309
-
310
- each_heroku_app do |name, app, repo|
311
- oldest = `heroku pgbackups --app #{app}`.split("\n")[2].split(" ").first
312
- sh "heroku pgbackups:destroy #{oldest} --app #{app}"
313
-
314
- sh "heroku pgbackups:capture --app #{app}"
315
- dump = `heroku pgbackups --app #{app}`.split("\n").last.split(" ").first
316
- sh "mkdir -p #{Rails.root}/db/dumps"
317
- file = "#{Rails.root}/db/dumps/#{dump}"
318
- url = `heroku pgbackups:url --app #{app} #{dump}`.chomp
319
- sh "wget", url, "-O", file
320
-
321
- sh "rake db:setup"
322
- sh "pg_restore --verbose --clean --no-acl --no-owner -h #{dbconfig['host']} -p #{dbconfig['port']} -U #{dbconfig['username']} -d #{dbconfig['database']} #{file}"
323
- sh "rake jobs:clear"
324
- end
325
- end
326
-
327
- desc 'Push local database to Heroku database'
328
- task :push do
329
- dbconfig = YAML.load(ERB.new(File.read(Rails.root.join('config/database.yml'))).result)[Rails.env]
330
- return if dbconfig['adapter'] != 'postgresql'
331
-
332
- each_heroku_app do |name, app, repo|
333
- sh "heroku db:push postgres://#{dbconfig['username']}:#{dbconfig['password']}@#{dbconfig['host']}/#{dbconfig['database']} --app #{app}"
334
- end
335
- end
336
- end
337
-
338
- def each_heroku_app
339
- if @heroku_apps.blank?
340
- if @app_settings.keys.size == 1
341
- app = @app_settings.keys.first
342
- puts "Defaulting to #{app} app since only one app is defined"
343
- @heroku_apps = [app]
344
- else
345
- @app_settings.keys.each do |key|
346
- active_branch = %x{git branch}.split("\n").select { |b| b =~ /^\*/ }.first.split(" ").last.strip
347
- if key == active_branch
348
- puts "Defaulting to #{key} as it matches the current branch"
349
- @heroku_apps = [key]
350
- end
351
- end
352
- end
353
- end
354
-
355
- if @heroku_apps.present?
356
- @heroku_apps.each do |name|
357
- app = @app_settings[name]['app']
358
- config = @app_settings[name]['config'] || {}
359
- config.merge!(@extra_config[name]) if (@extra_config && @extra_config[name])
360
- if @app_settings[name].has_key? 'repo'
361
- repo = @app_settings[name]['repo']
362
- else
363
- repo = "git@heroku.com:#{app}.git"
364
- end
365
- yield(name, app, repo, config)
366
- end
367
- puts
368
- else
369
- puts "You must first specify at least one Heroku app:
370
- rake <app> [<app>] <command>
371
- rake production restart
372
- rake demo staging deploy"
373
-
374
- puts "\nYou can use also command all Heroku apps for this project:
375
- rake all heroku:share"
376
-
377
- exit(1)
378
- end
379
- end
380
-
381
- def push(commit, repo)
382
- commit ||= "HEAD"
383
- @git_push_arguments ||= []
384
- begin
385
- sh "git update-ref refs/heroku_san/deploy #{commit}"
386
- sh "git push #{repo} #{@git_push_arguments.join(' ')} refs/heroku_san/deploy:refs/heads/master"
387
- ensure
388
- sh "git update-ref -d refs/heroku_san/deploy"
389
- end
390
- end
391
-
392
- def migrate(app)
393
- sh "heroku #{run_or_rake(app)} db:migrate"
394
- sh "heroku restart --app #{app}"
395
- end
396
-
397
- def maintenance(app, action)
398
- sh "heroku maintenance:#{action} --app #{app}"
399
- end
400
-
401
- # `heroku rake foo` has been superseded by `heroku run rake foo` on cedar
402
- def run_or_rake(app)
403
- if stack_is_cedar?(app)
404
- "run --app #{app} rake"
405
- else
406
- "rake --app #{app}"
407
- end
408
- end
409
-
410
- def stack_is_cedar?(app)
411
- stack(app) =~ /^cedar/
412
- end
413
-
414
- def stack(app)
415
- @app_settings.values.detect { |s| s['app'] == app }.tap do |settings|
416
- @stack = (settings['stack'] || (/^\* (.*)/.match `heroku stack --app #{app}`)[1] rescue nil)
417
- end
418
- @stack
419
- end