purl_fetcher-client 0.2.0 → 0.3.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: 6ec6b5027a5b19369098f11455f0d3244ff3758d5469bd91998b63f2f80ccf80
4
- data.tar.gz: fbfa4939cba5c30ea7f31d98923e6a48114dc0db5e4d29494a1062e5d1199e64
3
+ metadata.gz: c0fbb1d4ee923c8a04d013b372637f82b18c9a2fa433cf40792aec85152062f1
4
+ data.tar.gz: 01dad44de5ded0fd3206d7adb7be24d89103ce8cbafb3cf1aaa9abee51f8add8
5
5
  SHA512:
6
- metadata.gz: 5d6a1d548fc27b0eb7496f2f3603ef10acb22f7931e32899442b1f027d36a9b4b6d8f18bc517dd0d220cb9dff4cc3a56c79b58d9441d9a540d6bafc6d3f821ba
7
- data.tar.gz: f7aa278c16d5d1da2b38fb9ea9f11adbe4fe3cd4d2fc262b8f00cbfd00ee1a6ebdd933a2493c069904fc82bcd0e63feb0ad7598f76315838bbeaf9dd002f8a95
6
+ metadata.gz: 6c7daf20c0d96b891998a9a622d5ca05b319b2a1ff60da84a6200f536fd778ca91ed41b396aa688a7b5d4b4c40d62a56e5bf49366596539968fa4cf1dcb40e13
7
+ data.tar.gz: 5352c32604756a40e6d807e3c93b05321aeb4c67d1222fb6fe8b03b60e20ba15dffb16e40631b05ba15c1c1824749be9f0ec10d3f757623ff575e1da214a0417
@@ -4,15 +4,18 @@ class PurlFetcher::Client::DeletesReader < PurlFetcher::Client::Reader
4
4
  return to_enum(:each) unless block_given?
5
5
 
6
6
  deletes(first_modified: first_modified).each do |change|
7
- yield PurlFetcher::Client::PublicXmlRecord.new(change['druid'].sub('druid:', ''), settings)
7
+
8
+ public_xml = PurlFetcher::Client::PublicXmlRecord.new(change['druid'].sub('druid:', ''), settings)
9
+
10
+ yield public_xml, change, self
8
11
  end
9
12
 
10
13
  changes(first_modified: first_modified, target: target).each do |change|
11
- record = PurlFetcher::Client::PublicXmlRecord.new(change['druid'].sub('druid:', ''), settings)
14
+ public_xml = PurlFetcher::Client::PublicXmlRecord.new(change['druid'].sub('druid:', ''), settings)
12
15
 
13
16
  next unless target.nil? || (change['false_targets'] && change['false_targets'].include?(target)) || (settings['skip_if_catkey'] && record.catkey)
14
17
 
15
- yield record
18
+ yield public_xml, change, self
16
19
  end
17
20
  end
18
21
  end
@@ -1,10 +1,11 @@
1
1
  class PurlFetcher::Client::Reader
2
2
  include Enumerable
3
- attr_reader :input_stream, :settings
3
+ attr_reader :input_stream, :settings, :range
4
4
 
5
5
  def initialize(input_stream, settings = {})
6
6
  @settings = settings
7
7
  @input_stream = input_stream
8
+ @range = {}
8
9
  end
9
10
 
10
11
  def each
@@ -15,7 +16,7 @@ class PurlFetcher::Client::Reader
15
16
 
16
17
  public_xml = PurlFetcher::Client::PublicXmlRecord.new(change['druid'].sub('druid:', ''), settings)
17
18
 
18
- yield public_xml, change, meta
19
+ yield public_xml, change, self
19
20
  end
20
21
  end
21
22
 
@@ -68,18 +69,19 @@ class PurlFetcher::Client::Reader
68
69
  def paginated_get(path, accessor, options = {})
69
70
  Enumerator.new do |yielder|
70
71
  params = options.dup
71
- per_page = params.delete(:per_page) { 100 }
72
+ per_page = params.delete(:per_page) { 1000 }
72
73
  page = params.delete(:page) { 1 }
73
74
  max = params.delete(:max) { 1_000_000 }
74
75
  total = 0
75
76
 
76
77
  loop do
77
78
  data = get(path, { per_page: per_page, page: page }.merge(params))
79
+ @range = data['range']
78
80
 
79
81
  total += data[accessor].length
80
82
 
81
83
  data[accessor].each do |element|
82
- yielder.yield element, { 'range' => data['range'] || {} }
84
+ yielder.yield element, self
83
85
  end
84
86
 
85
87
  page = data['pages']['next_page']
@@ -1,5 +1,5 @@
1
1
  module PurlFetcher
2
2
  module Client
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.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: 0.2.0
4
+ version: 0.3.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: 2019-05-29 00:00:00.000000000 Z
11
+ date: 2019-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http