sdr-client 0.13.1 → 0.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e15faf788690b47e50e64e7af7ff83dcf048022e86a1456d440d82bf9ac52b9
4
- data.tar.gz: a0d50861d360ef14016a98a944b76d3b95e0aa2655b90b5ee2ce0559d63b641a
3
+ metadata.gz: 4fbf18f89def752a295fe6004aef3a08aed6809d023041aad877619a8309865f
4
+ data.tar.gz: 608e8c9670b3c929f8a7639c20ed34f4b924f561aed295a42162620ef007d146
5
5
  SHA512:
6
- metadata.gz: 0f4affedfd3e35fc4374f02a954bd1be820cb317b4b47cb741ba2acf650eece79eeadf34f404df73b60495c16d34a43103845dc28ce9cacfc9a8722f8d12a863
7
- data.tar.gz: 78c3eea15dca5e75dbd70022a871214376b9fe9ca84cea7bbb9b0c2adacbe56f365f3aaf0fda7e4f8c010d6a399609b1576261636913891d05a13659bf5efbe7
6
+ metadata.gz: 65633ede9a98646d7e722a6b7d42c761c2a8bc04aec21010ba7187ccfdd3fc5ebd79781140f566b0733a2cb9b87c1f0d14f2cf05de3a483dc45d2ea9fa3c6ed5
7
+ data.tar.gz: 752f5ce61da771161af8e66e7e0f2ad98ba9e2b6cdf406aa4f82cbf35d9b3ca77926fc5a3a4615393abe67aebd0368342f93145b6137b0f212e9611c39fd5c4c
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-01-10 17:16:01 -0600 using RuboCop version 0.79.0.
3
+ # on 2020-03-02 15:54:47 -0600 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
@@ -10,7 +10,7 @@
10
10
  Metrics/AbcSize:
11
11
  Max: 16
12
12
 
13
- # Offense count: 1
13
+ # Offense count: 4
14
14
  # Configuration parameters: CountComments, ExcludedMethods.
15
15
  Metrics/MethodLength:
