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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1add57b55260f495931de9280559b27e74c627adb2abd3f6ac5656f775f20f91
4
- data.tar.gz: 5472e7f295a06fb352dd3a2f9992126601efc0c9a1808be215752dd853a80039
3
+ metadata.gz: 417b013d1a277bbb0f15622d80475dd2371a306323156ef46a60b9730fefc159
4
+ data.tar.gz: eaa6ed298f737c3fa29b59b04f783b3278f4c3731f00fefc40cb39820505fd05
5
5
  SHA512:
6
- metadata.gz: ea605bf8b9b63af92224e246e56859ee4e6afd3ff831a89b4ed75c252934b5d2b3b236a9f8f04a78fc24dca2d4c0449ca4877d5b6a6cd1f1b30c74de74453484
7
- data.tar.gz: 4904b769e06cae1b6ec971ac7f83157777d0ca9a1d0cbbabfeb4e9b259569827487653642c6cebf5fb63984d631065bc96d892a4850057365e89d7254f7b0fa4
6
+ metadata.gz: 31d6d7d1fbec05153cd86db80c7556b9de2e774d10b0cbea10d8403fead584a6f47eb21b0d78d5424c6b219bf4d8950ec9c446bb3e9bab879715ef9f9a55557c
7
+ data.tar.gz: e813f21a9aef2ea51d88536ebfa4286e62fcbc6a0fe78e64fb23dc33c3877ea762d2260f022638dee4b57919daeab77f520f37ade199d060ec969c023ba3ac53
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gazer (0.2.39)
4
+ gazer (0.2.40)
5
5
  looker-sdk (~> 0.0.7)
6
6
  netrc (~> 0.11.0)
7
7
  pastel (~> 0.7.2)
@@ -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, @options[:fields])
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] = field_names(@options[:fields]) unless @options[:plain]
61
- rows = []
62
- data.each do |r|
63
- h = r.to_attrs
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
- table_hash[:rows] = rows
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
@@ -20,5 +20,5 @@
20
20
  # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  module Gzr
23
- VERSION = "0.2.39"
23
+ VERSION = "0.2.40"
24
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gazer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.39
4
+ version: 0.2.40
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike DeAngelo