public
Fork of defunkt/mofo
Description: Mofo is a fast and simple microformat parser, based on a concise DSL and Hpricot.
Homepage: http://mofo.rubyforge.org/
Clone URL: git://github.com/uggedal/mofo.git
hentry invalid without author. in_parent_hcard object instance instead of
class instance. address node need not be child of parent but can be 
descendant.
uggedal (author)
Sun Jan 27 05:27:33 -0800 2008
commit  70d22bd059e417b30b2f85e8575077febdee9dd5
tree    82530f6054dd4a9216e94f639eb27ee763418578
parent  c25faa0e5f7fa7dbf5cc93fde9c20ec888ab0fb5
...
54
55
56
57
 
 
 
 
 
 
 
58
59
60
...
64
65
66
67
68
69
70
71
 
 
 
72
73
74
...
54
55
56
 
57
58
59
60
61
62
63
64
65
66
...
70
71
72
 
 
73
 
 
74
75
76
77
78
79
0
@@ -54,7 +54,13 @@ class HEntry < Microformat
0
 
0
   def add_in_parent_hcard
0
     @properties << 'author'
0
- @author = self.class.find_in_parent_hcard
0
+ @author = in_parent_hcard
0
+ end
0
+
0
+ # Per spec: if the entry author is missing find the nearest in
0
+ # parent <address> element(s) with class name author
0
+ def in_parent_hcard
0
+ @in_parent_hcard ||= self.class.find_in_parent_hcard
0
   end
0
 
0
   class << self
0
@@ -64,11 +70,10 @@ class HEntry < Microformat
0
       hentry
0
     end
0
 
0
- # Per spec: if the entry author is missing find the nearest in
0
- # parent <address> element(s) with class name author
0
     def find_in_parent_hcard
0
- @in_parent_hcard ||= prepare_value(HCard.find(
0
- :text => (@doc/"//.hentry/../address.vcard").to_s))
0
+ author = HCard.find(:text => (@doc/"//.hentry/..//address.vcard").to_s)
0
+ raise InvalidMicroformat if @options[:strict] && author.empty?
0
+ prepare_value(author)
0
     end
0
   end
0
 end
...
20
21
22
 
 
 
 
 
 
 
23
24
25
...
20
21
22
23
24
25
26
27
28
29
30
31
32
0
@@ -20,6 +20,13 @@ context "A parsed hEntry object" do
0
                              :base => 'http://journal.redflavor.com')
0
     with_parent.author.should.be.an.instance_of HCard
0
     with_parent.author.fn.should.equal "Eivind Uggedal"
0
+ with_parent.author.url.should.equal "http://redflavor.com"
0
+ end
0
+
0
+ specify "should be invalid without any author in strict mode" do
0
+ proc { HEntry.find(:first => fixture(:hatom_without_author),
0
+ :base => 'http://bogus.redflavor.com',
0
+ :strict => true) }.should.raise InvalidMicroformat
0
   end
0
 
0
   specify "should have content" do

Comments

    No one has commented yet.