cocina_display 1.3.1 → 1.4.1

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: 625ecec0ef2895cc1e0dd39a73fb5ba9ae03e6df8f177ca074617f3ccc7e0f1a
4
- data.tar.gz: 82b88169d58ca2cca9ea43d1b96e6f90f41090490bfaeaba49224800e53e9744
3
+ metadata.gz: 19034929abb6dce0d501ff7ce3f898f5edbd10fa95bcd3b1acb80b91a3eed238
4
+ data.tar.gz: ed95d7744cc46312653b1d661d18bf60cf8d10a8c355c6cde937ea921086b4c9
5
5
  SHA512:
6
- metadata.gz: 2bdd91512c0402daaecd4aea177b767719fb45808083bda5e3901b00478f3d59cd9b17d599b66026563fac3dc97cf35e687bfb517d0721652019a2e49e115038
7
- data.tar.gz: ef16c53108d2d0d14ac1c69dadc14846b9cab4e7254aa45d46b88394b51713945bb0066794a9a3fbb69364fcfa2ec677259719a2ab842225ab3e68b900636aa3
6
+ metadata.gz: 7b4627ef8e75add721d28c80bd7fec72ad5a894435b75eefab82d31b6b099a2f857022e249d4fbf16b5a0dd9dadf2baaf428fd7e4ad724c5485e4712b03fa280
7
+ data.tar.gz: 29f3d16fabefb67e82a7e6b9c8b47df42a24715818ac3b872df8a9bf2736afcb1c0cb1773fec0113a70ee51f8eeda99aa546db304174186c8eb549e00deddb0b
@@ -64,6 +64,131 @@ module CocinaDisplay
64
64
  end
65
65
  end
66
66
 
67
+ # View rights for the object.
68
+ # @return [String, nil]
69
+ # @example "world", "stanford_only", "dark", "location-based"
70
+ def view_rights
71
+ path("$.access.view").first
72
+ end
73
+
74
+ # Download rights for the object.
75
+ # @note Individual files may have differing download rights.
76
+ # @return [String, nil]
77
+ # @example "world", "stanford_only", "none", "location-based"
78
+ def download_rights
79
+ path("$.access.download").first
80
+ end
81
+
82
+ # If access or download is location-based, which location has access.
83
+ # @return [String, nil]
84
+ # @example "spec", "music", "ars", "art", "hoover", "m&m"
85
+ def location_rights
86
+ path("$.access.location").first
87
+ end
88
+
89
+ # Is the object viewable in some capacity?
90
+ # @return [Boolean]
91
+ def viewable?
92
+ view_rights != "dark"
93
+ end
94
+
95
+ # Is the object downloadable in some capacity?
96
+ # @return [Boolean]
97
+ def downloadable?
98
+ download_rights != "none"
99
+ end
100
+
101
+ # Is the object viewable by anyone?
102
+ # @return [Boolean]
103
+ def world_viewable?
104
+ view_rights == "world"
105
+ end
106
+
107
+ # Is the object downloadable by anyone?
108
+ # @return [Boolean]
109
+ def world_downloadable?
110
+ download_rights == "world"
111
+ end
112
+
113
+ # Is the object both viewable and downloadable by anyone?
114
+ # @return [Boolean]
115
+ def world_access?
116
+ world_viewable? && world_downloadable?
117
+ end
118
+
119
+ # Is the object only viewable by Stanford affiliates?
120
+ # @return [Boolean]
121
+ def stanford_only_viewable?
122
+ view_rights == "stanford"
123
+ end
124
+
125
+ # Is the object only downloadable by Stanford affiliates?
126
+ # @return [Boolean]
127
+ def stanford_only_downloadable?
128
+ download_rights == "stanford"
129
+ end
130
+
131
+ # Is the object only viewable and downloadable by Stanford affiliates?
132
+ # @return [Boolean]
133
+ def stanford_only_access?
134
+ stanford_only_viewable? && stanford_only_downloadable?
135
+ end
136
+
137
+ # Is the object viewable by Stanford affiliates?
138
+ # @return [Boolean]
139
+ def stanford_viewable?
140
+ world_viewable? || stanford_only_viewable?
141
+ end
142
+
143
+ # Is the object downloadable by Stanford affiliates?
144
+ # @return [Boolean]
145
+ def stanford_downloadable?
146
+ world_downloadable? || stanford_only_downloadable?
147
+ end
148
+
149
+ # Is the object both viewable and downloadable by Stanford affiliates?
150
+ # @return [Boolean]
151
+ def stanford_access?
152
+ stanford_viewable? && stanford_downloadable?
153
+ end
154
+
155
+ # Is the object "dark" (not viewable or downloadable by anyone)?
156
+ # @return [Boolean]
157
+ def dark_access?
158
+ !viewable? && !downloadable?
159
+ end
160
+
161
+ # Is the object viewable only if in a location?
162
+ # @return [Boolean]
163
+ def location_only_viewable?
164
+ view_rights == "location-based"
165
+ end
166
+
167
+ # Is the object downloadable only if in a location?
168
+ # @return [Boolean]
169
+ def location_only_downloadable?
170
+ download_rights == "location-based"
171
+ end
172
+
173
+ # Is the object only viewable and downloadable if in a location?
174
+ # @return [Boolean]
175
+ def location_only_access?
176
+ location_only_viewable? && location_only_downloadable?
177
+ end
178
+
179
+ # Is the object viewable at the given location?
180
+ # @param location [String] The location to check
181
+ # @return [Boolean]
182
+ def viewable_at_location?(location)
183
+ world_viewable? || stanford_viewable? || location_rights == location
184
+ end
185
+
186
+ # Is the object only viewable for citation purposes?
187
+ # @return [Boolean]
188
+ def citation_only_access?
189
+ view_rights == "citation-only"
190
+ end
191
+
67
192
  private
