purl_fetcher-client 1.4.0 → 1.5.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 233e4d6ce236ac3fe3e709a8cf53448c4359323127a9cebdba34224abc871c44
|
4
|
+
data.tar.gz: cfea673eabf4c581c063e739f5a12e5fea9457abd4c4215a171ad6bff45dda41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dbcd2a66de4040e7f19a20d575cc6a6ad4e0df7f405b82fdbe4f1675300cdabf3cb31585f7173cbd4d669b142789090de88da9c3d7ba469b2fd252336ce1603
|
7
|
+
data.tar.gz: 1dfd89e05103193888d7c3c46c68037d175e87f98ae3f40690ca2d8de7f892a757a656e8a2a8177ce215c8b00cb443792cb69d6df1219551c2a193354db6ba86
|
@@ -30,6 +30,8 @@ module PurlFetcher
|
|
30
30
|
attr_reader :cocina, :filepath_map
|
31
31
|
|
32
32
|
def file_metadata
|
33
|
+
return [] unless cocina.dro?
|
34
|
+
|
33
35
|
cocina.structural.contains.flat_map do |fileset|
|
34
36
|
fileset.structural.contains.select { |file| filepath_map.include?(file.filename) }.map do |file|
|
35
37
|
direct_upload_request_for(file)
|
@@ -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
|
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 =
|
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
|
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
|
+
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-
|
11
|
+
date: 2024-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|