heroku-rails-saas 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- heroku-rails-saas (0.1.3)
4
+ heroku-rails-saas (0.1.4)
5
5
  heroku (>= 2.24.1)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
10
  ZenTest (4.7.0)
11
- addressable (2.2.7)
11
+ addressable (2.2.8)
12
12
  autotest (4.4.6)
13
13
  ZenTest (>= 4.4.1)
14
14
  diff-lcs (1.1.3)
@@ -1,13 +1,13 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "heroku-rails-saas"
3
- s.version = "0.1.3"
3
+ s.version = "0.1.4"
4
4
 
5
5
  s.authors = [ "Elijah Miller", "Glenn Roberts", "Jacques Crocker", "Lance Sanchez"]
6
-
6
+
7
7
  s.summary = "Deployment and configuration tools for Heroku/Rails"
8
8
  s.description = "Manage multiple Heroku instances/apps for a single Rails app using Rake."
9
9
 
10
- s.email = "railsjedi@gmail.com"
10
+ s.email = "lance.sanchez@gmail.com"
11
11
  s.homepage = "http://github.com/darkbushido/heroku-rails-saas"
12
12
  s.rubyforge_project = "none"
13
13
 
@@ -42,7 +42,7 @@ module HerokuRailsSaas
42
42
  # Allows for `rake <app:env> [<app:env>] <command>`
43
43
  def app_name_on_heroku(string)
44
44
  app_name, env = string.split(SEPERATOR)
45
- apps[app_name][env]
45
+ apps[app_name][env]
46
46
  end
47
47
 
48
48
  # return all enviromnets in this format app:env
@@ -53,7 +53,7 @@ module HerokuRailsSaas
53
53
  end
54
54
 
55
55
  # return all environments e.g. staging, production, development
56
- def all_environments
56
+ def all_environments
57
57
  environments = apps.each_with_object([]) do |(app, hsh), arr|
58
58
  hsh.each { |env, app_name| arr << env }
59
59
  end
@@ -74,7 +74,7 @@ module HerokuRailsSaas
74
74
  'heroku '
75
75
  end
76
76
  end
77
-
77
+
78
78
  # pull out the config setting hash for a particular app environment
79
79
  def config(app_env)
80
80
  name, env = app_env.split(SEPERATOR)
@@ -18,8 +18,8 @@ module HerokuRailsSaas
18
18
 
19
19
  # use all environments or filter out production environments
20
20
  def all_environments(filter=false)
21
- @environments = @config.app_environments
22
- filter ? @environments.reject! { |app| app[production_regex] } : @environments
21
+ @environments = @config.app_environments
22
+ filter ? @environments.reject! { |app| app[regex_for(:production)] } : @environments
23
23
  end
24
24
 
25
25
  # use all heroku apps filtered by environments
@@ -37,9 +37,9 @@ module HerokuRailsSaas
37
37
  each_heroku_app do |heroku_env, app_name, repo|
38
38
  next if @my_apps.include?(app_name)
39
39
 
40
- stack = @config.stack(heroku_env)
41
- stack_option = " --stack #{stack}" if stack.to_s.size > 0
42
- creation_command "heroku create #{app_name}#{stack_option} --remote #{app_name}"
40
+ options = { :remote => app_name, :stack => @config.stack(heroku_env) }
41
+
42
+ @heroku.create(app_name, options)
43
43
  end
44
44
  end
45
45
 
@@ -119,7 +119,7 @@ module HerokuRailsSaas
119
119
  new_config.each do |new_key, new_val|
120
120
  add_config[new_key] = new_val unless existing_config[new_key] == new_val
121
121
  end
122
-
122
+
123
123
  # persist the changes onto heroku
124
124
  unless add_config.empty?
125
125
  # add the config
@@ -128,7 +128,9 @@ module HerokuRailsSaas
128
128
  set_config << "#{key}='#{val}' "
129
129
  end
130
130
  creation_command "heroku config:add #{set_config} --app #{app_name}"
131
- system_with_echo("#{@config.cmd(app_env)} rails runner 'Rails.cache.clear' --app #{app_name}")
131
+
132
+ # This fails on a newly created app
133
+ system_with_echo("#{@config.cmd(app_env)} \"#{rails_cli(:runner)} 'Rails.cache.clear'\" --app #{app_name}")
132
134
  end
133
135
  end
134
136
  end
@@ -269,10 +271,17 @@ module HerokuRailsSaas
269
271
  raise "*** command \"#{args.join ' '}\" failed" unless system(*args)
270
272
  end
271
273
 
272
- private
274
+ def regex_for env
275
+ match = case env
276
+ when :production then "production|prod|live"
277
+ when :staging then "staging|stage"
278
+ end
279
+ Regexp.new("#{@config.class::SEPERATOR}(#{match})")
280
+ end
273
281
 
