Skip to content
This repository has been archived by the owner on Apr 14, 2018. It is now read-only.

Commit

Permalink
Merge branch 'refactor/next/unify_feed_methods' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrien Thebo committed May 27, 2012
2 parents f996dce + c650983 commit b83a0f5
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/gprov/provision/feed.rb
Expand Up @@ -11,14 +11,16 @@ def initialize(connection, url, xpath)
@connection = connection
@url = url
@xpath = xpath

@results = []
end

# Retrieve all entries in a feed, represented as nokogiri elements. Takes
# an optional block and yields to it each successive page of results
# retrieved. Returns all of the entries in the feed.
def fetch(&block)
# Fetch all entries in a feed, and ignore any cached entries. Accepts an
# optional block that will be fed each page of entries.
#
# This can be used to force a new fetch, but might cause unneeded overhead.
# You probably want #fetch.

def fetch!(&block)
@results = []
link = @url

until link.nil?
Expand All @@ -34,8 +36,8 @@ def fetch(&block)

# If no results are available, fetch them. Else return what data we have
# already downloaded.
def results
fetch unless @results
def fetch(&block)
fetch! &block unless @results
@results
end

Expand Down

0 comments on commit b83a0f5

Please sign in to comment.