meer 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/meer/cli.rb +16 -1
- data/lib/meer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74a7b94baf63c2ed8889a76af69ad39639806cd5
|
4
|
+
data.tar.gz: 153b800d8157f3c1791b6bef700179cbcee96430
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca38c0d7262817d04f2ee2e3e212a9d8abfe8ca5aba6b388ef832b74719a36ad56927b872e5f3c05cb9bd340060fca43d9441efb384c7820cc6631a9dd3324a1
|
7
|
+
data.tar.gz: 84f87d38740de815c5e25e5db9f24883a68835d6b7d78ee0102d3822b83b06bc3d88c446d78e320beccf561ef37475022a22e42be52750de45f07c2e0b85933b
|
data/lib/meer/cli.rb
CHANGED
@@ -32,11 +32,13 @@ module Meer
|
|
32
32
|
end
|
33
33
|
|
34
34
|
desc "table [WORKBOOK-ID] [SHEET_NAME]", "Outputs a nicely formatted table for a given workbook"
|
35
|
-
option :sort,
|
35
|
+
option :sort, type: :string
|
36
|
+
option :filter, type: :string
|
36
37
|
def table(workbook, sheet)
|
37
38
|
data = client.workbook_data(workbook, sheet)
|
38
39
|
rows = CSV.parse(data, :headers => true).to_a
|
39
40
|
headers = rows.slice!(0)
|
41
|
+
filter!(headers, rows, options[:filter]) if options[:filter]
|
40
42
|
sort!(headers, rows, options[:sort]) if options[:sort]
|
41
43
|
|
42
44
|
puts Terminal::Table.new(headings: headers, rows: rows)
|
@@ -49,6 +51,19 @@ module Meer
|
|
49
51
|
@client = Datameer.new ENV['DATAMEER_URL'], user, password
|
50
52
|
end
|
51
53
|
|
54
|
+
def filter! headers, rows, filter_str
|
55
|
+
cols = filter_str.split(',').map do |name|
|
56
|
+
name, q = name.split('=')
|
57
|
+
col = headers.find_index(name)
|
58
|
+
OpenStruct.new(col: col, query: q)
|
59
|
+
end
|
60
|
+
|
61
|
+
rows.select! do |row|
|
62
|
+
cols.map{|c| row[c.col].to_s == c.query}.all?
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
|
52
67
|
def sort! headers, rows, sort_str
|
53
68
|
cols = sort_str.split(',').map do |name|
|
54
69
|
reverse = name[-1] == '-'
|
data/lib/meer/version.rb
CHANGED