16
- Max: 13
16
+ Max: 14
data/exe/sdr CHANGED
@@ -70,11 +70,24 @@ subcommands = {
70
70
  options[:source_id] = source_id
71
71
  end
72
72
 
73
+ opts.on('--copyright COPYRIGHT', 'The copyright statement') do |copyright|
74
+ options[:copyright] = copyright
75
+ end
76
+
77
+ opts.on('--use-statement STATEMENT', 'The use and reproduction statement') do |use_statement|
78
+ options[:use_statement] = use_statement
79
+ end
80
+
73
81
  opts.on('--viewing-direction DIRECTION', 'The viewing direction (if a book). ' \
74
82
  'Either "left-to-right" or "right-to-left"') do |viewing_direction|
75
83
  options[:viewing_direction] = viewing_direction if %w[left-to-right right-to-left].include?(viewing_direction)
76
84
  end
77
85
 
86
+ opts.on('--access LEVEL', 'The access level for this object. ' \
87
+ 'Either "world", "stanford", "location-based", "citation-only" or "dark"') do |level|
88
+ options[:access] = level if %w[world stanford location-based citation-only dark].include?(level)
89
+ end
90
+
78
91
  opts.on('--files-metadata FILES_METADATA', 'A JSON object representing per-file metadata') do |files_metadata|
79
92
  options[:files_metadata] = JSON.parse(files_metadata)
80
93
  end
@@ -6,9 +6,13 @@ module SdrClient
6
6
  # The namespace for the "deposit" command
7
7
  module Deposit
8
8
  # rubocop:disable Metrics/ParameterLists
9
+ # rubocop:disable Metrics/MethodLength
9
10
  def self.run(label: nil,
10
11
  type: 'http://cocina.sul.stanford.edu/models/book.jsonld',
11
12
  viewing_direction: nil,
13
+ access: 'dark',
14
+ use_statement: nil,
15
+ copyright: nil,
12
16
  apo:,
13
17
  collection: nil,
14
18
  catkey: nil,
@@ -24,7 +28,10 @@ module SdrClient
24
28
 
25
29
  metadata = Request.new(label: label,
26
30
  type: type,
31
+ access: access,
27
32
  apo: apo,
33
+ use_statement: use_statement,
34
+ copyright: copyright,
28
35
  collection: collection,
29
36
  source_id: source_id,
30
37
  catkey: catkey,
@@ -35,6 +42,7 @@ module SdrClient
35
42
  Process.new(metadata: metadata, url: url, token: token, files: files,
36
43
  grouping_strategy: grouping_strategy, logger: logger).run
37
44
  end
45
+ # rubocop:enable Metrics/MethodLength
38
46
  # rubocop:enable Metrics/ParameterLists
39
47
  end
40
48
  end
@@ -65,7 +65,7 @@ module SdrClient
65
65
  raise "There was an error with your request: #{response.body}" if response.status == 400
66
66
  raise 'There was an error with your credentials. Perhaps they have expired?' if response.status == 401
67
67
 
68
- raise "unexpected response: #{response.inspect}"
68
+ raise "unexpected response: #{response.status} #{response.body}"
69
69
  end
70
70
 
71
71
  def connection
@@ -13,6 +13,9 @@ module SdrClient
13
13
  # Additional metadata includes access, preserve, shelve, md5, sha1
14
14
  # rubocop:disable Metrics/ParameterLists
15
15
  def initialize(label: nil,
16
+ access: 'dark',
17
+ use_statement: nil,
18
+ copyright: nil,
16
19
  apo:,
17
20
  collection: nil,
18
21
  source_id:,
@@ -30,6 +33,9 @@ module SdrClient
30
33
  @catkey = catkey
31
34
  @embargo_release_date = embargo_release_date
32
35
  @embargo_access = embargo_access
36
+ @access = access
37
+ @use_statement = use_statement
38
+ @copyright = copyright
33
39
  @apo = apo
34
40
  @file_sets = file_sets
35
41
  @files_metadata = files_metadata
@@ -39,7 +45,7 @@ module SdrClient
39
45
 
40
46
  def as_json
41
47
  {
42
- access: access,
48
+ access: access_struct,
43
49
  type: type,
44
50
  administrative: administrative,
45
51
  identification: identification,
@@ -52,13 +58,16 @@ module SdrClient
52
58
  # @return [Request] a clone of this request with the file_sets added
53
59
  def with_file_sets(file_sets)
54
60
  Request.new(label: label,
61
+ access: access,
55
62
  apo: apo,
56
63
  collection: collection,
64
+ copyright: copyright,
57
65
  source_id: source_id,
58
66
  catkey: catkey,
59
67
  embargo_release_date: embargo_release_date,
60
68
  embargo_access: embargo_access,
61
69
  type: type,
70
+ use_statement: use_statement,
62
71
  viewing_direction: viewing_direction,
63
72
  file_sets: file_sets,
64
73
  files_metadata: files_metadata)
@@ -72,9 +81,9 @@ module SdrClient
72
81
 
73
82
  private
74
83
 
75
- attr_reader :label, :file_sets, :source_id, :catkey, :apo, :collection,
84
+ attr_reader :access, :label, :file_sets, :source_id, :catkey, :apo, :collection,
76
85
  :type, :files_metadata, :embargo_release_date, :embargo_access,
77
- :viewing_direction
86
+ :viewing_direction, :use_statement, :copyright
78
87
 
79
88
  def administrative
80
89
  {
@@ -96,8 +105,11 @@ module SdrClient
96
105
  end
97
106
  end
98
107
 
99
- def access
100
- {}.tap do |json|
108
+ def access_struct
109
+ { access: access }.tap do |json|
110
+ json[:useAndReproductionStatement] = use_statement if use_statement
111
+ json[:copyright] = copyright if copyright
112
+
101
113
  if embargo_release_date
102
114
  json[:embargo] = {
103
115
  releaseDate: embargo_release_date.strftime('%FT%T%:z'),
@@ -35,7 +35,7 @@ module SdrClient
35
35
  file_name = ::File.basename(path)
36
36
  obj[path] = Files::DirectUploadRequest.from_file(path,
37
37
  file_name: file_name,
38
- content_type: metadata.for(file_name)[:mime_type])
38
+ content_type: metadata.for(file_name)['mime_type'])
39
39
  end
40
40
  end
41
41
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SdrClient
4
- VERSION = '0.13.1'
4
+ VERSION = '0.15.2'
5
5
  end
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.13.1
4
+ version: 0.15.2
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-02-20 00:00:00.000000000 Z
11
+ date: 2020-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-monads