sdr-client 0.54.0 → 0.58.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: 9375d3bf71081aaff025a3764f1243af12e4e323fd919ebef214aeb6033fb293
4
- data.tar.gz: ecd3081f5f90861b3c59eddeb13b053db1d954c54d7495f2f015ffbbff7aa4cd
3
+ metadata.gz: d0aeb8a257ee16931c449f5255f927b242fa1c9893303ae3b76feefa433adb24
4
+ data.tar.gz: b00a06552dcff58238a57e2f13b500f48960861daf4567490d567d5598b01415
5
5
  SHA512:
6
- metadata.gz: '0907a883ccaab8795077b8d5b077d7c71ae956d939867cbfaf801baf95116ea619a18f62de962c8d9d346d8e8df8f0f4852ad59b3474f0eabe702b3a4951aabf'
7
- data.tar.gz: 61b65826d6aaf4aac4db476ccc5978c353c2c8694ea71552debe5469df182538a26248a11fc3eee110b08ebf6fbd696b9503e4fc0517ea4eb2c7008b0d693618
6
+ metadata.gz: 045fa4dd33fce4c171c27dea01e0cbb12de8d91408eff404b2121f68690018549d26d6a43cb9792a8cae56f4953353952e0301b8b3a802215bc23d9ad7d2d730
7
+ data.tar.gz: c15e6aecf2652ce4eb42f1433d3baab4d2cf7605e3e1f60a9b1ed5c5c8a4d7069c8f76ca9aa594741535b6bb3177582375d28280617f7c1096820cb344e3bf9d
data/.rubocop.yml CHANGED
@@ -13,6 +13,10 @@ Metrics/BlockLength:
13
13
  ExcludedMethods:
14
14
  - 'OptionParser.new'
15
15
 
16
+ Metrics/ClassLength:
17
+ Exclude:
18
+ - 'lib/sdr_client/deposit/request.rb'
19
+
16
20
  Naming/FileName:
17
21
  Exclude:
18
22
  - 'lib/sdr-client.rb'
data/.rubocop_todo.yml CHANGED
@@ -1,19 +1,33 @@
1
1
  # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2021-03-12 13:21:16 -0600 using RuboCop version 0.79.0.
2
+ # `rubocop --auto-gen-config --auto-gen-only-exclude`
3
+ # on 2021-04-15 12:18:21 -0700 using RuboCop version 0.79.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
9
  # Offense count: 1
10
+ # Configuration parameters: Max.
10
11
  Metrics/AbcSize:
11
- Max: 16
12
+ Exclude:
13
+ - 'lib/sdr_client/deposit/model_process.rb'
14
+
15
+ # Offense count: 1
16
+ # Configuration parameters: Max.
17
+ Metrics/CyclomaticComplexity:
18
+ Exclude:
19
+ - 'lib/sdr_client/cli.rb'
12
20
 
13
21
  # Offense count: 9
14
- # Configuration parameters: CountComments, ExcludedMethods.
22
+ # Configuration parameters: CountComments, Max, ExcludedMethods.
15
23
  Metrics/MethodLength:
16
- Max: 15
24
+ Exclude:
25
+ - 'lib/sdr_client/cli.rb'
26
+ - 'lib/sdr_client/deposit/file.rb'
27
+ - 'lib/sdr_client/deposit/model_process.rb'
28
+ - 'lib/sdr_client/deposit/process.rb'
29
+ - 'lib/sdr_client/deposit/request.rb'
30
+ - 'lib/sdr_client/login.rb'
17
31
 
18
32
  # Offense count: 231
19
33
  # Cop supports --auto-correct.
data/README.md CHANGED
@@ -51,3 +51,8 @@ View the object:
51
51
  sdr --service-url https://sdr-api-server:3000 get druid:bw581ng3176
