atlas_rb 1.16.0 → 1.16.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 +4 -4
- data/.version +1 -1
- data/Gemfile.lock +1 -1
- data/lib/atlas_rb/collection.rb +9 -5
- data/lib/atlas_rb/community.rb +9 -5
- data/lib/atlas_rb/resource.rb +24 -0
- data/lib/atlas_rb/work.rb +9 -5
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 03b277e8683662db4b0809d548d274bce6e5cd51c64e242f606d0f911237ffe5
|
|
4
|
+
data.tar.gz: b010988a48817296d3e2ab24ae3ff4e5dcaa68239159e36d19cecfe826d85b64
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6560e0da51abf54fc2f6de456814022573626b2528e0592f1539f23e29c2106c0d98978dc768cae8e5d305caf3401f83853477d75cd6409806549e87aa8b0fa5
|
|
7
|
+
data.tar.gz: 3352534d5a2aeb187db42d36c8adf621666612023b36a65fb904b85c0aa9925430f7c897f9b67ce824969c04730b547bfc578ae4c1f3b7da8f064b815e48c4d7
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.16.
|
|
1
|
+
1.16.1
|
data/Gemfile.lock
CHANGED
data/lib/atlas_rb/collection.rb
CHANGED
|
@@ -220,6 +220,9 @@ module AtlasRb
|
|
|
220
220
|
# @param on_behalf_of [String, nil] optional NUID for the `On-Behalf-Of`
|
|
221
221
|
# header. Falls through to {AtlasRb.config}.default_on_behalf_of when
|
|
222
222
|
# omitted.
|
|
223
|
+
# @param origin [String, nil] free-text tag naming the surface that made this
|
|
224
|
+
# edit (e.g. `"metadata_form"`, `"xml_editor"`). Atlas records it verbatim
|
|
225
|
+
# on the audit event; omit it and the event carries no origin.
|
|
223
226
|
# @return [Hash] the parsed JSON response from the patch.
|
|
224
227
|
# @raise [AtlasRb::NotFoundError] if Atlas answers `404` — the id names no such
|
|
225
228
|
# resource, so the write did not happen.
|
|
@@ -228,12 +231,13 @@ module AtlasRb
|
|
|
228
231
|
#
|
|
229
232
|
# @example
|
|
230
233
|
# AtlasRb::Collection.update("col-456", "/tmp/collection-mods.xml")
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
234
|
+
#
|
|
235
|
+
# @example Recording which editing surface made the change
|
|
236
|
+
# AtlasRb::Collection.update("col-456", "/tmp/collection-mods.xml", origin: "xml_editor")
|
|
237
|
+
def self.update(id, xml_path, nuid: nil, on_behalf_of: nil, origin: nil)
|
|
235
238
|
AtlasRb::Mash.new(write_resource(
|
|
236
|
-
multipart(nuid, on_behalf_of: on_behalf_of)
|
|
239
|
+
multipart(nuid, on_behalf_of: on_behalf_of)
|
|
240
|
+
.patch(ROUTE + id, mods_upload_payload(xml_path, origin))
|
|
237
241
|
))
|
|
238
242
|
end
|
|
239
243
|
|
data/lib/atlas_rb/community.rb
CHANGED
|
@@ -199,6 +199,9 @@ module AtlasRb
|
|
|
199
199
|
# @param on_behalf_of [String, nil] optional NUID for the `On-Behalf-Of`
|
|
200
200
|
# header. Falls through to {AtlasRb.config}.default_on_behalf_of when
|
|
201
201
|
# omitted.
|
|
202
|
+
# @param origin [String, nil] free-text tag naming the surface that made this
|
|
203
|
+
# edit (e.g. `"metadata_form"`, `"xml_editor"`). Atlas records it verbatim
|
|
204
|
+
# on the audit event; omit it and the event carries no origin.
|
|
202
205
|
# @return [Hash] the parsed JSON response from the patch.
|
|
203
206
|
# @raise [AtlasRb::NotFoundError] if Atlas answers `404` — the id names no such
|
|
204
207
|
# resource, so the write did not happen.
|
|
@@ -207,12 +210,13 @@ module AtlasRb
|
|
|
207
210
|
#
|
|
208
211
|
# @example
|
|
209
212
|
# AtlasRb::Community.update("c-123", "/tmp/community-mods.xml")
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
213
|
+
#
|
|
214
|
+
# @example Recording which editing surface made the change
|
|
215
|
+
# AtlasRb::Community.update("c-123", "/tmp/community-mods.xml", origin: "xml_editor")
|
|
216
|
+
def self.update(id, xml_path, nuid: nil, on_behalf_of: nil, origin: nil)
|
|
214
217
|
AtlasRb::Mash.new(write_resource(
|
|
215
|
-
multipart(nuid, on_behalf_of: on_behalf_of)
|
|
218
|
+
multipart(nuid, on_behalf_of: on_behalf_of)
|
|
219
|
+
.patch(ROUTE + id, mods_upload_payload(xml_path, origin))
|
|
216
220
|
))
|
|
217
221
|
end
|
|
218
222
|
|
data/lib/atlas_rb/resource.rb
CHANGED
|
@@ -431,5 +431,29 @@ module AtlasRb
|
|
|
431
431
|
JSON.parse(resp.body)
|
|
432
432
|
end
|
|
433
433
|
private_class_method :write_resource
|
|
434
|
+
|
|
435
|
+
# The multipart body behind {Work.update} / {Collection.update} /
|
|
436
|
+
# {Community.update}: the MODS document, plus the optional `origin` tag
|
|
437
|
+
# naming the surface that produced the edit.
|
|
438
|
+
#
|
|
439
|
+
# Atlas records `origin` verbatim on the audit event and never branches on
|
|
440
|
+
# it, so a host names its own surfaces (Cerberus sends `metadata_form`,
|
|
441
|
+
# `advanced_form`, `xml_editor`). A `nil` origin is left out of the body
|
|
442
|
+
# entirely rather than sent empty, so the audit event of a host that does
|
|
443
|
+
# not set one looks exactly like every event recorded before the field
|
|
444
|
+
# existed.
|
|
445
|
+
#
|
|
446
|
+
# @param xml_path [String] path to a MODS XML file on disk.
|
|
447
|
+
# @param origin [String, nil] the edit-origin tag, or `nil` to send none.
|
|
448
|
+
# @return [Hash] the multipart payload.
|
|
449
|
+
# @api private
|
|
450
|
+
def self.mods_upload_payload(xml_path, origin)
|
|
451
|
+
payload = { binary: Faraday::Multipart::FilePart.new(File.open(xml_path),
|
|
452
|
+
"application/xml",
|
|
453
|
+
File.basename(xml_path)) }
|
|
454
|
+
payload[:origin] = origin.to_s unless origin.nil? || origin.to_s.empty?
|
|
455
|
+
payload
|
|
456
|
+
end
|
|
457
|
+
private_class_method :mods_upload_payload
|
|
434
458
|
end
|
|
435
459
|
end
|
data/lib/atlas_rb/work.rb
CHANGED
|
@@ -358,6 +358,9 @@ module AtlasRb
|
|
|
358
358
|
# @param on_behalf_of [String, nil] optional NUID for the `On-Behalf-Of`
|
|
359
359
|
# header. Falls through to {AtlasRb.config}.default_on_behalf_of when
|
|
360
360
|
# omitted.
|
|
361
|
+
# @param origin [String, nil] free-text tag naming the surface that made this
|
|
362
|
+
# edit (e.g. `"metadata_form"`, `"xml_editor"`). Atlas records it verbatim
|
|
363
|
+
# on the audit event; omit it and the event carries no origin.
|
|
361
364
|
# @return [Hash] the parsed JSON response from the patch.
|
|
362
365
|
# @raise [AtlasRb::NotFoundError] if Atlas answers `404` — the id names no such
|
|
363
366
|
# resource, so the write did not happen.
|
|
@@ -366,12 +369,13 @@ module AtlasRb
|
|
|
366
369
|
#
|
|
367
370
|
# @example
|
|
368
371
|
# AtlasRb::Work.update("w-789", "/tmp/work-mods.xml")
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
372
|
+
#
|
|
373
|
+
# @example Recording which editing surface made the change
|
|
374
|
+
# AtlasRb::Work.update("w-789", "/tmp/work-mods.xml", origin: "xml_editor")
|
|
375
|
+
def self.update(id, xml_path, nuid: nil, on_behalf_of: nil, origin: nil)
|
|
373
376
|
AtlasRb::Mash.new(write_resource(
|
|
374
|
-
multipart(nuid, on_behalf_of: on_behalf_of)
|
|
377
|
+
multipart(nuid, on_behalf_of: on_behalf_of)
|
|
378
|
+
.patch(ROUTE + id, mods_upload_payload(xml_path, origin))
|
|
375
379
|
))
|
|
376
380
|
end
|
|
377
381
|
|
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: 1.16.
|
|
4
|
+
version: 1.16.1
|
|
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-09-
|
|
11
|
+
date: 2026-09-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|