heroku_san 1.1.0 → 1.2.0

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.
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ .bundle
2
+ doc
3
+ pkg
4
+ Thumbs.db
5
+ tmp
6
+
7
+ Gemfile.lock
8
+ *.swp
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "features/data/test-config"]
2
+ path = features/data/test-config
3
+ url = git://github.com/rahearn/test-credentials.git
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm @heroku_san --create
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ # Specify dependencies in heroku_san.gemspec
4
+ gemspec
data/Rakefile CHANGED
@@ -1,22 +1,5 @@
1
- require 'rake'
2
-
3
- begin
4
- require 'jeweler'
5
- Jeweler::Tasks.new do |gem|
6
- gem.name = "heroku_san"
7
- gem.summary = %Q{A bunch of useful Rake tasks for managing your Heroku apps}
8
- gem.description = %Q{Manage multiple Heroku instances/apps for a single Rails app using Rake}
9
- gem.email = "elijah.miller@gmail.com"
10
- gem.homepage = "http://github.com/glennr/heroku_san"
11
- gem.authors = ["Elijah Miller", "Glenn Roberts"]
12
- gem.files = Dir["{lib}/**/*", "VERSION", "LICENSE", "CHANGELOG", "TODO", "README.rdoc", "Rakefile"]
13
- gem.extra_rdoc_files = []
14
- gem.add_dependency("heroku")
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
- end
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
20
3
 
21
4
  desc 'Default: build gem.'
22
5
  task :default => :build
