atlas_rb 0.0.92 → 0.0.95

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: 9ecdf5a4da61e030d7220fc9094a43bd91a850eaa1c599179d75c3d5381b300a
4
- data.tar.gz: eea705d4f0601b112b2182848241c5439ef4beb10b87e87939e73ea70eb30907
3
+ metadata.gz: 2f04b74aca7b48fdba1f279e1b818cacc6e34be23c96a12b90c7cdd201ee0904
4
+ data.tar.gz: 9aeefc94a12ac0d8798e4fbf0d5edd5a9d6dacf9a6ec540184e2617b0cb0d5cc
5
5
  SHA512:
6
- metadata.gz: 4aa3b1a2367bde1309f589eebf0bf9bf8ff9f744dc1cdf5648c820cd4d38b4e2afa496a9b50308947f00cb9ceab4d10df4e92018d7715ad7928aa415fb556e0c
7
- data.tar.gz: b006492ee9c5adde683c863d06cf7cbd233848709e6aa6176e0e6b2fbd663f81f70166b0e7da4889a9005e47c7ecd3cc39e7aa58bde32461b15b4448b18d786d
6
+ metadata.gz: e028b1c2439beff9c27bc2f6a98082f7b76ebe86b7a16620c0a3d8aadfe5bc2463093e4c70f7d91198cf04a38100c4ea311f3415195743640aeb833b7847df3b
7
+ data.tar.gz: 4730752d8d3df7ec5715d7ae0bc71c892944a3ee215659f611d4216be171a284f3d71bf3413b2d4db17404641691f4c18836d7246b0d8045e0128552e22e069b
data/.version CHANGED
@@ -1 +1 @@
1
- 0.0.92
1
+ 0.0.95
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- atlas_rb (0.0.92)
4
+ atlas_rb (0.0.95)
5
5
  faraday (~> 2.7)
6
6
  faraday-follow_redirects (~> 0.3.0)
7
7
  faraday-multipart (~> 1)
@@ -11,7 +11,7 @@ GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
13
  diff-lcs (1.6.1)
14
- faraday (2.14.1)
14
+ faraday (2.14.2)
15
15
  faraday-net_http (>= 2.0, < 3.5)
16
16
  json
17
17
  logger
@@ -125,7 +125,12 @@ module AtlasRb
125
125
  AtlasRb::Mash.new(JSON.parse(multipart({}).patch(ROUTE + id, payload)&.body))
126
126
  end
127
127
 
128
- # Patch individual metadata fields without uploading a full MODS document.
128
+ # Patch individual descriptive-metadata fields without uploading a
129
+ # full MODS document.
130
+ #
131
+ # Scoped to user-authored descriptive metadata only. Programmatic
132
+ # writes of machine-set Delegate URIs (thumbnails) have their own
133
+ # purpose-specific endpoint — see {.set_thumbnails}.
129
134
  #
130
135
  # @param id [String] the Collection ID.
131
136
  # @param values [Hash] field-level metadata updates.
@@ -137,6 +142,33 @@ module AtlasRb
137
142
  AtlasRb::Mash.new(JSON.parse(connection({ metadata: values }).patch(ROUTE + id)&.body))
138
143
  end
139
144
 
145
+ # Attach the three thumbnail/preview Delegate URIs to a Collection.
146
+ #
147
+ # Collection-level mirror of {Work.set_thumbnails}. Atlas dispatches
148
+ # each non-blank URI to its matching Delegate role
149
+ # (`thumbnail_image` / `thumbnail_image_2x` / `preview_image`) via
150
+ # `DelegateUpdater`. Missing keys are left untouched.
151
+ #
152
+ # @param id [String] the Collection ID.
153
+ # @param thumbnail [String, nil] IIIF URI for the ~85² thumbnail.
154
+ # @param thumbnail_2x [String, nil] IIIF URI for the ~170² 2x thumbnail.
155
+ # @param preview [String, nil] IIIF URI for the ~500w preview image.
156
+ # @return [AtlasRb::Mash] the parsed JSON response.
157
+ #
158
+ # @example
159
+ # AtlasRb::Collection.set_thumbnails(
160
+ # "col-456",
161
+ # thumbnail: "https://iiif.example.edu/iiif/3/c.jp2/full/!85,85/0/default.jpg",
162
+ # thumbnail_2x: "https://iiif.example.edu/iiif/3/c.jp2/full/!170,170/0/default.jpg",
163
+ # preview: "https://iiif.example.edu/iiif/3/c.jp2/full/500,/0/default.jpg"
164
+ # )
165
+ def self.set_thumbnails(id, thumbnail: nil, thumbnail_2x: nil, preview: nil)
166
+ body = { thumbnail: thumbnail, thumbnail_2x: thumbnail_2x, preview: preview }.compact
167
+ AtlasRb::Mash.new(JSON.parse(
168
+ connection({}).patch(ROUTE + id + '/thumbnails', JSON.dump(body))&.body
169
+ ))
170
+ end
171
+
140
172
  # Fetch the Collection's MODS representation in the requested format.
