C0 code coverage information

Generated on Fri Jul 11 15:55:30 -0700 2008 with rcov 0.7.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
lib/openid/yadis/xrds.rb 155 110
93.5% 
90.9% 
  1 require 'rexml/document'
  2 require 'rexml/element'
  3 require 'rexml/xpath'
  4 
  5 require 'openid/yadis/xri'
  6 
  7 module OpenID
  8   module Yadis
  9 
 10     XRD_NS_2_0 = 'xri://$xrd*($v*2.0)'
 11     XRDS_NS = 'xri://$xrds'
 12 
 13     XRDS_NAMESPACES = {
 14       'xrds' => XRDS_NS,
 15       'xrd' => XRD_NS_2_0,
 16     }
 17 
 18     class XRDSError < StandardError; end
 19 
 20     # Raised when there's an assertion in the XRDS that it does not
 21     # have the authority to make.
 22     class XRDSFraud < XRDSError
 23     end
 24 
 25     def Yadis::get_canonical_id(iname, xrd_tree)
 26       # Return the CanonicalID from this XRDS document.
 27       #
 28       # @param iname: the XRI being resolved.
 29       # @type iname: unicode
 30       #
 31       # @param xrd_tree: The XRDS output from the resolver.
 32       #
 33       # @returns: The XRI CanonicalID or None.
 34       # @returntype: unicode or None
 35 
 36       xrd_list = []
 37       REXML::XPath::match(xrd_tree.root, '/xrds:XRDS/xrd:XRD', XRDS_NAMESPACES).each { |el|
 38         xrd_list << el
 39       }
 40 
 41       xrd_list.reverse!
 42 
 43       cid_elements = []
 44 
 45       if !xrd_list.empty?
 46         xrd_list[0].elements.each { |e|
 47           if !e.respond_to?('name')
 48             next
 49           end
 50           if e.name == 'CanonicalID'
 51             cid_elements << e
 52           end
 53         }
 54       end
 55 
 56       cid_element = cid_elements[0]
 57 
 58       if !cid_element
 59         return nil
 60       end
 61 
 62       canonicalID = XRI.make_xri(cid_element.text)
 63 
 64       childID = canonicalID.downcase
 65 
 66       xrd_list[1..-1].each { |xrd|
 67         parent_sought = childID[0...childID.rindex('!')]
 68 
 69         parent = XRI.make_xri(xrd.elements["CanonicalID"].text)
 70 
 71         if parent_sought != parent.downcase
 72           raise XRDSFraud.new(sprintf("%s can not come from %s", parent_sought,
 73                                       parent))
 74         end
 75 
 76         childID = parent_sought
 77       }
 78 
 79       root = XRI.root_authority(iname)
 80       if not XRI.provider_is_authoritative(root, childID)
 81         raise XRDSFraud.new(sprintf("%s can not come from root %s", childID, root))
 82       end
 83 
 84       return canonicalID
 85     end
 86 
 87     class XRDSError < StandardError
 88     end
 89 
 90     def Yadis::parseXRDS(text)
 91       if text.nil?
 92         raise XRDSError.new("Not an XRDS document.")
 93       end
 94 
 95       begin
 96         d = REXML::Document.new(text)
 97       rescue RuntimeError => why
 98         raise XRDSError.new("Not an XRDS document. Failed to parse XML.")
 99       end
100 
101       if is_xrds?(d)
102         return d
103       else
104         raise XRDSError.new("Not an XRDS document.")
105       end
106     end
107 
108     def Yadis::is_xrds?(xrds_tree)
109       xrds_root = xrds_tree.root
110       return (!xrds_root.nil? and
111         xrds_root.name == 'XRDS' and
112         xrds_root.namespace == XRDS_NS)
113     end
114 
115     def Yadis::get_yadis_xrd(xrds_tree)
116       REXML::XPath.each(xrds_tree.root,
117                         '/xrds:XRDS/xrd:XRD[last()]',
118                         XRDS_NAMESPACES) { |el|
119         return el
120       }
121       raise XRDSError.new("No XRD element found.")
122     end
123 
124     # aka iterServices in Python
125     def Yadis::each_service(xrds_tree, &block)
126       xrd = get_yadis_xrd(xrds_tree)
127       xrd.each_element('Service', &block)
128     end
129 
130     def Yadis::services(xrds_tree)
131       s = []
132       each_service(xrds_tree) { |service|
133         s << service
134       }
135       return s
136     end
137 
138     def Yadis::expand_service(service_element)
139       es = service_element.elements
140       uris = es.each('URI') { |u| }
141       uris = prio_sort(uris)
142       types = es.each('Type/text()')
143       # REXML::Text objects are not strings.
144       types = types.collect { |t| t.to_s }
145       uris.collect { |uri| [types, uri.text, service_element] }
146     end
147 
148     # Sort a list of elements that have priority attributes.
149     def Yadis::prio_sort(elements)
150       elements.sort { |a,b|
151         a.attribute('priority').to_s.to_i <=> b.attribute('priority').to_s.to_i
152       }
153     end
154   end
155 end

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

Valid XHTML 1.0! Valid CSS!