68
193
 
69
194
  # The Purl URL to combine with other access metadata
@@ -105,8 +105,6 @@ module CocinaDisplay
105
105
  genres.include?("Dataset")
106
106
  end
107
107
 
108
- private
109
-
110
108
  # Collapses all nested form values into an array of {Form} objects.
111
109
  # Preserves resource type without flattening, since it can be structured.
112
110
  # @return [Array<Form>]
@@ -147,6 +145,38 @@ module CocinaDisplay
147
145
  all_forms.filter { |form| ["reformatting quality", "media type"].include?(form.type) }
148
146
  end
149
147
 
148
+ # All resource types forms, as {ResourceType}s.
149
+ # @return [Array<ResourceType>]
150
+ def all_resource_types
151
+ all_forms.filter { |form| form.is_a?(CocinaDisplay::Forms::ResourceType) }
152
+ end
153
+
154
+ # {ResourceType} objects that are Stanford self-deposit resource types.
155
+ # @return [Array<ResourceType>]
156
+ def self_deposit_resource_types
157
+ all_resource_types.filter { |resource_type| resource_type.stanford_self_deposit? }
158
+ end
159
+
160
+ # Display values of all resource types.
161
+ # @return [Array<String>]
162
+ def resource_type_values
163
+ all_resource_types.map(&:to_s).uniq
164
+ end
165
+
166
+ # Issuance terms for a work, drawn from the event notes.
167
+ # @return [Array<String>]
168
+ def issuance_terms
169
+ events.flat_map(&:notes).filter { |note| note.type == "issuance" }.map { |note| note.to_s.downcase }.uniq
170
+ end
171
+
172
+ # Frequency terms for a periodical, drawn from the event notes.
173
+ # @return [Array<String>]
174
+ def frequency
175
+ events.flat_map(&:notes).filter { |note| note.type == "frequency" }.map { |note| note.to_s.downcase }.uniq
176
+ end
177
+
178
+ private
179
+
150
180
  # Map a resource type to SearchWorks format value(s).
151
181
  # @param resource_type [String] The resource type to map.
152
182
  # @return [Array<String>]
@@ -186,36 +216,6 @@ module CocinaDisplay
186
216
 
187
217
  values.compact_blank
188
218
  end
189
-
190
- # All resource types forms, as {ResourceType}s.
191
- # @return [Array<ResourceType>]
192
- def all_resource_types
193
- all_forms.filter { |form| form.is_a?(CocinaDisplay::Forms::ResourceType) }
194
- end
195
-
196
- # {ResourceType} objects that are Stanford self-deposit resource types.
197
- # @return [Array<ResourceType>]
198
- def self_deposit_resource_types
199
- all_resource_types.filter { |resource_type| resource_type.stanford_self_deposit? }
200
- end
201
-
202
- # Display values of all resource types.
203
- # @return [Array<String>]
204
- def resource_type_values
205
- all_resource_types.map(&:to_s).uniq
206
- end
207
-
208
- # Issuance terms for a work, drawn from the event notes.
209
- # @return [Array<String>]
210
- def issuance_terms
211
- events.flat_map(&:notes).filter { |note| note.type == "issuance" }.map { |note| note.to_s.downcase }.uniq
212
- end
213
-
214
- # Frequency terms for a periodical, drawn from the event notes.
215
- # @return [Array<String>]
216
- def frequency
217
- events.flat_map(&:notes).filter { |note| note.type == "frequency" }.map { |note| note.to_s.downcase }.uniq
218
- end
219
219
  end
220
220
  end
221
221
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # :nodoc:
4
4
  module CocinaDisplay
5
- VERSION = "1.3.1" # :nodoc:
5
+ VERSION = "1.4.1" # :nodoc:
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocina_display
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Budak
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-10-10 00:00:00.000000000 Z
11
+ date: 2025-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: janeway-jsonpath