141
173
  #
142
174
  # @param id [String] the Collection ID.
@@ -130,7 +130,12 @@ module AtlasRb
130
130
  AtlasRb::Mash.new(JSON.parse(multipart({}).patch(ROUTE + id, payload)&.body))
131
131
  end
132
132
 
133
- # Patch individual metadata fields without uploading a full MODS document.
133
+ # Patch individual descriptive-metadata fields without uploading a
134
+ # full MODS document.
135
+ #
136
+ # Scoped to user-authored descriptive metadata only. Programmatic
137
+ # writes of machine-set Delegate URIs (thumbnails) have their own
138
+ # purpose-specific endpoint — see {.set_thumbnails}.
134
139
  #
135
140
  # @param id [String] the Community ID.
136
141
  # @param values [Hash] field-level metadata updates (shape determined by
@@ -143,6 +148,33 @@ module AtlasRb
143
148
  AtlasRb::Mash.new(JSON.parse(connection({ metadata: values }).patch(ROUTE + id)&.body))
144
149
  end
145
150
 
151
+ # Attach the three thumbnail/preview Delegate URIs to a Community.
152
+ #
153
+ # Community-level mirror of {Work.set_thumbnails}. Atlas dispatches
154
+ # each non-blank URI to its matching Delegate role
155
+ # (`thumbnail_image` / `thumbnail_image_2x` / `preview_image`) via
156
+ # `DelegateUpdater`. Missing keys are left untouched.
157
+ #
158
+ # @param id [String] the Community ID.
159
+ # @param thumbnail [String, nil] IIIF URI for the ~85² thumbnail.
160
+ # @param thumbnail_2x [String, nil] IIIF URI for the ~170² 2x thumbnail.
161
+ # @param preview [String, nil] IIIF URI for the ~500w preview image.
162
+ # @return [AtlasRb::Mash] the parsed JSON response.
163
+ #
164
+ # @example
165
+ # AtlasRb::Community.set_thumbnails(
166
+ # "c-123",
167
+ # thumbnail: "https://iiif.example.edu/iiif/3/m.jp2/full/!85,85/0/default.jpg",
168
+ # thumbnail_2x: "https://iiif.example.edu/iiif/3/m.jp2/full/!170,170/0/default.jpg",
169
+ # preview: "https://iiif.example.edu/iiif/3/m.jp2/full/500,/0/default.jpg"
170
+ # )
171
+ def self.set_thumbnails(id, thumbnail: nil, thumbnail_2x: nil, preview: nil)
172
+ body = { thumbnail: thumbnail, thumbnail_2x: thumbnail_2x, preview: preview }.compact
173
+ AtlasRb::Mash.new(JSON.parse(
174
+ connection({}).patch(ROUTE + id + '/thumbnails', JSON.dump(body))&.body
175
+ ))
176
+ end
177
+
146
178
  # Fetch the Community's MODS representation in the requested format.
147
179
  #
