datacite 0.8.5 → 0.8.6

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: 00f41bdc53e8f7aaa02f9f09e1dfe88edf480c12227f76fd8119b1ec261db326
4
- data.tar.gz: f99aa687067a3b5ed223916e1a10b52e14c2ccce291f79369db3308646034865
3
+ metadata.gz: 4673dab2c36b209696de4969fd06ef8ca6a85d6e0d14dc8b2455b85dd3ee83bb
4
+ data.tar.gz: 93f119fb2ca080a2fe664574310342ed4859bd82944eabff1932137acab66189
5
5
  SHA512:
6
- metadata.gz: 59c3b1b903a6b0288816db41213e6c0201863b8f94acf411e8851edd9717f14c1f4f3e54dd7ddfceeec762f113ff77d203b74971bee596ad22a916162dc0c49c
7
- data.tar.gz: ffa85b5ecf4d3042f98b3565ae4105ce08ef1c065fc622e5f38392cccd7e7548773344fa46d9ae4202f399ff848289420b04c79b4810ea949aa870de71d249ce
6
+ metadata.gz: 4a68baebbf3e4685a920c84d77846a20565b318be6e3fe528d11d4471eea02fa82e6dfd141c41aa4e78f546b4137034086d6e8061a7384a4d7898da6516b00a9
7
+ data.tar.gz: 53d018337e391ceeb366b0260fda2777595b1c618d8bbde7a43619d1338cc777c2d62a8e623c979bc20732c89bff8830c0ec8f81d5b10bfc88dabb7534ba4120
data/.rubocop.yml CHANGED
@@ -357,3 +357,48 @@ Style/RedundantArrayFlatten: # new in 1.76
357
357
  Enabled: true
358
358
  RSpec/IncludeExamples: # new in 3.6
359
359
  Enabled: true
360
+
361
+ Lint/DataDefineOverride: # new in 1.85
362
+ Enabled: true
363
+ Lint/DeprecatedReference: # new in 1.89
364
+ Enabled: true
365
+ Lint/NameTypo: # new in 1.89
366
+ Enabled: true
367
+ Lint/UnreachablePatternBranch: # new in 1.85
368
+ Enabled: true
369
+ Style/EmptyClassDefinition: # new in 1.84
370
+ Enabled: true
371
+ Style/FileOpen: # new in 1.85
372
+ Enabled: true
373
+ Style/MapJoin: # new in 1.85
374
+ Enabled: true
375
+ Style/ModuleMemberExistenceCheck: # new in 1.82
376
+ Enabled: true
377
+ Style/NegativeArrayIndex: # new in 1.84
378
+ Enabled: true
379
+ Style/OneClassPerFile: # new in 1.85
380
+ Enabled: true
381
+ Style/PartitionInsteadOfDoubleSelect: # new in 1.85
382
+ Enabled: true
383
+ Style/PredicateWithKind: # new in 1.85
384
+ Enabled: true
385
+ Style/ReduceToHash: # new in 1.85
386
+ Enabled: true
387
+ Style/RedundantMinMaxBy: # new in 1.85
388
+ Enabled: true
389
+ Style/ReverseFind: # new in 1.84
390
+ Enabled: true
391
+ Style/SelectByKind: # new in 1.85
392
+ Enabled: true
393
+ Style/SelectByRange: # new in 1.85
394
+ Enabled: true
395
+ Style/TallyMethod: # new in 1.85
396
+ Enabled: true
397
+ RSpec/DiscardedMatcher: # new in 3.10
398
+ Enabled: true
399
+ RSpec/LeakyLocalVariable: # new in 3.8
400
+ Enabled: true
401
+ RSpec/MatchWithSimpleRegex: # new in 3.10
402
+ Enabled: true
403
+ RSpec/Output: # new in 3.9
404
+ Enabled: true
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- datacite (0.8.5)
4
+ datacite (0.8.6)
5
5
  activesupport
6
+ cocina_display
6
7
  dry-monads (~> 1.3)
7
8
  faraday (~> 2.0)
8
9
  json_schemer
@@ -44,7 +45,7 @@ GEM
44
45
  super_diff
45
46
  thor
46
47
  zeitwerk (~> 2.1)
47
- cocina_display (2.10.0)
48
+ cocina_display (2.12.0)
48
49
  activesupport (>= 7)
49
50
  edtf (~> 3.2)
50
51
  geo_coord (~> 0.2)
@@ -121,20 +122,20 @@ GEM
121
122
  hana (~> 1.3)
122
123
  regexp_parser (~> 2.0)
123
124
  simpleidn (~> 0.2)
124
- jsonschema_rs (0.49.9)
125
+ jsonschema_rs (0.50.0)
125
126
  bigdecimal (>= 3.1, < 5)
126
127
  rb_sys (~> 0.9.124)
127
- jsonschema_rs (0.49.9-aarch64-linux)
128
+ jsonschema_rs (0.50.0-aarch64-linux)
128
129
  bigdecimal (>= 3.1, < 5)
129
- jsonschema_rs (0.49.9-aarch64-linux-musl)
130
+ jsonschema_rs (0.50.0-aarch64-linux-musl)
130
131
  bigdecimal (>= 3.1, < 5)
131
- jsonschema_rs (0.49.9-arm64-darwin)
132
+ jsonschema_rs (0.50.0-arm64-darwin)
132
133
  bigdecimal (>= 3.1, < 5)
