curate-indexer 0.1.2 → 0.2.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
  SHA1:
3
- metadata.gz: 8e7f820cf5499fdc307ee6ea730a617aa25e207f
4
- data.tar.gz: d487a7ebe7a70531e18af7daef7686ff9f1fcc77
3
+ metadata.gz: ecfbe4261639066afa2f5f7bfe07a454bd93eafd
4
+ data.tar.gz: 7e05eb98cf120fdb06b8c8e64796f033f35df13d
5
5
  SHA512:
6
- metadata.gz: 323c1728db8083c2e621d729766c6790d1e0c46d1c8f4981d33aeda32a9f4bcd49e5b97df0c811df678a46aeee57a6f5735046a6840bafbab9edc4153910da25
7
- data.tar.gz: 8fe73493197258f63500fa0841e153a4b9e9a9a2dd7cbfd1471af7d9558ce49376c6b3fa54f0e5798b45ad19d5876fe64f2afe6044890af479605ae90e1a1138
6
+ metadata.gz: 9a697810391125695cfa863c29ae5d2bf4cb9f61a1da7576211f3b0c5597551aa4b613ebd070fda1795eb7ea5e31de7e530b76e6c93a9551e82f3baf5485b6e7
7
+ data.tar.gz: edf309676d3f07e1332b9328cd3a04330387dedfcf66318f545a234a44d05f8f31c938dcbe0ce0e9080b23878d0f70c7fd017e0215b04526341093706419025e
@@ -25,7 +25,7 @@ module Curate
25
25
  end
26
26
 
27
27
  # @api public
28
- # @param pid [String]
28
+ # @param document [Curate::Indexer::Documents::IndexDocument]
29
29
  # @yield Curate::Indexer::Documents::IndexDocument
30
30
  def self.each_child_document_of(*, &_block)
31
31
  raise NotImplementedError
@@ -29,10 +29,10 @@ module Curate
29
29
  end
30
30
 
31
31
  # @api public
32
- # @param pid [String]
32
+ # @param document [Curate::Indexer::Documents::IndexDocument]
33
33
  # @yield Curate::Indexer::Documents::IndexDocument
34
- def self.each_child_document_of(pid, &block)
35
- Index.each_child_document_of(pid, &block)
34
+ def self.each_child_document_of(document, &block)
35
+ Index.each_child_document_of(document, &block)
36
36
  end
37
37
 
38
38
  # @api public
@@ -17,8 +17,8 @@ module Curate
17
17
  Storage.find(pid)
18
18
  end
19
19
 
20
- def self.each_child_document_of(pid, &block)
21
- Storage.find_children_of_pid(pid).each(&block)
20
+ def self.each_child_document_of(document, &block)
21
+ Storage.find_children_of_pid(document.pid).each(&block)
22
22
  end
23
23
 
24
24
  def self.write_document(attributes = {})
@@ -24,12 +24,12 @@ module Curate
24
24
  attr_reader :pid, :time_to_live, :queue, :adapter
25
25
 
26
26
  def call
27
- enqueue(pid, time_to_live)
28
- index_document = dequeue
29
- while index_document
30
- process_a_document(index_document)
31
- adapter.each_child_document_of(index_document.pid) { |child| enqueue(child.pid, index_document.time_to_live - 1) }
32
- index_document = dequeue
27
+ enqueue(initial_index_document, time_to_live)
28
+ processing_document = dequeue
29
+ while processing_document
30
+ process_a_document(processing_document)
31
+ adapter.each_child_document_of(processing_document) { |child| enqueue(child, processing_document.time_to_live - 1) }
32
+ processing_document = dequeue
33
33
  end
34
34
  self
35
35
  end
@@ -38,13 +38,25 @@ module Curate
38
38
 
39
39
  attr_writer :document
40
40
 
41
+ def initial_index_document
42
+ adapter.find_index_document_by(pid)
43
+ end
44
+
41
45
  extend Forwardable
42
46
  def_delegator :queue, :shift, :dequeue
43
47
 
44
- ProcessingDocument = Struct.new(:pid, :time_to_live)
48
+ require 'delegate'
49
+ # A small object to help track time to live concerns
50
+ class ProcessingDocument < SimpleDelegator
51
+ def initialize(document, time_to_live)
52
+ @time_to_live = time_to_live
53
+ super(document)
54
+ end
55
+ attr_reader :time_to_live
56
+ end
45
57
  private_constant :ProcessingDocument
46
- def enqueue(pid, time_to_live)
47
- queue.push(ProcessingDocument.new(pid, time_to_live))
58
+ def enqueue(document, time_to_live)
59
+ queue.push(ProcessingDocument.new(document, time_to_live))
48
60
  end
49
61
 
50
62
  def process_a_document(index_document)
@@ -1,5 +1,5 @@
1
1
  module Curate
2
2
  module Indexer
3
- VERSION = "0.1.2".freeze
3
+ VERSION = "0.2.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curate-indexer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Friesen