csv_to_gsheet 0.0.1 → 0.0.2
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 +4 -4
- data/lib/csv_to_gsheet.rb +18 -0
- 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: 44edc451f3006b6118fa8724f1db59ee411e98977df58a75d94d310fea1b3ba2
|
4
|
+
data.tar.gz: bbcdced331263be4d54faddf235e018dd0f93d092e7c53120df18340d47e2d6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18577284c1ba5549bc7d343ca28b8767aa2bf25baeed83910bf988a8fe90363d4bccaaaccb078ff7f196ca7bfb90420b8ca2e97f291d8ee977452a98057caab4
|
7
|
+
data.tar.gz: 85a7bef5ad32a371b95968f583da94bc19d8f304b0b465832f16dd4e4026ea9f75bd93ebdfc68ce8dc926408357152002be024a191818b5935cc4b7258aee261
|
data/lib/csv_to_gsheet.rb
CHANGED
@@ -32,6 +32,11 @@ module CsvToGsheet
|
|
32
32
|
# See https://stackoverflow.com/questions/2166862/why-is-gets-throwing-an-error-when-arguments-are-passed-to-my-ruby-script
|
33
33
|
ARGV.clear
|
34
34
|
|
35
|
+
# Check files to see if they exist and if they don't then tell the user what to do
|
36
|
+
#
|
37
|
+
# This exits the program early if the credentials.json-equivalent file is not present.
|
38
|
+
CsvToGsheet.check_token_files
|
39
|
+
|
35
40
|
# Initialize the API
|
36
41
|
service = Google::Apis::SheetsV4::SheetsService.new
|
37
42
|
service.client_options.application_name = APPLICATION_NAME
|
@@ -117,6 +122,19 @@ module CsvToGsheet
|
|
117
122
|
end
|
118
123
|
end
|
119
124
|
|
125
|
+
def self.check_token_files
|
126
|
+
if !File.exists? CREDENTIALS_PATH
|
127
|
+
puts "No credentials.json equivalent file for your OAuth2 app exists at #{CREDENTIALS_PATH}"
|
128
|
+
puts ""
|
129
|
+
puts "Download your credentials.json file from https://developers.google.com/identity/sign-in/web/sign-in"
|
130
|
+
puts ""
|
131
|
+
puts "Move that credentials.json file to #{CREDENTIALS_PATH}"
|
132
|
+
puts ""
|
133
|
+
puts "Exiting now without connecting to Google's API"
|
134
|
+
exit 1
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
120
138
|
##
|
121
139
|
# Ensure valid credentials, either by restoring from the saved credentials
|
122
140
|
# files or intitiating an OAuth2 authorization. If authorization is required,
|