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/upcoming.rb 78 48
48.7% 
29.2% 
 1 require 'open-uri'
 2 require 'rexml/document'
 3 
 4 # Example:
 5 # 
 6 # upcoming = Upcoming.new('http://upcoming.org/syndicate/my_events/<your_user_id>')
 7 # upcoming.events.each do |event|
 8 #   puts "#{event.title} @  #{event.timespan} #{event.link} : #{event.description}"
 9 # end
10 #
11 
12 class Upcoming
13   include REXML
14 
15   def choose(num)
16     return events unless events.size > num
17     bag = []
18     set = events.dup
19     (0..num-1).each {|x| bag << set.delete_at(set.size)}
20     bag
21   end
22   
23   attr_accessor :events, :link, :title, :description, :url
24     
25   # This object holds given information for an Event
26   class Event < Struct.new(:link, :title, :description)
27     def to_s; title end          
28 
29     def timespan 
30       description.split(':')[0]
31     end
32 
33     def info
34         description.split(':')[1]
35     end  
36   end
37     
38   # Pass the url to the RSS feed you would like to keep tabs on
39   # by default this will request the rss from the server right away and 
40   # fill the tasks array
41   def initialize(url, refresh = true)
42     self.events  = []
43     self.url    = url
44     self.refresh if refresh
45   end
46   
47   # This method lets you refresh the tasks int the tasks array
48   # useful if you keep the object cached in memory and 
49   def refresh
50     open(@url) do |http|
51       parse(http.read)
52     end
53   end
54   
55 private
56 
57   def parse(body)
58   
59     xml = Document.new(body)
60   
61     self.events       = []    
62     self.link         = XPath.match(xml, "//channel/link/text()").to_s
63     self.title        = XPath.match(xml, "//channel/title/text()").to_s
64     self.description  = XPath.match(xml, "//channel/description/text()").to_s
65           
66     XPath.each(xml, "//item/") do |elem| 
67     
68       event = Event.new
69       event.title       = XPath.match(elem, "title/text()").to_s                  
70       event.link        = XPath.match(elem, "link/text()").to_s
71       event.description = XPath.match(elem, "description/text()").to_s
72       event.inspect
73       events << event
74     end
75   end
76 end
77 
78 

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

Valid XHTML 1.0! Valid CSS!