bps-google-api 0.2.2 → 0.2.3
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/Gemfile.lock +1 -1
- data/bps-google-api.gemspec +1 -1
- data/lib/google_api.rb +2 -0
- data/lib/google_api/base.rb +0 -8
- data/lib/google_api/base/authorization.rb +2 -2
- data/lib/google_api/calendar.rb +2 -0
- data/lib/google_api/calendar/clear_test_calendar.rb +3 -4
- data/spec/lib/google_api/base_spec.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e31fcc3561f54e4e1c81770287c13ba26a226911
|
4
|
+
data.tar.gz: 10dc3a67b664fe45a43f1a968bc25135a1f29f1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb9060833604e6ba41e77968cd4ebec2f07f08c773bdc7f9298b4731b030b52c69b393d84282d152490a3446ae11e952463df937a355050f50ce1f5308ab5d46
|
7
|
+
data.tar.gz: fab01b55b6e722e5d64a7449f3db89d6f89947f4a7bc5e2fc68556b650940af2100e8655d75e17c25179c1a9646987437544fa69a45dff501abf4268838613e0
|
data/Gemfile.lock
CHANGED
data/bps-google-api.gemspec
CHANGED
data/lib/google_api.rb
CHANGED
data/lib/google_api/base.rb
CHANGED
@@ -30,13 +30,5 @@ module GoogleAPI
|
|
30
30
|
def call(method, *args)
|
31
31
|
ExpRetry.for(exception: RETRIES) { service.send(method, *args) }
|
32
32
|
end
|
33
|
-
|
34
|
-
def root_path
|
35
|
-
defined?(Rails) ? Rails.root : '.'
|
36
|
-
end
|
37
|
-
|
38
|
-
def last_token_path
|
39
|
-
File.join(root_path, 'tmp', 'run', 'last_page_token')
|
40
|
-
end
|
41
33
|
end
|
42
34
|
end
|
@@ -81,7 +81,7 @@ module GoogleAPI
|
|
81
81
|
|
82
82
|
def client_id_file
|
83
83
|
store_key(
|
84
|
-
File.join(
|
84
|
+
File.join(GoogleAPI::ROOT_PATH, 'config/keys/google_api_client.json'),
|
85
85
|
<<~KEY
|
86
86
|
{"installed":{"client_id":"#{ENV['GOOGLE_CLIENT_ID']}","project_id":"charming-scarab-208718",
|
87
87
|
"auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token",
|
@@ -93,7 +93,7 @@ module GoogleAPI
|
|
93
93
|
|
94
94
|
def token_file
|
95
95
|
store_key(
|
96
|
-
File.join(
|
96
|
+
File.join(GoogleAPI::ROOT_PATH, 'config/keys/google_token.yaml'),
|
97
97
|
<<~KEY
|
98
98
|
---
|
99
99
|
default: '{"client_id":"#{ENV['GOOGLE_CLIENT_ID']}","access_token":"#{ENV['GOOGLE_ACCESS_TOKEN']}",
|
data/lib/google_api/calendar.rb
CHANGED
@@ -4,6 +4,8 @@ module GoogleAPI
|
|
4
4
|
require 'google_api/calendar/clear_test_calendar'
|
5
5
|
|
6
6
|
class Calendar < GoogleAPI::Base
|
7
|
+
LAST_TOKEN_PATH ||= File.join(ROOT_PATH, 'tmp', 'run', 'last_page_token')
|
8
|
+
|
7
9
|
include GoogleAPI::Calendar::ClearTestCalendar
|
8
10
|
|
9
11
|
SERVICE_CLASS = Google::Apis::CalendarV3::CalendarService
|
@@ -20,8 +20,7 @@ module GoogleAPI
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def choose_page_token(page_token)
|
23
|
-
|
24
|
-
@page_token ||= File.read(last_token) if File.exist?(last_token)
|
23
|
+
@page_token ||= File.read(LAST_TOKEN_PATH) if File.exist?(LAST_TOKEN_PATH)
|
25
24
|
@page_token = page_token if token?(page_token)
|
26
25
|
end
|
27
26
|
|
@@ -55,8 +54,8 @@ module GoogleAPI
|
|
55
54
|
|
56
55
|
def log_last_page_token
|
57
56
|
puts "\n\n*** Last page token cleared: #{@page_token}" if @verbose
|
58
|
-
File.open(
|
59
|
-
puts "\n*** Token stored in #{
|
57
|
+
File.open(LAST_TOKEN_PATH, 'w+') { |f| f.write(@page_token) }
|
58
|
+
puts "\n*** Token stored in #{LAST_TOKEN_PATH}" if @verbose
|
60
59
|
end
|
61
60
|
|
62
61
|
def progress_bar(total)
|
@@ -15,7 +15,7 @@ RSpec.describe GoogleAPI::Base do
|
|
15
15
|
subject { GoogleAPI::Calendar }
|
16
16
|
|
17
17
|
it 'returns the correct last token path' do
|
18
|
-
expect(
|
18
|
+
expect(GoogleAPI::Calendar::LAST_TOKEN_PATH).to eql('./tmp/run/last_page_token')
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'returns an array from authorize with reveal' do
|