rzo 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/CHANGELOG.md +8 -1
- data/lib/rzo/app/subcommand.rb +52 -3
- data/lib/rzo/option_parsing.rb +3 -3
- data/lib/rzo/version.rb +1 -1
- data/rzo.gemspec +0 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70297031778e27174c132a827c094554b20a13f1
|
4
|
+
data.tar.gz: 47971b6987221ea6c623004eddb1736927a4300a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3d7ac91f360bdd6bcc169699bfc08faeb18343b7b1f3dc7887d87ac82b5a83e51b0f7a7dbec0a3777eac56bbf0c53a2d316170af56f635f62c5a2e5ffe51ade
|
7
|
+
data.tar.gz: b70d5f81eb88e8a4b9950a97b76a1d9a937f33b751d755e3af8116d3e9b689d800d2276074b08f62d79b4632b8a8636bbb10acdc930cc2f31fc766d1d9212571
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [v0.
|
3
|
+
## [v0.5.0](https://github.com/ghoneycutt/rizzo/tree/v0.5.0)
|
4
4
|
|
5
|
+
[Full Changelog](https://github.com/ghoneycutt/rizzo/compare/v0.4.0...v0.5.0)
|
6
|
+
|
7
|
+
**Merged pull requests:**
|
8
|
+
|
9
|
+
- Prioritize the present working control repository [\#24](https://github.com/ghoneycutt/rizzo/pull/24) ([jeffmccune](https://github.com/jeffmccune))
|
10
|
+
|
11
|
+
## [v0.4.0](https://github.com/ghoneycutt/rizzo/tree/v0.4.0) (2017-09-13)
|
5
12
|
[Full Changelog](https://github.com/ghoneycutt/rizzo/compare/v0.3.0...v0.4.0)
|
6
13
|
|
7
14
|
**Closed issues:**
|
data/lib/rzo/app/subcommand.rb
CHANGED
@@ -5,6 +5,7 @@ require 'rzo/app/config_validation'
|
|
5
5
|
module Rzo
|
6
6
|
class App
|
7
7
|
# The base class for subcommands
|
8
|
+
# rubocop:disable Metrics/ClassLength
|
8
9
|
class Subcommand
|
9
10
|
include ConfigValidation
|
10
11
|
include Logging
|
@@ -15,6 +16,8 @@ module Rzo
|
|
15
16
|
# The Rizzo configuration after loading ~/.rizzo.json (--config).
|
16
17
|
# See #load_config!
|
17
18
|
attr_reader :config
|
19
|
+
# The present working directory at startup
|
20
|
+
attr_reader :pwd
|
18
21
|
|
19
22
|
##
|
20
23
|
# Delegated method to mock with fixture data.
|
@@ -38,6 +41,7 @@ module Rzo
|
|
38
41
|
@stdout = stdout
|
39
42
|
@stderr = stderr
|
40
43
|
reset_logging!(opts)
|
44
|
+
@pwd = Dir.pwd
|
41
45
|
end
|
42
46
|
|
43
47
|
##
|
@@ -59,7 +63,8 @@ module Rzo
|
|
59
63
|
def load_config!
|
60
64
|
config = load_rizzo_config(opts[:config])
|
61
65
|
validate_personal_config!(config)
|
62
|
-
repos = config['control_repos']
|
66
|
+
repos = reorder_repos(config['control_repos'])
|
67
|
+
config['control_repos'] = repos
|
63
68
|
@config = load_repo_configs(config, repos)
|
64
69
|
debug "Merged configuration: \n#{JSON.pretty_generate(@config)}"
|
65
70
|
# TODO: Move these validations to an instance method?
|
@@ -84,8 +89,8 @@ module Rzo
|
|
84
89
|
def load_repo_configs(config = {}, repos = [])
|
85
90
|
repos.each_with_object(config.dup) do |repo, hsh|
|
86
91
|
fp = Pathname.new(repo).expand_path + '.rizzo.json'
|
87
|
-
if fp.
|
88
|
-
hsh.deep_merge!(load_rizzo_config(fp))
|
92
|
+
if readable?(fp.to_s)
|
93
|
+
hsh.deep_merge!(load_rizzo_config(fp.to_s))
|
89
94
|
else
|
90
95
|
log.debug "Skipped #{fp} (it is not readable)"
|
91
96
|
end
|
@@ -161,6 +166,50 @@ module Rzo
|
|
161
166
|
else File.open(filepath, 'w') { |fd| yield fd }
|
162
167
|
end
|
163
168
|
end
|
169
|
+
|
170
|
+
# helper method to to stub in tests
|
171
|
+
def readable?(path)
|
172
|
+
File.readable?(path)
|
173
|
+
end
|
174
|
+
|
175
|
+
##
|
176
|
+
# Memoized method to return the fully qualified path to the current rizzo
|
177
|
+
# project directory, based on the pwd. The project directory is the
|
178
|
+
# dirname of the full path to a `.rizzo.json` config file. Return false
|
179
|
+
# if not a project directory. ~/.rizzo.json is considered a personal
|
180
|
+
# configuration and not a project configuration.
|
181
|
+
#
|
182
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
183
|
+
def project_dir(path)
|
184
|
+
return @project_dir unless @project_dir.nil?
|
185
|
+
rizzo_file = Pathname.new("#{path}/.rizzo.json")
|
186
|
+
personal_config = Pathname.new(File.expand_path('~/.rizzo.json'))
|
187
|
+
iterations = 0
|
188
|
+
while @project_dir.nil? && iterations < 100
|
189
|
+
iterations += 1
|
190
|
+
if readable?(rizzo_file.to_s) && rizzo_file != personal_config
|
191
|
+
@project_dir = rizzo_file.dirname.to_s
|
192
|
+
else
|
193
|
+
rizzo_file = rizzo_file.dirname.dirname + '.rizzo.json'
|
194
|
+
@project_dir = false if rizzo_file.dirname.root?
|
195
|
+
end
|
196
|
+
end
|
197
|
+
@project_dir
|
198
|
+
end
|
199
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
200
|
+
|
201
|
+
##
|
202
|
+
# Given a list of control repositories, determine if the user's runtime
|
203
|
+
# pwd is in a control repository. If it is, move that control repository
|
204
|
+
# to the top level. If the user is inside a control repository and
|
205
|
+
def reorder_repos(repos = [])
|
206
|
+
if path = project_dir(pwd)
|
207
|
+
new_repos = repos - [path]
|
208
|
+
new_repos.unshift(path)
|
209
|
+
else
|
210
|
+
repos
|
211
|
+
end
|
212
|
+
end
|
164
213
|
end
|
165
214
|
end
|
166
215
|
end
|
data/lib/rzo/option_parsing.rb
CHANGED
@@ -59,7 +59,7 @@ module Rzo
|
|
59
59
|
'STDOUT, STDERR {RZO_LOGTO}'
|
60
60
|
opt :logto, log_msg, default: env['RZO_LOGTO'] || 'STDERR'
|
61
61
|
opt :validate, 'Check the configuration for common issues {RZO_VALIDATE="false"}',
|
62
|
-
default: env['RZO_VALIDATE'] == 'false'
|
62
|
+
default: !(env['RZO_VALIDATE'] == 'false')
|
63
63
|
opt :syslog, 'Log to syslog', default: false, conflicts: :logto
|
64
64
|
opt :verbose, 'Set log level to INFO {RZO_VERBOSE="true"}',
|
65
65
|
default: env['RZO_VERBOSE'] == 'true'
|
@@ -119,7 +119,7 @@ module Rzo
|
|
119
119
|
NAME = File.basename($PROGRAM_NAME).freeze
|
120
120
|
|
121
121
|
# rubocop:disable Layout/IndentHeredoc
|
122
|
-
BANNER = <<-
|
122
|
+
BANNER = <<-BANNERMSG.freeze
|
123
123
|
usage: #{NAME} [GLOBAL OPTIONS] SUBCOMMAND [ARGS]
|
124
124
|
Sub Commands:
|
125
125
|
|
@@ -128,6 +128,6 @@ Sub Commands:
|
|
128
128
|
roles Output all roles defined in the combined config
|
129
129
|
|
130
130
|
Global options: (Note, command line arguments supersede ENV vars in {}'s)
|
131
|
-
|
131
|
+
BANNERMSG
|
132
132
|
end
|
133
133
|
end
|
data/lib/rzo/version.rb
CHANGED
@@ -5,7 +5,7 @@ module Rzo
|
|
5
5
|
# The authoritative location of the rzo version. It should be possible to
|
6
6
|
# `require 'rizzo/version'` and access `Rizzo::VERSION` from third party
|
7
7
|
# libraries and the gemspec. The version is defined as a Semantic Version.
|
8
|
-
VERSION = '0.
|
8
|
+
VERSION = '0.5.0'.freeze
|
9
9
|
|
10
10
|
##
|
11
11
|
# Return the SemVer string, e.g. `"0.1.0"`
|
data/rzo.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rzo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garrett Honeycutt
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-10-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|