bps-google-api 0.6.2.pre.1 → 0.7.0

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
  SHA256:
3
- metadata.gz: 3289f4d16d65e63d55f50a64eee1f304a9bdc09cbde938f768bd7f21905cb297
4
- data.tar.gz: bd3b5363ec5fe6612029d8cbf084682384f60db8060f9b67f1b9a2c8230944f2
3
+ metadata.gz: 3d03de79db68f08c0dd05c7e91955c855f8c3ece70d22a7c8002a6a82c6ecc14
4
+ data.tar.gz: 54d786a5e83008507af3a6aaed1cc9e5a8583e4c7b56f7fab51a3ca547c3f6ce
5
5
  SHA512:
6
- metadata.gz: 598ebafb62a6dea9464f51515bf5909438ed0c418398e2a4ecf77d3e9ee3cc71d5694c476a0bd759c06ca0f5089855e0db2ac63987465f43314642bbf382eb13
7
- data.tar.gz: a0092ecc8d0e6c2e171626eaa33ba307ef653b2a932e3975403a26fa0f976ed33182871d9edcfecfb5536c9ea7b1072a0896f28486aa797a644e63f9c3f648ab
6
+ metadata.gz: a85417faada4b864ca801a2176f2fdcdd9e73eeb23f01309cc2baf636958556d751ff3303707273740b5e451f1b42b6224600e84973399282e809b327f02f803
7
+ data.tar.gz: 011633b06862cf729406cb513ec8eedb24c70b012d31de15178774c6d6619933a9a7f4cb5f9d9020fa8e5fdb8441bd661b14c4d8b6dc291c875086c79a8bcd5b
data/.gitignore CHANGED
@@ -2,3 +2,4 @@ config/
2
2
  coverage/
3
3
  tmp/
4
4
  lib/google_api/tmp
5
+ .env
data/.rubocop.yml CHANGED
@@ -1,21 +1,22 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.4
2
+ TargetRubyVersion: 3.0
3
3
  Exclude:
4
4
  - bin/**/*
5
5
  - config/**/*
6
6
  - db/**/*
7
7
  - vendor/**/*
8
8
  - tmp/**/*
9
+ NewCops: enable
9
10
 
10
- Layout/IndentFirstHashElement:
11
+ Layout/FirstHashElementIndentation:
11
12
  EnforcedStyle: consistent
12
13
  Layout/AccessModifierIndentation:
13
14
  EnforcedStyle: outdent
14
15
  Layout/EmptyLinesAroundAccessModifier:
15
16
  Enabled: true
16
- Layout/AlignArray:
17
+ Layout/ArrayAlignment:
17
18
  Enabled: true
18
- Layout/AlignHash:
19
+ Layout/HashAlignment:
19
20
  Enabled: true
20
21
  Layout/EmptyLineAfterGuardClause:
21
22
  Enabled: true
@@ -52,7 +53,7 @@ Metrics/AbcSize:
52
53
 
53
54
  Naming/MemoizedInstanceVariableName:
54
55
  Enabled: false
55
- Naming/UncommunicativeMethodParamName:
56
+ Naming/MethodParameterName:
56
57
  Enabled: false
57
58
 
58
59
  Style/Documentation:
@@ -69,6 +70,8 @@ Style/ClassCheck:
69
70
  Enabled: true
70
71
  Style/GuardClause:
71
72
  Enabled: true
73
+ Style/OptionalBooleanParameter:
74
+ Enabled: false
72
75
 
73
76
  Security/Eval:
74
77
  Enabled: true
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bps-google-api (0.6.1)
4
+ bps-google-api (0.7.0)
5
5
  exp_retry (~> 0.0.13)
6
6
  fileutils (~> 1.4, >= 1.4.1)
7
7
  google-apis-admin_directory_v1 (~> 0.40)
@@ -19,6 +19,7 @@ GEM
19
19
  declarative (0.0.20)
20
20
  diff-lcs (1.5.1)
21
21
  docile (1.4.0)
22
+ dotenv (2.8.1)
22
23
  exp_retry (0.0.14)
23
24
  faraday (2.9.0)
24
25
  faraday-net_http (>= 2.0, < 3.2)
@@ -27,8 +28,8 @@ GEM
27
28
  fileutils (1.7.2)
28
29
  google-apis-admin_directory_v1 (0.54.0)
29
30
  google-apis-core (>= 0.14.0, < 2.a)