52
52
  {"type":"http://cocina.sul.stanford.edu/models/document.jsonld","externalIdentifier":"druid:bw581ng3176","label":"Something something better title","version":1,"access":{"access":"stanford","copyright":"This work is copyrighted by the creator.","download":"stanford","useAndReproductionStatement":"This document is available only to the Stanford faculty, staff and student community."},"administrative":{"hasAdminPolicy":"druid:zx485kb6348"},"description":{"title":[{"value":"Something something better title"}],"contributor":[{"name":[{"value":"Hodge, Amy"}],"type":"person","role":[{"value":"Author"},{"value":"author","uri":"http://id.loc.gov/vocabulary/relators/aut","source":{"code":"marcrelator","uri":"http://id.loc.gov/vocabulary/relators/"}},{"value":"Creator"}]}],"form":[{"structuredValue":[{"value":"Text","type":"type"},{"value":"Report","type":"subtype"}],"type":"resource type","source":{"value":"Stanford self-deposit resource types"}},{"value":"reports","type":"genre","uri":"http://vocab.getty.edu/aat/300027267","source":{"code":"aat"}},{"value":"text","type":"resource type","source":{"value":"MODS resource types"}}],"note":[{"value":";alkdfjlsadkjf;l","type":"summary"},{"value":"amyhodge@stanford.edu","type":"contact","displayLabel":"Contact"}],"subject":[{"value":"lkfj","type":"topic"},{"value":";kfj","type":"topic"},{"value":"fjwelkb","type":"topic"}]},"identification":{"sourceId":"hydrus:20"},"structural":{"contains":[{"type":"http://cocina.sul.stanford.edu/models/resources/file.jsonld","externalIdentifier":"bw581ng3176_1","label":"Test file","version":1,"structural":{"contains":[{"type":"http://cocina.sul.stanford.edu/models/file.jsonld","externalIdentifier":"druid:bw581ng3176/test.txt","label":"test.txt","filename":"test.txt","size":11,"version":1,"hasMimeType":"text/plain","hasMessageDigests":[{"type":"sha1","digest":"5d39343e4bb48abd97f759828282f5ebbac56c5e"},{"type":"md5","digest":"63b8812b0c05722a9d6c51cbd2bfb54b"}],"access":{"access":"world","download":"world"},"administrative":{"sdrPreserve":true,"shelve":true}}]}}]}}
