C0 code coverage information

Generated on Tue May 30 23:34:43 CEST 2006 with rcov 0.5.0


Code reported as executed by Ruby looks like this...
and this: this line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this,
and this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not executed.
Name Total lines Lines of code Total coverage Code coverage
app/models/aggregations/flickr.rb 81 53
88.9% 
86.8% 
 1 require 'open-uri'
 2 require 'time'
 3 require 'rexml/document'
 4 
 5 # Example:
 6 # 
 7 # flickr = Flickr.new('http://www.flickr.com/services/feeds/photos_public.gne?id=40235412@N00&format=rss_200')
 8 # flickr.pics.each do |pic|
 9 #   puts "#{pic.title} @ #{pic.link} updated at #{pic.date}"
10 # end
11 #
12 class Flickr
13   include REXML
14 
15   def choose(num)
16     return pics unless pics.size > num
17     bag = []
18     set = pics.dup
19     (0..num-1).each {|x| bag << set.delete_at(rand(set.size))}
20     bag
21   end
22   
23   attr_accessor :url, :pics, :link, :title, :description
24     
25   # This object holds given information of a picture
26   class Picture < Struct.new(:link, :title, :date, :description)
27     def to_s; title end          
28     def date=(value); super(Time.parse(value)) end
29     def image 
30       description.scan( /(http:\/\/(static|photos).*?\.jpg)/ ).first.first
31     end
32     def thumb
33       image.gsub( /\_(m)\./, '_t.' )
34     end
35     def square
36       image.gsub( /\_(m)\./, '_s.' )
37     end
38   end
39     
40   # Pass the url to the RSS feed you would like to keep tabs on
41   # by default this will request the rss from the server right away and 
42   # fill the tasks array
43   def initialize(url, refresh = true)
44     self.pics  = []
45     self.url    = url
46     self.refresh if refresh
47   end
48   
49   # This method lets you refresh the tasks int the tasks array
50   # useful if you keep the object cached in memory and 
51   def refresh
52     open(@url) do |http|
53       parse(http.read)
54     end
55   end
56   
57 private
58 
59   def parse(body)
60   
61     xml = Document.new(body)
62   
63     self.pics        = []    
64     self.link         = XPath.match(xml, "//channel/link/text()").to_s
65     self.title        = XPath.match(xml, "//channel/title/text()").to_s
66     self.description  = XPath.match(xml, "//channel/description/text()").to_s
67           
68     XPath.each(xml, "//item/") do |elem| 
69     
70       picture = Picture.new
71       picture.title       = XPath.match(elem, "title/text()").to_s                  
72       picture.date        = XPath.match(elem, "pubDate/text()").to_s
73       picture.link        = XPath.match(elem, "link/text()").to_s
74       picture.description = XPath.match(elem, "description/text()").to_s
75       
76       pics << picture
77     end
78   end
79 end
80 
81 

Generated using the rcov code coverage analysis tool for Ruby version 0.5.0.

Valid XHTML 1.0! Valid CSS!