adds more tests from microformats wiki

This commit is contained in:
Jessica Lynn Suttles 2013-02-14 14:24:05 -08:00
parent 7385f09eaf
commit fb7cc7f2eb
11 changed files with 16 additions and 4 deletions

View file

@ -37,8 +37,8 @@ module Microformats2
def parse_implied_properties
ip = []
ip << ImpliedProperty::Name.new(@element).parse unless property_present?(:name)
ip << ImpliedProperty::Photo.new(@element).parse unless property_present?(:photo)
ip << ImpliedProperty::Url.new(@element).parse unless property_present?(:url)
ip << ImpliedProperty::Photo.new(@element).parse unless property_present?(:photo)
ip.compact.each do |property|
save_property_name(property.method_name)
define_method(property.method_name)

View file

@ -2,9 +2,21 @@ module Microformats2
module Property
class DateTime < Foundation
def value
::DateTime.parse(super)
::DateTime.parse(string_value)
rescue ArgumentError => e
super
string_value
end
def string_value
@string_value ||= value_class_pattern || element_value || text_value
end
def to_hash
if formats.empty?
string_value.to_s
else
{ value: string_value.to_s }.merge(formats.first.to_hash)
end
end
protected

View file

@ -41,7 +41,7 @@ module Microformats2
end
def element_value
@element.attribute(attribute).to_s if attribute
@element.attribute(attribute).to_s if attribute && @element.attribute(attribute)
end
def text_value