274
- def production_regex
275
- Regexp.new("#{@config.class::SEPERATOR}(production|prod|live)")
282
+ def rails_cli script
283
+ Rails::VERSION::MAJOR < 3 ? ".script/#{script}" : "rails #{script}"
276
284
  end
285
+
277
286
  end
278
287
  end
@@ -75,10 +75,10 @@ namespace :heroku do
75
75
  Rake::Task["heroku:before_each_deploy"].invoke(app_name)
76
76
 
77
77
  cmd = HEROKU_CONFIG.cmd(heroku_env)
78
- if heroku_env == "production"
79
- branch = `git branch`.scan(/^\* (.*)\n/).flatten.first.to_s
78
+
79
+ if heroku_env[HEROKU_RUNNER.regex_for(:production)]
80
80
  all_tags = `git tag`
81
- target_tag = all_tags[/.+\Z/] # Set lastest tag as default
81
+ target_tag = `git describe --tags --abbrev=0`.chomp # Set latest tag as default
82
82
 
83
83
  begin
84
84
  puts "\nGit tags:"
@@ -93,24 +93,27 @@ namespace :heroku do
93
93
  puts "\n\nInvalid git tag!"
94
94
  invalid = true
95
95
  end
96
- end
96
+ end
97
97
  end while invalid
98
+ puts "Unable to determine the tag to deploy." and exit(1) if target_tag.empty?
99
+ to_deploy = "#{target_tag}^{}"
98
100
  else
99
- branch = `git branch`.scan(/^\* (.*)\n/).flatten.first.to_s
100
- if branch.present?
101
- @git_push_arguments ||= []
102
- @git_push_arguments << '--force'
103
- to_deploy = "#{target_tag}^{}"
104
- system_with_echo "git push #{repo} #{@git_push_arguments.join(' ')} #{branch}:master"
105
- Rake::Task["heroku:setup:config"].invoke
106
- system_with_echo "#{cmd} rake --app #{app_name} db:migrate && heroku restart --app #{app_name}"
107
- else
108
- puts "Unable to determine the current git branch, please checkout the branch you'd like to deploy."
109
-
110
- exit(1)
111
- end
101
+ to_deploy = `git branch`.scan(/^\* (.*)\n/).flatten.first.to_s
102
+ puts "Unable to determine the current git branch, please checkout the branch you'd like to deploy." and exit(1) if to_deploy.empty?
112
103
  end
113
-
104
+
105
+ @git_push_arguments ||= []
106
+ @git_push_arguments << '--force'
107
+
108
+ system_with_echo "git push #{repo} #{@git_push_arguments.join(' ')} #{to_deploy}:master"
109
+
110
+ system_with_echo "heroku maintenance:on --app #{app_name}"
111
+
112
+ Rake::Task["heroku:setup:config"].invoke
113
+ system_with_echo "#{cmd} rake --app #{app_name} db:migrate && heroku restart --app #{app_name}"
114
+
115
+ system_with_echo "heroku maintenance:off --app #{app_name}"
116
+
114
117
  Rake::Task["heroku:after_each_deploy"].reenable
115
118
  Rake::Task["heroku:after_each_deploy"].invoke(app_name)
116
119
  puts "\n"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku-rails-saas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,11 +12,11 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2012-04-30 00:00:00.000000000Z
15
+ date: 2012-05-03 00:00:00.000000000Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: heroku
19
- requirement: &2164893760 !ruby/object:Gem::Requirement
19
+ requirement: &2169042360 !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
22
  - - ! '>='
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: 2.24.1
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *2164893760
27
+ version_requirements: *2169042360
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rspec
30
- requirement: &2164892680 !ruby/object:Gem::Requirement
30
+ requirement: &2169041700 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ~>
@@ -35,9 +35,9 @@ dependencies:
35
35
  version: '2.0'
36
36
  type: :development
37
37
  prerelease: false
38
- version_requirements: *2164892680
38
+ version_requirements: *2169041700
39
39
  description: Manage multiple Heroku instances/apps for a single Rails app using Rake.
40
- email: railsjedi@gmail.com
40
+ email: lance.sanchez@gmail.com
41
41
  executables: []
42
42
  extensions: []
43
43
  extra_rdoc_files:
@@ -84,7 +84,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
84
84
  version: '0'
85
85
  segments:
86
86
  - 0
87
- hash: -3605644454962400049
87
+ hash: 4416327361781470259
88
88
  required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  segments:
95
95
  - 0
96
- hash: -3605644454962400049
96
+ hash: 4416327361781470259
97
97
  requirements: []
98
98
  rubyforge_project: none
99
99
  rubygems_version: 1.8.6