bps-google-api 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 899cc313e6b5e72312c23bde1a9d16f129baced9
4
- data.tar.gz: b70921ec7472e2e187194c4ee33483ab90929bb4
3
+ metadata.gz: e31fcc3561f54e4e1c81770287c13ba26a226911
4
+ data.tar.gz: 10dc3a67b664fe45a43f1a968bc25135a1f29f1a
5
5
  SHA512:
6
- metadata.gz: e7f4b5b46818a23efa0d897369288dda6610463565b4b6950c4b468fc2de1885a066a6f882e6554ea68b2ed7bc0b3f9671aa10f648db605c352dd4d81010e292
7
- data.tar.gz: 58e69aa261ddd94beafd4880dcca17b5e969f19eaf9c8a097b56138527659a8a8b3489bf4302df483f362175e1a05bccdbe1080871c9e2e03579790b91d9ef97
6
+ metadata.gz: bb9060833604e6ba41e77968cd4ebec2f07f08c773bdc7f9298b4731b030b52c69b393d84282d152490a3446ae11e952463df937a355050f50ce1f5308ab5d46
7
+ data.tar.gz: fab01b55b6e722e5d64a7449f3db89d6f89947f4a7bc5e2fc68556b650940af2100e8655d75e17c25179c1a9646987437544fa69a45dff501abf4268838613e0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bps-google-api (0.2.2)
4
+ bps-google-api (0.2.3)
5
5
  exp_retry (~> 0.0.11)
6
6
  fileutils (~> 1.2)
7
7
  google-api-client (~> 0.23.4)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'bps-google-api'
5
- s.version = '0.2.2'
5
+ s.version = '0.2.3'
6
6
  s.date = '2019-06-20'
7
7
  s.summary = 'Configured Google API'
8
8
  s.description = 'A configured Google API wrapper.'
data/lib/google_api.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GoogleAPI
4
+ ROOT_PATH ||= defined?(Rails) ? Rails.root : '.'
5
+
4
6
  require 'google/apis/calendar_v3'
5
7
  require 'google/apis/groupssettings_v1'
6
8
  require 'google/apis/admin_directory_v1'
@@ -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(root_path, 'config/keys/google_api_client.json'),
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(root_path, 'config/keys/google_token.yaml'),
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']}",
@@ -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
- last_token = last_token_path
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(last_token_path, 'w+') { |f| f.write(@page_token) }
59
- puts "\n*** Token stored in #{last_token_path}" if @verbose
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(subject.new.send(:last_token_path)).to eql('./tmp/run/last_page_token')
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bps-google-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander