lib/mida/document.rb in mida-0.3.2 vs lib/mida/document.rb in mida-0.3.3
- old
+ new
@@ -13,15 +13,14 @@
# Create a new Microdata object
#
# [target] The string containing the html that you want to parse.
# [page_url] The url of target used for form absolute urls. This must
# include the filename, e.g. index.html.
- # [validate] Whether to validate the items against known vocabularies.
- def initialize(target, page_url=nil, validate=true)
+ def initialize(target, page_url=nil)
@doc = Nokogiri(target)
@page_url = page_url
- @items = extract_items(validate)
+ @items = extract_items
end
# Implements method for Enumerable
def each
@items.each {|item| yield(item)}
@@ -44,16 +43,16 @@
found_items.concat(search_values(item.properties.values, itemtype))
end
end
private
- def extract_items(validate)
+ def extract_items
itemscopes = @doc.search('//*[@itemscope and not(@itemprop)]')
return nil unless itemscopes
itemscopes.collect do |itemscope|
itemscope = Itemscope.new(itemscope, @page_url)
- Item.new(itemscope, validate)
+ Item.new(itemscope)
end
end
def search_values(values, vocabulary)
values.each_with_object([]) do |value, items|