148
180
  # @param id [String] the Community ID.
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AtlasRb
4
+ # A server-managed derivative asset attached to a {Work} — thumbnails,
5
+ # previews, and other generated representations.
6
+ #
7
+ # Unlike a {Blob}, a Delegate is not user-uploaded binary content; it is
8
+ # produced and addressed by Atlas itself. Each Delegate exposes a `uri`
9
+ # pointing at the underlying bytes plus enough metadata
10
+ # (`mime_type`, `original_filename`, `label`, `use`) for clients to
11
+ # render or link to it without fetching the bytes first.
12
+ #
13
+ # Lookups accept either the resource NOID or the `valkyrie_id`: Atlas
14
+ # redirects NOIDs to `/delegates/:valkyrie_id` and Faraday transparently
15
+ # follows the redirect.
16
+ #
17
+ # See also: {Work}, {Blob}.
18
+ class Delegate < Resource
19
+ # Atlas REST endpoint prefix for this resource.
20
+ # @api private
21
+ ROUTE = "/delegates/"
22
+
23
+ # Fetch a single Delegate by NOID or `valkyrie_id`.
24
+ #
25
+ # @param id [String] the Delegate's NOID or `valkyrie_id`.
26
+ # @return [AtlasRb::Mash] the `"delegate"` object, already unwrapped —
27
+ # includes `id`, `valkyrie_id`, `use`, `uri`, `mime_type`,
28
+ # `original_filename`, `label`, and tombstone fields.
29
+ #
30
+ # @example
31
+ # AtlasRb::Delegate.find("d-555")
32
+ def self.find(id)
33
+ AtlasRb::Mash.new(JSON.parse(connection({}).get(ROUTE + id)&.body))["delegate"]
34
+ end
35
+ end
36
+ end
data/lib/atlas_rb/work.rb CHANGED
@@ -177,7 +177,13 @@ module AtlasRb
177
177
  AtlasRb::Mash.new(JSON.parse(multipart({}).patch(ROUTE + id, payload)&.body))
178
178
  end
179
179
 
180
- # Patch individual metadata fields without uploading a full MODS document.
180
+ # Patch individual descriptive-metadata fields without uploading a
181
+ # full MODS document.
182
+ #
183
+ # Scoped to user-authored descriptive metadata only. Programmatic
184
+ # writes of machine-set Delegate URIs (thumbnails, image
185
+ # derivatives) have their own purpose-specific endpoints — see
186
+ # {.set_thumbnails} and {.set_image_derivatives}.
181
187
  #
182
188
  # @param id [String] the Work ID.
183
189
  # @param values [Hash] field-level metadata updates.
@@ -189,19 +195,86 @@ module AtlasRb
189
195
  AtlasRb::Mash.new(JSON.parse(connection({ metadata: values }).patch(ROUTE + id)&.body))
190
196
  end
191
197
 
192
- # List the {FileSet}s and {Blob}s attached to a Work.
198
+ # Attach the three thumbnail/preview Delegate URIs to a Work.
199
+ #
200
+ # Purpose-specific PATCH for the `thumbnail_image` /
201
+ # `thumbnail_image_2x` / `preview_image` Delegate roles. Atlas
202
+ # dispatches each URI to its matching role via `DelegateUpdater`.
203
+ # Distinct from {.metadata} — these are machine-set IIIF URIs, not
204
+ # user-authored descriptive content. Missing keys are left
205
+ # untouched server-side; only the URIs you pass are upserted.
206
+ #
207
+ # @param id [String] the Work ID.
208
+ # @param thumbnail [String, nil] IIIF URI for the ~85² thumbnail.
209
+ # @param thumbnail_2x [String, nil] IIIF URI for the ~170² 2x thumbnail.
210
+ # @param preview [String, nil] IIIF URI for the ~500w preview image.
211
+ # @return [AtlasRb::Mash] the parsed JSON response.
212
+ #
213
+ # @example
214
+ # AtlasRb::Work.set_thumbnails(
215
+ # "w-789",
216
+ # thumbnail: "https://iiif.example.edu/iiif/3/abc.jp2/full/!85,85/0/default.jpg",
217
+ # thumbnail_2x: "https://iiif.example.edu/iiif/3/abc.jp2/full/!170,170/0/default.jpg",
218
+ # preview: "https://iiif.example.edu/iiif/3/abc.jp2/full/500,/0/default.jpg"
219
+ # )
220
+ def self.set_thumbnails(id, thumbnail: nil, thumbnail_2x: nil, preview: nil)
221
+ body = { thumbnail: thumbnail, thumbnail_2x: thumbnail_2x, preview: preview }.compact
222
+ AtlasRb::Mash.new(JSON.parse(
223
+ connection({}).patch(ROUTE + id + '/thumbnails', JSON.dump(body))&.body
224
+ ))
225
+ end
226
+
227
+ # Attach the three image-derivative Delegate URIs to a Work.
228
+ #
229
+ # Sibling of {.set_thumbnails} for the `small_image` /
230
+ # `medium_image` / `large_image` Delegate roles. Atlas dispatches
231
+ # each URI to its matching role via `DelegateUpdater`. The
232
+ # resulting Delegates are downloadable and surface through
233
+ # {.assets} for the downloads UI. Missing keys are left untouched
234
+ # server-side; only the URIs you pass are upserted.
235
+ #
236
+ # @param id [String] the Work ID.
237
+ # @param small [String, nil] IIIF URI for the small derivative.
238
+ # @param medium [String, nil] IIIF URI for the medium derivative.
239
+ # @param large [String, nil] IIIF URI for the large derivative.
240
+ # @return [AtlasRb::Mash] the parsed JSON response.
241
+ #
242
+ # @example
243
+ # AtlasRb::Work.set_image_derivatives(
244
+ # "w-789",
245
+ # small: "https://iiif.example.edu/iiif/3/abc.jp2/full/800,/0/default.jpg",
246
+ # medium: "https://iiif.example.edu/iiif/3/abc.jp2/full/1600,/0/default.jpg",
247
+ # large: "https://iiif.example.edu/iiif/3/abc.jp2/full/full/0/default.jpg"
248
+ # )
249
+ def self.set_image_derivatives(id, small: nil, medium: nil, large: nil)
250
+ body = { small: small, medium: medium, large: large }.compact
251
+ AtlasRb::Mash.new(JSON.parse(
252
+ connection({}).patch(ROUTE + id + '/image_derivatives', JSON.dump(body))&.body
253
+ ))
254
+ end
255
+
256
+ # List the assets attached to a Work — {Blob}s and {Delegate}s alike.
193
257
  #
