cocina_display 1.3.1 → 1.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: 625ecec0ef2895cc1e0dd39a73fb5ba9ae03e6df8f177ca074617f3ccc7e0f1a
4
- data.tar.gz: 82b88169d58ca2cca9ea43d1b96e6f90f41090490bfaeaba49224800e53e9744
3
+ metadata.gz: 319ba499a1ae1ce8f20511b28de441b55e364e2d51ab7ae34d3c1abaaceff04f
4
+ data.tar.gz: 4a1a263d1d89f7295fd14bb407736e0a995b48d29d635b864d91ce26f52ac14e
5
5
  SHA512:
6
- metadata.gz: 2bdd91512c0402daaecd4aea177b767719fb45808083bda5e3901b00478f3d59cd9b17d599b66026563fac3dc97cf35e687bfb517d0721652019a2e49e115038
7
- data.tar.gz: ef16c53108d2d0d14ac1c69dadc14846b9cab4e7254aa45d46b88394b51713945bb0066794a9a3fbb69364fcfa2ec677259719a2ab842225ab3e68b900636aa3
6
+ metadata.gz: 3e585e286c4477a970b0cfb880b171b1bc1cb7d4d694ec5d238e5fb536df635dfa3a0d53df842fa87471edf7f537baede39fa392797e6112b08c6d98d632818d
7
+ data.tar.gz: 0a32bb97d75abdb367f324ff0c9b71cc28ad82d61f8226adb7b0b1c8adc7d8cb729a956d590296bda5b81fd2db6512389f5965d9f2825b1e556574ad7505ae3a
@@ -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
@@ -2,5 +2,5 @@
2
2
 
3
3
  # :nodoc:
4
4
  module CocinaDisplay
5
- VERSION = "1.3.1" # :nodoc:
5
+ VERSION = "1.4.0" # :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.0
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