Permalink
Browse files

use in parent hcard for hentry without author

  • Loading branch information...
1 parent 53550ce commit c25faa0e5f7fa7dbf5cc93fde9c20ec888ab0fb5 Eivind Uggedal committed Jan 27, 2008
Showing with 738 additions and 0 deletions.
  1. +24 −0 lib/mofo/hentry.rb
  2. +707 −0 test/fixtures/redflavor.html
  3. +7 −0 test/hatom_test.rb
View
@@ -47,6 +47,30 @@ def to_atom(property = nil, value = nil)
</entry>
atom_entity
end
+
+ def missing_author?
+ @author.nil?
+ end
+
+ def add_in_parent_hcard
+ @properties << 'author'
+ @author = self.class.find_in_parent_hcard
+ end
+
+ class << self
+ def build_class(microformat)
+ hentry = super(microformat)
+ hentry.add_in_parent_hcard if hentry.missing_author?
+ hentry
+ end
+
+ # Per spec: if the entry author is missing find the nearest in
+ # parent <address> element(s) with class name author
+ def find_in_parent_hcard
+ @in_parent_hcard ||= prepare_value(HCard.find(
+ :text => (@doc/"//.hentry/../address.vcard").to_s))
+ end
+ end
end
class Array
Oops, something went wrong.

0 comments on commit c25faa0

Please sign in to comment.