30
- google-apis-calendar_v3 (0.40.0)
31
- google-apis-core (>= 0.14.0, < 2.a)
31
+ google-apis-calendar_v3 (0.27.0)
32
+ google-apis-core (>= 0.11.0, < 2.a)
32
33
  google-apis-core (0.15.0)
33
34
  addressable (~> 2.5, >= 2.5.1)
34
35
  googleauth (~> 1.9)
@@ -119,6 +120,7 @@ PLATFORMS
119
120
 
120
121
  DEPENDENCIES
121
122
  bps-google-api!
123
+ dotenv
122
124
  rspec (~> 3.8, >= 3.8.0)
123
125
  rubocop (~> 0.71, >= 0.71.0)
124
126
  simplecov (~> 0.16, >= 0.16.1)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'bps-google-api'
5
- s.version = '0.6.2-1'
5
+ s.version = '0.7.0'
6
6
  s.date = '2024-05-17'
7
7
  s.summary = 'Configured Google API'
8
8
  s.description = 'A configured Google API wrapper.'
@@ -17,11 +17,12 @@ Gem::Specification.new do |s|
17
17
 
18
18
  s.add_runtime_dependency 'exp_retry', '~> 0.0.13'
19
19
  s.add_runtime_dependency 'fileutils', '~> 1.4', '>= 1.4.1'
20
+ s.add_runtime_dependency 'google-apis-admin_directory_v1', '~> 0.40'
20
21
  s.add_runtime_dependency 'google-apis-calendar_v3', '~> 0.27'
21
22
  s.add_runtime_dependency 'google-apis-groupssettings_v1', '~> 0.13'
22
- s.add_runtime_dependency 'google-apis-admin_directory_v1', '~> 0.40'
23
23
  s.add_runtime_dependency 'ruby-progressbar', '~> 1.10'
24
24
 
25
+ s.add_development_dependency 'dotenv'
25
26
  s.add_development_dependency 'rspec', '~> 3.8', '>= 3.8.0'
26
27
  s.add_development_dependency 'rubocop', '~> 0.71', '>= 0.71.0'
27
28
  s.add_development_dependency 'simplecov', '~> 0.16', '>= 0.16.1'
@@ -27,11 +27,11 @@ class GoogleAPI
27
27
  @service ||= service_class.new
28
28
  end
29
29
 
30
- def call(method, *args)
30
+ def call(...)
31
31
  if GoogleAPI.mock
32
- send(:mock, method, *args)
32
+ mock(...)
33
33
  else
34
- ExpRetry.for(exception: RETRIES) { service.send(method, *args) }
34
+ ExpRetry.for(exception: RETRIES) { service.send(...) }
35
35
  end
36
36
  end
37
37
 
@@ -22,7 +22,7 @@ class GoogleAPI
22
22
  end
23
23
 
24
24
  def create(calendar_id, **event_options)
25
- call(:insert_event, calendar_id, event(**event_options), conference_data_version: 1)
25
+ call(:insert_event, calendar_id, event(false, **event_options), conference_data_version: 1)
26
26
  end
27
27
 
28
28
  def list(calendar_id, max_results: 2500, page_token: nil)
@@ -32,13 +32,13 @@ class GoogleAPI
32
32
  def list_all(calendar_id, verbose: false)
33
33
  events = []
34
34
 
35
- list = call(:list_events, calendar_id)
36
- events += list.items
35
+ l = call(:list_events, calendar_id)
36
+ events += l.items
37
37
 
38
- while (page_token = list.next_page_token)
39
- list = call(:list_events, calendar_id, page_token: page_token)
40
- page_token = list.next_page_token
41
- events += list.items
38
+ while (page_token = l.next_page_token)
39
+ l = call(:list_events, calendar_id, page_token: page_token)
40
+ page_token = l.next_page_token
41
+ events += l.items
42
42
  print('.') if verbose
43
43
  end
44
44
 
@@ -50,7 +50,7 @@ class GoogleAPI
50
50
  end
51
51
 
52
52
  def patch(calendar_id, event_id, **patch_options)
53
- call(:patch_event, calendar_id, event_id, **patch_options, conference_data_version: 1)
53
+ call(:patch_event, calendar_id, event_id, patch_options, conference_data_version: 1)
54
54
  end
55
55
 
56
56
  def update(calendar_id, event_id, **event_options)
@@ -85,21 +85,21 @@ class GoogleAPI
85
85
 
86
86
  private
87
87
 
88
- def event(event_options, patch: false)
89
- validate_keys(event_options, patch)
88
+ def event(patch = false, **event_options)
89
+ validate_keys(patch, **event_options)
90
90
 
