lt-google-api 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +1 -1
- data/.github/workflows/rubocop-analysis.yml +42 -0
- data/.gitignore +0 -1
- data/.rubocop.yml +3 -2
- data/.ruby-version +1 -1
- data/CHANGELOG.md +8 -2
- data/Gemfile.lock +90 -0
- data/lib/lt/google/api/drive.rb +14 -8
- data/lib/lt/google/api/version.rb +1 -1
- data/lt-google-api.gemspec +5 -4
- metadata +14 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9444e503f8be57c766e0c911d17bcad4a1ae91f9c0cedb41e6fe7c2aaac22b4
|
4
|
+
data.tar.gz: 26594726c1328938016457e9d1c418d31b1bf870f1c79099ee2f2df8051386a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20c99bfa0afea23058e415ac0514117864c7232f6590a583e589fdcf8f4c3809e726939dc1b4bac317f24801ab25cd4245b4ca40983f03f38dc7acad28f8cb45
|
7
|
+
data.tar.gz: b5a6fdc5a4b4471a374f8f7abf75079892dcfed5647abef945ad7cffb85d743115ff58462aa02858d0f3263cd2b6b9095b764fe2c602c9fb34a230dae727e9a2
|
data/.codeclimate.yml
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
name: "Rubocop"
|
2
|
+
|
3
|
+
on: push
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
rubocop:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
|
11
|
+
steps:
|
12
|
+
- name: Checkout repository
|
13
|
+
uses: actions/checkout@v2
|
14
|
+
|
15
|
+
# If running on a self-hosted runner, check it meets the requirements
|
16
|
+
# listed at https://github.com/ruby/setup-ruby#using-self-hosted-runners
|
17
|
+
- name: Set up Ruby
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: 2.6
|
21
|
+
|
22
|
+
- name: Intall legacy bundler version
|
23
|
+
run: gem install bundler -v 1.17.3
|
24
|
+
|
25
|
+
# This step is not necessary if you add the gem to your Gemfile
|
26
|
+
- name: Install Code Scanning integration
|
27
|
+
run: bundle _1.17.3_ add code-scanning-rubocop --version 0.4.0 --skip-install
|
28
|
+
|
29
|
+
- name: Install dependencies
|
30
|
+
run: bundle _1.17.3_ install
|
31
|
+
|
32
|
+
- name: Rubocop run
|
33
|
+
run: |
|
34
|
+
bash -c "
|
35
|
+
bundle exec rubocop --require code_scanning --format CodeScanning::SarifFormatter -o rubocop.sarif
|
36
|
+
[[ $? -ne 2 ]]
|
37
|
+
"
|
38
|
+
|
39
|
+
- name: Upload Sarif output
|
40
|
+
uses: github/codeql-action/upload-sarif@v1
|
41
|
+
with:
|
42
|
+
sarif_file: rubocop.sarif
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -12,7 +12,8 @@ AllCops:
|
|
12
12
|
- bin/*
|
13
13
|
- db/schema.rb
|
14
14
|
- node_modules/**/*
|
15
|
-
|
15
|
+
NewCops: enable
|
16
|
+
TargetRubyVersion: 2.6
|
16
17
|
|
17
18
|
Layout/MultilineMethodCallIndentation:
|
18
19
|
EnforcedStyle: indented_relative_to_receiver
|
@@ -44,7 +45,7 @@ Metrics/MethodLength:
|
|
44
45
|
Metrics/PerceivedComplexity:
|
45
46
|
Max: 9
|
46
47
|
|
47
|
-
Naming/
|
48
|
+
Naming/MethodParameterName:
|
48
49
|
MinNameLength: 2
|
49
50
|
|
50
51
|
Style/AndOr:
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.5
|
1
|
+
2.6.5
|
data/CHANGELOG.md
CHANGED
@@ -4,9 +4,15 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
-
## [Unreleased](https://github.com/learningtapestry/lt-google-api/compare/v0.
|
7
|
+
## [Unreleased](https://github.com/learningtapestry/lt-google-api/compare/v0.2.0...HEAD)
|
8
8
|
|
9
|
-
## [0.
|
9
|
+
## [0.2.0](https://github.com/learningtapestry/lt-lcms/compare/v0.1.1...v0.2.0) - 2020-10-15
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- Add support for Google Shared Drives ([#7](https://github.com/learningtapestry/lt-google-api/pull/7))
|
14
|
+
|
15
|
+
## [0.1.1](https://github.com/learningtapestry/lt-lcms/compare/v0.1.0...v0.1.1) - 2020-01-13
|
10
16
|
|
11
17
|
### Added
|
12
18
|
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
lt-google-api (0.1.1)
|
5
|
+
google-api-client
|
6
|
+
googleauth
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.7.0)
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
13
|
+
ast (2.4.1)
|
14
|
+
childprocess (4.0.0)
|
15
|
+
declarative (0.0.20)
|
16
|
+
declarative-option (0.1.0)
|
17
|
+
faraday (1.0.1)
|
18
|
+
multipart-post (>= 1.2, < 3)
|
19
|
+
google-api-client (0.46.1)
|
20
|
+
addressable (~> 2.5, >= 2.5.1)
|
21
|
+
googleauth (~> 0.9)
|
22
|
+
httpclient (>= 2.8.1, < 3.0)
|
23
|
+
mini_mime (~> 1.0)
|
24
|
+
representable (~> 3.0)
|
25
|
+
retriable (>= 2.0, < 4.0)
|
26
|
+
rexml
|
27
|
+
signet (~> 0.12)
|
28
|
+
googleauth (0.14.0)
|
29
|
+
faraday (>= 0.17.3, < 2.0)
|
30
|
+
jwt (>= 1.4, < 3.0)
|
31
|
+
memoist (~> 0.16)
|
32
|
+
multi_json (~> 1.11)
|
33
|
+
os (>= 0.9, < 2.0)
|
34
|
+
signet (~> 0.14)
|
35
|
+
httpclient (2.8.3)
|
36
|
+
iniparse (1.5.0)
|
37
|
+
jwt (2.2.2)
|
38
|
+
memoist (0.16.2)
|
39
|
+
mini_mime (1.0.2)
|
40
|
+
multi_json (1.15.0)
|
41
|
+
multipart-post (2.1.1)
|
42
|
+
os (1.1.1)
|
43
|
+
overcommit (0.57.0)
|
44
|
+
childprocess (>= 0.6.3, < 5)
|
45
|
+
iniparse (~> 1.4)
|
46
|
+
parallel (1.19.2)
|
47
|
+
parser (2.7.2.0)
|
48
|
+
ast (~> 2.4.1)
|
49
|
+
public_suffix (4.0.6)
|
50
|
+
rainbow (3.0.0)
|
51
|
+
rake (13.0.1)
|
52
|
+
regexp_parser (1.8.2)
|
53
|
+
representable (3.0.4)
|
54
|
+
declarative (< 0.1.0)
|
55
|
+
declarative-option (< 0.2.0)
|
56
|
+
uber (< 0.2.0)
|
57
|
+
retriable (3.1.2)
|
58
|
+
rexml (3.2.4)
|
59
|
+
rubocop (0.93.1)
|
60
|
+
parallel (~> 1.10)
|
61
|
+
parser (>= 2.7.1.5)
|
62
|
+
rainbow (>= 2.2.2, < 4.0)
|
63
|
+
regexp_parser (>= 1.8)
|
64
|
+
rexml
|
65
|
+
rubocop-ast (>= 0.6.0)
|
66
|
+
ruby-progressbar (~> 1.7)
|
67
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
68
|
+
rubocop-ast (0.8.0)
|
69
|
+
parser (>= 2.7.1.5)
|
70
|
+
ruby-progressbar (1.10.1)
|
71
|
+
signet (0.14.0)
|
72
|
+
addressable (~> 2.3)
|
73
|
+
faraday (>= 0.17.3, < 2.0)
|
74
|
+
jwt (>= 1.5, < 3.0)
|
75
|
+
multi_json (~> 1.10)
|
76
|
+
uber (0.1.0)
|
77
|
+
unicode-display_width (1.7.0)
|
78
|
+
|
79
|
+
PLATFORMS
|
80
|
+
ruby
|
81
|
+
|
82
|
+
DEPENDENCIES
|
83
|
+
bundler (~> 1.16)
|
84
|
+
lt-google-api!
|
85
|
+
overcommit (~> 0.57)
|
86
|
+
rake (~> 13)
|
87
|
+
rubocop (~> 0.93.1)
|
88
|
+
|
89
|
+
BUNDLED WITH
|
90
|
+
1.17.3
|
data/lib/lt/google/api/drive.rb
CHANGED
@@ -4,7 +4,7 @@ module Lt
|
|
4
4
|
module Google
|
5
5
|
module Api
|
6
6
|
class Drive
|
7
|
-
FOLDER_RE = %r{/drive/(.*/)?folders/([
|
7
|
+
FOLDER_RE = %r{/drive/(.*/)?folders/([^/?]+)/?}.freeze
|
8
8
|
MIME_FILE = 'application/vnd.google-apps.document'
|
9
9
|
MIME_FOLDER = 'application/vnd.google-apps.folder'
|
10
10
|
|
@@ -31,11 +31,15 @@ module Lt
|
|
31
31
|
|
32
32
|
def copy(file_ids, folder_id)
|
33
33
|
file_ids.each do |id|
|
34
|
-
service.get_file(id, fields: 'name') do |f, err|
|
34
|
+
service.get_file(id, fields: 'name', supports_all_drives: true) do |f, err|
|
35
35
|
if err.present?
|
36
36
|
Rails.logger.error "Failed to get file with #{id}, #{err.message}"
|
37
37
|
else
|
38
|
-
service.copy_file(
|
38
|
+
service.copy_file(
|
39
|
+
id,
|
40
|
+
Google::Apis::DriveV3::File.new(name: f.name, parents: [folder_id]),
|
41
|
+
supports_all_drives: true
|
42
|
+
)
|
39
43
|
end
|
40
44
|
end
|
41
45
|
end
|
@@ -50,7 +54,7 @@ module Lt
|
|
50
54
|
current_files.each do |file|
|
51
55
|
next if new_files.detect { |f| f.name == file.name }
|
52
56
|
|
53
|
-
service.delete_file(file.id)
|
57
|
+
service.delete_file(file.id, supports_all_drives: true)
|
54
58
|
end
|
55
59
|
|
56
60
|
new_files.each do |file|
|
@@ -59,7 +63,7 @@ module Lt
|
|
59
63
|
|
60
64
|
# copy if it's a new file
|
61
65
|
new_file = Google::Apis::DriveV3::File.new(name: file.name, parents: [target_id])
|
62
|
-
service.copy_file(file.id, new_file)
|
66
|
+
service.copy_file(file.id, new_file, supports_all_drives: true)
|
63
67
|
end
|
64
68
|
end
|
65
69
|
|
@@ -73,7 +77,7 @@ module Lt
|
|
73
77
|
mime_type: MIME_FOLDER,
|
74
78
|
parents: [parent_id]
|
75
79
|
)
|
76
|
-
service.create_file(metadata)&.id
|
80
|
+
service.create_file(metadata, supports_all_drives: true)&.id
|
77
81
|
end
|
78
82
|
|
79
83
|
def list_file_ids_in(folder_id, mime_type: MIME_FILE, with_subfolders: true)
|
@@ -104,7 +108,8 @@ module Lt
|
|
104
108
|
def fetch_folders(name, folder_id)
|
105
109
|
service.list_files(
|
106
110
|
q: "'#{folder_id}' in parents and name = '#{name}' and mimeType = '#{MIME_FOLDER}' and trashed = false",
|
107
|
-
fields: 'files(id)'
|
111
|
+
fields: 'files(id)',
|
112
|
+
supports_all_drives: true
|
108
113
|
)&.files
|
109
114
|
end
|
110
115
|
|
@@ -113,7 +118,8 @@ module Lt
|
|
113
118
|
def list(folder_id)
|
114
119
|
service.list_files(
|
115
120
|
q: "'#{folder_id}' in parents and mimeType = '#{MIME_FILE}' and trashed = false",
|
116
|
-
fields: 'files(id, name)'
|
121
|
+
fields: 'files(id, name)',
|
122
|
+
supports_all_drives: true
|
117
123
|
)&.files
|
118
124
|
end
|
119
125
|
end
|
data/lt-google-api.gemspec
CHANGED
@@ -15,6 +15,8 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
15
15
|
spec.description = ''
|
16
16
|
spec.license = 'Apache-2.0'
|
17
17
|
|
18
|
+
spec.required_ruby_version = '>= 2.6'
|
19
|
+
|
18
20
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
21
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
20
22
|
if spec.respond_to?(:metadata)
|
@@ -35,8 +37,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
35
37
|
spec.add_dependency 'googleauth'
|
36
38
|
|
37
39
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
38
|
-
spec.add_development_dependency '
|
39
|
-
spec.add_development_dependency '
|
40
|
-
spec.add_development_dependency '
|
41
|
-
spec.add_development_dependency 'rubocop', '~> 0.59.2'
|
40
|
+
spec.add_development_dependency 'overcommit', '~> 0.57'
|
41
|
+
spec.add_development_dependency 'rake', '~> 13'
|
42
|
+
spec.add_development_dependency 'rubocop', '~> 0.93.1'
|
42
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lt-google-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Kuznetsov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-api-client
|
@@ -52,62 +52,48 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.16'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: bundler-audit
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: overcommit
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - "~>"
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
61
|
+
version: '0.57'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
66
|
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
68
|
+
version: '0.57'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: rake
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
73
|
- - "~>"
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
75
|
+
version: '13'
|
90
76
|
type: :development
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
82
|
+
version: '13'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: rubocop
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - "~>"
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
89
|
+
version: 0.93.1
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
94
|
- - "~>"
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
96
|
+
version: 0.93.1
|
111
97
|
description: ''
|
112
98
|
email:
|
113
99
|
- alexander@learningtapeestry.com
|
@@ -117,6 +103,7 @@ extensions: []
|
|
117
103
|
extra_rdoc_files: []
|
118
104
|
files:
|
119
105
|
- ".codeclimate.yml"
|
106
|
+
- ".github/workflows/rubocop-analysis.yml"
|
120
107
|
- ".gitignore"
|
121
108
|
- ".overcommit.yml"
|
122
109
|
- ".rubocop.yml"
|
@@ -124,6 +111,7 @@ files:
|
|
124
111
|
- ".ruby-version"
|
125
112
|
- CHANGELOG.md
|
126
113
|
- Gemfile
|
114
|
+
- Gemfile.lock
|
127
115
|
- LICENSE
|
128
116
|
- README.md
|
129
117
|
- Rakefile
|
@@ -142,7 +130,7 @@ licenses:
|
|
142
130
|
- Apache-2.0
|
143
131
|
metadata:
|
144
132
|
allowed_push_host: https://rubygems.org
|
145
|
-
post_install_message:
|
133
|
+
post_install_message:
|
146
134
|
rdoc_options: []
|
147
135
|
require_paths:
|
148
136
|
- lib
|
@@ -150,7 +138,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
138
|
requirements:
|
151
139
|
- - ">="
|
152
140
|
- !ruby/object:Gem::Version
|
153
|
-
version: '
|
141
|
+
version: '2.6'
|
154
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
143
|
requirements:
|
156
144
|
- - ">="
|
@@ -158,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
146
|
version: '0'
|
159
147
|
requirements: []
|
160
148
|
rubygems_version: 3.0.6
|
161
|
-
signing_key:
|
149
|
+
signing_key:
|
162
150
|
specification_version: 4
|
163
151
|
summary: Provides the set of classes to simplify work with Google services
|
164
152
|
test_files: []
|