purl_fetcher-client 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 027601e72f94ac6befda0395719b6d334221fce396e2c6ef306c7ec012e19609
4
- data.tar.gz: f77c4469ee2f67e340db177d092844011619725aa28681e3ef074b362532715e
3
+ metadata.gz: 233e4d6ce236ac3fe3e709a8cf53448c4359323127a9cebdba34224abc871c44
4
+ data.tar.gz: cfea673eabf4c581c063e739f5a12e5fea9457abd4c4215a171ad6bff45dda41
5
5
  SHA512:
6
- metadata.gz: 2b704e9fac0330914822891a6ddd73034b7100eb11653cd506699569d341eefda56613949a64fffd4616bbfc7b63404ff529ef386228c02c54887e7316dc12e9
7
- data.tar.gz: 43eabc9ce42dcdc937cacac235550bdb396096cce0caeedf8134976b0c50aaf8848065da739aa6afec8a6c0d3d83a96a9f182e6538c246820c74c158129d4ee3
6
+ metadata.gz: 0dbcd2a66de4040e7f19a20d575cc6a6ad4e0df7f405b82fdbe4f1675300cdabf3cb31585f7173cbd4d669b142789090de88da9c3d7ba469b2fd252336ce1603
7
+ data.tar.gz: 1dfd89e05103193888d7c3c46c68037d175e87f98ae3f40690ca2d8de7f892a757a656e8a2a8177ce215c8b00cb443792cb69d6df1219551c2a193354db6ba86
@@ -1,5 +1,6 @@
1
1
  class PurlFetcher::Client::Reader
2
2
  include Enumerable
3
+
3
4
  attr_reader :host, :conn, :range
4
5
 
5
6
  def initialize(host: "https://purl-fetcher.stanford.edu", conn: nil)
@@ -18,11 +19,17 @@ class PurlFetcher::Client::Reader
18
19
  end
19
20
  end
20
21
 
22
+ # @return [Array<Hash<String,String>>] a list of hashes where the key is a digest and the value is a filepath/filename
23
+ def files_by_digest(druid)
24
+ retrieve_json("/purls/druid:#{druid.delete_prefix('druid:')}", {})
25
+ .fetch("files_by_md5", [])
26
+ end
27
+
21
28
  private
22
29
 
23
30
  ##
24
31
  # @return [Hash] a parsed JSON hash
25
- def fetch(path, params)
32
+ def retrieve_json(path, params)
26
33
  response = conn.get(path, params: params)
27
34
 
28
35
  unless response.success?
@@ -54,7 +61,7 @@ class PurlFetcher::Client::Reader
54
61
  total = 0
55
62
 
56
63
  loop do
57
- data = fetch(path, { per_page: per_page, page: page }.merge(params))
64
+ data = retrieve_json(path, { per_page: per_page, page: page }.merge(params))
58
65
  @range = data["range"]
59
66
 
60
67
  total += data[accessor].length
@@ -1,5 +1,5 @@
1
1
  module PurlFetcher
2
2
  class Client
3
- VERSION = "1.4.1"
3
+ VERSION = "1.5.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: purl_fetcher-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-30 00:00:00.000000000 Z
11
+ date: 2024-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport