sdr-client 0.55.1 → 0.56.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: 6bbde1ddcec86f8c2368ce9b336dae6dc1f52dbcf774bd0e51df25f2ffb15256
4
- data.tar.gz: 73b363c29c6b51383379eee5772eaf28b87ab98be850a848194a73986ba91d2c
3
+ metadata.gz: 335b17d92fb6fc1987038e7837b751ca4c918b4bfb3510e6738e763191416aa4
4
+ data.tar.gz: db5ef06226d88fdab05db520a5402ce3606e119147386d7fcc1e52027bb0f1b0
5
5
  SHA512:
6
- metadata.gz: dbfa9a16a0f897543c93efd08c5fc85de429cfa6457c0ba460361572f403c3b646bafed431eaa431e96ade03d5fe1c2ade8b62e08185df23069818bdb41e8e63
7
- data.tar.gz: aa384461001ec16966c6287c9e595005d80a3e9a19c783b1793726ed7551190b4983fca8289f41bb9b2f336332b3732fea64d295249d5338664b593617876ba8
6
+ metadata.gz: da2726c5a061d58185d32ba50d7a17073a8ad35cb4db9469875895a60374fbab96d07df007c684078589ba3efb85d2b6590a60de6cd3164fd41d26746e71392c
7
+ data.tar.gz: e1a60e9dec9cb2d6b32788f87da85f9667b00cb4b2a6ec592c83acff1508eb6f6842ed8befc2915714e822e8d8190320a85e397c50f751a114db546cfb640eff
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,13 +6,14 @@ 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
18
  @shelve = shelve
18
19
  @publish = publish
@@ -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
 
@@ -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.55.1'
4
+ VERSION = '0.56.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.58.1'
31
+ spec.add_dependency 'cocina-models', '~> 0.59.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.55.1
4
+ version: 0.56.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: 2021-03-31 00:00:00.000000000 Z
11
+ date: 2021-04-21 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.58.1
33
+ version: 0.59.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.58.1
40
+ version: 0.59.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: dry-monads
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -239,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  - !ruby/object:Gem::Version
240
240
  version: '0'
241
241
  requirements: []
242
- rubygems_version: 3.1.4
242
+ rubygems_version: 3.0.3
243
243
  signing_key:
244
244
  specification_version: 4
245
245
  summary: The CLI for https://github.com/sul-dlss/sdr-api