googlesheets 0.1.0 → 0.2.0

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: 8943510443e9c7f239448ca1f51f24aef69623a55943cccd9cca909ed898fc0a
4
- data.tar.gz: 1af91f45355e465b6576c722a5fbc9a1cd2371dbd6706d76dd61a019c4e933e7
3
+ metadata.gz: bf746361c54702e6e6045cc2f50709116f5f03605d7e7031501fc328211a158a
4
+ data.tar.gz: 7d619e57b7c3795c45db5f6105f9ba5ffd12840f329e4d53f740da98b3f7f7ff
5
5
  SHA512:
6
- metadata.gz: 6d149d61718cf93b2a4e8c373a4cbe30b9f462591b1a603a26a5a455cc14ea03742f65125b9ca61ef5d83213530f958304c69eb501a2f1c00ab17912156b8a8a
7
- data.tar.gz: a3d4744b72f90b29bbc7c9fa85c27f81b7f5bb0c4e317f454d48ab856d9cba83af8be5f533ea550f7f2c55f1a43bc8af7ec6f51c016c0e7dc953c0de58b92132
6
+ metadata.gz: 439768572b8ee44f0effce13a375c03ece7a65e4df406dbb2ddcff705b1dcf5b9933ef0f1d7bc118bad548b0d3181816ee0d2f87698993099146fb1862bb1b0a
7
+ data.tar.gz: 8601bc53985319b1e087dd00ee3f32ca7a8c8022e30813ea6131bbe9dc3d4ffb89ea33ae52b4b995811ad6e7586cd3d7db674f75ffb62e3405c55d590c4ac4aa
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
1
  # googlesheets
2
2
 
3
3
  Ruby gem for Google Sheets API
4
+
5
+ ### NOTE: gem install google-api-client
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "googlesheets"
5
- s.version = "0.1.0"
5
+ s.version = "0.2.0"
6
6
  s.author = "Steve Shreeve"
7
7
  s.email = "steve.shreeve@gmail.com"
8
8
  s.summary = "Ruby gem for Google Sheets"
@@ -70,6 +70,19 @@ class GoogleSheets
70
70
  end
71
71
  end
72
72
 
73
+ def filter_criteria(hash)
74
+ hash.inject({}) do |h, (k,v)|
75
+ l = Array(v)
76
+ h[biject(k.to_s) - 1] = {
77
+ condition: {
78
+ type: "TEXT_EQ",
79
+ values: l.map {|e| { user_entered_value: e} },
80
+ }
81
+ }
82
+ h
83
+ end
84
+ end
85
+
73
86
  def range(area)
74
87
  sh, rc = area.split('!', 2); rc, sh = sh, nil if sh.nil?
75
88
  as, ae = rc.split(':', 2); ae ||= as
@@ -132,11 +145,12 @@ class GoogleSheets
132
145
  true
133
146
  end
134
147
 
135
- def sheet_filter(area)
148
+ def sheet_filter(area, want=nil)
136
149
  range = range(area)
150
+ criteria = filter_criteria(want) if want
137
151
  reqs = []
138
152
  reqs.push(clear_basic_filter: { sheet_id: range[:sheet_id] })
139
- reqs.push(set_basic_filter: { filter: { range: range } })
153
+ reqs.push(set_basic_filter: { filter: { range: range, criteria: criteria}.compact })
140
154
  resp = api.batch_update_spreadsheet(@ssid, { requests: reqs }, {})
141
155
  true
142
156
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: googlesheets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Shreeve
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-10 00:00:00.000000000 Z
11
+ date: 2020-09-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This gem allows easy access to Google Sheets API V4.
14
14
  email: steve.shreeve@gmail.com
@@ -26,7 +26,7 @@ homepage: https://github.com/shreeve/googlesheets
26
26
  licenses:
27
27
  - MIT
28
28
  metadata: {}
29
- post_install_message:
29
+ post_install_message:
30
30
  rdoc_options: []
31
31
  require_paths:
32
32
  - lib
@@ -41,8 +41,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
41
  - !ruby/object:Gem::Version
42
42
  version: '0'
43
43
  requirements: []
44
- rubygems_version: 3.1.2
45
- signing_key:
44
+ rubygems_version: 3.1.4
45
+ signing_key:
46
46
  specification_version: 4
47
47
  summary: Ruby gem for Google Sheets
48
48
  test_files: []