cocina-models 0.3.0 → 0.4.0

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: ffc816e681925104816410cec76d490280cfa82aa8639ddd4292c5d99e02e97d
4
- data.tar.gz: a7f8258c0ca7da9298f63b550c5c73cb6b917ab755eec76db3ec69e9d967f883
3
+ metadata.gz: cc8ddb0dfd77463068313414c399d9329c69a1ea93904123a84834443a874c01
4
+ data.tar.gz: f372df6bd7648df6d5f331335538eb7d27ece1a2acd1ddc824954cf0df941451
5
5
  SHA512:
6
- metadata.gz: adee7aa04a85ef78d9182b11c9f6177c4595203928c429537781d92fdf2c4321447d7b4c5624708de64534ca383e009068e2e9555e7f03df65a96cdd7b0a7e9f
7
- data.tar.gz: 58d7beb4fce083a74cd000cfa5fa99c1c57345e94c9010ca9abdc9b6e031a5f15cffd0a0bbab3bdd6a8b860c53fbcaddefbd0a36b06bedab0befaf813f1b52f5
6
+ metadata.gz: dfe212d14d1b84929028c272b7a94518ac31d3924d640e72d683da70565283043c884396f3612210622de473b1dc7b4dbde8cb8f2f23df229e2490658efc9b5e
7
+ data.tar.gz: bb584811cf3ea4ffaf4ef8babce832dae1f5f623214554e735b56965214c76e539ce4bebb65001f0b2c3ca0f3f2ddfab330a6def4c1e64c078d7fe181d8b66dc
data/.rubocop.yml ADDED
@@ -0,0 +1,21 @@
1
+ # This is the configuration used to check the rubocop source code.
2
+
3
+ inherit_from: .rubocop_todo.yml
4
+ require:
5
+ - rubocop-rspec
6
+
7
+ Metrics/BlockLength:
8
+ Exclude:
9
+ - spec/cocina/**/*
10
+
11
+ Metrics/LineLength:
12
+ Max: 100
13
+
14
+ Metrics/MethodLength:
15
+ Max: 13
16
+
17
+ RSpec/MultipleExpectations:
18
+ Enabled: false
19
+
20
+ RSpec/ExampleLength:
21
+ Max: 9
data/.rubocop_todo.yml ADDED
File without changes
data/.travis.yml CHANGED
@@ -5,3 +5,7 @@ cache: bundler
5
5
  rvm:
6
6
  - 2.5.3
7
7
  before_install: gem install bundler -v 2.0.1
8
+
9
+ script:
10
+ - bundle exec rspec
11
+ - bundle exec rubocop
@@ -30,4 +30,6 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency 'bundler', '~> 2.0'
31
31
  spec.add_development_dependency 'rake', '~> 12.0'
32
32
  spec.add_development_dependency 'rspec', '~> 3.0'
33
+ spec.add_development_dependency 'rubocop', '~> 0.74.0'
34
+ spec.add_development_dependency 'rubocop-rspec'
33
35
  end
@@ -6,22 +6,51 @@ module Cocina
6
6
  module Models
7
7
  # A digital repository object. See https://github.com/sul-dlss-labs/taco/blob/master/maps/DRO.json
8
8
  class DRO < Dry::Struct
9
+ # Subschema for release tags
10
+ class ReleaseTag < Dry::Struct
11
+ attribute :to, Types::Strict::String
12
+ attribute :what, Types::Strict::String.enum('self', 'collection')
13
+ # we use 'when' other places, but that's reserved word, so 'date' it is!
14
+ attribute :date, Types::Params::DateTime
15
+ attribute :who, Types::Strict::String
16
+ attribute :release, Types::Params::Bool
17
+ end
18
+
19
+ # Subschema for access concerns
20
+ class Access < Dry::Struct
21
+ attribute :embargoReleaseDate, Types::Params::DateTime.meta(omittable: true)
22
+ end
23
+
24
+ # Subschema for administrative concerns
25
+ class Administrative < Dry::Struct
26
+ attribute :releaseTags, Types::Strict::Array.of(ReleaseTag).meta(omittable: true)
27
+ end
28
+
29
+ class Identification < Dry::Struct
30
+ end
31
+
32
+ class Structural < Dry::Struct
33
+ end
34
+
9
35
  attribute :externalIdentifier, Types::Strict::String
10
36
  attribute :type, Types::Strict::String
11
37
  attribute :label, Types::Strict::String
12
- attribute :access, Dry::Struct.meta(omittable: true) do
13
- attribute :embargoReleaseDate, Types::Params::DateTime
14
- end
38
+ attribute :version, Types::Strict::Integer
39
+ attribute(:access, Access.default { Access.new })
40
+ attribute(:administrative, Administrative.default { Administrative.new })
41
+ attribute(:identification, Identification.default { Identification.new })
42
+ attribute(:structural, Structural.default { Structural.new })
15
43
 
16
- def self.from_dynamic(d)
44
+ def self.from_dynamic(dyn)
17
45
  params = {
18
- externalIdentifier: d['externalIdentifier'],
19
- type: d['type'],
20
- label: d['label']
46
+ externalIdentifier: dyn['externalIdentifier'],
47
+ type: dyn['type'],
48
+ label: dyn['label'],
49
+ version: dyn['version']
21
50
  }
22
- if d['access']
51
+ if dyn['access']
23
52
  access = {
24
- embargoReleaseDate: d['access']['embargoReleaseDate']
53
+ embargoReleaseDate: dyn['access']['embargoReleaseDate']
25
54
  }
26
55
  params[:access] = access
27
56
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cocina
4
4
  module Models
5
- VERSION = '0.3.0'
5
+ VERSION = '0.4.0'
6
6
  end
7
7
  end
data/lib/cocina/models.rb CHANGED
@@ -5,6 +5,7 @@ require 'zeitwerk'
5
5
  require 'dry-struct'
6
6
  require 'dry-types'
7
7
 
8
+ # Help Zeitwerk find some of our classes
8
9
  class CocinaModelsInflector < Zeitwerk::Inflector
9
10
  def camelize(basename, _abspath)
10
11
  case basename
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocina-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
@@ -94,6 +94,34 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.74.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.74.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  description: SDR data models that can be validated
98
126
  email:
99
127
  - jcoyne@justincoyne.com
@@ -103,6 +131,8 @@ extra_rdoc_files: []
103
131
  files:
104
132
  - ".gitignore"
105
133
  - ".rspec"
134
+ - ".rubocop.yml"
135
+ - ".rubocop_todo.yml"
106
136
  - ".travis.yml"
107
137
  - Gemfile
108
138
  - README.md