gazer 0.2.39 → 0.2.40
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/gzr/commands/space/ls.rb +37 -22
- data/lib/gzr/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 417b013d1a277bbb0f15622d80475dd2371a306323156ef46a60b9730fefc159
|
4
|
+
data.tar.gz: eaa6ed298f737c3fa29b59b04f783b3278f4c3731f00fefc40cb39820505fd05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31d6d7d1fbec05153cd86db80c7556b9de2e774d10b0cbea10d8403fead584a6f47eb21b0d78d5424c6b219bf4d8950ec9c446bb3e9bab879715ef9f9a55557c
|
7
|
+
data.tar.gz: e813f21a9aef2ea51d88536ebfa4286e62fcbc6a0fe78e64fb23dc33c3877ea762d2260f022638dee4b57919daeab77f520f37ade199d060ec969c023ba3ac53
|
data/Gemfile.lock
CHANGED
@@ -36,6 +36,28 @@ module Gzr
|
|
36
36
|
@options = options
|
37
37
|
end
|
38
38
|
|
39
|
+
def flatten_data(raw_array)
|
40
|
+
rows = raw_array.map do |entry|
|
41
|
+
entry.select do |k,v|
|
42
|
+
!(v.kind_of?(Array) || v.kind_of?(Hash))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
raw_array.map do |entry|
|
46
|
+
entry.select do |k,v|
|
47
|
+
v.kind_of? Array
|
48
|
+
end.each do |section,section_value|
|
49
|
+
section_value.each do |section_entry|
|
50
|
+
h = {}
|
51
|
+
section_entry.each_pair do |k,v|
|
52
|
+
h[:"#{section}.#{k}"] = v
|
53
|
+
end
|
54
|
+
rows.push(h)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
rows
|
59
|
+
end
|
60
|
+
|
39
61
|
def execute(input: $stdin, output: $stdout)
|
40
62
|
say_warning("options: #{@options.inspect}") if @options[:debug]
|
41
63
|
with_session do
|
@@ -45,40 +67,33 @@ module Gzr
|
|
45
67
|
return nil
|
46
68
|
end unless space_ids && space_ids.length > 0
|
47
69
|
|
70
|
+
@options[:fields] = 'dashboards(id,title)' if @filter_spec == 'lookml'
|
71
|
+
f = @options[:fields]
|
72
|
+
|
48
73
|
data = space_ids.map do |space_id|
|
49
|
-
query_space(space_id,
|
74
|
+
query_space(space_id, f).to_attrs
|
50
75
|
end.compact
|
76
|
+
space_ids.each do |space_id|
|
77
|
+
query_space_children(space_id, 'id,name,parent_id').map {|child| child.to_attrs}.each do |child|
|
78
|
+
data.push child
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
51
82
|
|
52
83
|
begin
|
53
84
|
puts "No data returned for spaces #{space_ids.inspect}"
|
54
85
|
return nil
|
55
86
|
end unless data && data.length > 0
|
56
87
|
|
57
|
-
@options[:fields] = 'dashboards(id,title)' if @filter_spec == 'lookml'
|
58
88
|
table_hash = Hash.new
|
59
89
|
fields = field_names(@options[:fields])
|
60
|
-
table_hash[:header] =
|
61
|
-
rows =
|
62
|
-
|
63
|
-
|
64
|
-
if @filter_spec != 'lookml' then
|
65
|
-
rows << [h[:parent_id],h[:id],h[:name], nil, nil, nil, nil]
|
66
|
-
subspaces = query_space_children(h[:id], "id,name,parent_id")
|
67
|
-
rows += subspaces.map do |r|
|
68
|
-
h1 = r.to_attrs
|
69
|
-
[h1[:parent_id], h1[:id], h1[:name], nil, nil, nil, nil]
|
70
|
-
end
|
90
|
+
table_hash[:header] = fields unless @options[:plain]
|
91
|
+
table_hash[:rows] = flatten_data(data).map do |row|
|
92
|
+
fields.collect do |e|
|
93
|
+
row.fetch(e.to_sym,nil)
|
71
94
|
end
|
72
|
-
h[:looks].each do |r|
|
73
|
-
rows << [h[:parent_id],h[:id],h[:name], r[:id], r[:title], nil, nil]
|
74
|
-
end if h[:looks]
|
75
|
-
h[:dashboards].each do |r|
|
76
|
-
rows << [h[:parent_id],h[:id],h[:name], nil, nil, r[:id], r[:title]] unless @filter_spec == 'lookml'
|
77
|
-
rows << [r[:id], r[:title]] if @filter_spec == 'lookml'
|
78
|
-
end if h[:dashboards]
|
79
95
|
end
|
80
|
-
|
81
|
-
table = TTY::Table.new(table_hash) if data[0]
|
96
|
+
table = TTY::Table.new(table_hash)
|
82
97
|
alignments = fields.collect do |k|
|
83
98
|
(k =~ /id\)*$/) ? :right : :left
|
84
99
|
end
|
data/lib/gzr/version.rb
CHANGED