Permalink
Browse files

simplify feed method

  • Loading branch information...
1 parent 72898be commit ab5a7822e0b7bc9b8ac1aeb473944fa58bd4b30b @jaimeiniesta committed Dec 2, 2012
Showing with 7 additions and 6 deletions.
  1. +7 −6 lib/meta_inspector/scraper.rb
@@ -72,13 +72,9 @@ def image
meta_og_image
end
- # Returns the parsed document meta rss links
+ # Returns the parsed document meta rss link
def feed
- @feed ||= parsed_document.xpath("//link").select{ |link|
- link.attributes["type"] && link.attributes["type"].value =~ /(atom|rss)/
- }.map { |link|
- absolutify_url(link.attributes["href"].value)
- }.first rescue nil
+ @feed ||= (parsed_feed('rss') || parsed_feed('atom'))
end
# Returns the charset from the meta tags, looking for it in the following order:
@@ -197,6 +193,11 @@ def get_meta_name_or_property(element)
end
end
+ def parsed_feed(format)
+ feed = parsed_document.search("//link[@type='application/#{format}+xml']").first
+ absolutify_url feed.attributes['href'].value
+ end
+
def parsed_links
@parsed_links ||= cleanup_nokogiri_values(parsed_document.search("//a/@href"))
end

0 comments on commit ab5a782

Please sign in to comment.