bps-google-api 0.2.3 → 0.2.4

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
  SHA1:
3
- metadata.gz: e31fcc3561f54e4e1c81770287c13ba26a226911
4
- data.tar.gz: 10dc3a67b664fe45a43f1a968bc25135a1f29f1a
3
+ metadata.gz: 62dc0559dea2c506661457f032e9e60df284d2f9
4
+ data.tar.gz: 25d483983fe5607af8d87fbfaad9120674575d2f
5
5
  SHA512:
6
- metadata.gz: bb9060833604e6ba41e77968cd4ebec2f07f08c773bdc7f9298b4731b030b52c69b393d84282d152490a3446ae11e952463df937a355050f50ce1f5308ab5d46
7
- data.tar.gz: fab01b55b6e722e5d64a7449f3db89d6f89947f4a7bc5e2fc68556b650940af2100e8655d75e17c25179c1a9646987437544fa69a45dff501abf4268838613e0
6
+ metadata.gz: af86ddc607a96df38f7bf1b2dc321898def9f3be7fffd01273423d6bf9d8ecf373e422c6fa039e5db686edc1ef7bf22438a28be2bfe477aa68df833c59b75c3e
7
+ data.tar.gz: ffcad31969723afadaf920de95f4ae06caa3c109786293d74f39476b09090c08f7871a92dd8fdecda0ffa48af1542d3515568121de9941732f28d98cb3350afa
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bps-google-api (0.2.3)
4
+ bps-google-api (0.2.4)
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.3'
5
+ s.version = '0.2.4'
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,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GoogleAPI
4
- ROOT_PATH ||= defined?(Rails) ? Rails.root : '.'
4
+ ROOT_PATH ||= File.dirname(__dir__)
5
5
 
6
6
  require 'google/apis/calendar_v3'
7
7
  require 'google/apis/groupssettings_v1'
@@ -72,7 +72,7 @@ module GoogleAPI
72
72
  def store_key(path, key)
73
73
  return if File.exist?(path)
74
74
 
75
- FileUtils.mkdir_p('config/keys')
75
+ FileUtils.mkdir_p(File.join(ROOT_PATH, 'config', 'keys'))
76
76
  File.open(path, 'w+') do |f|
77
77
  File.chmod(0o600, f)
78
78
  block_given? ? yield(f) : f.write(key)
@@ -81,7 +81,7 @@ module GoogleAPI
81
81
 
82
82
  def client_id_file
83
83
  store_key(
84
- File.join(GoogleAPI::ROOT_PATH, 'config/keys/google_api_client.json'),
84
+ File.join(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(GoogleAPI::ROOT_PATH, 'config/keys/google_token.yaml'),
96
+ File.join(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']}",
@@ -1,11 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GoogleAPI
4
- require 'google_api/calendar/clear_test_calendar'
5
-
6
4
  class Calendar < GoogleAPI::Base
7
5
  LAST_TOKEN_PATH ||= File.join(ROOT_PATH, 'tmp', 'run', 'last_page_token')
8
6
 
7
+ require 'google_api/calendar/clear_test_calendar'
9
8
  include GoogleAPI::Calendar::ClearTestCalendar
10
9
 
11
10
  SERVICE_CLASS = Google::Apis::CalendarV3::CalendarService
@@ -20,7 +20,7 @@ module GoogleAPI
20
20
  private
21
21
 
22
22
  def choose_page_token(page_token)
23
- @page_token ||= File.read(LAST_TOKEN_PATH) if File.exist?(LAST_TOKEN_PATH)
23
+ @page_token ||= File.read(Calendar::LAST_TOKEN_PATH) if File.exist?(Calendar::LAST_TOKEN_PATH)
24
24
  @page_token = page_token if token?(page_token)
25
25
  end
26
26
 
@@ -54,8 +54,8 @@ module GoogleAPI
54
54
 
55
55
  def log_last_page_token
56
56
  puts "\n\n*** Last page token cleared: #{@page_token}" 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
57
+ File.open(Calendar::LAST_TOKEN_PATH, 'w+') { |f| f.write(@page_token) }
58
+ puts "\n*** Token stored in #{Calendar::LAST_TOKEN_PATH}" if @verbose
59
59
  end
60
60
 
61
61
  def progress_bar(total)
@@ -15,7 +15,9 @@ RSpec.describe GoogleAPI::Base do
15
15
  subject { GoogleAPI::Calendar }
16
16
 
17
17
  it 'returns the correct last token path' do
18
- expect(GoogleAPI::Calendar::LAST_TOKEN_PATH).to eql('./tmp/run/last_page_token')
18
+ expect(GoogleAPI::Calendar::LAST_TOKEN_PATH).to eql(
19
+ File.join(GoogleAPI::ROOT_PATH, 'tmp', 'run', 'last_page_token')
20
+ )
19
21
  end
20
22
 
21
23
  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.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander