heroku_rails_deploy 0.3.0 → 0.4.0.rc0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59063858cd146cef356f6822b6a3e4b2828b7763
4
- data.tar.gz: '0785252959606cd3a2ddec9bbd07ff321e071e3a'
3
+ metadata.gz: 011e522544ae6747ba888aa135ecf61bc5f41ca8
4
+ data.tar.gz: 2d8c4d7942848b6a842ef675cfa2861b35fd8e9f
5
5
  SHA512:
6
- metadata.gz: ba03127adfc0f2601d57b3100247eba65cc2773cc8152f267d8183bb2ceb5356a5e385acdf5688245aa3c9e4425762c851c2aff3fa65cc35f7dc69c21ffa2eac
7
- data.tar.gz: a554b5d01e12482f0acd011c1dfa356e249c11d8068242f16086851e33b53a52259f2af6be2f9e62612d442a4cbf7567f1af7c2cf7fc6ffe654189ffd75e50d4
6
+ metadata.gz: 8845289a2ff2d63b0813993d008f8c1e9954618fe7100e4a628d97d369457e7d132cce7f13f9016e332ff0e321bd6cd069f87066963fb80cc4bd2d7f708b2078
7
+ data.tar.gz: 4017936ca0d8eefab9823959880c9268cfcfb5c2facd2ad56b22900ac0de849ff62c88149fdd4ad969a53cad3fa0e8c111d9af7f119b97f7299cfb68b134a55e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # heroku_rails_deploy
2
2
 
3
+ ## v0.4.0
4
+ - Refactor to expose environment from `Deployer`.
5
+
3
6
  ## v0.3.0
4
7
  - Add support for Avro schema registration during deployment.
5
8
  - Refuse to deploy when there are uncommitted changes.
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ['lib']
21
21
 
22
22
  spec.add_runtime_dependency 'rails'
23
+ spec.add_runtime_dependency 'private_attr'
23
24
 
24
25
  spec.add_development_dependency 'bundler', '~> 1.12'
25
26
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -2,13 +2,17 @@ require 'optparse'
2
2
  require 'shellwords'
3
3
  require 'yaml'
4
4
  require 'english'
5
+ require 'private_attr'
5
6
 
6
7
  module HerokuRailsDeploy
7
8
  class Deployer
9
+ extend PrivateAttr
10
+
8
11
  PRODUCTION_BRANCH_REGEX = /\A((master)|(release\/.+)|(hotfix\/.+))\z/
9
12
  PRODUCTION = 'production'.freeze
10
13
 
11
14
  attr_reader :config_file, :args
15
+ private_attr_reader :options, :app_registry
12
16
 
13
17
  class Options < Struct.new(:environment, :revision, :register_avro_schemas, :skip_avro_schemas)
14
18
  def self.create_default(app_registry)
@@ -17,43 +21,15 @@ module HerokuRailsDeploy
17
21
  end
18
22
 
19
23
  def initialize(config_file, args)
24
+ raise "Missing config file #{config_file}" unless File.file?(config_file)
25
+ @app_registry = YAML.load(File.read(config_file))
20
26
  @config_file = config_file
21
27
  @args = args
28
+ @options = parse_options
22
29
  end
23
30
 
24
31
  def run
25
- raise "Missing config file #{config_file}" unless File.file?(config_file)
26
- app_registry = YAML.load(File.read(config_file))
27
-
28
- options = Options.create_default(app_registry)
29
- OptionParser.new do |parser|
30
- parser.on_tail('-h', '--help', 'Show this message') do
31
- puts parser
32
- # rubocop:disable Lint/NonLocalExitFromIterator
33
- return
34
- # rubocop:enable Lint/NonLocalExitFromIterator
35
- end
36
-
37
- parser.on('-e', '--environment ENVIRONMENT',
38
- "The environment to deploy to. Must be in #{app_registry.keys.join(', ')} (default #{app_registry.keys.first})") do |environment|
39
- options.environment = environment
40
- end
41
-
42
- parser.on('-r', '--revision REVISION',
43
- 'The git revision to push. (default HEAD)') do |revision|
44
- options.revision = revision
45
- end
46
-
47
- parser.on('--register-avro-schemas',
48
- 'Force the registration of Avro schemas when deploying to a non-production environment.') do |register_avro_schemas|
49
- options.register_avro_schemas = register_avro_schemas
50
- end
51
-
52
- parser.on('--skip-avro-schemas',
53
- 'Skip the registration of Avro schemas when deploying to production.') do |skip_avro_schemas|
54
- options.skip_avro_schemas = skip_avro_schemas
55
- end
56
- end.parse!(args)
32
+ return unless options
57
33
 
58
34
  app_name = app_registry.fetch(options.environment) do
59
35
  raise OptionParser::InvalidArgument.new("Invalid environment '#{options.environment}'. " \
@@ -66,7 +42,7 @@ module HerokuRailsDeploy
66
42
 
67
43
  puts "Deploying to Heroku app #{app_name} for environment #{options.environment}"
68
44
 
69
- if !options.skip_avro_schemas && (production?(options) || options.register_avro_schemas)
45
+ if !options.skip_avro_schemas && (production? || options.register_avro_schemas)
70
46
  puts 'Checking for pending Avro schemas'
71
47
  pending_schemas = list_pending_schemas(app_name)
72
48
  if pending_schemas.any?
@@ -91,10 +67,44 @@ module HerokuRailsDeploy
91
67
  end
92
68
  end
93
69
 
70
+ def production?
71
+ options.try(:environment) == PRODUCTION
72
+ end
73
+
94
74
  private
95
75
 
96
- def production?(options)
97
- options.environment == PRODUCTION
76
+ def parse_options
77
+ options = Options.create_default(app_registry)
78
+ OptionParser.new do |parser|
79
+ parser.on_tail('-h', '--help', 'Show this message') do
80
+ puts parser
81
+ # rubocop:disable Lint/NonLocalExitFromIterator
82
+ return
83
+ # rubocop:enable Lint/NonLocalExitFromIterator
84
+ end
85
+
86
+ parser.on('-e', '--environment ENVIRONMENT',
87
+ "The environment to deploy to. Must be in #{app_registry.keys.join(', ')} (default #{app_registry.keys.first})") do |environment|
88
+ options.environment = environment
89
+ end
90
+
91
+ parser.on('-r', '--revision REVISION',
92
+ 'The git revision to push. (default HEAD)') do |revision|
93
+ options.revision = revision
94
+ end
95
+
96
+ parser.on('--register-avro-schemas',
97
+ 'Force the registration of Avro schemas when deploying to a non-production environment.') do |register_avro_schemas|
98
+ options.register_avro_schemas = register_avro_schemas
99
+ end
100
+
101
+ parser.on('--skip-avro-schemas',
102
+ 'Skip the registration of Avro schemas when deploying to production.') do |skip_avro_schemas|
103
+ options.skip_avro_schemas = skip_avro_schemas
104
+ end
105
+ end.parse!(args)
106
+
107
+ options
98
108
  end
99
109
 
100
110
  def production_branch?(revision)
@@ -1,3 +1,3 @@
1
1
  module HerokuRailsDeploy
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.4.0.rc0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku_rails_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0.rc0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salsify, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-27 00:00:00.000000000 Z
11
+ date: 2017-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: private_attr
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -151,9 +165,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
165
  version: '0'
152
166
  required_rubygems_version: !ruby/object:Gem::Requirement
153
167
  requirements:
154
- - - ">="
168
+ - - ">"
155
169
  - !ruby/object:Gem::Version
156
- version: '0'
170
+ version: 1.3.1
157
171
  requirements: []
158
172
  rubyforge_project:
159
173
  rubygems_version: 2.6.11