googlesheets 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/googlesheets.rb +7 -5
- 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: 0aefe530c8bfd81c39a9117a0ae9fd698070e2886961c74e2c80a0ddb21aefeb
|
4
|
+
data.tar.gz: e623d3db0855c721127f56a463b79b4d2eb68d51e88d4ba8bce49da8c440a459
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 130fed8b81b90818069b02343ebf919f8aaa0ca90a33a0278552287e65e2c410cf583c969498fe6e4cb73fd884eb9e1ec69a43b4b263badba17bd47d0d11a7d3
|
7
|
+
data.tar.gz: 0cc8e0f830615ca7708800900e0bfbc8307f7032f21740a961bc1047d6fd9aa10f43b5bbdf9e5684984b90b2a3ca5f84df825f61afb7ba02e3a92b1e130d5529
|
data/lib/googlesheets.rb
CHANGED
@@ -18,13 +18,14 @@ end
|
|
18
18
|
# https://googleapis.dev/ruby/google-api-client/latest/Google/Apis/SheetsV4/Request.html
|
19
19
|
|
20
20
|
class GoogleSheets
|
21
|
-
VERSION = "0.5.
|
21
|
+
VERSION = "0.5.1"
|
22
22
|
|
23
23
|
attr_accessor :api
|
24
24
|
|
25
25
|
def initialize(ssid, **opts)
|
26
26
|
@ssid = ssid =~ /^https?:/ ? ssid.split("/")[5] : ssid # spreadsheet id
|
27
|
-
@wsid = ssid
|
27
|
+
@wsid = ssid =~ /(?<=#gid=)(\d+)(?:!([a-z\d:]+))?$/i ? $1.to_i : "#1" # worksheet id
|
28
|
+
@rect = $2 ? $2.sub(/(?<=\D):/, "1:") : "A:ZZ"
|
28
29
|
|
29
30
|
@json = opts[:credentials] || "credentials.json"
|
30
31
|
@yaml = opts[:token ] || "token.yaml"
|
@@ -137,10 +138,10 @@ class GoogleSheets
|
|
137
138
|
end
|
138
139
|
|
139
140
|
def sheet_name(obj=nil)
|
140
|
-
case obj ||= @wsid
|
141
|
+
case obj ||= @wsid
|
141
142
|
when /^#(\d+)$/ then sheets[$1.to_i - 1].title
|
143
|
+
when "", 0, nil then sheets.first.title
|
142
144
|
when Integer then sheets.first_result {|item| item.title if item.sheet_id == obj }
|
143
|
-
when "", nil then sheets.first.title
|
144
145
|
else obj
|
145
146
|
end
|
146
147
|
end
|
@@ -157,7 +158,8 @@ class GoogleSheets
|
|
157
158
|
else
|
158
159
|
wsid = sheet_name(area)
|
159
160
|
end
|
160
|
-
|
161
|
+
rect = rect ? rect.sub(/(?<=\D):/, "1:") : @rect
|
162
|
+
"#{wsid}!#{rect}"
|
161
163
|
end
|
162
164
|
|
163
165
|
def sheet_rename(pick, name=nil)
|