public
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/defunkt/mofo.git
Search Repo:
fixed find and added test/fixture because hCards passed in via the :text 
option were missing postal_code
Ben Kerney (author)
Tue May 13 11:02:33 -0700 2008
commit  e9d951e07094409feff2c69d8c89406332bd9c16
tree    ab9ca09894b02e200f3d7ad8c7b49da363d988fb
parent  1a737bc6d4ea4404217729bcb612452dc14d1b2c
...
18
19
20
21
 
22
23
24
...
18
19
20
 
21
22
23
24
0
@@ -18,7 +18,7 @@ class Microformat
0
 
0
       extract_base_url! target
0
       
0
- @doc = build_doc(@options[:text] ? @options : target)
0
+ @doc = target.kind_of?(Hpricot::Elem) ? target : build_doc(@options[:text] ? @options : target)
0
 
0
       microformats = find_occurences(@doc)
0
       raise MicroformatNotFound if @options[:strict] && microformats.empty?
...
143
144
145
146
 
147
148
149
...
143
144
145
 
146
147
148
149
0
@@ -143,7 +143,7 @@
0
   <span class="fn org"><a href="/venue/3804/">Calvin College: Fine Arts Centre</a></span><br />
0
   <div class="address adr">
0
     <span class="street-address">3210 Burton SE</span><br />
0
- <span class="locality">Grand Rapids</span>, <span class="region">Michigan</span> <span class="postal-code"></span>
0
+ <span class="locality">Grand Rapids</span>, <span class="region">Michigan</span> <span class="postal-code">49546</span>
0
 
0
   </div>
0
     <span class="geo" style="display: none">
...
29
30
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
33
34
...
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
0
@@ -29,6 +29,25 @@ context "A simple hcard definition" do
0
   end
0
 end
0
 
0
+context "The hCard found in the upcoming_single page" do
0
+ setup do
0
+ $upcoming_text = HCard.find(:text => open(fixture(:upcoming_single)).read)
0
+ $upcoming_find = HCard.find(fixture(:upcoming_single))
0
+ end
0
+
0
+ specify "should be identical whether passed as :text or found with default method" do
0
+ $upcoming_text.fn.should.equal $upcoming_find.fn
0
+ $upcoming_text.org.should.equal $upcoming_find.org
0
+ $upcoming_text.adr.base_url.should.equal $upcoming_find.adr.base_url
0
+ $upcoming_text.adr.postal_code.should.equal $upcoming_find.adr.postal_code
0
+ $upcoming_text.adr.locality.should.equal $upcoming_find.adr.locality
0
+ $upcoming_text.adr.region.should.equal $upcoming_find.adr.region
0
+ $upcoming_text.adr.street_address.should.equal $upcoming_find.adr.street_address
0
+ $upcoming_text.geo.longitude.should.equal $upcoming_find.geo.longitude
0
+ $upcoming_text.geo.latitude.should.equal $upcoming_find.geo.latitude
0
+ end
0
+end
0
+
0
 context "The parsed fauxtank hCard object" do
0
   setup do
0
     $fauxtank ||= HCard.find(:first => fixture(:fauxtank))

Comments

    No one has commented yet.