dldinternet-mixlib-thor 0.9.9 → 0.9.10
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 +1 -1
- data/lib/dldinternet/formatters/basic.rb +26 -9
- data/lib/dldinternet/thor/mixins/no_commands.rb +24 -13
- data/lib/dldinternet/thor/vcr.rb +20 -3
- data/lib/dldinternet/thor/version.rb +1 -1
- 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: a6efd1afc533c8d23bf9a984f4a57f70f99ef6cd
|
4
|
+
data.tar.gz: 18f57be1edfa890bdacf57b4fcd5ab000127dd40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f4c54834b264f178a19f62d9a3e5084e3761386fee6921011229a179ce2cae52c532baba7a5a31ac5587b9c0ed639a9819d73cd165210e8aea55740e7b6ba0a
|
7
|
+
data.tar.gz: b155ad5382a1abe5dd1cfc8f952f17a058fa63dff690c7cfad22bd1a89bbb188107a2d5f60a178a606bea66b87583ed4d45fcff34e0026d27b20d32d0686edc4
|
data/Gemfile.lock
CHANGED
@@ -28,7 +28,7 @@ module DLDInternet
|
|
28
28
|
if @columns
|
29
29
|
@columns = Hashie::Mash.new(Hash[@columns.split(/\s*,\s*/).map{ |c| [c, nil]}])
|
30
30
|
@columns.dup.map{ |h,v|
|
31
|
-
submap(h, v)
|
31
|
+
submap!(h, v)
|
32
32
|
}
|
33
33
|
@object = columnize_item(@object)
|
34
34
|
end
|
@@ -253,7 +253,7 @@ module DLDInternet
|
|
253
253
|
columnize_item(obj)
|
254
254
|
}
|
255
255
|
else
|
256
|
-
itm = ::Hashie::Mash.new
|
256
|
+
itm = {} # ::Hashie::Mash.new
|
257
257
|
@columns.map {|k, _|
|
258
258
|
itm[k] = item[k]
|
259
259
|
}
|
@@ -261,13 +261,13 @@ module DLDInternet
|
|
261
261
|
itm
|
262
262
|
end
|
263
263
|
|
264
|
-
def submap(col, val, sub=nil)
|
264
|
+
def submap!(col, val, sub=nil)
|
265
265
|
sub ||= @columns
|
266
266
|
m = col.match(/^([^.]+)\.(.*)$/)
|
267
267
|
if m
|
268
268
|
val = sub[m[1]]
|
269
|
-
val ||= Hashie::Mash.new
|
270
|
-
submap(m[2], val, val)
|
269
|
+
val ||= {} # Hashie::Mash.new
|
270
|
+
submap!(m[2], val, val)
|
271
271
|
sub[m[1]] = val
|
272
272
|
sub.delete(col)
|
273
273
|
else
|
@@ -348,20 +348,37 @@ module DLDInternet
|
|
348
348
|
val.map {|v|
|
349
349
|
subvalues(k, v[k], sub[key])
|
350
350
|
}
|
351
|
+
else
|
352
|
+
raise "Not catering for #{val.class.name}"
|
351
353
|
end
|
352
354
|
}
|
353
355
|
elsif sk.is_a?(Array)
|
354
|
-
sk.map {|v|
|
356
|
+
fsk = sk.map {|v|
|
355
357
|
h = @columns.nil? ? v : @columns[key]
|
356
|
-
h.keys.map { |k|
|
358
|
+
fv = h ? h.keys.map { |k|
|
357
359
|
subvalues(k, v[k], v)
|
358
|
-
}
|
359
|
-
|
360
|
+
} : v
|
361
|
+
fv = simple_value(fv)
|
362
|
+
fv
|
363
|
+
}.flatten
|
364
|
+
fsk
|
360
365
|
else
|
361
366
|
val
|
362
367
|
end
|
363
368
|
end
|
364
369
|
|
370
|
+
def simple_value(fv)
|
371
|
+
if fv.is_a?(Hash)
|
372
|
+
fv.to_hash
|
373
|
+
elsif fv.is_a?(Array)
|
374
|
+
fv.map{ |v| simple_value(v) }
|
375
|
+
elsif fv.is_a?(String)
|
376
|
+
fv
|
377
|
+
else
|
378
|
+
raise "Not catering for #{fv.class.name}"
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
365
382
|
def subkeys(key, sub=nil)
|
366
383
|
sub ||= @columns
|
367
384
|
if sub && sub[key]
|
@@ -42,15 +42,17 @@ class FalseClass
|
|
42
42
|
end
|
43
43
|
|
44
44
|
module DLDInternet
|
45
|
+
|
46
|
+
class SilentMash < ::Hashie::Mash
|
47
|
+
def initialize(source_hash = nil, default = nil, &blk)
|
48
|
+
self.class.disable_warnings
|
49
|
+
super
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
45
53
|
module Thor
|
46
54
|
LOG_LEVELS = [:trace, :debug, :info, :note, :warn, :error, :fatal, :todo]
|
47
55
|
|
48
|
-
class SilentMash < ::Hashie::Mash
|
49
|
-
def initialize(source_hash = nil, default = nil, &blk)
|
50
|
-
self.class.disable_warnings
|
51
|
-
super
|
52
|
-
end
|
53
|
-
end
|
54
56
|
class OptionsMash < SilentMash ; end
|
55
57
|
class ConfigMash < SilentMash ; end
|
56
58
|
|
@@ -289,6 +291,8 @@ module DLDInternet
|
|
289
291
|
when :none
|
290
292
|
# when :basic
|
291
293
|
when :text
|
294
|
+
when :plain
|
295
|
+
when :none
|
292
296
|
# noop
|
293
297
|
when :awesome
|
294
298
|
format_helper = DLDInternet::Formatters::Awesome.new(obj, notation, title: opts[:title], columns: opts[:columns])
|
@@ -319,15 +323,20 @@ module DLDInternet
|
|
319
323
|
end
|
320
324
|
if robj.nil?
|
321
325
|
robj
|
322
|
-
elsif robj.respond_to?(:to_hash)
|
323
|
-
robj.to_hash
|
324
|
-
elsif robj.respond_to?(:to_a)
|
325
|
-
robj.to_a.map { |obj| hash_it(obj) }
|
326
326
|
elsif repre
|
327
327
|
representation = repre.new(robj)
|
328
328
|
representation.to_hash
|
329
|
-
elsif robj.
|
330
|
-
robj.
|
329
|
+
elsif robj.is_a?(Hash)
|
330
|
+
robj = if robj.respond_to?(:to_hash)
|
331
|
+
robj.to_hash
|
332
|
+
elsif robj.respond_to?(:to_h)
|
333
|
+
robj.to_h
|
334
|
+
else
|
335
|
+
raise "How to hash #{robj.ai}"
|
336
|
+
end
|
337
|
+
Hash[robj.map{ |k,v| [k,hash_it(v)] }]
|
338
|
+
elsif robj.is_a?(Array)
|
339
|
+
robj.to_a.map { |obj| hash_it(obj) }
|
331
340
|
else
|
332
341
|
robj
|
333
342
|
end
|
@@ -440,7 +449,9 @@ module DLDInternet
|
|
440
449
|
options[:cassette] = @_invocations.map{ |_,v| v[0]}.join('-')
|
441
450
|
options[:cassette_not_given] = true
|
442
451
|
end
|
443
|
-
|
452
|
+
options[:cassette_options] ||= {}
|
453
|
+
::VCR::Cassette.logger ||= logger
|
454
|
+
@cassette = ::VCR.insert_cassette(opts[:cassette] || options[:cassette], options[:cassette_options])
|
444
455
|
end
|
445
456
|
yield if block_given?
|
446
457
|
end
|
data/lib/dldinternet/thor/vcr.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'vcr'
|
2
2
|
require 'dldinternet/thor/vcr/logger'
|
3
3
|
|
4
|
+
require 'vcr/cassette/http_interaction_list'
|
5
|
+
require 'vcr/cassette/erb_renderer'
|
6
|
+
require 'vcr/cassette/serializers'
|
7
|
+
|
4
8
|
|
5
9
|
module VCR
|
6
10
|
class Configuration
|
@@ -8,13 +12,26 @@ module VCR
|
|
8
12
|
attr_accessor :logger
|
9
13
|
|
10
14
|
end
|
11
|
-
end
|
12
15
|
|
13
|
-
module VCR
|
14
16
|
# The media VCR uses to store HTTP interactions for later re-use.
|
15
17
|
class Cassette
|
16
|
-
|
18
|
+
class << self
|
19
|
+
attr_accessor :logger
|
20
|
+
end
|
17
21
|
attr_reader :options
|
18
22
|
|
23
|
+
def raw_cassette_bytes
|
24
|
+
unless @raw_cassette_bytes
|
25
|
+
path = @persister.absolute_path_to_file(storage_key)
|
26
|
+
if File.exist?(path)
|
27
|
+
# Log as info ONE time
|
28
|
+
VCR::Cassette.logger ? VCR::Cassette.logger.info( "Loading cassette '#{@name}' ...") : log( "Loading cassette ...")
|
29
|
+
else
|
30
|
+
# Log as debug on every request
|
31
|
+
VCR::Cassette.logger ? VCR::Cassette.logger.debug( "Cassette '#{@name}' not found!") : log( "Cassette not found ...")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
@raw_cassette_bytes ||= VCR::Cassette::ERBRenderer.new(@persister[storage_key], erb, name).render
|
35
|
+
end
|
19
36
|
end
|
20
37
|
end
|
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.9.
|
4
|
+
version: 0.9.10
|
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:
|
11
|
+
date: 2018-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|