cocina_display 2.13.0 → 2.14.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 +4 -4
- data/lib/cocina_display/cocina_record.rb +1 -15
- data/lib/cocina_display/concerns/accesses.rb +8 -1
- data/lib/cocina_display/concerns/content_type.rb +21 -0
- data/lib/cocina_display/events/event.rb +1 -1
- data/lib/cocina_display/related_resource.rb +1 -0
- data/lib/cocina_display/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 688c7fafb0400ee43f4164d61ef4ef59c664345243ddaeb7ad57f18c236129b2
|
|
4
|
+
data.tar.gz: ea761030a2784394d0ce3d13624a39f212080fb084d2387a48b1e36c07a3eb25
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d52107bf61c72a2020b42883bf8e3679d3dbf5c9e202d770b6bf3adb4273f1b53c8af38525ae292dbffbe36aa7f45063898188fcb8f620fa5ae31b79f6a5799d
|
|
7
|
+
data.tar.gz: dba215b6897c505518a2509c6781f9f2dda73e81b31a0f86f74fe11c173e79172cdbf5c6f5e2fcfbb70f1d6222614b412cfda8e10449956937863046c7f8b7b1
|
|
@@ -17,6 +17,7 @@ module CocinaDisplay
|
|
|
17
17
|
include CocinaDisplay::Concerns::Geospatial
|
|
18
18
|
include CocinaDisplay::Concerns::Structural
|
|
19
19
|
include CocinaDisplay::Concerns::RelatedResources
|
|
20
|
+
include CocinaDisplay::Concerns::ContentType
|
|
20
21
|
|
|
21
22
|
# Fetch a public Cocina document from PURL and create a CocinaRecord.
|
|
22
23
|
# @param druid [String] The bare DRUID of the object to fetch.
|
|
@@ -51,21 +52,6 @@ module CocinaDisplay
|
|
|
51
52
|
Time.parse(cocina_doc["modified"])
|
|
52
53
|
end
|
|
53
54
|
|
|
54
|
-
# SDR content type of the object.
|
|
55
|
-
# @return [String, nil]
|
|
56
|
-
# @see https://github.com/sul-dlss/cocina-models/blob/main/openapi.yml#L532-L546
|
|
57
|
-
# @example
|
|
58
|
-
# record.content_type #=> "image"
|
|
59
|
-
def content_type
|
|
60
|
-
cocina_doc["type"]&.delete_prefix("https://cocina.sul.stanford.edu/models/")
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# True if the object is a collection.
|
|
64
|
-
# @return [Boolean]
|
|
65
|
-
def collection?
|
|
66
|
-
content_type == "collection"
|
|
67
|
-
end
|
|
68
|
-
|
|
69
55
|
# Copyright statement from Cocina access metadata.
|
|
70
56
|
# @return [String, nil]
|
|
71
57
|
def copyright
|
|
@@ -73,6 +73,7 @@ module CocinaDisplay
|
|
|
73
73
|
|
|
74
74
|
# Download rights for the object.
|
|
75
75
|
# @note Individual files may have differing download rights.
|
|
76
|
+
# @note Collections have no download rights, so this is always nil for them.
|
|
76
77
|
# @return [String, nil]
|
|
77
78
|
# @example "world", "stanford_only", "none", "location-based"
|
|
78
79
|
def download_rights
|
|
@@ -95,7 +96,7 @@ module CocinaDisplay
|
|
|
95
96
|
# Is the object downloadable in some capacity?
|
|
96
97
|
# @return [Boolean]
|
|
97
98
|
def downloadable?
|
|
98
|
-
download_rights != "none"
|
|
99
|
+
download_rights.present? && download_rights != "none"
|
|
99
100
|
end
|
|
100
101
|
|
|
101
102
|
# Is the object viewable by anyone?
|
|
@@ -111,8 +112,11 @@ module CocinaDisplay
|
|
|
111
112
|
end
|
|
112
113
|
|
|
113
114
|
# Is the object both viewable and downloadable by anyone?
|
|
115
|
+
# @note Collections have no download rights, so only view rights are considered.
|
|
114
116
|
# @return [Boolean]
|
|
115
117
|
def world_access?
|
|
118
|
+
return world_viewable? if collection?
|
|
119
|
+
|
|
116
120
|
world_viewable? && world_downloadable?
|
|
117
121
|
end
|
|
118
122
|
|
|
@@ -147,8 +151,11 @@ module CocinaDisplay
|
|
|
147
151
|
end
|
|
148
152
|
|
|
149
153
|
# Is the object both viewable and downloadable by Stanford affiliates?
|
|
154
|
+
# @note Collections have no download rights, so only view rights are considered.
|
|
150
155
|
# @return [Boolean]
|
|
151
156
|
def stanford_access?
|
|
157
|
+
return stanford_viewable? if collection?
|
|
158
|
+
|
|
152
159
|
stanford_viewable? && stanford_downloadable?
|
|
153
160
|
end
|
|
154
161
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module CocinaDisplay
|
|
2
|
+
module Concerns
|
|
3
|
+
# Methods related to the content type of a Cocina object.
|
|
4
|
+
module ContentType
|
|
5
|
+
# SDR content type of the object.
|
|
6
|
+
# @return [String, nil]
|
|
7
|
+
# @see https://github.com/sul-dlss/cocina-models/blob/main/openapi.yml#L532-L546
|
|
8
|
+
# @example
|
|
9
|
+
# record.content_type #=> "image"
|
|
10
|
+
def content_type
|
|
11
|
+
cocina_doc["type"]&.delete_prefix("https://cocina.sul.stanford.edu/models/")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# True if the object is a collection.
|
|
15
|
+
# @return [Boolean]
|
|
16
|
+
def collection?
|
|
17
|
+
content_type == "collection"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -157,7 +157,7 @@ module CocinaDisplay
|
|
|
157
157
|
# Dates associated with this event as a single string.
|
|
158
158
|
# @return [String]
|
|
159
159
|
def date_str
|
|
160
|
-
display_dates.map(&:
|
|
160
|
+
display_dates.map(&:to_s).compact_blank.uniq.to_sentence
|
|
161
161
|
end
|
|
162
162
|
|
|
163
163
|
# Locations associated with this event as a single string.
|
|
@@ -15,6 +15,7 @@ module CocinaDisplay
|
|
|
15
15
|
include CocinaDisplay::Concerns::Forms
|
|
16
16
|
include CocinaDisplay::Concerns::Languages
|
|
17
17
|
include CocinaDisplay::Concerns::Geospatial
|
|
18
|
+
include CocinaDisplay::Concerns::ContentType
|
|
18
19
|
|
|
19
20
|
# Description of the relation to the source record.
|
|
20
21
|
# @return [String]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cocina_display
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nick Budak
|
|
@@ -238,6 +238,7 @@ files:
|
|
|
238
238
|
- lib/cocina_display/cocina_record.rb
|
|
239
239
|
- lib/cocina_display/concerns.rb
|
|
240
240
|
- lib/cocina_display/concerns/accesses.rb
|
|
241
|
+
- lib/cocina_display/concerns/content_type.rb
|
|
241
242
|
- lib/cocina_display/concerns/contributors.rb
|
|
242
243
|
- lib/cocina_display/concerns/druid.rb
|
|
243
244
|
- lib/cocina_display/concerns/events.rb
|
|
@@ -313,7 +314,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
313
314
|
- !ruby/object:Gem::Version
|
|
314
315
|
version: '0'
|
|
315
316
|
requirements: []
|
|
316
|
-
rubygems_version: 4.0.
|
|
317
|
+
rubygems_version: 4.0.3
|
|
317
318
|
specification_version: 4
|
|
318
319
|
summary: Helpers for rendering Cocina metadata
|
|
319
320
|
test_files: []
|