@@ -0,0 +1,47 @@
1
+ Feature: Command Line
2
+
3
+ Scenario: Config file can be formatted like Rails' database.yml
4
+ Given I run `rails new heroku_san_test -O`
5
+ And I cd to "heroku_san_test"
6
+ And I overwrite "Gemfile" with:
7
+ """
8
+ source :rubygems
9
+ gem 'heroku_san', :path => '../../../.'
10
+ """
11
+ Given a file named "config/heroku.yml" with:
12
+ """
13
+ production:
14
+ app: awesomeapp
15
+ staging:
16
+ app: awesomeapp-staging
17
+ demo:
18
+ app: awesomeapp-demo
19
+ """
20
+
21
+ When I run `rake heroku:apps:local`
22
+
23
+ Then the output should contain "production is shorthand for the Heroku app awesomeapp"
24
+ And the output should contain "staging is shorthand for the Heroku app awesomeapp-staging"
25
+ And the output should contain "demo is shorthand for the Heroku app awesomeapp-demo"
26
+
27
+ Scenario: Config file still accepts the heroku_san format
28
+ Given I run `rails new heroku_san_test -O`
29
+ And I cd to "heroku_san_test"
30
+ And I overwrite "Gemfile" with:
31
+ """
32
+ source :rubygems
33
+ gem 'heroku_san', :path => '../../../.'
34
+ """
35
+ Given a file named "config/heroku.yml" with:
36
+ """
37
+ apps:
38
+ production: awesomeapp
39
+ staging: awesomeapp-staging
40
+ demo: awesomeapp-demo
41
+ """
42
+
43
+ When I run `rake heroku:apps:local`
44
+
45
+ Then the output should contain "production is shorthand for the Heroku app awesomeapp"
46
+ And the output should contain "staging is shorthand for the Heroku app awesomeapp-staging"
47
+ And the output should contain "demo is shorthand for the Heroku app awesomeapp-demo"
@@ -0,0 +1,81 @@
1
+ Feature: Extended config
2
+
3
+ Scenario: Config information can be pulled from a separate git repository
4
+ Given I run `rails new heroku_san_test -O`
5
+ And I cd to "heroku_san_test"
6
+ And I overwrite "Gemfile" with:
7
+ """
8
+ source :rubygems
9
+ gem 'heroku_san', :path => '../../../.'
10
+ """
11
+ Given a file named "config/heroku.yml" with:
12
+ """
13
+ config_repo: 'file:///<%= File.join(File.expand_path(File.dirname(__FILE__)), '..', '..', '..', 'features', 'data', 'test-config') %>'
14
+ production:
15
+ app: awesomeapp
16
+ staging:
17
+ app: awesomeapp-staging
18
+ demo:
19
+ app: awesomeapp-demo
20
+ """
21
+
22
+ When I run `rake all heroku:config:list:local`
23
+
24
+ Then the output should contain "production TEST_REMOTE: 'hello_world'"
25
+ And the output should contain "staging TEST_REMOTE: 'goodbye_world'"
26
+
27
+ Scenario: Config information can be listed
28
+ Given I run `rails new heroku_san_test -O`
29
+ And I cd to "heroku_san_test"
30
+ And I overwrite "Gemfile" with:
31
+ """
32
+ source :rubygems
33
+ gem 'heroku_san', :path => '../../../.'
34
+ """
35
+ Given a file named "config/heroku.yml" with:
36
+ """
37
+ production:
38
+ app: awesomeapp
39
+ config:
40
+ TEST_LOCAL: 'hello_world'
41
+ staging:
42
+ app: awesomeapp-staging
43
+ config:
44
+ TEST_LOCAL: 'goodbye_world'
45
+ demo:
46
+ app: awesomeapp-demo
47
+ """
48
+
49
+ When I run `rake all heroku:config:list:local`
50
+
51
+ Then the output should contain "production TEST_LOCAL: 'hello_world'"
52
+ And the output should contain "staging TEST_LOCAL: 'goodbye_world'"
53
+
54
+ Scenario: Config information can be merged between local and remote
55
+ Given I run `rails new heroku_san_test -O`
56
+ And I cd to "heroku_san_test"
57
+ And I overwrite "Gemfile" with:
58
+ """
59
+ source :rubygems
60
+ gem 'heroku_san', :path => '../../../.'
61
+ """
62
+ Given a file named "config/heroku.yml" with:
63
+ """
64
+ config_repo: 'file:///<%= File.join(File.expand_path(File.dirname(__FILE__)), '..', '..', '..', 'features', 'data', 'test-config') %>'
65
+ production:
66
+ app: awesomeapp
67
+ config:
68
+ TEST_LOCAL: 'hello_world'
69
+ staging:
70
+ app: awesomeapp-staging
71
+ config:
72
+ TEST_LOCAL: 'goodbye_world'
73
+ TEST_REMOTE: 'overridden_by_remote'
74
+ """
75
+
76
+ When I run `rake all heroku:config:list:local`
77
+
78
+ Then the output should contain "production TEST_LOCAL: 'hello_world'"
79
+ And the output should contain "production TEST_REMOTE: 'hello_world'"
80
+ And the output should contain "staging TEST_LOCAL: 'goodbye_world'"
81
+ And the output should contain "staging TEST_REMOTE: 'goodbye_world'"
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
+
3
+ require 'aruba/cucumber'
4
+
5
+ # ensure test-config submodule has been cloned
6
+ unless File.readable? File.join(File.dirname(__FILE__), '..', 'data', 'test-config', 'config.yml')
7
+ `git submodule init && git submodule update`
8
+ end
@@ -0,0 +1,42 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{heroku_san}
5
+ s.version = "1.2.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Elijah Miller", "Glenn Roberts"]
9
+ s.date = %q{2011-03-14}
10
+ s.description = %q{Manage multiple Heroku instances/apps for a single Rails app using Rake}
11
+ s.email = %q{elijah.miller@gmail.com}
12
+ s.homepage = %q{http://github.com/glennr/heroku_san}
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.require_paths = ["lib"]
16
+ s.extra_rdoc_files = ["README.rdoc"]
17
+ s.rubygems_version = %q{1.6.1}
18
+ s.summary = %q{A bunch of useful Rake tasks for managing your Heroku apps}
19
+
20
+ if s.respond_to? :specification_version then
21
+ s.specification_version = 3
22
+
23
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
24
+ s.add_runtime_dependency(%q<rails>, ['>= 2'])
25
+ s.add_runtime_dependency(%q<heroku>)
26
+ s.add_development_dependency(%q<rails>, ['>= 3'])
27
+ s.add_development_dependency(%q<aruba>)
28
+ s.add_development_dependency(%q<cucumber>)
29
+ else
30
+ s.add_dependency(%q<rails>, ['>= 2'])
31
+ s.add_dependency(%q<heroku>)
32
+ s.add_dependency(%q<aruba>)
33
+ s.add_dependency(%q<cucumber>)
34
+ end
35
+ else
36
+ s.add_dependency(%q<rails>, ['>= 2'])
37
+ s.add_dependency(%q<heroku>)
38
+ s.add_dependency(%q<aruba>)
39
+ s.add_dependency(%q<cucumber>)
40
+ end
41
+ end
42
+
@@ -18,6 +18,27 @@ if @app_settings.has_key? 'apps'
18
18
  end
19
19
  end
20
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
+
21
42
  (@app_settings.keys || []).each do |name|
22
43
  desc "Select #{name} Heroku app for later commands"
23
44
  task name do
@@ -86,12 +107,30 @@ namespace :heroku do
86
107
  desc 'Lists configured apps'
87
108
  task :apps => :all do
88
109
  each_heroku_app do |name, app, repo|
89
- puts "#{name} is shorthand for the Heroku app #{app} located at:"
90
- puts " #{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
91
119
  puts
92
120
  end
93
121
  end
94
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
+
95
134
  desc 'Add proper RACK_ENV to each application'
96
135
  task :rack_env => :all do
97
136
  each_heroku_app do |name, app, repo|
@@ -118,12 +157,35 @@ namespace :heroku do
118
157
 
119
158
  desc 'Add config:vars to each application.'
120
159
  task :config do
160
+ retrieve_configuration
121
161
  each_heroku_app do |name, app, repo, config|
122
162
  (config).each do |var, value|
123
163
  sh "heroku config:add --app #{app} #{var}=#{value}"
124
164
  end
125
165
  end
126
166
  end
167
+
168
+ namespace :config do
169
+ desc "Lists config variables as set on Heroku"
170
+ task :list do
171
+ each_heroku_app do |name, app|
172
+ puts "#{name}:"
173
+ sh "heroku config --app #{app} --long"
174
+ end
175
+ end
176
+
177
+ namespace :list do
178
+ desc "Lists local config variables without setting them"
179
+ task :local do
180
+ retrieve_configuration
181
+ each_heroku_app do |name, app, repo, config|
182
+ (config).each do |var, value|
183
+ puts "#{name} #{var}: '#{value}'"
184
+ end
185
+ end
186
+ end
187
+ end
188
+ end
127
189
 
128
190
  desc 'Runs a rake task remotely'
129
191
  task :rake, :task do |t, args|
@@ -246,15 +308,27 @@ namespace :db do
246
308
  end
247
309
 
248
310
  def each_heroku_app
249
- if @heroku_apps.blank? && @app_settings.keys.size == 1
250
- app = @app_settings.keys.first
251
- puts "Defaulting to #{app} app since only one app is defined"
252
- @heroku_apps = [app]
311
+ if @heroku_apps.blank?
312
+ if @app_settings.keys.size == 1
313
+ app = @app_settings.keys.first
314
+ puts "Defaulting to #{app} app since only one app is defined"
315
+ @heroku_apps = [app]
316
+ else
317
+ @app_settings.keys.each do |key|
318
+ active_branch = %x{git branch}.split("\n").select { |b| b =~ /^\*/ }.first.split(" ").last.strip
319
+ if key == active_branch
320
+ puts "Defaulting to #{key} as it matches the current branch"
321
+ @heroku_apps = [key]
322
+ end
323
+ end
324
+ end
253
325
  end
326
+
254
327
  if @heroku_apps.present?
255
328
  @heroku_apps.each do |name|
256
329
  app = @app_settings[name]['app']
257
- config = @app_settings[name]['config'] || []
330
+ config = @app_settings[name]['config'] || {}
331
+ config.merge!(@extra_config[name]) if (@extra_config && @extra_config[name])
258
332
  yield(name, app, "git@heroku.com:#{app}.git", config)
259
333
  end
260
334
  puts
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku_san
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 1.1.0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Elijah Miller
@@ -20,6 +20,8 @@ date: 2011-03-14 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
+ name: rails
24
+ prerelease: false
23
25
  requirement: &id001 !ruby/object:Gem::Requirement
24
26
  none: false
25
27
  requirements:
@@ -29,11 +31,11 @@ dependencies:
29
31
  segments:
30
32
  - 2
31
33
  version: "2"
32
- version_requirements: *id001
33
- name: rails
34
- prerelease: false
35
34
  type: :runtime
35
+ version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency
37
+ name: heroku
38
+ prerelease: false
37
39
  requirement: &id002 !ruby/object:Gem::Requirement
38
40
  none: false
39
41
  requirements:
@@ -43,12 +45,26 @@ dependencies:
43
45
  segments:
44
46
  - 0
45
47
  version: "0"
48
+ type: :runtime
46
49
  version_requirements: *id002
47
- name: jeweler
50
+ - !ruby/object:Gem::Dependency
51
+ name: rails
48
52
  prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 5
59
+ segments:
60
+ - 3
61
+ version: "3"
49
62
  type: :development
63
+ version_requirements: *id003
50
64
  - !ruby/object:Gem::Dependency
51
- requirement: &id003 !ruby/object:Gem::Requirement
65
+ name: aruba
66
+ prerelease: false
67
+ requirement: &id004 !ruby/object:Gem::Requirement
52
68
  none: false
53
69
  requirements:
54
70
  - - ">="
@@ -57,24 +73,42 @@ dependencies:
57
73
  segments:
58
74
  - 0
59
75
  version: "0"
60
- version_requirements: *id003
61
- name: heroku
76
+ type: :development
77
+ version_requirements: *id004
78
+ - !ruby/object:Gem::Dependency
79
+ name: cucumber
62
80
  prerelease: false
63
- type: :runtime
81
+ requirement: &id005 !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ hash: 3
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ type: :development
91
+ version_requirements: *id005
64
92
  description: Manage multiple Heroku instances/apps for a single Rails app using Rake
65
93
  email: elijah.miller@gmail.com
66
94
  executables: []
67
95
 
68
96
  extensions: []
69
97
 
70
- extra_rdoc_files: []
71
-
98
+ extra_rdoc_files:
99
+ - README.rdoc
72
100
  files:
101
+ - .gitignore
102
+ - .gitmodules
103
+ - .rvmrc
104
+ - Gemfile
73
105
  - LICENSE
74
106
  - README.rdoc
75
107
  - Rakefile
76
- - TODO
77
- - VERSION
108
+ - features/command_line.feature
109
+ - features/extended-config.feature
110
+ - features/support/env.rb
111
+ - heroku_san.gemspec
78
112
  - lib/heroku_san.rb
79
113
  - lib/heroku_san/railtie.rb
80
114
  - lib/heroku_san/tasks.rb
@@ -114,5 +148,7 @@ rubygems_version: 1.6.1
114
148
  signing_key:
115
149
  specification_version: 3
116
150
  summary: A bunch of useful Rake tasks for managing your Heroku apps
117
- test_files: []
118
-
151
+ test_files:
152
+ - features/command_line.feature
153
+ - features/extended-config.feature
154
+ - features/support/env.rb
data/TODO DELETED
@@ -1,2 +0,0 @@
1
- - refactor config/helpers out of tasks.rb into own file(s)
2
- -
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.1.0