dldinternet-mixlib-thor 0.7.0 → 0.9.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/dldinternet-mixlib-thor.gemspec +1 -0
- data/lib/dldinternet/formatters/awesome.rb +3 -5
- data/lib/dldinternet/formatters/basic.rb +81 -10
- data/lib/dldinternet/formatters/table.rb +47 -17
- data/lib/dldinternet/thor/command.rb +1 -0
- data/lib/dldinternet/thor/errors.rb +5 -0
- data/lib/dldinternet/thor/mixins/no_commands.rb +107 -34
- data/lib/dldinternet/thor/version.rb +1 -1
- metadata +24 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e304facbf9df8b0d9f56707bb2fff2c05e7eeb33
|
4
|
+
data.tar.gz: acf675f70dfd8c77efb5f58ceaee071802094762
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9981d254c00a9be82d1db0936dcd7222ad2dff0212ab1d01ed00486b71ab8d204a7d4ee893156dbaf6c7d01bc92c14ea9723c82531c3cd8797d020c7dc00ba56
|
7
|
+
data.tar.gz: e65fada56e6859ec0b78f1a1e30b9e4e2864d9ba45a267d0159c6b053a5f070cb69d4a5959768f9155082d1686aba5f573720707662b5c67d6813aa4b35ae362
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dldinternet-mixlib-thor (0.
|
4
|
+
dldinternet-mixlib-thor (0.9.1)
|
5
5
|
activesupport (~> 5.1, >= 5.1.4)
|
6
6
|
awesome_print
|
7
7
|
command_line_reporter (~> 3.3, >= 3.3.6)
|
@@ -9,6 +9,7 @@ PATH
|
|
9
9
|
dldinternet-mixlib-logging (>= 0.7.0)
|
10
10
|
hashie
|
11
11
|
inifile
|
12
|
+
json-pointer (~> 0.0, < 0.1)
|
12
13
|
paint-shortcuts
|
13
14
|
thor (~> 0.19, >= 0.19.4)
|
14
15
|
vcr (~> 3.0, >= 3.0.3)
|
@@ -43,6 +44,7 @@ GEM
|
|
43
44
|
i18n (0.8.6)
|
44
45
|
inifile (3.0.0)
|
45
46
|
json (2.0.3)
|
47
|
+
json-pointer (0.0.1)
|
46
48
|
little-plugger (1.1.4)
|
47
49
|
logging (2.2.2)
|
48
50
|
little-plugger (~> 1.1)
|
@@ -27,6 +27,7 @@ Gem::Specification.new do |gem|
|
|
27
27
|
gem.add_dependency 'config-factory' #, '~> '
|
28
28
|
gem.add_dependency 'vcr', '~> 3.0', '>= 3.0.3'
|
29
29
|
gem.add_dependency 'activesupport', '~> 5.1', '>= 5.1.4'
|
30
|
+
gem.add_dependency 'json-pointer', '~> 0.0', '< 0.1'
|
30
31
|
|
31
32
|
gem.add_development_dependency 'bundler', '~> 1.0'
|
32
33
|
gem.add_development_dependency 'rake', '~> 10'
|
@@ -7,16 +7,14 @@ module DLDInternet
|
|
7
7
|
module Formatters
|
8
8
|
# Awesome formatter
|
9
9
|
class Awesome < DLDInternet::Formatters::Basic
|
10
|
-
attr_reader :format
|
11
|
-
attr_reader :object
|
12
|
-
attr_reader :title
|
13
10
|
|
14
11
|
def initialize(obj, format, options)
|
15
12
|
super
|
16
13
|
end
|
17
14
|
|
18
|
-
def format_it
|
19
|
-
object
|
15
|
+
def format_it(item=nil)
|
16
|
+
item ||= object
|
17
|
+
item.ai
|
20
18
|
end
|
21
19
|
end
|
22
20
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'json'
|
4
4
|
require 'yaml'
|
5
|
+
require 'csv'
|
5
6
|
require 'awesome_print'
|
6
7
|
require 'hashie/mash'
|
7
8
|
|
@@ -72,8 +73,10 @@ module DLDInternet
|
|
72
73
|
@widths = Hashie::Mash.new
|
73
74
|
if @is_a_hash
|
74
75
|
widths_hash
|
75
|
-
|
76
|
+
elsif @object.is_a?(Array)
|
76
77
|
widths_array
|
78
|
+
else
|
79
|
+
widths_object
|
77
80
|
end
|
78
81
|
end
|
79
82
|
@widths
|
@@ -106,11 +109,75 @@ module DLDInternet
|
|
106
109
|
private
|
107
110
|
|
108
111
|
def format_item(item, header=false)
|
109
|
-
|
112
|
+
fmt = format.to_s.downcase
|
113
|
+
if /json|yaml|csv/.match?(fmt)
|
114
|
+
item = if @columns.nil?
|
115
|
+
item
|
116
|
+
else
|
117
|
+
item = item.dup
|
118
|
+
if item.is_a?(Array)
|
119
|
+
nitm = item.map do |itm|
|
120
|
+
hitm = Hash[itm.map do |key, val|
|
121
|
+
if @columns.keys.include?(key) && @columns[key].nil?
|
122
|
+
[key,val]
|
123
|
+
end
|
124
|
+
end.select{ |e| !e.nil? }]
|
125
|
+
end
|
126
|
+
nitm
|
127
|
+
elsif item.is_a?(Hash)
|
128
|
+
else
|
129
|
+
item
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
case fmt
|
110
134
|
when 'json'
|
111
135
|
JSON.pretty_generate(item)
|
112
136
|
when 'yaml'
|
113
137
|
item.to_yaml
|
138
|
+
when 'csv'
|
139
|
+
columns = if @columns.nil?
|
140
|
+
if item.is_a?(Array)
|
141
|
+
if item[0].is_a?(Array)
|
142
|
+
# [2017-10-06 Christo] Assume first row is headings?
|
143
|
+
item[0] # raise StandardError, "Cannot find column headings"
|
144
|
+
elsif item[0].is_a?(Hash)
|
145
|
+
item[0].keys
|
146
|
+
else
|
147
|
+
# [2017-10-06 Christo] Assume first row is headings?
|
148
|
+
item
|
149
|
+
end
|
150
|
+
elsif item.is_a?(Hash)
|
151
|
+
item.keys
|
152
|
+
else
|
153
|
+
item
|
154
|
+
end
|
155
|
+
else
|
156
|
+
@columns.keys
|
157
|
+
end
|
158
|
+
nitm = if item.is_a?(Array)
|
159
|
+
item.map { |itm|
|
160
|
+
if itm.is_a?(Array)
|
161
|
+
itm
|
162
|
+
elsif itm.is_a?(Hash)
|
163
|
+
itm.values.map{|v| v.nil? ? '' : v}
|
164
|
+
else
|
165
|
+
[itm]
|
166
|
+
end
|
167
|
+
}
|
168
|
+
elsif item.is_a?(Hash)
|
169
|
+
itm.values.map{|v| v.nil? ? '' : v}
|
170
|
+
else
|
171
|
+
[itm]
|
172
|
+
end
|
173
|
+
nitm.unshift(columns)
|
174
|
+
header_row = true
|
175
|
+
nitm.map! { |row|
|
176
|
+
o = CSV::Row.new(columns,row,header_row)
|
177
|
+
header_row = false
|
178
|
+
o
|
179
|
+
}
|
180
|
+
csv = CSV::Table.new(nitm).to_csv
|
114
181
|
when 'none'
|
115
182
|
item
|
116
183
|
else
|
@@ -130,13 +197,14 @@ module DLDInternet
|
|
130
197
|
}
|
131
198
|
nitm.join(" ")
|
132
199
|
elsif item.is_a?(Hash)
|
133
|
-
item.map do |key, val|
|
200
|
+
nitm = item.map do |key, val|
|
134
201
|
if @columns.nil? || (@columns.keys.include?(key) && @columns[key].nil?)
|
135
202
|
sprintf("%-#{widths[key]}s", val.to_s)
|
136
|
-
|
203
|
+
elsif !key.index('.').nil?
|
137
204
|
sprintf("%-#{widths[key]}s", subcolumn(key, val))
|
138
205
|
end
|
139
206
|
end
|
207
|
+
nitm.select{|s| !s.nil?}.join(" ")
|
140
208
|
else
|
141
209
|
item.to_s
|
142
210
|
end
|
@@ -161,21 +229,24 @@ module DLDInternet
|
|
161
229
|
end
|
162
230
|
end
|
163
231
|
|
232
|
+
def widths_object
|
233
|
+
set_width(0, @object)
|
234
|
+
end
|
235
|
+
|
164
236
|
def widths_array
|
165
|
-
idx = 0
|
166
237
|
@object.each do |val|
|
167
|
-
|
168
|
-
idx += 1
|
238
|
+
widths_hash(val)
|
169
239
|
end
|
170
240
|
end
|
171
241
|
|
172
|
-
def widths_hash
|
173
|
-
@object
|
242
|
+
def widths_hash(item=nil)
|
243
|
+
item ||= @object
|
244
|
+
item.each do |key, _|
|
174
245
|
klen = key.to_s.length
|
175
246
|
wid = @widths[key]
|
176
247
|
@widths[key] = klen if !wid || wid < klen
|
177
248
|
end
|
178
|
-
obj_width(
|
249
|
+
obj_width(item)
|
179
250
|
end
|
180
251
|
|
181
252
|
def set_width(idx, val)
|
@@ -17,39 +17,64 @@ module DLDInternet
|
|
17
17
|
@values = Hashie::Mash.new
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
|
20
|
+
def capture_output
|
21
|
+
@previous_stdout, $stdout = $stdout, StringIO.new
|
22
|
+
begin
|
23
|
+
yield
|
24
|
+
rescue Exception => e
|
25
|
+
previous_stdout.write $stdout.string
|
26
|
+
raise e
|
27
|
+
end
|
28
|
+
|
29
|
+
$stdout.string
|
30
|
+
ensure
|
31
|
+
# Restore the previous value of stdout (typically equal to stdout).
|
32
|
+
$stdout = @previous_stdout
|
33
|
+
end
|
34
|
+
|
35
|
+
def suppress_output
|
36
|
+
@previous_stdout, $stdout = $stdout, StringIO.new
|
37
|
+
end
|
22
38
|
|
23
|
-
|
39
|
+
def restore_output
|
40
|
+
string = $stdout.string
|
41
|
+
$stdout = @previous_stdout
|
42
|
+
string
|
43
|
+
end
|
44
|
+
|
45
|
+
def run
|
46
|
+
# suppress_output
|
47
|
+
capture_output do
|
48
|
+
header(title: @title, align: 'center') if @title #&& !@title.empty?
|
24
49
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
50
|
+
table border: true, encoding: :ascii do
|
51
|
+
header_row
|
52
|
+
idx = 0
|
53
|
+
list = @object.is_a?(Array) ? @object : [@object]
|
54
|
+
list.each do |obj|
|
55
|
+
obj_row(idx, obj)
|
56
|
+
end
|
31
57
|
end
|
32
58
|
end
|
33
59
|
|
34
|
-
|
60
|
+
# string = restore_output
|
35
61
|
rescue => exe
|
36
62
|
restore_output
|
37
63
|
raise exe
|
38
64
|
end
|
39
65
|
|
40
66
|
def header_row
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
67
|
+
list = @object.is_a?(Array) ? @object : [@object]
|
68
|
+
row color: 'light_yellow', bold: true, encoding: :ascii do
|
69
|
+
list[0].each do |key, _|
|
70
|
+
column key.to_s, width: widths[key] if (@columns.nil? || @columns.keys.include?(key))
|
46
71
|
end
|
47
72
|
end
|
48
73
|
end
|
49
74
|
|
50
75
|
def obj_row(idx, obj)
|
51
76
|
row color: 'white', bold: false do
|
52
|
-
if
|
77
|
+
if obj.is_a? Hash
|
53
78
|
obj.each do |key, val|
|
54
79
|
if @columns.nil? || (@columns.keys.include?(key) && @columns[key].nil?)
|
55
80
|
column val.to_s
|
@@ -64,7 +89,12 @@ module DLDInternet
|
|
64
89
|
end
|
65
90
|
end
|
66
91
|
|
67
|
-
def format_it
|
92
|
+
def format_it(item=nil)
|
93
|
+
if item
|
94
|
+
@object = item
|
95
|
+
@is_a_hash = @object.is_a?(Hash)
|
96
|
+
@widths = nil
|
97
|
+
end
|
68
98
|
run
|
69
99
|
end
|
70
100
|
end
|
@@ -4,6 +4,7 @@ require 'yaml'
|
|
4
4
|
require 'dldinternet/formatters'
|
5
5
|
require 'hashie/mash'
|
6
6
|
require 'dldinternet/thor/version'
|
7
|
+
require 'dldinternet/thor/errors'
|
7
8
|
require 'inifile'
|
8
9
|
require 'config/factory'
|
9
10
|
require 'dldinternet/thor/vcr'
|
@@ -45,22 +46,32 @@ module DLDInternet
|
|
45
46
|
LOG_LEVELS = [:trace, :debug, :info, :note, :warn, :error, :fatal, :todo]
|
46
47
|
|
47
48
|
class OptionsMash < ::Hashie::Mash ; end
|
49
|
+
class ConfigMash < ::Hashie::Mash
|
50
|
+
def initialize(source_hash = nil, default = nil, &blk)
|
51
|
+
self.class.disable_warnings
|
52
|
+
super
|
53
|
+
end
|
54
|
+
end
|
48
55
|
|
49
56
|
module MixIns
|
50
57
|
module NoCommands
|
51
58
|
require 'dldinternet/mixlib/logging'
|
52
59
|
include DLDInternet::Mixlib::Logging
|
53
60
|
|
54
|
-
def validate_options
|
61
|
+
def validate_options(*args)
|
55
62
|
writeable_options
|
56
63
|
if options[:log_level]
|
57
64
|
log_level = options[:log_level].to_sym
|
58
65
|
raise "Invalid log-level: #{log_level}" unless LOG_LEVELS.include?(log_level)
|
59
66
|
options[:log_level] = log_level
|
60
67
|
end
|
61
|
-
@options[:log_level] ||= :warn
|
62
68
|
@options[:format] ||= @options[:output]
|
63
69
|
@options[:output] ||= @options[:format]
|
70
|
+
|
71
|
+
args.flatten!
|
72
|
+
if !args.empty? && args.map{ |a| /^-/.match(a) }.any?
|
73
|
+
raise DLDInternet::Thor::BadArgumentError, "Invalid arguments provided: #{args}"
|
74
|
+
end
|
64
75
|
end
|
65
76
|
|
66
77
|
def writeable_options
|
@@ -113,21 +124,25 @@ module DLDInternet
|
|
113
124
|
end
|
114
125
|
|
115
126
|
def load_config
|
116
|
-
|
117
|
-
@
|
118
|
-
|
127
|
+
if @options[:configfile].blank?
|
128
|
+
@logger.error 'Invalid/No configuration file specified'
|
129
|
+
else
|
130
|
+
@options[:configfile] = File.expand_path(@options[:configfile])
|
131
|
+
if ::File.exist?(@options[:configfile])
|
119
132
|
begin
|
120
|
-
envs = ::Config::Factory::Environments.load_file(@options[:
|
133
|
+
# envs = ::Config::Factory::Environments.load_file(@options[:configfile])
|
134
|
+
hash = config_to_yaml
|
135
|
+
envs = ::Config::Factory::Environments.load_hash(hash)
|
121
136
|
if envs and envs.is_a?(Hash) and @options[:environment]
|
122
137
|
@options[:environments] = ::Hashie::Mash.new(envs)
|
123
138
|
else
|
124
|
-
yaml = ::YAML.load(File.read(@options[:
|
139
|
+
yaml = ::YAML.load(File.read(@options[:configfile]))
|
125
140
|
if yaml
|
126
141
|
yaml.each {|key, value|
|
127
142
|
@options[key.to_s.gsub(%r{[-]}, '_').to_sym]=value
|
128
143
|
}
|
129
144
|
else
|
130
|
-
msg = "#{options
|
145
|
+
msg = "#{options[:configfile]} is not a valid configuration!"
|
131
146
|
@logger.error msg
|
132
147
|
raise StandardError.new(msg)
|
133
148
|
end
|
@@ -137,27 +152,67 @@ module DLDInternet
|
|
137
152
|
raise e
|
138
153
|
end
|
139
154
|
else
|
140
|
-
@logger.warn "#{options
|
155
|
+
@logger.warn "'#{options[:configfile]}' not found"
|
141
156
|
@logger.error "Invalid/No configuration file specified"
|
142
157
|
exit 2
|
143
158
|
#@options[:environments] = ::Hashie::Mash.new
|
144
159
|
end
|
145
|
-
else
|
146
|
-
@logger.error 'Invalid/No configuration file specified'
|
147
160
|
end
|
148
161
|
end
|
149
162
|
|
150
|
-
def
|
151
|
-
|
163
|
+
def solve_pointers(haystack, hash=nil)
|
164
|
+
hash ||= haystack
|
165
|
+
return haystack unless hash.is_a?(Hash) && hash.size
|
152
166
|
|
167
|
+
hash.dup.each do |k,v|
|
168
|
+
if %r{^[#/]}.match?(k) && v.nil?
|
169
|
+
begin
|
170
|
+
require 'hana'
|
171
|
+
pointer = Hana::Pointer.new k
|
172
|
+
v = pointer.eval(haystack)
|
173
|
+
hash.delete(k)
|
174
|
+
hash.merge!(v)
|
175
|
+
rescue Exception => e
|
176
|
+
require 'json-pointer'
|
177
|
+
pointer = ::JsonPointer.new(haystack, k, :symbolize_keys => true)
|
178
|
+
if pointer.exists?
|
179
|
+
hash.delete(k)
|
180
|
+
hash.merge!(pointer.value)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
hash.each do |k,v|
|
186
|
+
if v && v.is_a?(Hash)
|
187
|
+
haystack = solve_pointers(haystack, v)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
haystack
|
191
|
+
end
|
192
|
+
|
193
|
+
def config_to_yaml
|
194
|
+
begin
|
195
|
+
yaml = ConfigMash.new(::YAML.load(File.read(@options[:configfile])))
|
196
|
+
yaml = solve_pointers(yaml)
|
197
|
+
yaml
|
198
|
+
rescue StandardError => e
|
199
|
+
raise e
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
def parse_options(*args)
|
153
204
|
get_logger(true)
|
154
205
|
|
206
|
+
args.flatten!
|
207
|
+
check_for_help(args)
|
208
|
+
validate_options(args)
|
209
|
+
|
155
210
|
if @options[:inifile]
|
156
211
|
@options[:inifile] = File.expand_path(@options[:inifile])
|
157
212
|
load_inifile
|
158
|
-
elsif @options[:
|
159
|
-
if @options[:
|
160
|
-
@options[:inifile] = @options[:
|
213
|
+
elsif @options[:configfile]
|
214
|
+
if @options[:configfile] =~ /\.ini/i
|
215
|
+
@options[:inifile] = @options[:configfile]
|
161
216
|
load_inifile
|
162
217
|
else
|
163
218
|
load_config
|
@@ -166,19 +221,22 @@ module DLDInternet
|
|
166
221
|
if options[:debug]
|
167
222
|
@logger.info "Options:\n#{options.ai}"
|
168
223
|
end
|
169
|
-
if options[:stubber].is_a?(String)
|
170
|
-
options[:stubber] = options[:stubber].split(/\s*,\s*/).map(&:to_sym)
|
171
|
-
elsif options[:stubber].is_a?(Array) && options[:stubber].size == 1 && options[:stubber][0].is_a?(String)
|
172
|
-
options[:stubber] = options[:stubber][0].split(/\s*,\s*/).map(&:to_sym)
|
173
|
-
elsif options[:stubber].is_a?(Array) && options[:stubber].size > 1 && options[:stubber][0].is_a?(String)
|
174
|
-
options[:stubber] = options[:stubber].map(&:to_sym)
|
175
|
-
end
|
176
224
|
|
177
225
|
end
|
178
226
|
|
227
|
+
# Child classes can override this if desired
|
228
|
+
def check_for_help(args)
|
229
|
+
if args && args.size > 0 && (args[0] && args[0].downcase.eql?('help') || args.select {|a| a.match(/--help/i)}.any?)
|
230
|
+
invocations = @_invocations.map {|_, v| v[0]}
|
231
|
+
self.class.command_help(shell, invocations[-1], invocations)
|
232
|
+
exit 0
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
179
236
|
def get_logger(force=false)
|
180
237
|
return unless force || @logger.nil?
|
181
238
|
writeable_options
|
239
|
+
@options[:log_level] ||= :warn
|
182
240
|
lcs = ::Logging::ColorScheme.new('compiler', :levels => {
|
183
241
|
:trace => :blue,
|
184
242
|
:debug => :cyan,
|
@@ -217,7 +275,7 @@ module DLDInternet
|
|
217
275
|
end
|
218
276
|
|
219
277
|
def notation
|
220
|
-
@config[:
|
278
|
+
@config[:format] || :none
|
221
279
|
end
|
222
280
|
|
223
281
|
def default_formatter(obj, opts=nil)
|
@@ -226,8 +284,9 @@ module DLDInternet
|
|
226
284
|
case notation.to_sym
|
227
285
|
when :json
|
228
286
|
when :yaml
|
287
|
+
when :csv
|
229
288
|
when :none
|
230
|
-
when :basic
|
289
|
+
# when :basic
|
231
290
|
when :text
|
232
291
|
# noop
|
233
292
|
when :awesome
|
@@ -291,8 +350,8 @@ module DLDInternet
|
|
291
350
|
end
|
292
351
|
|
293
352
|
def command_pre(*args)
|
294
|
-
args.flatten!
|
295
|
-
parse_options
|
353
|
+
# args.flatten!
|
354
|
+
parse_options(args)
|
296
355
|
@logger.info @_invocations.map{ |_,v| v[0]}.join(' ') if options[:verbose]
|
297
356
|
command_pre_start_vcr(args)
|
298
357
|
end
|
@@ -308,6 +367,8 @@ module DLDInternet
|
|
308
367
|
fmtr = formatter.call(res, options)
|
309
368
|
fmtr.table_widths
|
310
369
|
end
|
370
|
+
# [2017-10-06 Christo] header_line and format_line serves to invoke client hooks if provided.
|
371
|
+
# It means we may go through the process once with an object and a second time with a formatted string
|
311
372
|
case options[:format]
|
312
373
|
when /text|none|plain/
|
313
374
|
output(header_line(res, fmtr), fmtr, true) unless options[:header] === false
|
@@ -361,6 +422,13 @@ module DLDInternet
|
|
361
422
|
|
362
423
|
def command_pre_start_vcr(*args)
|
363
424
|
args.flatten!
|
425
|
+
if options[:stubber].is_a?(String)
|
426
|
+
options[:stubber] = options[:stubber].split(/\s*,\s*/).map(&:to_sym)
|
427
|
+
elsif options[:stubber].is_a?(Array) && options[:stubber].size == 1 && options[:stubber][0].is_a?(String)
|
428
|
+
options[:stubber] = options[:stubber][0].split(/\s*,\s*/).map(&:to_sym)
|
429
|
+
elsif options[:stubber].is_a?(Array) && options[:stubber].size > 1 && options[:stubber][0].is_a?(String)
|
430
|
+
options[:stubber] = options[:stubber].map(&:to_sym)
|
431
|
+
end
|
364
432
|
if options[:vcr]
|
365
433
|
unless options[:cassette_path].match(%r{^#{File::SEPARATOR}})
|
366
434
|
if File.dirname($0).eql?(Dir.pwd)
|
@@ -369,19 +437,24 @@ module DLDInternet
|
|
369
437
|
end
|
370
438
|
end
|
371
439
|
|
372
|
-
|
373
|
-
::VCR.configure do |config|
|
374
|
-
config.cassette_library_dir = options[:cassette_path]
|
375
|
-
config.hook_into *options[:stubber]
|
376
|
-
config.logger = @vcr_logger
|
377
|
-
end
|
440
|
+
command_pre_config_vcr
|
378
441
|
opts = args[0].is_a?(Hash) ? args.shift : {}
|
379
442
|
options[:cassette] ||= @_invocations.map{ |_,v| v[0]}.join('-')
|
380
|
-
@cassette = ::VCR.insert_cassette(opts[:cassette] || options[:cassette]
|
443
|
+
@cassette = ::VCR.insert_cassette(opts[:cassette] || options[:cassette])
|
381
444
|
end
|
382
445
|
yield if block_given?
|
383
446
|
end
|
384
447
|
|
448
|
+
def command_pre_config_vcr
|
449
|
+
@vcr_logger ||= ::DLDInternet::Thor::VCR::Logger.new(nil, @logger)
|
450
|
+
::VCR.configure do |config|
|
451
|
+
config.cassette_library_dir = options[:cassette_path]
|
452
|
+
config.hook_into *options[:stubber]
|
453
|
+
config.logger = @vcr_logger
|
454
|
+
config.default_cassette_options.merge!({ match_requests_on: [:method, :uri, :headers, :body], record: options[:record_mode] })
|
455
|
+
end
|
456
|
+
end
|
457
|
+
|
385
458
|
def command_post_stop_vcr
|
386
459
|
if options[:vcr]
|
387
460
|
::VCR.eject_cassette
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dldinternet-mixlib-thor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christo De Lange
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -174,6 +174,26 @@ dependencies:
|
|
174
174
|
- - ">="
|
175
175
|
- !ruby/object:Gem::Version
|
176
176
|
version: 5.1.4
|
177
|
+
- !ruby/object:Gem::Dependency
|
178
|
+
name: json-pointer
|
179
|
+
requirement: !ruby/object:Gem::Requirement
|
180
|
+
requirements:
|
181
|
+
- - "~>"
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: '0.0'
|
184
|
+
- - "<"
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0.1'
|
187
|
+
type: :runtime
|
188
|
+
prerelease: false
|
189
|
+
version_requirements: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - "~>"
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: '0.0'
|
194
|
+
- - "<"
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: '0.1'
|
177
197
|
- !ruby/object:Gem::Dependency
|
178
198
|
name: bundler
|
179
199
|
requirement: !ruby/object:Gem::Requirement
|
@@ -239,6 +259,7 @@ files:
|
|
239
259
|
- lib/dldinternet/formatters/table.rb
|
240
260
|
- lib/dldinternet/thor/command.rb
|
241
261
|
- lib/dldinternet/thor/dynamic_command.rb
|
262
|
+
- lib/dldinternet/thor/errors.rb
|
242
263
|
- lib/dldinternet/thor/mixins/no_commands.rb
|
243
264
|
- lib/dldinternet/thor/vcr.rb
|
244
265
|
- lib/dldinternet/thor/vcr/logger.rb
|
@@ -263,7 +284,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
263
284
|
version: '0'
|
264
285
|
requirements: []
|
265
286
|
rubyforge_project:
|
266
|
-
rubygems_version: 2.
|
287
|
+
rubygems_version: 2.6.13
|
267
288
|
signing_key:
|
268
289
|
specification_version: 4
|
269
290
|
summary: Thor no_commands reuse
|