googlesheets 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/googlesheets.rb +7 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 484ead7c7ddf83bd062e24d8edb28fb0da072cbbe348f598974c7dcc6fc81687
4
- data.tar.gz: 224d0e6b86d115a4b9aff60faba79a174686f65f551dff9322bb8ff22d0445ce
3
+ metadata.gz: 0aefe530c8bfd81c39a9117a0ae9fd698070e2886961c74e2c80a0ddb21aefeb
4
+ data.tar.gz: e623d3db0855c721127f56a463b79b4d2eb68d51e88d4ba8bce49da8c440a459
5
5
  SHA512:
6
- metadata.gz: 38d00ab0cd8ac505238f604542e0f56f814d397cdf8d606c0a64cba8bf022afcd58173cf5af5e23cbf38590b18c49bc849001c231c23b509aee8b384a62b4580
7
- data.tar.gz: a34dc14942dd9433331221804a95f940104a58b08c2830e1a6866c046db9b35c9ec220c91fd9c26aedc8b98b54a96274d007f045f0434c3db10fcf804543f670
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.0"
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[/(?<=#gid=)(\d+)$/] && $1.to_i # default worksheet id
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 || "#1"
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
- "#{wsid}!#{rect || 'A:ZZ'}"
161
+ rect = rect ? rect.sub(/(?<=\D):/, "1:") : @rect
162
+ "#{wsid}!#{rect}"
161
163
  end
162
164
 
163
165
  def sheet_rename(pick, name=nil)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: googlesheets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Shreeve