atlas_rb 1.29.1 → 1.29.3
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 +24 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -2
- data/lib/atlas_rb/blob.rb +1 -1
- data/lib/atlas_rb/errors.rb +3 -3
- data/lib/atlas_rb/resource_writes.rb +1 -1
- data/lib/atlas_rb/work.rb +55 -3
- 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: 070db91bb5753d1cdc5961a4ba71a834935ebd8ba206fc72326d2e050188625f
|
|
4
|
+
data.tar.gz: 5317100f574d3449b1df75a6700a6091b999d251402e565d34580632e141652b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 370d588a000805cf88998daa6c1b7afc267e099ce68b172459c098e7e9c3659f4ac29d15eafddbc0429287ef88ac359e41c23645df19c427cf0b0585b3bfda37
|
|
7
|
+
data.tar.gz: 646ff86552eecd1c5dc0a6db03bc3cbd78eb5a9c1cabbb166e593437776eb90fb0311f5f0a17284ad5a74a1698d35ff9cf6a8ad05ddf1ec9b7281407caf1e7f5
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.29.
|
|
1
|
+
1.29.3
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.29.3
|
|
4
|
+
|
|
5
|
+
Needs an Atlas that serves the citation route (0.6.274 or later). Against an
|
|
6
|
+
older Atlas the route is not there, so the binding returns `nil`.
|
|
7
|
+
|
|
8
|
+
### Added — `Work.citation`
|
|
9
|
+
|
|
10
|
+
Wraps `GET /works/<id>/citation` and returns the Work's CSL-JSON item as a
|
|
11
|
+
Mash, `nil` on a `404`. It raises `TombstonedError` for a tombstoned Work below
|
|
12
|
+
the admin tiers, and `ResourceError` on any other failure. Atlas leaves out a
|
|
13
|
+
key the record does not give, `keyword` is a comma-joined String, and `issued`
|
|
14
|
+
has two shapes; the YARD text says how to read each.
|
|
15
|
+
|
|
16
|
+
## 1.29.2
|
|
17
|
+
|
|
18
|
+
### Changed — `TombstonedError#work_retracted?` is now `work_suppressed?`
|
|
19
|
+
|
|
20
|
+
"Suppressed" is the staff-facing name for a tombstone, the term library
|
|
21
|
+
catalogues use for a reversible removal. The method is renamed with no alias,
|
|
22
|
+
so a caller of `work_retracted?` must switch to `work_suppressed?`. The YARD
|
|
23
|
+
text that called a tombstoned Work "retracted" says "suppressed" too.
|
|
24
|
+
`Work.disassociate` keeps "retract": withdrawing a relationship claim is
|
|
25
|
+
not a suppression.
|
|
26
|
+
|
|
3
27
|
## 1.29.1
|
|
4
28
|
|
|
5
29
|
Needs an Atlas that withholds the files beneath a tombstone (0.6.245 or later).
|
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
|
|
@@ -757,7 +758,7 @@ begin
|
|
|
757
758
|
AtlasRb::Blob.content(blob_id) { |chunk| response.stream.write(chunk) }
|
|
758
759
|
rescue AtlasRb::TombstonedError => e
|
|
759
760
|
e.tombstoned_resource_type # => "FileSet" (one file removed) or "Work"
|
|
760
|
-
e.
|
|
761
|
+
e.work_suppressed? # => true when the whole Work is tombstoned
|
|
761
762
|
end
|
|
762
763
|
```
|
|
763
764
|
|
data/lib/atlas_rb/blob.rb
CHANGED
|
@@ -32,7 +32,7 @@ module AtlasRb
|
|
|
32
32
|
#
|
|
33
33
|
# `"tombstoned_in_effect"` is true when the Blob, its FileSet or its Work
|
|
34
34
|
# is tombstoned, and `"tombstoned_resource_type"` says which (`"FileSet"`
|
|
35
|
-
# for a removed file, `"Work"` for a
|
|
35
|
+
# for a removed file, `"Work"` for a suppressed Work). Atlas answers such a
|
|
36
36
|
# Blob `410` with this body, which is returned, so a host can refuse a
|
|
37
37
|
# download before it calls {.content}. Atlas 0.6.245 or later.
|
|
38
38
|
# @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410` (e.g. an
|
data/lib/atlas_rb/errors.rb
CHANGED
|
@@ -384,11 +384,11 @@ module AtlasRb
|
|
|
384
384
|
# A tombstone does not cascade, so the resource that carries it can be an
|
|
385
385
|
# ancestor of the one requested. A Blob is withheld when its FileSet is
|
|
386
386
|
# tombstoned (one file removed) or when its Work is (the whole Work
|
|
387
|
-
#
|
|
387
|
+
# suppressed). {#tombstoned_resource_type} tells the two apart, so a host can
|
|
388
388
|
# show "file not found" for the first and its "Removed" page for the second.
|
|
389
389
|
#
|
|
390
390
|
# rescue AtlasRb::TombstonedError => e
|
|
391
|
-
# e.
|
|
391
|
+
# e.work_suppressed? ? render("errors/gone", status: :gone) : head(:not_found)
|
|
392
392
|
#
|
|
393
393
|
# Admins and the devolved-admin tier are still served, so they never see
|
|
394
394
|
# this. A `410` from a single-resource read such as {Work.find} is not this:
|
|
@@ -418,7 +418,7 @@ module AtlasRb
|
|
|
418
418
|
end
|
|
419
419
|
|
|
420
420
|
# @return [Boolean] true when the whole Work is tombstoned.
|
|
421
|
-
def
|
|
421
|
+
def work_suppressed?
|
|
422
422
|
tombstoned_resource_type == "Work"
|
|
423
423
|
end
|
|
424
424
|
|
|
@@ -200,7 +200,7 @@ module AtlasRb
|
|
|
200
200
|
# Restore is the operator's counterpart and lives in
|
|
201
201
|
# {AtlasRb::Admin::Resource}, where the namespace is the marker.
|
|
202
202
|
#
|
|
203
|
-
# Tombstone a resource:
|
|
203
|
+
# Tombstone a resource: suppress it from discovery, reversibly.
|
|
204
204
|
#
|
|
205
205
|
# Returns the **raw response** rather than raising, because Atlas refuses a
|
|
206
206
|
# container that still holds live children with a `422` carrying
|
data/lib/atlas_rb/work.rb
CHANGED
|
@@ -468,7 +468,7 @@ module AtlasRb
|
|
|
468
468
|
# misconfigured `ATLAS_URL`, the route is not Atlas's at all.
|
|
469
469
|
# @raise [AtlasRb::TombstonedError] when the Work is tombstoned and the
|
|
470
470
|
# caller is below the admin and devolved-admin tiers (Atlas 0.6.245 or
|
|
471
|
-
# later), so a
|
|
471
|
+
# later), so a suppressed Work's files are never listed.
|
|
472
472
|
# @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410`
|
|
473
473
|
# (an auth or validation envelope, a `5xx`, a proxy's `503`), carrying
|
|
474
474
|
# Atlas's status and body so the failure is attributable at the boundary.
|
|
@@ -548,7 +548,7 @@ module AtlasRb
|
|
|
548
548
|
# `ATLAS_URL`, the route is not Atlas's at all.
|
|
549
549
|
# @raise [AtlasRb::TombstonedError] when the Work is tombstoned and the
|
|
550
550
|
# caller is below the admin and devolved-admin tiers (Atlas 0.6.245 or
|
|
551
|
-
# later), so a
|
|
551
|
+
# later), so a suppressed Work's files are never listed.
|
|
552
552
|
# @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410`
|
|
553
553
|
# (a `403` for a caller who cannot read the Work, a `5xx`, a proxy's
|
|
554
554
|
# `503`), carrying Atlas's status and body so the failure is attributable
|
|
@@ -633,7 +633,7 @@ module AtlasRb
|
|
|
633
633
|
# misconfigured `ATLAS_URL`, the route is not Atlas's at all.
|
|
634
634
|
# @raise [AtlasRb::TombstonedError] when the Work is tombstoned and the
|
|
635
635
|
# caller is below the admin and devolved-admin tiers (Atlas 0.6.245 or
|
|
636
|
-
# later), so a
|
|
636
|
+
# later), so a suppressed Work's files are never listed.
|
|
637
637
|
# @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410`
|
|
638
638
|
# (an auth or validation envelope, a `5xx`, a proxy's `503`), carrying
|
|
639
639
|
# Atlas's status and body so the failure is attributable at the boundary.
|
|
@@ -687,6 +687,58 @@ module AtlasRb
|
|
|
687
687
|
end
|
|
688
688
|
end
|
|
689
689
|
|
|
690
|
+
# Fetch the Work's citation as a CSL-JSON item.
|
|
691
|
+
#
|
|
692
|
+
# Wraps `GET /works/<id>/citation` (Atlas 0.6.274 or later). The body is a
|
|
693
|
+
# single CSL-JSON (Citation Style Language) object with no envelope, so a
|
|
694
|
+
# citation formatter such as citeproc can take it as it is. Atlas builds it
|
|
695
|
+
# with the same rule as its citation index, so it states the same facts.
|
|
696
|
+
#
|
|
697
|
+
# Only `id` (the NOID), `type` (a CSL type, `"document"` by default) and
|
|
698
|
+
# `title` are always present. Atlas **leaves out** a key the record does not
|
|
699
|
+
# give, rather than sending `null`, so read the others with `&.` or `dig`:
|
|
700
|
+
#
|
|
701
|
+
# - `author`, `contributor`: arrays of `{ "literal" => String }`. Names are
|
|
702
|
+
# not split into family and given parts.
|
|
703
|
+
# - `issued`: one of two shapes. `{ "date-parts" => [[y, m, d]] }` carries
|
|
704
|
+
# one, two or three parts at the precision the record states;
|
|
705
|
+
# `{ "literal" => String }` carries the record's own words for a date it
|
|
706
|
+
# could not encode, with no parts to read.
|
|
707
|
+
# - `abstract`: a String.
|
|
708
|
+
# - `keyword`: a **String**, the topical subjects joined with `", "` as CSL
|
|
709
|
+
# expects, not an Array. A subject can itself contain a comma, so
|
|
710
|
+
# `split(", ")` is approximate; {.mods} gives the exact list.
|
|
711
|
+
# - `URL`: the handle, once one is minted.
|
|
712
|
+
#
|
|
713
|
+
# `date-parts` is not a valid method name, so read it with
|
|
714
|
+
# `issued["date-parts"]` or `dig`, never as a method on the Mash.
|
|
715
|
+
#
|
|
716
|
+
# @param id [String] the Work ID.
|
|
717
|
+
# @param nuid [String, nil] optional acting user's NUID. On the relay-signing
|
|
718
|
+
# path it is signed into the assertion `sub`; on the BYO-JWT (`ATLAS_JWT`)
|
|
719
|
+
# path it is ignored (identity lives in the token).
|
|
720
|
+
# @param on_behalf_of [String, nil] optional NUID for the `On-Behalf-Of`
|
|
721
|
+
# header. Falls through to {AtlasRb.config}.default_on_behalf_of when
|
|
722
|
+
# omitted.
|
|
723
|
+
# @return [AtlasRb::Mash, nil] the CSL-JSON item, or `nil` when Atlas
|
|
724
|
+
# answers `404` (no such Work).
|
|
725
|
+
# @raise [AtlasRb::TombstonedError] when the Work is tombstoned and the
|
|
726
|
+
# caller is below the admin and devolved-admin tiers.
|
|
727
|
+
# @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410`
|
|
728
|
+
# (a `403` for a caller who cannot read the Work, an auth envelope, a
|
|
729
|
+
# `5xx`, a proxy's `503`), carrying Atlas's status and body.
|
|
730
|
+
# @example
|
|
731
|
+
# cite = AtlasRb::Work.citation("w-789")
|
|
732
|
+
# cite.title
|
|
733
|
+
# cite.author&.map(&:literal)
|
|
734
|
+
# cite.issued&.dig("date-parts", 0, 0) # the year, or nil
|
|
735
|
+
# cite.keyword&.split(", ")
|
|
736
|
+
def self.citation(id, nuid: nil, on_behalf_of: nil)
|
|
737
|
+
read_body(connection({}, nuid, on_behalf_of: on_behalf_of).get("#{ROUTE}#{id}/citation")) do |body|
|
|
738
|
+
AtlasRb::Mash.new(body)
|
|
739
|
+
end
|
|
740
|
+
end
|
|
741
|
+
|
|
690
742
|
# Fetch the Work's MODS representation in the requested format.
|
|
691
743
|
#
|
|
692
744
|
# @param id [String] the Work ID.
|