class Wayfarer::Frontiers::Frontier

@abstract The common behaviour of all frontiers. @api private

Attributes

config[R]

Public Class Methods

new(config) click to toggle source
# File lib/wayfarer/frontiers/frontier.rb, line 10
def initialize(config)
  @config = config
end

Public Instance Methods

cache(*_uris) click to toggle source

Caches URIs so they don't get processed again. @param [*Array<URI>, *Array<String>] uris

# File lib/wayfarer/frontiers/frontier.rb, line 40
def cache(*_uris)
  raise "Unimplemented"
end
cached?(_uri) click to toggle source

Whether a URI is cached.

# File lib/wayfarer/frontiers/frontier.rb, line 45
def cached?(_uri)
  raise "Unimplemented"
end
current_uris() click to toggle source

Returns URIs to be scraped in the current cycle. @note Usually an expensive operation! @return [Array<URI>]

# File lib/wayfarer/frontiers/frontier.rb, line 17
def current_uris
  raise "Unimplemented"
end
cycle() click to toggle source

TODO: Documentation

# File lib/wayfarer/frontiers/frontier.rb, line 53
def cycle
  unless config.allow_circulation
    cache(*current_uris) # TODO: Make it a template method
    filter_staged_uris!
  end

  return false if staged_uris.none?

  swap!
  reset_staged_uris!

  true
end
free() click to toggle source

Frees resources.

# File lib/wayfarer/frontiers/frontier.rb, line 50
def free; end
stage(*_uris) click to toggle source

Stages URIs for processing in the next cycle. @param [*Array<URI>, *Array<String>] uris

# File lib/wayfarer/frontiers/frontier.rb, line 29
def stage(*_uris)
  raise "Unimplemented"
end
staged?(_uri) click to toggle source

Whether a URI is cached.

# File lib/wayfarer/frontiers/frontier.rb, line 34
def staged?(_uri)
  raise "Unimplemented"
end
staged_uris() click to toggle source

Returns staged URIs. @return [Array<URI>]

# File lib/wayfarer/frontiers/frontier.rb, line 23
def staged_uris
  raise "Unimplemented"
end

Protected Instance Methods

filter_staged_uris!() click to toggle source

TODO: Documentation

# File lib/wayfarer/frontiers/frontier.rb, line 70
def filter_staged_uris!; end
reset_staged_uris!() click to toggle source

TODO: Documentation

# File lib/wayfarer/frontiers/frontier.rb, line 76
def reset_staged_uris!; end
swap!() click to toggle source

TODO: Documentation

# File lib/wayfarer/frontiers/frontier.rb, line 73
def swap!; end