194
258
  # Useful for building download UIs — the response includes enough to
195
- # render each file's display name, size, and download URL.
259
+ # render each entry's display name, size or `uri`, and download URL.
260
+ # The shape is polymorphic: Blob-backed entries carry fields like
261
+ # `size`, while Delegate-backed entries carry `uri`. Callers should
262
+ # duck-type on the field they need rather than expecting a single
263
+ # schema.
196
264
  #
197
265
  # @param id [String] the Work ID.
198
- # @return [Array<AtlasRb::Mash>] the listing from `GET /works/<id>/files`,
199
- # one entry per attached file.
266
+ # @return [Array<AtlasRb::Mash>] the listing from `GET /works/<id>/assets`,
267
+ # one entry per attached asset.
200
268
  #
201
269
  # @example
202
- # AtlasRb::Work.files("w-789").each { |f| puts f.label }
270
+ # AtlasRb::Work.assets("w-789").each { |a| puts a.label }
271
+ def self.assets(id)
272
+ JSON.parse(connection({}).get(ROUTE + id + '/assets')&.body).map { |entry| AtlasRb::Mash.new(entry) }
273
+ end
274
+
275
+ # @deprecated Use {.assets} instead. Will be removed in the next release.
203
276
  def self.files(id)
204
- JSON.parse(connection({}).get(ROUTE + id + '/files')&.body).map { |entry| AtlasRb::Mash.new(entry) }
277
+ assets(id)
205
278
  end
206
279
 
207
280
  # Fetch the Work's MODS representation in the requested format.
data/lib/atlas_rb.rb CHANGED
@@ -13,6 +13,7 @@ require_relative "atlas_rb/collection"
13
13
  require_relative "atlas_rb/work"
14
14
  require_relative "atlas_rb/file_set"
15
15
  require_relative "atlas_rb/blob"
16
+ require_relative "atlas_rb/delegate"
16
17
  require_relative "atlas_rb/user"
17
18
 
18
19
  # Ruby client for the Atlas API — Northeastern University's institutional
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atlas_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.92
4
+ version: 0.0.95
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cliff
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-05-13 00:00:00.000000000 Z
11
+ date: 2026-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -118,6 +118,7 @@ files:
118
118
  - lib/atlas_rb/blob.rb
119
119
  - lib/atlas_rb/collection.rb
120
120
  - lib/atlas_rb/community.rb
121
+ - lib/atlas_rb/delegate.rb
121
122
  - lib/atlas_rb/faraday_helper.rb
122
123
  - lib/atlas_rb/file_set.rb
123
124
  - lib/atlas_rb/mash.rb