bps-google-api 0.4.1 → 0.4.8

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
- SHA1:
3
- metadata.gz: b77040196a93c3ed682e0bcd28b1db7ef594bb49
4
- data.tar.gz: 9aa7deb73ce20a9dea1ecc582c627d7120c76fae
2
+ SHA256:
3
+ metadata.gz: ac23f313f3e6a5bd469d43b3097bd94f2b7d8e6e4a2cefbbd416b7d783224f82
4
+ data.tar.gz: ebe61c322c7e1fbb37cee4b925cb4f40707b0b16e3a2d4f4b18973aec24a08d2
5
5
  SHA512:
6
- metadata.gz: 9c017f0c3170205f69642fce1e107ce705a76bf7b2d233ad60a3c63425aa24ea4db3599063cdcc209366043399178173cbc992e7931a97600752d129b11e2539
7
- data.tar.gz: b659861c968fc28453cd7b1e4cc467445aade4c60356ddf19a2d44c96fd52ec1f566bc1ef5ac15ff2179e10e4a1ed5b3734661ba36cd133b95b197eee24e4a6c
6
+ metadata.gz: 8d514d9e36cd7b017a33ccccbc71acb2b8353b2c9c69320189186853e772d0adcbbfed8cee132e31593f51a624fa40f59c08d94e72d4101151447536ab494cfa
7
+ data.tar.gz: 3f14a711aa4a0668f62aeb91abf381d346010973de1074b0f8b8ff6d94338c326eb8b68f3a9ebbffd53c09a6472362f94fe12ae5e54d102e8ecdb678718a8126
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  config/
2
2
  coverage/
3
- tmp/
3
+ tmp/
4
+ lib/google_api/tmp
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bps-google-api (0.4.1)
5
- exp_retry (~> 0.0.11)
4
+ bps-google-api (0.4.8)
5
+ exp_retry (~> 0.0.13)
6
6
  fileutils (~> 1.2)
7
7
  google-api-client (~> 0.23.4)
8
8
  ruby-progressbar (~> 1.10)
@@ -10,17 +10,17 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- addressable (2.6.0)
14
- public_suffix (>= 2.0.2, < 4.0)
13
+ addressable (2.7.0)
14
+ public_suffix (>= 2.0.2, < 5.0)
15
15
  ast (2.4.0)
16
- declarative (0.0.10)
16
+ declarative (0.0.20)
17
17
  declarative-option (0.1.0)
18
18
  diff-lcs (1.3)
19
19
  docile (1.3.2)
20
- exp_retry (0.0.12)
21
- faraday (0.15.4)
20
+ exp_retry (0.0.13)
21
+ faraday (0.17.3)
22
22
  multipart-post (>= 1.2, < 3)
23
- fileutils (1.2.0)
23
+ fileutils (1.5.0)
24
24
  google-api-client (0.23.9)
25
25
  addressable (~> 2.5, >= 2.5.1)
26
26
  googleauth (>= 0.5, < 0.7.0)
@@ -38,19 +38,19 @@ GEM
38
38
  signet (~> 0.7)
39
39
  httpclient (2.8.3)
40
40
  jaro_winkler (1.5.3)
41
- json (2.2.0)
42
- jwt (2.2.1)
43
- memoist (0.16.0)
44
- mime-types (3.2.2)
41
+ json (2.3.1)
42
+ jwt (2.2.2)
43
+ memoist (0.16.2)
44
+ mime-types (3.3.1)
45
45
  mime-types-data (~> 3.2015)
46
- mime-types-data (3.2019.0331)
47
- multi_json (1.13.1)
46
+ mime-types-data (3.2020.1104)
47
+ multi_json (1.15.0)
48
48
  multipart-post (2.1.1)
49
- os (1.0.1)
49
+ os (1.1.1)
50
50
  parallel (1.17.0)
51
51
  parser (2.6.3.0)
52
52
  ast (~> 2.4.0)
53
- public_suffix (3.1.1)
53
+ public_suffix (4.0.6)
54
54
  rainbow (3.0.0)
55
55
  representable (3.0.4)
56
56
  declarative (< 0.1.0)
@@ -78,9 +78,9 @@ GEM
78
78
  ruby-progressbar (~> 1.7)
79
79
  unicode-display_width (>= 1.4.0, < 1.7)
80
80
  ruby-progressbar (1.10.1)
81
- signet (0.11.0)
81
+ signet (0.14.1)
82
82
  addressable (~> 2.3)
83
- faraday (~> 0.9)
83
+ faraday (>= 0.17.3, < 2.0)
84
84
  jwt (>= 1.5, < 3.0)
85
85
  multi_json (~> 1.10)
86
86
  simplecov (0.16.1)
data/Readme.md CHANGED
@@ -36,6 +36,12 @@ GoogleAPI.configure do |config|
36
36
  end