53
53
  ```
54
+
55
+ Display version of sdr-client:
56
+ ```
57
+ sdr version
58
+ ```
data/exe/sdr CHANGED
@@ -19,9 +19,6 @@ end
19
19
  global.order!
20
20
  command = ARGV.shift
21
21
 
22
- retrieve_options = OptionParser.new do |opts|
23
- end
24
-
25
22
  deposit_options = OptionParser.new do |opts|
26
23
  opts.banner = "Usage: sdr #{command} [options]"
27
24
  opts.on('--label LABEL', 'The object label') do |label|
@@ -97,10 +94,11 @@ end
97
94
  SdrClient::CLI.help unless command
98
95
 
99
96
  subcommands = {
100
- 'get' => retrieve_options,
97
+ 'get' => OptionParser.new,
101
98
  'deposit' => deposit_options,
102
99
  'register' => deposit_options,
103
- 'login' => OptionParser.new
100
+ 'login' => OptionParser.new,
101
+ 'version' => OptionParser.new
104
102
  }
105
103
 
106
104
  unless subcommands.key?(command)
@@ -35,6 +35,9 @@ module SdrClient
35
35
  login
36
36
  Will prompt for email & password and exchange it for an login token, which it saves in ~/.sdr/token
37
37
 
38
+ version
39
+ Display the sdr-client version
40
+
38
41
  HELP
39
42
 
40
43
  def self.start(command, options, arguments = [])
@@ -46,6 +49,8 @@ module SdrClient
46
49
  when 'login'
47
50
  status = SdrClient::Login.run(options)
48
51
  puts status.failure if status.failure?
52
+ when 'version'
53
+ puts SdrClient::VERSION
49
54
  else
50
55
  raise "Unknown command #{command}"
51
56
  end
@@ -21,6 +21,7 @@ module SdrClient
21
21
  catkey: nil,
22
22
  embargo_release_date: nil,
23
23
  embargo_access: 'world',
24
+ embargo_download: 'world',
24
25
  source_id:,
25
26
  url:,
26
27
  files: [],
@@ -41,6 +42,7 @@ module SdrClient
41
42
  catkey: catkey,
42
43
  embargo_release_date: embargo_release_date,
43
44
  embargo_access: embargo_access,
45
+ embargo_download: embargo_download,
44
46
  viewing_direction: viewing_direction,
45
47
  files_metadata: augmented_metadata)
46
48
  connection = Connection.new(url: url)
@@ -39,7 +39,9 @@ module SdrClient
39
39
  json = metadata.to_json
40
40
  logger.debug("Starting upload metadata: #{json}")
41
41
 
42
- connection.post(path, json, 'Content-Type' => 'application/json')
42
+ connection.post(path, json,
43
+ 'Content-Type' => 'application/json',
44
+ 'X-Cocina-Models-Version' => Cocina::Models::VERSION)
43
45
  end
44
46
 
45
47
  def accession?
@@ -6,15 +6,16 @@ module SdrClient
6
6
  class File
7
7
  # rubocop:disable Metrics/ParameterLists
8
8
  def initialize(external_identifier:, label:, filename:,
9
- access: 'world', preserve: true, shelve: true,
9
+ access: 'dark', download: 'none', preserve: true, shelve: true,
10
10
  publish: true, mime_type: nil, md5: nil, sha1: nil,
11
11
  use: nil)
12
12
  @external_identifier = external_identifier
13
13
  @label = label
14
14
  @filename = filename
15
15
  @access = access
16
+ @download = download
16
17
  @preserve = preserve
17
- @shelve = shelve
18
+ @shelve = access == 'dark' ? false : shelve
18
19
  @publish = publish
19
20
  @mime_type = mime_type
20
21
  @md5 = md5
@@ -23,7 +24,6 @@ module SdrClient
23
24
  end
24
25
  # rubocop:enable Metrics/ParameterLists
25
26
 
26
- # rubocop:disable Metrics/MethodLength
27
27
  def as_json
28
28
  {
29
29
  "type": 'http://cocina.sul.stanford.edu/models/file.jsonld',
@@ -31,7 +31,8 @@ module SdrClient
31
31
  filename: @filename,
32
32
  externalIdentifier: @external_identifier,
33
33
  access: {
34
- access: @access
34
+ access: @access,
35
+ download: @download
35
36
  },
36
37
  administrative: {
37
38
  sdrPreserve: @preserve,
@@ -45,7 +46,6 @@ module SdrClient
45
46
  json['use'] = @use if @use
46
47
  end
47
48
  end
48
- # rubocop:enable Metrics/MethodLength
49
49
 
50
50
  private
51
51
 
@@ -5,7 +5,7 @@ module SdrClient
5
5
  # This represents the FileSet metadata that we send to the server for doing a deposit
6
6
  class FileSet
7
7
  # @param [Array] uploads
8
- # @param [Hash<String,Hash<String,String>>] the file level metadata
8
+ # @param [Hash<String,Hash<String,String>>] uploads_metadata the file level metadata
9
9
  # @param [Array] files
10
10
  # @param [String] label
11
11
  def initialize(uploads: [], uploads_metadata: {}, files: [], label:)
@@ -12,6 +12,7 @@ module SdrClient
12
12
  # @param [Hash<String, Hash<String, String>>] files_metadata file name, hash of additional file metadata
13
13
  # Additional metadata includes access, preserve, shelve, publish, md5, sha1
14
14
  # rubocop:disable Metrics/ParameterLists
15
+ # rubocop:disable Metrics/AbcSize
15
16
  def initialize(label: nil,
16
17
  access: 'dark',
17
18
  download: 'none',
@@ -23,6 +24,7 @@ module SdrClient
23
24
  catkey: nil,
24
25
  embargo_release_date: nil,
25
26
  embargo_access: 'world',
27
+ embargo_download: 'world',
26
28
  type: 'http://cocina.sul.stanford.edu/models/object.jsonld',
27
29
  viewing_direction: nil,
28
30
  file_sets: [],
@@ -34,6 +36,7 @@ module SdrClient
34
36
  @catkey = catkey
35
37
  @embargo_release_date = embargo_release_date
36
38
  @embargo_access = embargo_access
39
+ @embargo_download = embargo_download
37
40
  @access = access
38
41
  @download = download
39
42
  @use_statement = use_statement
@@ -44,6 +47,7 @@ module SdrClient
44
47
  @viewing_direction = viewing_direction
45
48
  end
46
49
  # rubocop:enable Metrics/ParameterLists
50
+ # rubocop:enable Metrics/AbcSize
47
51
 
48
52
  def as_json
49
53
  {
@@ -58,6 +62,7 @@ module SdrClient
58
62
  end
59
63
 
60
64
  # @return [Request] a clone of this request with the file_sets added
65
+ # rubocop:disable Metrics/AbcSize
61
66
  def with_file_sets(file_sets)
62
67
  Request.new(label: label,
63
68
  access: access,
@@ -69,17 +74,22 @@ module SdrClient
69
74
  catkey: catkey,
70
75
  embargo_release_date: embargo_release_date,
71
76
  embargo_access: embargo_access,
77
+ embargo_download: embargo_download,
72
78
  type: type,
73
79
  use_statement: use_statement,
74
80
  viewing_direction: viewing_direction,
75
81
  file_sets: file_sets,
76
82
  files_metadata: files_metadata)
77
83
  end
84
+ # rubocop:enable Metrics/AbcSize
78
85
 
79
86
  # @param [String] filename
80
87
  # @return [Hash] the metadata for the file
81
88
  def for(filename)
82
- files_metadata.fetch(filename, {})
89
+ metadata = files_metadata.fetch(filename, {}).with_indifferent_access
90
+ metadata[:access] = access unless metadata.key?(:access)
91
+ metadata[:download] = download unless metadata.key?(:download)
92
+ metadata
83
93
  end
84
94
 
85
95
  attr_reader :type
@@ -87,7 +97,7 @@ module SdrClient
87
97
  private
88
98
 
89
99
  attr_reader :access, :label, :file_sets, :source_id, :catkey, :apo, :collection,
90
- :files_metadata, :embargo_release_date, :embargo_access,
100
+ :files_metadata, :embargo_release_date, :embargo_access, :embargo_download,
91
101
  :viewing_direction, :use_statement, :copyright, :download
92
102
 
93
103
  def administrative
@@ -121,7 +131,8 @@ module SdrClient
121
131
  if embargo_release_date
122
132
  json[:embargo] = {
123
133
  releaseDate: embargo_release_date.strftime('%FT%T%:z'),
124
- access: embargo_access
134
+ access: embargo_access,
135
+ download: embargo_download
125
136
  }
126
137
  end
127
138
  end
@@ -37,7 +37,9 @@ module SdrClient
37
37
  json = metadata.to_json
38
38
  logger.debug("Starting upload metadata: #{json}")
39
39
 
40
- connection.put(path(metadata), json, 'Content-Type' => 'application/json')
40
+ connection.put(path(metadata), json,
41
+ 'Content-Type' => 'application/json',
42
+ 'X-Cocina-Models-Version' => Cocina::Models::VERSION)
41
43
  end
42
44
 
43
45
  def path(metadata)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SdrClient
4
- VERSION = '0.54.0'
4
+ VERSION = '0.58.0'
5
5
  end
data/sdr-client.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ['lib']
29
29
 
30
30
  spec.add_dependency 'activesupport'
31
- spec.add_dependency 'cocina-models', '~> 0.57.0'
31
+ spec.add_dependency 'cocina-models', '~> 0.61.0'
32
32
  spec.add_dependency 'dry-monads'
33
33
  spec.add_dependency 'faraday', '>= 0.16'
34
34
 
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.54.0
4
+ version: 0.58.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-30 00:00:00.000000000 Z
11
+ date: 2021-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.57.0
33
+ version: 0.61.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.57.0
40
+ version: 0.61.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: dry-monads
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -224,7 +224,7 @@ metadata:
224
224
  homepage_uri: https://github.com/sul-dlss/sdr-client
225
225
  source_code_uri: https://github.com/sul-dlss/sdr-client
226
226
  changelog_uri: https://github.com/sul-dlss/sdr-client/releases
227
- post_install_message:
227
+ post_install_message:
228
228
  rdoc_options: []
229
229
  require_paths:
230
230
  - lib
@@ -239,8 +239,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  - !ruby/object:Gem::Version
240
240
  version: '0'
241
241
  requirements: []
242
- rubygems_version: 3.0.6
243
- signing_key:
242
+ rubygems_version: 3.1.4
243
+ signing_key:
244
244
  specification_version: 4
245
245
  summary: The CLI for https://github.com/sul-dlss/sdr-api
246
246
  test_files: []