133
- jsonschema_rs (0.49.9-x86_64-darwin)
134
+ jsonschema_rs (0.50.0-x86_64-darwin)
134
135
  bigdecimal (>= 3.1, < 5)
135
- jsonschema_rs (0.49.9-x86_64-linux)
136
+ jsonschema_rs (0.50.0-x86_64-linux)
136
137
  bigdecimal (>= 3.1, < 5)
137
- jsonschema_rs (0.49.9-x86_64-linux-musl)
138
+ jsonschema_rs (0.50.0-x86_64-linux-musl)
138
139
  bigdecimal (>= 3.1, < 5)
139
140
  language_server-protocol (3.17.0.6)
140
141
  lint_roller (1.1.0)
@@ -227,7 +228,7 @@ GEM
227
228
  rubocop (~> 1.86, >= 1.86.2)
228
229
  ruby-progressbar (1.13.0)
229
230
  securerandom (0.4.1)
230
- simplecov (1.0.3)
231
+ simplecov (1.1.1)
231
232
  simpleidn (0.2.3)
232
233
  super_diff (0.19.0)
233
234
  attr_extras (>= 6.2.4, < 8)
data/README.md CHANGED
@@ -127,6 +127,16 @@ bin/validate-cocina path/to/file.json
127
127
 
128
128
  This will result in either a `Valid!` message or an `Invalid!` message with a list of validation errors.
129
129
 
130
+ ## Transforming cocina locally
131
+
132
+ With cocina json saved from Argo (append `.json` to an Argo view URL and save the content locally) then run:
133
+
134
+ ```
135
+ bin/transform path/to/file.json
136
+ ```
137
+
138
+ This will output the formatted json content that would be sent to DataCite.
139
+
130
140
  ## Development
131
141
 
132
142
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/bin/transform ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # This is used to review the transformation of a cocina object
5
+ # to a datacite payload
6
+ # usage: bin/transform tmp/druid.json
7
+
8
+ require 'bundler/setup'
9
+ require 'datacite'
10
+ require 'cocina/models'
11
+ require 'json'
12
+
13
+ if ARGV.empty?
14
+ warn "Usage: #{$PROGRAM_NAME} <path-to-cocina-json>"
15
+ exit 1
16
+ end
17
+
18
+ json_path = ARGV[0]
19
+
20
+ unless File.exist?(json_path)
21
+ warn "File not found: #{json_path}"
22
+ exit 1
23
+ end
24
+
25
+ json = JSON.parse(File.read(json_path))
26
+ cocina_object = Cocina::Models::DROWithMetadata.new(json)
27
+ attributes = Datacite::Mapping::FromCocina::Attributes.build(cocina_object:)
28
+
29
+ puts JSON.pretty_generate(attributes)
data/datacite.gemspec CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.require_paths = ['lib']
30
30
 
31
31
  spec.add_dependency 'activesupport'
32
+ spec.add_dependency 'cocina_display'
32
33
  spec.add_dependency 'dry-monads', '~> 1.3'
33
34
  spec.add_dependency 'faraday', '~> 2.0'
34
35
  spec.add_dependency 'json_schemer'
@@ -30,7 +30,7 @@ module Datacite
30
30
  event: 'publish',
31
31
  url: description.purl,
32
32
  identifiers: Identifiers.build(identification:),
33
- titles: Titles.build(description:),
33
+ titles: Titles.build(title: cocina_display.full_title),
34
34
  publisher: { name: 'Stanford Digital Repository' }, # per DataCite schema
35
35
  publicationYear: publication_year,
36
36
  subjects: Subject.build(description:),
@@ -46,6 +46,10 @@ module Datacite
46
46
  }.merge(ContributorAttributes.build(description:)).compact
47
47
  end
48
48
 
49
+ def cocina_display
50
+ @cocina_display ||= CocinaDisplay::CocinaRecord.from_json(cocina_object.to_json)
51
+ end
52
+
49
53
  private
50
54
 
51
55
  def publication_year
@@ -13,19 +13,19 @@ module Datacite
13
13
  new(...).call
14
14
  end
15
15
 
16
- def initialize(description:)
17
- @description = description
16
+ def initialize(title:)
17
+ @title = title
18
18
  end
19
19
 
20
20
  # @return [Array<Hash>] list of titles for DataCite, conforming to the expectations of HTTP PUT request
21
21
  # to DataCite
22
22
  def call
23
- [{ title: description.title.first.value }]
23
+ [{ title: }]
24
24
  end
25
25
 
26
26
  private
27
27
 
28
- attr_reader :description
28
+ attr_reader :title
29
29
  end
30
30
  end
31
31
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Datacite
4
- VERSION = '0.8.5'
4
+ VERSION = '0.8.6'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datacite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5
4
+ version: 0.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
@@ -23,6 +23,20 @@ dependencies:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
25
  version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: cocina_display
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
26
40
  - !ruby/object:Gem::Dependency
27
41
  name: dry-monads
28
42
  requirement: !ruby/object:Gem::Requirement
@@ -98,6 +112,7 @@ files:
98
112
  - Rakefile
99
113
  - bin/console
100
114
  - bin/setup
115
+ - bin/transform
101
116
  - bin/validate-cocina
102
117
  - datacite.gemspec
103
118
  - lib/datacite.rb