37
37
  ```
38
38
 
39
+ You can also alter the logging level using:
40
+
41
+ ```ruby
42
+ GoogleAPI.logging!(:FATAL) # %i[INFO WARN ERROR FATAL]
43
+ ```
44
+
39
45
  Then add the following in `config/application.rb`:
40
46
 
41
47
  ```ruby
@@ -72,10 +78,12 @@ calendar = GoogleAPI::Configured::Calendar.new(calendar_id)
72
78
 
73
79
  calendar.create(event_options)
74
80
  calendar.list(max_results: 2500, page_token: nil)
81
+ calendar.list_all
75
82
  calendar.get(event_id)
76
83
  calendar.patch(event_id, patch_options)
77
84
  calendar.update(event_id, updated_event_options)
78
85
  calendar.add_conference(event_id)
86
+ calendar.conference_info(event_id, all: false)
79
87
  calendar.delete(event_id)
80
88
 
81
89
  calendar.permit(user)
@@ -100,6 +108,7 @@ event.get
100
108
  event.patch(patch_options)
101
109
  event.update(updated_event_options)
102
110
  event.add_conference
111
+ event.conference_info(all: false)
103
112
  event.delete
104
113
  ```
105
114
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'bps-google-api'
5
- s.version = '0.4.1'
6
- s.date = '2019-06-27'
5
+ s.version = '0.4.8'
6
+ s.date = '2021-01-30'
7
7
  s.summary = 'Configured Google API'
8
8
  s.description = 'A configured Google API wrapper.'
9
9
  s.homepage = 'http://rubygems.org/gems/bps-google-api'
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
 
16
16
  s.required_ruby_version = '~> 2.4'
17
17
 
18
- s.add_runtime_dependency 'exp_retry', '~> 0.0.11'
18
+ s.add_runtime_dependency 'exp_retry', '~> 0.0.13'
19
19
  s.add_runtime_dependency 'fileutils', '~> 1.2'
20
20
  s.add_runtime_dependency 'google-api-client', '~> 0.23.4'
21
21
  s.add_runtime_dependency 'ruby-progressbar', '~> 1.10'
@@ -29,6 +29,12 @@ class GoogleAPI
29
29
  configuration
30
30
  end
31
31
 
32
+ def self.logging!(level = :FATAL)
33
+ raise ArgumentError, 'Unknown level' unless %i[DEBUG INFO WARN ERROR FATAL].include?(level)
34
+
35
+ Google::Apis.logger.level = Logger.const_get(level)
36
+ end
37
+
32
38
  # Internal requires
33
39
  require 'google_api/base'
34
40
  require 'google_api/calendar'
@@ -14,8 +14,7 @@ class GoogleAPI
14
14
 
15
15
  SERVICE_CLASS = Google::Apis::CalendarV3::CalendarService
16
16
  VALID_EVENT_KEYS ||= %i[
17
- summary start end description location recurrence conference
18
- conference_data
17
+ summary start end description location recurrence conference conference_data
19
18
  ].freeze
20
19
  VALID_PATCH_KEYS ||= %i[
21
20
  summary start end description location recurrence conference_data created reminders creator
@@ -15,6 +15,13 @@ class GoogleAPI
15
15
  call(:patch_event, calendar_id, event_id, patch_options, conference_data_version: 1)
16
16
  end
17
17
 
18
+ def conference_info(calendar_id, event_id, all: false)
19
+ conf = call(:get_event, calendar_id, event_id).conference_data
20
+ return conf if all || conf.nil?
21
+
22
+ { id: conf.conference_id, signature: conf.signature }
23
+ end
24
+
18
25
  private
19
26
 
20
27
  def format_conference_data(event_options)
@@ -6,7 +6,7 @@ class GoogleAPI
6
6
  attr_writer :keys
7
7
 
8
8
  def initialize
9
- self.root = __dir__
9
+ self.root = File.join(__dir__, 'tmp')
10
10
 
11
11
  yield self if block_given?
12
12
  end
@@ -58,6 +58,10 @@ class GoogleAPI
58
58
  def add_conference(event_id)
59
59
  self.class.api.add_conference(calendar_id, event_id)
60
60
  end
61
+
62
+ def conference_info(event_id, all: false)
63
+ self.class.api.conference_info(calendar_id, event_id, all: all)
64
+ end
61
65
  end
62
66
  end
63
67
  end
@@ -34,6 +34,10 @@ class GoogleAPI
34
34
  def add_conference
35
35
  self.class.api.add_conference(calendar_id, event_id)
36
36
  end
37
+
38
+ def conference_info(all: false)
39
+ self.class.api.conference_info(calendar_id, event_id, all: all)
40
+ end
37
41
  end
38
42
  end
39
43
  end
@@ -78,6 +78,8 @@ RSpec.describe GoogleAPI::Calendar do
78
78
  end
79
79
 
80
80
  it 'returns the array of all events from list_all' do
81
+ subject.create(test_event) # Ensure at least one event exists
82
+
81
83
  expect(subject.list_all.map(&:class).uniq).to eql([Google::Apis::CalendarV3::Event])
82
84
  end
83
85
 
@@ -85,22 +87,35 @@ RSpec.describe GoogleAPI::Calendar do
85
87
  expect(subject.create(test_event)).to be_a(Google::Apis::CalendarV3::Event)
86
88
  end
87
89
 
88
- it 'creates an event with a new conference' do
89
- event = test_event.merge(conference: { id: :new })
90
- expect(subject.create(event)).to be_a(Google::Apis::CalendarV3::Event)
91
- end
90
+ describe 'conference data' do
91
+ it 'creates an event with a new conference' do
92
+ event = test_event.merge(conference: { id: :new })
92
93
 
93
- it 'creates an event with conference data' do
94
- event = subject.create(test_event)
95
- event = subject.add_conference(event.id)
96
- event_options = test_event.merge(
97
- conference: {
94
+ expect(subject.create(event)).to be_a(Google::Apis::CalendarV3::Event)
95
+ end
96
+
97
+ it 'creates an event with conference data' do
98
+ event = subject.create(test_event)
99
+ event = subject.add_conference(event.id)
100
+ event_options = test_event.merge(
101
+ conference: {
102
+ id: event.conference_data.conference_id,
103
+ signature: event.conference_data.signature
104
+ }
105
+ )
106
+
107
+ expect(subject.create(event_options)).to be_a(Google::Apis::CalendarV3::Event)
108
+ end
109
+
110
+ it 'returns valid conference information' do
111
+ event = subject.create(test_event)
112
+ event = subject.add_conference(event.id)
113
+
114
+ expect(subject.conference_info(event.id)).to eql(
98
115
  id: event.conference_data.conference_id,
99
116
  signature: event.conference_data.signature
100
- }
101
- )
102
-
103
- expect(subject.create(event_options)).to be_a(Google::Apis::CalendarV3::Event)
117
+ )
118
+ end
104
119
  end
105
120
 
106
121
  it 'gets an event ' do
@@ -40,7 +40,18 @@ RSpec.describe GoogleAPI::Configured::Calendar::Event do
40
40
  expect(subject.delete).to eql('')
41
41
  end
42
42
 
43
- it 'adds conference data' do
44
- expect(subject.add_conference).to be_a(Google::Apis::CalendarV3::Event)
43
+ describe 'conference data' do
44
+ it 'adds conference data' do
45
+ expect(subject.add_conference).to be_a(Google::Apis::CalendarV3::Event)
46
+ end
47
+
48
+ it 'returns valid conference information' do
49
+ event = subject.add_conference
50
+
51
+ expect(subject.conference_info).to eql(
52
+ id: event.conference_data.conference_id,
53
+ signature: event.conference_data.signature
54
+ )
55
+ end
45
56
  end
46
57
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe GoogleAPI do
6
+ it 'sets the log level correctly' do
7
+ expect { GoogleAPI.logging!(:FATAL) }.to(
8
+ change(Google::Apis.logger, :level).from(Logger::WARN).to(Logger::FATAL)
9
+ )
10
+ end
11
+
12
+ it 'raises for invalid levels' do
13
+ expect { GoogleAPI.logging!(:WRONG) }.to raise_error(ArgumentError, 'Unknown level')
14
+ end
15
+ end
@@ -25,6 +25,8 @@ RSpec.configure do |config|
25
25
  c.keys = 'tmp/spec/keys'
26
26
  end
27
27
 
28
+ GoogleAPI.logging!(:INFO)
29
+
28
30
  FileUtils.rm(Dir.glob(GoogleAPI.configuration.local_path('*', &:keys)))
29
31
 
30
32
  ENV['GOOGLE_AUTHORIZATION_CODE'] = 'test-auth-code'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bps-google-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-27 00:00:00.000000000 Z
11
+ date: 2021-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: exp_retry
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.11
19
+ version: 0.0.13
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.11
26
+ version: 0.0.13
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: fileutils
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -159,12 +159,13 @@ files:
159
159
  - spec/lib/google_api/calendar_spec.rb
160
160
  - spec/lib/google_api/event_spec.rb
161
161
  - spec/lib/google_api/group_spec.rb
162
+ - spec/lib/google_api_spec.rb
162
163
  - spec/spec_helper.rb
163
164
  homepage: http://rubygems.org/gems/bps-google-api
164
165
  licenses:
165
166
  - GPL-3.0
166
167
  metadata: {}
167
- post_install_message:
168
+ post_install_message:
168
169
  rdoc_options: []
169
170
  require_paths:
170
171
  - lib
@@ -179,9 +180,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
180
  - !ruby/object:Gem::Version
180
181
  version: '0'
181
182
  requirements: []
182
- rubyforge_project:
183
- rubygems_version: 2.6.14.1
184
- signing_key:
183
+ rubygems_version: 3.2.7
184
+ signing_key:
185
185
  specification_version: 4
186
186
  summary: Configured Google API
187
187
  test_files: []