fixes whitespace issue. uses two spaces instead of tabs

This commit is contained in:
Jessica Lynn Suttles 2013-02-13 17:28:08 -08:00
parent b4084d5325
commit 1d8e46ce95
8 changed files with 181 additions and 141 deletions

View file

@ -31,7 +31,10 @@ module Microformats2
# find ruby class for kind of property # find ruby class for kind of property
klass = Microformats2::Property::PREFIX_CLASS_MAP[prefix] klass = Microformats2::Property::PREFIX_CLASS_MAP[prefix]
klass.new(element, property_class).parse property = klass.new(element, property_class).parse
properties = format_classes(element).empty? ? PropertyParser.parse(element.children) : []
properties << property
end end
end end
@ -40,6 +43,12 @@ module Microformats2
html_class =~ Property::CLASS_REG_EXP html_class =~ Property::CLASS_REG_EXP
end end
end end
def format_classes(element)
element.attribute("class").to_s.split.select do |html_class|
html_class =~ Format::CLASS_REG_EXP
end
end
end # class << self end # class << self
end end
end end

View file

@ -101,4 +101,35 @@ describe Microformats2::Collection do
end end
end end
end end
describe ".h-entry .p-author.h-card nested" do
before do
html = "spec/support/hcard-pname-pnickname-nested.html"
@collection = Microformats2.parse(html)
end
describe "#parse" do
it "assigns .h-card .p-name to HCard#name" do
@collection.first.name.first.value.should == "jlsuttles"
end
it "assigns .h-card .p-nickname to HCard#nickname" do
@collection.first.nickname.first.value.should == "jlsuttles"
end
end
describe "#to_hash" do
it "returns the correct Hash" do
hash = {
:items => [{
:type => ["h-card"],
:properties => {
:name => ["jlsuttles"],
:nickname => ["jlsuttles"]
}
}]
}
@collection.to_hash.should == hash
end
end
end
end end