sdr-client 0.18.0 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sdr_client.rb +1 -0
- data/lib/sdr_client/connection.rb +24 -0
- data/lib/sdr_client/deposit.rb +2 -3
- data/lib/sdr_client/deposit/process.rb +5 -16
- data/lib/sdr_client/deposit/upload_files.rb +1 -1
- data/lib/sdr_client/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ae3d332b62dd4908555f961ffa5f9ebc12e0388836f36f855672731d8b940a1
|
4
|
+
data.tar.gz: 97c3c18fc7e4ed98b5577ea24390eef9f2ecbf8c24970c92fd3d3097a13b5492
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f03baa42607cd68d3b814e46df38dda0567ca78082292faaf5ec47dfe518b68e0399f25305a89bed835bf68cde2e680f553646b4c921490ae06c7e426a812c5f
|
7
|
+
data.tar.gz: d392e1bfda994e6266ca4e6e1834036e76a5cfd37008c6ceda87ed6c20d4cbae9becef1fe8f47e3631f824dae7ae883735e0718dec7161488763d891f9d57121
|
data/lib/sdr_client.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SdrClient
|
4
|
+
# The connection to the server
|
5
|
+
class Connection
|
6
|
+
def initialize(url:, token: Credentials.read)
|
7
|
+
@url = url
|
8
|
+
@token = token
|
9
|
+
end
|
10
|
+
|
11
|
+
def connection
|
12
|
+
@connection ||= Faraday.new(url: url) do |conn|
|
13
|
+
conn.authorization :Bearer, token
|
14
|
+
conn.adapter :net_http
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
delegate :put, :post, to: :connection
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
attr_reader :url, :token
|
23
|
+
end
|
24
|
+
end
|
data/lib/sdr_client/deposit.rb
CHANGED
@@ -25,8 +25,6 @@ module SdrClient
|
|
25
25
|
files_metadata: {},
|
26
26
|
grouping_strategy: SingleFileGroupingStrategy,
|
27
27
|
logger: Logger.new(STDOUT))
|
28
|
-
token = Credentials.read
|
29
|
-
|
30
28
|
augmented_metadata = FileMetadataBuilder.build(files: files, files_metadata: files_metadata)
|
31
29
|
metadata = Request.new(label: label,
|
32
30
|
type: type,
|
@@ -41,7 +39,8 @@ module SdrClient
|
|
41
39
|
embargo_access: embargo_access,
|
42
40
|
viewing_direction: viewing_direction,
|
43
41
|
files_metadata: augmented_metadata)
|
44
|
-
|
42
|
+
connection = Connection.new(url: url)
|
43
|
+
Process.new(metadata: metadata, connection: connection, files: files,
|
45
44
|
grouping_strategy: grouping_strategy, logger: logger).run
|
46
45
|
end
|
47
46
|
# rubocop:enable Metrics/MethodLength
|
@@ -9,21 +9,17 @@ module SdrClient
|
|
9
9
|
DRO_PATH = '/v1/resources'
|
10
10
|
# @param [Request] metadata information about the object
|
11
11
|
# @param [Class] grouping_strategy class whose run method groups an array of uploads
|
12
|
-
# @param [String]
|
13
|
-
# @param [String] token the bearer auth token for the server
|
12
|
+
# @param [String] connection the server connection to use
|
14
13
|
# @param [Array<String>] files a list of file names to upload
|
15
14
|
# @param [Logger] logger the logger to use
|
16
|
-
|
17
|
-
|
18
|
-
token:, files: [], logger: Logger.new(STDOUT))
|
15
|
+
def initialize(metadata:, grouping_strategy: SingleFileGroupingStrategy,
|
16
|
+
connection:, files: [], logger: Logger.new(STDOUT))
|
19
17
|
@files = files
|
20
|
-
@
|
21
|
-
@token = token
|
18
|
+
@connection = connection
|
22
19
|
@metadata = metadata
|
23
20
|
@logger = logger
|
24
21
|
@grouping_strategy = grouping_strategy
|
25
22
|
end
|
26
|
-
# rubocop:enable Metrics/ParameterLists
|
27
23
|
|
28
24
|
def run
|
29
25
|
check_files_exist
|
@@ -40,7 +36,7 @@ module SdrClient
|
|
40
36
|
|
41
37
|
private
|
42
38
|
|
43
|
-
attr_reader :metadata, :files, :
|
39
|
+
attr_reader :metadata, :files, :connection, :logger, :grouping_strategy
|
44
40
|
|
45
41
|
def check_files_exist
|
46
42
|
logger.info('checking to see if files exist')
|
@@ -68,13 +64,6 @@ module SdrClient
|
|
68
64
|
raise "unexpected response: #{response.status} #{response.body}"
|
69
65
|
end
|
70
66
|
|
71
|
-
def connection
|
72
|
-
@connection ||= Faraday.new(url: url) do |conn|
|
73
|
-
conn.authorization :Bearer, token
|
74
|
-
conn.adapter :net_http
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
67
|
def mime_types
|
79
68
|
@mime_types ||=
|
80
69
|
Hash[
|
@@ -9,7 +9,7 @@ module SdrClient
|
|
9
9
|
BLOB_PATH = '/v1/direct_uploads'
|
10
10
|
# @param [Array<String>] files a list of filepaths to upload
|
11
11
|
# @param [Logger] logger the logger to use
|
12
|
-
# @param [
|
12
|
+
# @param [Connection] connection
|
13
13
|
# @param [Hash<String,String] mime_types a map of filenames to mime types
|
14
14
|
def initialize(files:, mime_types:, logger:, connection:)
|
15
15
|
@files = files
|
data/lib/sdr_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sdr-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -189,6 +189,7 @@ files:
|
|
189
189
|
- lib/sdr-client.rb
|
190
190
|
- lib/sdr_client.rb
|
191
191
|
- lib/sdr_client/cli.rb
|
192
|
+
- lib/sdr_client/connection.rb
|
192
193
|
- lib/sdr_client/credentials.rb
|
193
194
|
- lib/sdr_client/deposit.rb
|
194
195
|
- lib/sdr_client/deposit/file.rb
|