91
- event_options = format_dates(event_options)
92
- event_options = format_conference_data(event_options)
91
+ event_options = format_dates(**event_options)
92
+ event_options = format_conference_data(**event_options)
93
93
 
94
- Google::Apis::CalendarV3::Event.new(event_options.reject { |_, v| v.nil? })
94
+ Google::Apis::CalendarV3::Event.new(**event_options.reject { |_, v| v.nil? })
95
95
  end
96
96
 
97
- def validate_keys(event_options, patch)
97
+ def validate_keys(patch = false, **event_options)
98
98
  event_options.assert_valid_keys(VALID_EVENT_KEYS) unless patch
99
99
  event_options.assert_valid_keys(VALID_PATCH_KEYS) if patch
100
100
  end
101
101
 
102
- def format_dates(event_options)
102
+ def format_dates(**event_options)
103
103
  event_options[:start] = format_date(event_options[:start])
104
104
  event_options[:end] = format_date(event_options[:end])
105
105
  event_options
@@ -108,7 +108,7 @@ class GoogleAPI
108
108
  def format_date(date)
109
109
  return date if date.is_a?(Google::Apis::CalendarV3::EventDateTime)
110
110
 
111
- key = date&.is_a?(String) ? :date : :date_time
111
+ key = date.is_a?(String) ? :date : :date_time
112
112
  Google::Apis::CalendarV3::EventDateTime.new(key => date, time_zone: ENV['TZ'])
113
113
  end
114
114
 
data/spec/.rubocop.yml CHANGED
@@ -1,3 +1,7 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.0
3
+ NewCops: enable
4
+
1
5
  Metrics/LineLength:
2
6
  Max: 100
3
7
  Metrics/BlockLength:
@@ -78,7 +78,7 @@ 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
81
+ subject.create(**test_event) # Ensure at least one event exists
82
82
 
83
83
  expect(subject.list_all.map(&:class).uniq).to eql([Google::Apis::CalendarV3::Event])
84
84
  end
@@ -97,7 +97,7 @@ RSpec.describe GoogleAPI::Calendar do
97
97
  ]
98
98
  end
99
99
 
100
- before { allow(calendar).to receive(:call).and_return(events) }
100
+ before { allow(calendar).to receive(:call).and_return(*events) }
101
101
 
102
102
  it 'returns the array of all events from list_all when paginated' do
103
103
  expect(calendar).to receive(:call).twice
@@ -107,18 +107,18 @@ RSpec.describe GoogleAPI::Calendar do
107
107
  end
108
108
 
109
109
  it 'creates an event' do
110
- expect(subject.create(test_event)).to be_a(Google::Apis::CalendarV3::Event)
110
+ expect(subject.create(**test_event)).to be_a(Google::Apis::CalendarV3::Event)
111
111
  end
112
112
 
113
113
  describe 'conference data' do
114
114
  it 'creates an event with a new conference' do
115
115
  event = test_event.merge(conference: { id: :new })
116
116
 
117
- expect(subject.create(event)).to be_a(Google::Apis::CalendarV3::Event)
117
+ expect(subject.create(**event)).to be_a(Google::Apis::CalendarV3::Event)
118
118
  end
119
119
 
120
120
  it 'creates an event with conference data', :aggregate_failures do
121
- event = subject.create(test_event)
121
+ event = subject.create(**test_event)
122
122
  event = subject.add_conference(event.id)
123
123
  event_options = test_event.merge(
124
124
  conference: {
@@ -127,13 +127,13 @@ RSpec.describe GoogleAPI::Calendar do
127
127
  }
128
128
  )
129
129
 
130
- event = subject.create(event_options)
130
+ event = subject.create(**event_options)
131
131
  expect(event).to be_a(Google::Apis::CalendarV3::Event)
132
132
  expect(event.conference_data).not_to be_nil
133
133
  end
134
134
 
135
135
  it 'returns valid conference information' do
136
- event = subject.create(test_event)
136
+ event = subject.create(**test_event)
137
137
  event = subject.add_conference(event.id)
138
138
 
