fpl_gsheet 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21c9e082024e848d7bce1cde916dd2af099188aa29c7088961dfea2bfb7a8c88
4
- data.tar.gz: '038a7049bf9d921b6c80940fbf2ae96ec4bfafc54233e6c221117ca0d0fb5f6c'
3
+ metadata.gz: 5a5d79b3377e97f1b0c3198b7fa038fc9a262b437b40578d8c9c91fbd298d94d
4
+ data.tar.gz: c2983a1426ae814e4e14955572f2d93308151053b4503f7917c284b1b4bba889
5
5
  SHA512:
6
- metadata.gz: 9eafec5afc91026d2764bccf6f77f2ee579f1823a69abccd36d86972a20ec99a4baac43e7855a65ae0818c94406169b7c10f288bfc13328ecc060e9fa6108ce5
7
- data.tar.gz: 107fa3ab205e4c7a0b72d1d8c1b32cd9fa582ad40a6a4b8395bdf217a15efbb81d65ebdeaef12fdaa763a4a91c80c7873f98942e36b9655048ea09f563b589a8
6
+ metadata.gz: b46c906c4f20a2c32e582b9e785aeb0e921e4bda110351a18983c55721d2c749d9a9bd47bc9dc7224c31bbb464e71e06b71f7c3b916f02c2ca90cb8c5da644f1
7
+ data.tar.gz: b650817dda488fa0f0a624ed512b85a13b5f44c0ee8638d2934b77288b8380b554f5848ecb477a30d08236b46520536731d874c44483b4c2849f70ba34c020b9
@@ -10,7 +10,12 @@ module FplGsheet
10
10
 
11
11
  def initialize(spreadsheet_title)
12
12
  # Authenticate a session with your Service Account
13
- session = GoogleDrive::Session.from_service_account_key("client_secret.json")
13
+ if File.file?("client_secret.json")
14
+ session = GoogleDrive::Session.from_service_account_key("client_secret.json")
15
+ else
16
+ credentials = StringIO.new(ENV['GOOGLE_CLIENT_SECRET'])
17
+ session = GoogleDrive::Session.from_service_account_key(credentials)
18
+ end
14
19
 
15
20
  # Get the spreadsheet by its title
16
21
  @spreadsheet = session.spreadsheet_by_title(spreadsheet_title)
@@ -18,7 +23,7 @@ module FplGsheet
18
23
  @max_row = @worksheet.num_rows
19
24
  @rows_to_add = Array.new
20
25
  end
21
-
26
+
22
27
  def new_sheet(sheet_name)
23
28
  doomed_ws = @spreadsheet.worksheet_by_title(sheet_name)
24
29
  doomed_ws.delete if !doomed_ws.nil?
@@ -26,22 +31,22 @@ module FplGsheet
26
31
  @max_row = 1
27
32
  save
28
33
  end
29
-
34
+
30
35
  def insert_new_row(row_data)
31
36
  @rows_to_add << row_data
32
37
  end
33
-
38
+
34
39
  def insert_new_rows(row_data) # assumes array of arrays
35
40
  @rows_to_add += row_data
36
41
  end
37
-
42
+
38
43
  def save
39
44
  @worksheet.insert_rows(@max_row +1, @rows_to_add) if !@rows_to_add.empty?
40
45
  @worksheet.save
41
46
  @rows_to_add.clear # empty the array
42
47
  @max_row = @worksheet.num_rows
43
48
  end
44
-
49
+
45
50
  def all_rows
46
51
  @worksheet.rows
47
52
  end
@@ -1,3 +1,3 @@
1
1
  module FplGsheet
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fpl_gsheet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - reedstonefood
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-09 00:00:00.000000000 Z
11
+ date: 2020-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler