cocina-models 0.91.4 → 0.92.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +3 -10
- data/Gemfile.lock +9 -9
- data/cocina-models.gemspec +1 -0
- data/docs/description_types.md +2 -0
- data/lib/cocina/models/file.rb +2 -0
- data/lib/cocina/models/request_file.rb +1 -0
- data/lib/cocina/models/validators/language_tag_validator.rb +48 -0
- data/lib/cocina/models/validators/validator.rb +2 -1
- data/lib/cocina/models/version.rb +1 -1
- data/openapi.yml +5 -0
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fb90197036280ad978dc4e59b548fcb954d7b602799294cfdde8bd3ef2a1568
|
4
|
+
data.tar.gz: fd7c2c49522772f866dc04d629296c537f88d88dd8943ce4b74bb77460be31d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84a09b86f9f922ba9b8c433760fe3613035d72cba102f5a93dc9e7ec07a4d7bfdef5f449375fa4792eb0b8045f3324f23360183b0f9b5aa8ea21082336681b22
|
7
|
+
data.tar.gz: 93b59a61650aae4c19cab66d84a216f66f65a289444e58fc48fdbd9088d33dd083fe9c57f57971574dae13a0b21ab4453ee48f8bad14f408ee3149534eb2aa99
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config --auto-gen-only-exclude`
|
3
|
-
# on 2023-
|
3
|
+
# on 2023-11-01 19:51:40 UTC using RuboCop version 1.57.2.
|
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
|
@@ -57,18 +57,11 @@ Metrics/ParameterLists:
|
|
57
57
|
RSpec/DescribeClass:
|
58
58
|
Enabled: false
|
59
59
|
|
60
|
-
# Offense count:
|
60
|
+
# Offense count: 224
|
61
61
|
# Configuration parameters: CountAsOne.
|
62
62
|
RSpec/ExampleLength:
|
63
63
|
Max: 103
|
64
64
|
|
65
|
-
# Offense count: 10
|
66
|
-
# Configuration parameters: Max, AllowedGroups.
|
67
|
-
RSpec/NestedGroups:
|
68
|
-
Exclude:
|
69
|
-
- 'spec/cocina/models/mapping/normalizers/mods/origin_info_normalizer_spec.rb'
|
70
|
-
- 'spec/cocina/models/validators/date_time_validator_spec.rb'
|
71
|
-
|
72
65
|
# Offense count: 19
|
73
66
|
RSpec/PendingWithoutReason:
|
74
67
|
Exclude:
|
@@ -99,7 +92,7 @@ Style/MultilineBlockChain:
|
|
99
92
|
- 'lib/cocina/models/mapping/to_mods/form.rb'
|
100
93
|
- 'lib/cocina/models/mapping/to_mods/subject.rb'
|
101
94
|
|
102
|
-
# Offense count:
|
95
|
+
# Offense count: 249
|
103
96
|
# This cop supports safe autocorrection (--autocorrect).
|
104
97
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
|
105
98
|
# URISchemes: http, https
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cocina-models (0.
|
4
|
+
cocina-models (0.92.0)
|
5
5
|
activesupport
|
6
6
|
deprecation
|
7
7
|
dry-struct (~> 1.0)
|
8
8
|
dry-types (~> 1.1)
|
9
9
|
edtf
|
10
10
|
equivalent-xml
|
11
|
+
i18n
|
11
12
|
jsonpath
|
12
13
|
nokogiri
|
13
14
|
openapi3_parser
|
@@ -79,7 +80,7 @@ GEM
|
|
79
80
|
jsonpath (1.1.5)
|
80
81
|
multi_json
|
81
82
|
language_server-protocol (3.17.0.3)
|
82
|
-
mini_portile2 (2.8.
|
83
|
+
mini_portile2 (2.8.5)
|
83
84
|
minitest (5.20.0)
|
84
85
|
multi_json (1.15.0)
|
85
86
|
mutex_m (0.1.2)
|
@@ -99,7 +100,7 @@ GEM
|
|
99
100
|
racc (1.7.1)
|
100
101
|
rack (3.0.8)
|
101
102
|
rainbow (3.1.1)
|
102
|
-
rake (13.0
|
103
|
+
rake (13.1.0)
|
103
104
|
regexp_parser (2.8.2)
|
104
105
|
rexml (3.2.6)
|
105
106
|
rspec (3.12.0)
|
@@ -119,8 +120,7 @@ GEM
|
|
119
120
|
rspec-core (>= 2, < 4, != 2.12.0)
|
120
121
|
rss (0.3.0)
|
121
122
|
rexml
|
122
|
-
rubocop (1.57.
|
123
|
-
base64 (~> 0.1.1)
|
123
|
+
rubocop (1.57.2)
|
124
124
|
json (~> 2.3)
|
125
125
|
language_server-protocol (>= 3.17.0)
|
126
126
|
parallel (~> 1.10)
|
@@ -131,7 +131,7 @@ GEM
|
|
131
131
|
rubocop-ast (>= 1.28.1, < 2.0)
|
132
132
|
ruby-progressbar (~> 1.7)
|
133
133
|
unicode-display_width (>= 2.4.0, < 3.0)
|
134
|
-
rubocop-ast (1.
|
134
|
+
rubocop-ast (1.30.0)
|
135
135
|
parser (>= 3.2.1.0)
|
136
136
|
rubocop-capybara (2.19.0)
|
137
137
|
rubocop (~> 1.41)
|
@@ -139,8 +139,8 @@ GEM
|
|
139
139
|
rubocop (~> 1.33)
|
140
140
|
rubocop-rake (0.6.0)
|
141
141
|
rubocop (~> 1.0)
|
142
|
-
rubocop-rspec (2.
|
143
|
-
rubocop (~> 1.
|
142
|
+
rubocop-rspec (2.25.0)
|
143
|
+
rubocop (~> 1.40)
|
144
144
|
rubocop-capybara (~> 2.17)
|
145
145
|
rubocop-factory_bot (~> 2.22)
|
146
146
|
ruby-progressbar (1.13.0)
|
@@ -155,7 +155,7 @@ GEM
|
|
155
155
|
attr_extras (>= 6.2.4)
|
156
156
|
diff-lcs
|
157
157
|
patience_diff
|
158
|
-
thor (1.
|
158
|
+
thor (1.3.0)
|
159
159
|
tzinfo (2.0.6)
|
160
160
|
concurrent-ruby (~> 1.0)
|
161
161
|
unicode-display_width (2.5.0)
|
data/cocina-models.gemspec
CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_dependency 'dry-types', '~> 1.1'
|
31
31
|
spec.add_dependency 'edtf' # used for date/time validation
|
32
32
|
spec.add_dependency 'equivalent-xml' # for diffing MODS
|
33
|
+
spec.add_dependency 'i18n' # for validating BCP 47 language tags, according to RFC 4646
|
33
34
|
spec.add_dependency 'jsonpath' # used for date/time validation
|
34
35
|
spec.add_dependency 'nokogiri'
|
35
36
|
spec.add_dependency 'openapi3_parser' # Parsing openapi doc
|
data/docs/description_types.md
CHANGED
data/lib/cocina/models/file.rb
CHANGED
@@ -22,6 +22,8 @@ module Cocina
|
|
22
22
|
attribute :version, Types::Strict::Integer
|
23
23
|
# MIME Type of the File.
|
24
24
|
attribute? :hasMimeType, Types::Strict::String
|
25
|
+
# BCP 47 language tag: https://www.rfc-editor.org/rfc/rfc4646.txt -- other applications (like media players) expect language codes of this format, see e.g. https://videojs.com/guides/text-tracks/#srclang
|
26
|
+
attribute? :languageTag, Types::Strict::String
|
25
27
|
# Use for the File.
|
26
28
|
attribute? :use, Types::Strict::String
|
27
29
|
attribute :hasMessageDigests, Types::Strict::Array.of(MessageDigest).default([].freeze)
|
@@ -13,6 +13,7 @@ module Cocina
|
|
13
13
|
attribute? :size, Types::Strict::Integer
|
14
14
|
attribute :version, Types::Strict::Integer
|
15
15
|
attribute? :hasMimeType, Types::Strict::String
|
16
|
+
attribute? :languageTag, Types::Strict::String
|
16
17
|
attribute? :externalIdentifier, Types::Strict::String
|
17
18
|
attribute? :use, Types::Strict::String
|
18
19
|
attribute :hasMessageDigests, Types::Strict::Array.of(MessageDigest).default([].freeze)
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cocina
|
4
|
+
module Models
|
5
|
+
module Validators
|
6
|
+
# Validates that a languageTag is valid according to RFC 4646, if one is present
|
7
|
+
class LanguageTagValidator
|
8
|
+
def self.validate(clazz, attributes)
|
9
|
+
new(clazz, attributes).validate
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(clazz, attributes)
|
13
|
+
@clazz = clazz
|
14
|
+
@attributes = attributes
|
15
|
+
end
|
16
|
+
|
17
|
+
def validate
|
18
|
+
return unless meets_preconditions?
|
19
|
+
|
20
|
+
return if valid_language_tag?
|
21
|
+
|
22
|
+
raise ValidationError, 'The provided language tag is not valid according to RFC 4646: ' \
|
23
|
+
"#{attributes[:languageTag]}"
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_reader :clazz, :attributes
|
29
|
+
|
30
|
+
def meets_preconditions?
|
31
|
+
file? && attributes[:languageTag].present?
|
32
|
+
end
|
33
|
+
|
34
|
+
def file?
|
35
|
+
(clazz::TYPES & File::TYPES).any?
|
36
|
+
rescue NameError
|
37
|
+
false
|
38
|
+
end
|
39
|
+
|
40
|
+
def valid_language_tag?
|
41
|
+
parsed_tag = I18n::Locale::Tag::Rfc4646.tag(attributes[:languageTag])
|
42
|
+
|
43
|
+
parsed_tag.present? && parsed_tag.is_a?(I18n::Locale::Tag::Rfc4646)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/openapi.yml
CHANGED
@@ -1044,6 +1044,9 @@ components:
|
|
1044
1044
|
hasMimeType:
|
1045
1045
|
description: MIME Type of the File.
|
1046
1046
|
type: string
|
1047
|
+
languageTag:
|
1048
|
+
description: "BCP 47 language tag: https://www.rfc-editor.org/rfc/rfc4646.txt -- other applications (like media players) expect language codes of this format, see e.g. https://videojs.com/guides/text-tracks/#srclang"
|
1049
|
+
type: string
|
1047
1050
|
use:
|
1048
1051
|
description: Use for the File.
|
1049
1052
|
type: string
|
@@ -1775,6 +1778,8 @@ components:
|
|
1775
1778
|
type: integer
|
1776
1779
|
hasMimeType:
|
1777
1780
|
type: string
|
1781
|
+
languageTag:
|
1782
|
+
type: string
|
1778
1783
|
externalIdentifier:
|
1779
1784
|
type: string
|
1780
1785
|
use:
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocina-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.92.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: 2023-
|
11
|
+
date: 2023-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: i18n
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: jsonpath
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -516,6 +530,7 @@ files:
|
|
516
530
|
- lib/cocina/models/validators/date_time_validator.rb
|
517
531
|
- lib/cocina/models/validators/description_types_validator.rb
|
518
532
|
- lib/cocina/models/validators/description_values_validator.rb
|
533
|
+
- lib/cocina/models/validators/language_tag_validator.rb
|
519
534
|
- lib/cocina/models/validators/open_api_validator.rb
|
520
535
|
- lib/cocina/models/validators/purl_validator.rb
|
521
536
|
- lib/cocina/models/validators/validator.rb
|
@@ -545,7 +560,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
545
560
|
- !ruby/object:Gem::Version
|
546
561
|
version: '0'
|
547
562
|
requirements: []
|
548
|
-
rubygems_version: 3.
|
563
|
+
rubygems_version: 3.4.19
|
549
564
|
signing_key:
|
550
565
|
specification_version: 4
|
551
566
|
summary: Data models for the SDR
|