Skip to content

Commit

Permalink
refactor local variable into private method
Browse files Browse the repository at this point in the history
  • Loading branch information
tilsammans committed Aug 20, 2010
1 parent 62ddd8e commit 17be453
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions lib/anemone/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,22 @@ def links_to_follow(page)
# Returns +false+ otherwise.
#
def visit_link?(link, from_page = nil)
allowed = @opts[:obey_robots_txt] ? @robots.allowed?(link) : true

if from_page && @opts[:depth_limit]
too_deep = from_page.depth >= @opts[:depth_limit]
else
too_deep = false
end

!@pages.has_page?(link) && !skip_link?(link) && !skip_query_string?(link) && allowed && !too_deep
!@pages.has_page?(link) && !skip_link?(link) && !skip_query_string?(link) && allowed(link) && !too_deep
end

#
# Returns +true+ if we are obeying robots.txt and the link
# is granted access in it. Always returns +true+ when we are
# not obeying robots.txt.
#
def allowed(link)
@opts[:obey_robots_txt] ? @robots.allowed?(link) : true
end

#
Expand Down
2 changes: 1 addition & 1 deletion spec/core_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module Anemone
core.should have(2).pages
core.pages.keys.should_not include(pages[2].url)
end

it "should be able to skip links with query strings" do
pages = []
pages << FakePage.new('0', :links => ['1?foo=1', '2'])
Expand Down

0 comments on commit 17be453

Please sign in to comment.