Module: Synchroniser::Ingestor::Uri

Includes:
Synchroniser::Ingestor
Included in:
DummyIngestor, RssIngestor
Defined in:
lib/synchroniser/ingestor/uri.rb

Instance Attribute Summary

Attributes included from Synchroniser::Ingestor

#container

Instance Method Summary collapse

Methods included from Synchroniser::Ingestor

#sync

Instance Method Details

#load(uri) ⇒ Object



12
13
14
# File 'lib/synchroniser/ingestor/uri.rb', line 12

def load(uri)
  @data = open(uri).read
end

#paginationObject



16
17
18
19
# File 'lib/synchroniser/ingestor/uri.rb', line 16

def pagination
  # pagination is not enabled by default
  []
end

#populate(url) ⇒ Object



6
7
8
9
10
# File 'lib/synchroniser/ingestor/uri.rb', line 6

def populate(url)
  ingestor = self.clone
  ingestor.load(url)
  ingestor
end

#strategise(urls) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/synchroniser/ingestor/uri.rb', line 21

def strategise(urls)
  strategies = urls.inject([]) do |strategies, url|
      strategies << populate(url)
  end

  # not sure if this will actually work
  # for every ingestor
  strategies.inject([]) do |strategies, ingestor|
    # grab the pagination urls and populate strategy with a new ingestor
    ingestor.pagination.inject([]) do |strategies, url|
      strategies << ingestor.populate(url)
      #lastly add in the original ingestor
    end << ingestor
  end
end