meer 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/meer/cli.rb +16 -1
  3. data/lib/meer/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e62dab0fd5d4a9a6a34e93968661a539d69fc8c
4
- data.tar.gz: 55650f992f5e311db2e99c6a52e361c05f59039c
3
+ metadata.gz: 74a7b94baf63c2ed8889a76af69ad39639806cd5
4
+ data.tar.gz: 153b800d8157f3c1791b6bef700179cbcee96430
5
5
  SHA512:
6
- metadata.gz: b736bc3ff843a59fb4f365a012838a93056ea58d7dbdf92501a7a9a555657d3ab4fc999a6af97a79218397ff0772c32b6e0bb7e427653e674a34e68646144dc2
7
- data.tar.gz: e90df007ba9f46adedf3bd090fa7cd86a549b95bd7e263d3d8444dfab280900b2677c63d72348f5af0d034437ab8a7e6c34389d911e5d3a3651a2db8ab5d540d
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, type: :string
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
@@ -1,3 +1,3 @@
1
1
  module Meer
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - philip.monroe