139
139
  expect(subject.conference_info(event.id)).to eql(
@@ -144,27 +144,27 @@ RSpec.describe GoogleAPI::Calendar do
144
144
  end
145
145
 
146
146
  it 'gets an event ' do
147
- event = subject.create(test_event)
147
+ event = subject.create(**test_event)
148
148
  expect(subject.get(event.id)).to be_a(Google::Apis::CalendarV3::Event)
149
149
  end
150
150
 
151
151
  it 'patches an event' do
152
- event = subject.create(test_event)
152
+ event = subject.create(**test_event)
153
153
  subject.patch(event.id, description: 'Patched.')
154
154
 
155
155
  expect(subject.get(event.id).description).to eql('Patched.')
156
156
  end
157
157
 
158
158
  it 'updates an event' do
159
- event = subject.create(test_event)
159
+ event = subject.create(**test_event)
160
160
  updated_test_event = test_event.merge(description: 'Updated.')
161
- subject.update(event.id, updated_test_event)
161
+ subject.update(event.id, **updated_test_event)
162
162
 
163
163
  expect(subject.get(event.id).description).to eql('Updated.')
164
164
  end
165
165
 
166
166
  it 'deletes an event' do
167
- event = subject.create(test_event)
167
+ event = subject.create(**test_event)
168
168
 
169
169
  expect(subject.delete(event.id)).to eql('')
170
170
  end
@@ -187,7 +187,7 @@ RSpec.describe GoogleAPI::Calendar do
187
187
  end
188
188
 
189
189
  it 'does not raise any errors with verbose' do
190
- subject.create(test_event)
190
+ subject.create(**test_event)
191
191
 
192
192
  silently do
193
193
  expect do
@@ -198,7 +198,7 @@ RSpec.describe GoogleAPI::Calendar do
198
198
  end
199
199
 
200
200
  it 'adds conference data' do
201
- event = subject.create(test_event)
201
+ event = subject.create(**test_event)
202
202
 
203
203
  expect(subject.add_conference(event.id)).to be_a(Google::Apis::CalendarV3::Event)
204
204
  end
@@ -15,7 +15,7 @@ RSpec.describe GoogleAPI::Configured::Calendar::Event do
15
15
  let(:test_cal_id) { ENV['GOOGLE_CALENDAR_ID_TEST'] }
16
16
 
17
17
  subject do
18
- event = GoogleAPI::Configured::Calendar.new(test_cal_id).create(test_event)
18
+ event = GoogleAPI::Configured::Calendar.new(test_cal_id).create(**test_event)
19
19
  GoogleAPI::Configured::Calendar::Event.new(test_cal_id, event.id)
20
20
  end
21
21
 
@@ -31,7 +31,7 @@ RSpec.describe GoogleAPI::Configured::Calendar::Event do
31
31
 
32
32
  it 'updates the event' do
33
33
  updated_test_event = test_event.merge(description: 'Updated.')
34
- subject.update(updated_test_event)
34
+ subject.update(**updated_test_event)
35
35
 
36
36
  expect(subject.get.description).to eql('Updated.')
37
37
  end
data/spec/spec_helper.rb CHANGED
@@ -9,6 +9,7 @@ SimpleCov.start do
9
9
  end
10
10
  SimpleCov.minimum_coverage(100)
11
11
 
12
+ require 'dotenv/load'
12
13
  require 'google_api'
13
14
 
14
15
  def silently
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.6.2.pre.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander
@@ -45,47 +45,47 @@ dependencies:
45
45
  - !ruby/object:Gem::Version
46
46
  version: 1.4.1
47
47
  - !ruby/object:Gem::Dependency
48
- name: google-apis-calendar_v3
48
+ name: google-apis-admin_directory_v1
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0.27'
53
+ version: '0.40'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '0.27'
60
+ version: '0.40'
61
61
  - !ruby/object:Gem::Dependency
62
- name: google-apis-groupssettings_v1
62
+ name: google-apis-calendar_v3
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0.13'
67
+ version: '0.27'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '0.13'
74
+ version: '0.27'
75
75
  - !ruby/object:Gem::Dependency
76
- name: google-apis-admin_directory_v1
76
+ name: google-apis-groupssettings_v1
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '0.40'
81
+ version: '0.13'
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '0.40'
88
+ version: '0.13'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: ruby-progressbar
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -100,6 +100,20 @@ dependencies:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '1.10'
103
+ - !ruby/object:Gem::Dependency
104
+ name: dotenv
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
103
117
  - !ruby/object:Gem::Dependency
104
118
  name: rspec
105
119
  requirement: !ruby/object:Gem::Requirement
@@ -210,9 +224,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
210
224
  version: '3.0'
211
225
  required_rubygems_version: !ruby/object:Gem::Requirement
212
226
  requirements:
213
- - - ">"
227
+ - - ">="
214
228
  - !ruby/object:Gem::Version
215
- version: 1.3.1
229
+ version: '0'
216
230
  requirements: []
217
231
  rubygems_version: 3.2.33
218
232
  signing_key: