atlas_rb 1.29.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db0cdca29eb7e27fab3995adff0e6f7b33aba897aa46fd164c2f11de02eb2d96
4
- data.tar.gz: 3f2b9746c5f4384dd3e9cacc8d50eed2d1d2c60ea92c3cf2130142b2d48c6bf2
3
+ metadata.gz: 070db91bb5753d1cdc5961a4ba71a834935ebd8ba206fc72326d2e050188625f
4
+ data.tar.gz: 5317100f574d3449b1df75a6700a6091b999d251402e565d34580632e141652b
5
5
  SHA512:
6
- metadata.gz: 649e9ccbd07ca7bfa9bd507aeea9e0973edc1f524bf00cae8b1dd6d00464cc2ce71dfd761121ee1aae7321be80e5b6e35534e8eabf0251e5738303e1c29ec481
7
- data.tar.gz: d765582a2a7c0fbf187b45019c3934c2215aeac396fe568b5bd56b509d89694dd75eda0a46849b84ba6434e4863ba8a2b0bcfa24e95b4421a1016af85bc3f113
6
+ metadata.gz: 370d588a000805cf88998daa6c1b7afc267e099ce68b172459c098e7e9c3659f4ac29d15eafddbc0429287ef88ac359e41c23645df19c427cf0b0585b3bfda37
7
+ data.tar.gz: 646ff86552eecd1c5dc0a6db03bc3cbd78eb5a9c1cabbb166e593437776eb90fb0311f5f0a17284ad5a74a1698d35ff9cf6a8ad05ddf1ec9b7281407caf1e7f5
data/.version CHANGED
@@ -1 +1 @@
1
- 1.29.2
1
+ 1.29.3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
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
+
3
16
  ## 1.29.2
4
17
 
5
18
  ### Changed — `TombstonedError#work_retracted?` is now `work_suppressed?`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- atlas_rb (1.29.2)
4
+ atlas_rb (1.29.3)
5
5
  faraday (~> 2.7)
6
6
  faraday-follow_redirects (~> 0.3.0)
7
7
  faraday-multipart (~> 1)
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
@@ -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.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atlas_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.29.2
4
+ version: 1.29.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cliff