C0 code coverage information
Generated on Sun Jun 11 23:15:13 CEST 2006 with rcov 0.6.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.
1 require 'open-uri'
Calls
1 Object#require at vendor/rails/activesupport/lib/active_support/dependencies.rb:213
2 require 'time'
Calls
1 Object#require at vendor/rails/activesupport/lib/active_support/dependencies.rb:213
3 require 'rexml/document'
Calls
1 Object#require at vendor/rails/activesupport/lib/active_support/dependencies.rb:213
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
Calls
1 Class#inherited at vendor/rails/activesupport/lib/active_support/class_inheritable_attributes.rb:108
13 include REXML
14
15 def choose(num)
Calls
1 #<Class:Object>#method_added at vendor/rails/actionpack/lib/action_view/vendor/builder/blankslate.rb:47
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
Calls
10 #<Class:Object>#method_added at vendor/rails/actionpack/lib/action_view/vendor/builder/blankslate.rb:47
24
25 # This object holds given information of a picture
26 class Picture < Struct.new(:link, :title, :date, :description)
Calls
8 #<Class:Object>#method_added at vendor/rails/actionpack/lib/action_view/vendor/builder/blankslate.rb:47
2 Class#inherited at vendor/rails/activesupport/lib/active_support/class_inheritable_attributes.rb:108
27 def to_s; title end
Calls
1 #<Class:Object>#method_added at vendor/rails/actionpack/lib/action_view/vendor/builder/blankslate.rb:47
28 def date=(value); super(Time.parse(value)) end
Calls
1 #<Class:Object>#method_added at vendor/rails/actionpack/lib/action_view/vendor/builder/blankslate.rb:47
29 def image
Calls
1 #<Class:Object>#method_added at vendor/rails/actionpack/lib/action_view/vendor/builder/blankslate.rb:47
30 description.scan( /(http:\/\/(static|photos).*?\.jpg)/ ).first.first
31 end
32 def thumb
Calls
1 #<Class:Object>#method_added at vendor/rails/actionpack/lib/action_view/vendor/builder/blankslate.rb:47
33 image.gsub( /\_(m)\./, '_t.' )
34 end
35 def square
Calls
1 #<Class:Object>#method_added at vendor/rails/actionpack/lib/action_view/vendor/builder/blankslate.rb:47
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)
Calls
1 #<Class:Object>#method_added at vendor/rails/actionpack/lib/action_view/vendor/builder/blankslate.rb:47
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
Calls
1 #<Class:Object>#method_added at vendor/rails/actionpack/lib/action_view/vendor/builder/blankslate.rb:47
52 open(@url) do |http|
53 parse(http.read)
54 end
55 end
56
57 private
58
59 def parse(body)
Calls
1 #<Class:Object>#method_added at vendor/rails/actionpack/lib/action_view/vendor/builder/blankslate.rb:47
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.6.0.