atlas_rb 1.29.2 → 1.29.4
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/CHANGELOG.md +26 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/lib/atlas_rb/work.rb +71 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bc6d758d43135f85f61b7a8a0aa8ba86af108d4894d84f17cee9d91b7bdffbb8
|
|
4
|
+
data.tar.gz: ca3e2c5a080af089e4fd2734b2a8b185f3ad54d2ee58a53b3aef61ec3b518691
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fd67f7abf09587a4dc0d5fc284a76108e618fa34e0c32f38a900a5ccda11d5e31255f5ab01461435674a03d08a067b71eabba49a37ceada0ad034ee5dc7d1531
|
|
7
|
+
data.tar.gz: eae45b648e6322aeefefc3e67f4e35c53fda0a87a36a29613b2b7d27183237a104ec5ecd5082bde721b6dfe6f049109aa247ea7d027f7762574adc9e50ab6ea7
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.29.
|
|
1
|
+
1.29.4
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.29.4
|
|
4
|
+
|
|
5
|
+
Needs an Atlas that accepts a supplied handle (0.6.277 or later). An older
|
|
6
|
+
Atlas ignores the param, and `complete` then mints a second handle.
|
|
7
|
+
|
|
8
|
+
### Added — `handle:` on `Work.create`
|
|
9
|
+
|
|
10
|
+
Creates a Work with a handle it already owns, such as a migrated v1 record's.
|
|
11
|
+
Atlas records it as supplied, so `complete` mints nothing and never re-points
|
|
12
|
+
it. Admin and delegated admin only: anyone else gets `ForbiddenError` with
|
|
13
|
+
`action` `"supply_handle"`, and no Work is created. A malformed handle is a
|
|
14
|
+
`422` and a handle another Work holds is a `409`, both as `ResourceError`.
|
|
15
|
+
|
|
16
|
+
## 1.29.3
|
|
17
|
+
|
|
18
|
+
Needs an Atlas that serves the citation route (0.6.274 or later). Against an
|
|
19
|
+
older Atlas the route is not there, so the binding returns `nil`.
|
|
20
|
+
|
|
21
|
+
### Added — `Work.citation`
|
|
22
|
+
|
|
23
|
+
Wraps `GET /works/<id>/citation` and returns the Work's CSL-JSON item as a
|
|
24
|
+
Mash, `nil` on a `404`. It raises `TombstonedError` for a tombstoned Work below
|
|
25
|
+
the admin tiers, and `ResourceError` on any other failure. Atlas leaves out a
|
|
26
|
+
key the record does not give, `keyword` is a comma-joined String, and `issued`
|
|
27
|
+
has two shapes; the YARD text says how to read each.
|
|
28
|
+
|
|
3
29
|
## 1.29.2
|
|
4
30
|
|
|
5
31
|
### Changed — `TombstonedError#work_retracted?` is now `work_suppressed?`
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -749,7 +749,8 @@ Atlas withholds a file when the Blob, its FileSet or its Work is tombstoned,
|
|
|
749
749
|
and a tombstoned Work's file lists. It answers `410` with `error:
|
|
750
750
|
"tombstoned"`, and the gem raises `AtlasRb::TombstonedError`, a
|
|
751
751
|
`ResourceError`. `Blob.content` raises it before your block sees a chunk, and
|
|
752
|
-
`Work.assets`, `.file_sets` and `.file_revisions` raise it in place of a list
|
|
752
|
+
`Work.assets`, `.file_sets` and `.file_revisions` raise it in place of a list,
|
|
753
|
+
and `Work.citation` raises it in place of the citation.
|
|
753
754
|
Admins and the devolved-admin tier are still served.
|
|
754
755
|
|
|
755
756
|
```ruby
|
data/lib/atlas_rb/work.rb
CHANGED
|
@@ -126,12 +126,25 @@ module AtlasRb
|
|
|
126
126
|
# it should be attributed to. The acting user becomes the Work's
|
|
127
127
|
# `proxy_uploader`. The depositor is immutable post-create; there is no
|
|
128
128
|
# setter on the update surface.
|
|
129
|
+
# @param handle [String, nil] optional handle the Work already owns, such
|
|
130
|
+
# as a migrated v1 record's `"2047/d20001234"`. A resolver URL is
|
|
131
|
+
# accepted; Atlas strips the host. Admin and delegated admin only. Atlas
|
|
132
|
+
# records it as supplied, and `complete` then mints nothing and never
|
|
133
|
+
# re-points it. There is no way to change it after the create. Needs
|
|
134
|
+
# Atlas 0.6.277 or later; an older Atlas ignores the param and mints a
|
|
135
|
+
# second handle on `complete`.
|
|
129
136
|
# @return [Hash] the created Work payload (post-update if `xml_path` was
|
|
130
137
|
# supplied).
|
|
131
138
|
# @raise [AtlasRb::NotFoundError] if Atlas answers `404` — the id names no such
|
|
132
139
|
# resource, so the write did not happen.
|
|
140
|
+
# @raise [AtlasRb::ForbiddenError] if Atlas answers `403`: the caller holds no
|
|
141
|
+
# edit rights on the Collection, or sent `handle:` without being an admin
|
|
142
|
+
# or delegated admin (`action` is then `"supply_handle"`). No Work is
|
|
143
|
+
# created.
|
|
133
144
|
# @raise [AtlasRb::ResourceError] on any other non-2xx, carrying Atlas's status
|
|
134
|
-
# and body.
|
|
145
|
+
# and body. With `handle:`, a `422` (`invalid_handle`) means the value is
|
|
146
|
+
# not `<prefix>/<suffix>`, and a `409` (`handle_taken`) means another
|
|
147
|
+
# Work, live or tombstoned, holds it.
|
|
135
148
|
#
|
|
136
149
|
# @example Empty work, metadata to be added later
|
|
137
150
|
# AtlasRb::Work.create("col-456")
|
|
@@ -145,10 +158,14 @@ module AtlasRb
|
|
|
145
158
|
#
|
|
146
159
|
# @example Proxy deposit — librarian uploads on behalf of a researcher
|
|
147
160
|
# AtlasRb::Work.create("col-456", depositor: "000000123")
|
|
161
|
+
#
|
|
162
|
+
# @example Migrated Work that keeps its v1 handle
|
|
163
|
+
# AtlasRb::Work.create("col-456", handle: "2047/d20001234", nuid: admin_nuid)
|
|
148
164
|
def self.create(id, xml_path = nil, idempotency_key: nil, nuid: nil,
|
|
149
|
-
on_behalf_of: nil, depositor: nil)
|
|
165
|
+
on_behalf_of: nil, depositor: nil, handle: nil)
|
|
150
166
|
params = { collection_id: id }
|
|
151
167
|
params[:depositor] = depositor if depositor
|
|
168
|
+
params[:handle] = handle if handle
|
|
152
169
|
result = AtlasRb::Mash.new(write_resource(
|
|
153
170
|
connection(params, nuid,
|
|
154
171
|
on_behalf_of: on_behalf_of, idempotency_key: idempotency_key).post(ROUTE)
|
|
@@ -687,6 +704,58 @@ module AtlasRb
|
|
|
687
704
|
end
|
|
688
705
|
end
|
|
689
706
|
|
|
707
|
+
# Fetch the Work's citation as a CSL-JSON item.
|
|
708
|
+
#
|
|
709
|
+
# Wraps `GET /works/<id>/citation` (Atlas 0.6.274 or later). The body is a
|
|
710
|
+
# single CSL-JSON (Citation Style Language) object with no envelope, so a
|
|
711
|
+
# citation formatter such as citeproc can take it as it is. Atlas builds it
|
|
712
|
+
# with the same rule as its citation index, so it states the same facts.
|
|
713
|
+
#
|
|
714
|
+
# Only `id` (the NOID), `type` (a CSL type, `"document"` by default) and
|
|
715
|
+
# `title` are always present. Atlas **leaves out** a key the record does not
|
|
716
|
+
# give, rather than sending `null`, so read the others with `&.` or `dig`:
|
|
717
|
+
#
|
|
718
|
+
# - `author`, `contributor`: arrays of `{ "literal" => String }`. Names are
|
|
719
|
+
# not split into family and given parts.
|
|
720
|
+
# - `issued`: one of two shapes. `{ "date-parts" => [[y, m, d]] }` carries
|
|
721
|
+
# one, two or three parts at the precision the record states;
|
|
722
|
+
# `{ "literal" => String }` carries the record's own words for a date it
|
|
723
|
+
# could not encode, with no parts to read.
|
|
724
|
+
# - `abstract`: a String.
|
|
725
|
+
# - `keyword`: a **String**, the topical subjects joined with `", "` as CSL
|
|
726
|
+
# expects, not an Array. A subject can itself contain a comma, so
|
|
727
|
+
# `split(", ")` is approximate; {.mods} gives the exact list.
|
|
728
|
+
# - `URL`: the handle, once one is minted.
|
|
729
|
+
#
|
|
730
|
+
# `date-parts` is not a valid method name, so read it with
|
|
731
|
+
# `issued["date-parts"]` or `dig`, never as a method on the Mash.
|
|
732
|
+
#
|
|
733
|
+
# @param id [String] the Work ID.
|
|
734
|
+
# @param nuid [String, nil] optional acting user's NUID. On the relay-signing
|
|
735
|
+
# path it is signed into the assertion `sub`; on the BYO-JWT (`ATLAS_JWT`)
|
|
736
|
+
# path it is ignored (identity lives in the token).
|
|
737
|
+
# @param on_behalf_of [String, nil] optional NUID for the `On-Behalf-Of`
|
|
738
|
+
# header. Falls through to {AtlasRb.config}.default_on_behalf_of when
|
|
739
|
+
# omitted.
|
|
740
|
+
# @return [AtlasRb::Mash, nil] the CSL-JSON item, or `nil` when Atlas
|
|
741
|
+
# answers `404` (no such Work).
|
|
742
|
+
# @raise [AtlasRb::TombstonedError] when the Work is tombstoned and the
|
|
743
|
+
# caller is below the admin and devolved-admin tiers.
|
|
744
|
+
# @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410`
|
|
745
|
+
# (a `403` for a caller who cannot read the Work, an auth envelope, a
|
|
746
|
+
# `5xx`, a proxy's `503`), carrying Atlas's status and body.
|
|
747
|
+
# @example
|
|
748
|
+
# cite = AtlasRb::Work.citation("w-789")
|
|
749
|
+
# cite.title
|
|
750
|
+
# cite.author&.map(&:literal)
|
|
751
|
+
# cite.issued&.dig("date-parts", 0, 0) # the year, or nil
|
|
752
|
+
# cite.keyword&.split(", ")
|
|
753
|
+
def self.citation(id, nuid: nil, on_behalf_of: nil)
|
|
754
|
+
read_body(connection({}, nuid, on_behalf_of: on_behalf_of).get("#{ROUTE}#{id}/citation")) do |body|
|
|
755
|
+
AtlasRb::Mash.new(body)
|
|
756
|
+
end
|
|
757
|
+
end
|
|
758
|
+
|
|
690
759
|
# Fetch the Work's MODS representation in the requested format.
|
|
691
760
|
#
|
|
692
761
|
# @param id [String] the Work ID.
|