bps-google-api 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/bps-google-api.gemspec +2 -2
- data/lib/google_api/calendar/clear_test_calendar.rb +9 -8
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ce9a24661d8641417f6bade32c5232d1d781359
|
4
|
+
data.tar.gz: dfd8b1f1155c7d82962a0044eb78d539dc87423b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68779cc842f13e8f5c5741651e6a91b55e62ae33d9a21e67bf4e0566185883f2d2d633f8725ab7ae53b4ad03e13956507e135136b1cb152a9cfcddcfc570a191
|
7
|
+
data.tar.gz: b8bfc5bd9b20f3dd4636409047742bf7132c6bb579e2aa5e965aed256a282424df09e600214e184ec9547341a42b9be7ab2701d4df89f5b9aa6d195a8f02f083
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bps-google-api (0.1.
|
5
|
-
exp_retry (~> 0.0.
|
4
|
+
bps-google-api (0.1.4)
|
5
|
+
exp_retry (~> 0.0.10)
|
6
6
|
fileutils (~> 1.2)
|
7
7
|
google-api-client (~> 0.23.4)
|
8
8
|
ruby-progressbar (~> 1.10)
|
@@ -14,7 +14,7 @@ GEM
|
|
14
14
|
public_suffix (>= 2.0.2, < 4.0)
|
15
15
|
declarative (0.0.10)
|
16
16
|
declarative-option (0.1.0)
|
17
|
-
exp_retry (0.0.
|
17
|
+
exp_retry (0.0.10)
|
18
18
|
faraday (0.15.4)
|
19
19
|
multipart-post (>= 1.2, < 3)
|
20
20
|
fileutils (1.2.0)
|
data/bps-google-api.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'bps-google-api'
|
5
|
-
s.version = '0.1.
|
5
|
+
s.version = '0.1.4'
|
6
6
|
s.date = '2019-06-15'
|
7
7
|
s.summary = 'Configured Google API'
|
8
8
|
s.description = 'A configured Google API wrapper.'
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.require_paths = %w[lib]
|
14
14
|
s.files = `git ls-files`.split("\n")
|
15
15
|
|
16
|
-
s.add_runtime_dependency 'exp_retry', '~> 0.0.
|
16
|
+
s.add_runtime_dependency 'exp_retry', '~> 0.0.10'
|
17
17
|
s.add_runtime_dependency 'fileutils', '~> 1.2'
|
18
18
|
s.add_runtime_dependency 'google-api-client', '~> 0.23.4'
|
19
19
|
s.add_runtime_dependency 'ruby-progressbar', '~> 1.10'
|
@@ -3,11 +3,12 @@
|
|
3
3
|
module GoogleAPI
|
4
4
|
class Calendar < GoogleAPI::Base
|
5
5
|
module ClearTestCalendar
|
6
|
-
def clear_test_calendar(page_token: nil, page_limit: 50)
|
6
|
+
def clear_test_calendar(page_token: nil, page_limit: 50, verbose: false)
|
7
|
+
@verbose = verbose
|
7
8
|
Google::Apis.logger.level = Logger::WARN
|
8
9
|
choose_page_token(page_token)
|
9
10
|
loop_over_pages(ENV['GOOGLE_CALENDAR_ID_TEST'], page_limit: page_limit)
|
10
|
-
puts '*** Cleared all events!'
|
11
|
+
puts '*** Cleared all events!' if @verbose
|
11
12
|
rescue Google::Apis::RateLimitError
|
12
13
|
puts "\n\n*** Google::Apis::RateLimitError (Rate Limit Exceeded)"
|
13
14
|
ensure
|
@@ -23,7 +24,7 @@ module GoogleAPI
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def loop_over_pages(cal_id, page_limit: 50)
|
26
|
-
puts "*** Starting with page token: #{@page_token}" if @page_token.present?
|
27
|
+
puts "*** Starting with page token: #{@page_token}" if @verbose && @page_token.present?
|
27
28
|
|
28
29
|
page_limit -= 1 while (@page_token = clear_page(cal_id)) && page_limit.positive?
|
29
30
|
end
|
@@ -35,20 +36,20 @@ module GoogleAPI
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def clear_events_from_page(cal_id, items)
|
38
|
-
puts "*** Page token: #{@page_token}"
|
39
|
-
pb = progress_bar(items.count)
|
39
|
+
puts "*** Page token: #{@page_token}" if @verbose
|
40
|
+
pb = progress_bar(items.count) if @verbose
|
40
41
|
items&.each_with_index do |event, _index|
|
41
42
|
ExpRetry.for(exception: Calendar::RETRIES) do
|
42
43
|
delete(cal_id, event.id)
|
43
|
-
pb.increment
|
44
|
+
pb.increment if @verbose
|
44
45
|
end
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
49
|
def log_last_page_token
|
49
|
-
puts "\n\n*** Last page token cleared: #{@page_token}"
|
50
|
+
puts "\n\n*** Last page token cleared: #{@page_token}" if @verbose
|
50
51
|
File.open(last_token_path, 'w+') { |f| f.write(@page_token) }
|
51
|
-
puts "\n*** Token stored in #{last_token_path}"
|
52
|
+
puts "\n*** Token stored in #{last_token_path}" if @verbose
|
52
53
|
end
|
53
54
|
|
54
55
|
def progress_bar(total)
|
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.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Fiander
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.0.
|
19
|
+
version: 0.0.10
|
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.
|
26
|
+
version: 0.0.10
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: fileutils
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|