ruby-yadis 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,6 @@ class ServiceEndpoint
8
8
  @uri = nil
9
9
  @yadis_uri = nil
10
10
  @element = nil
11
- @yadis_uri = nil
12
11
  end
13
12
 
14
13
  def match_type_uris(type_uris)
@@ -96,7 +96,7 @@ class XRDS
96
96
  service.uri = nil
97
97
  service.service_types = []
98
98
 
99
- service_element.elements.each('Type') do |t|
99
+ REXML::XPath.each(service_element, 'xrdns:Type', @@namespaces) do |t|
100
100
  # XXX: If the Type element is empty, should we add an empty element
101
101
  # to our list, or none at all?
102
102
  service.service_types << t.text.strip unless t.text.nil?
@@ -104,23 +104,23 @@ class XRDS
104
104
 
105
105
  sp = service_element.attributes['priority']
106
106
  service_priority = sp ? sp.to_i : -1
107
+ has_uri = false
107
108
 
108
- if service.element.elements['URI']
109
- service.element.elements.each('URI') do |uri|
110
- _service = service.dup
111
- _service.uri = uri.text.strip
112
-
113
- up = uri.attributes['priority']
114
- uri_priority = up ? up.to_i : -1
115
- priority = [service_priority, uri_priority]
116
-
117
- _add_service(priority, _service)
118
- end
109
+ REXML::XPath.each(service.element, 'xrdns:URI', @@namespaces) do |uri|
110
+ has_uri = true
111
+ _service = service.dup
112
+ _service.uri = uri.text.strip
113
+
114
+ up = uri.attributes['priority']
115
+ uri_priority = up ? up.to_i : -1
116
+ priority = [service_priority, uri_priority]
119
117
 
120
- else
118
+ _add_service(priority, _service)
119
+ end
120
+
121
+ unless has_uri
121
122
  priority = [service_priority, -1]
122
123
  _add_service(priority, service)
123
-
124
124
  end
125
125
 
126
126
  end
@@ -14,6 +14,10 @@ class XRDSTestCase < Test::Unit::TestCase
14
14
  xrds = XRDS.new(f.read)
15
15
  assert_not_nil(xrds)
16
16
  assert_equal(xrds.services.length, 9)
17
+
18
+ service = xrds.services[0]
19
+ assert_not_nil(service)
20
+ assert_not_nil(service.uri)
17
21
  end
18
22
  end
19
23
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: ruby-yadis
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.3.1
7
- date: 2006-06-09 00:00:00 -07:00
6
+ version: 0.3.2
7
+ date: 2006-06-26 00:00:00 -07:00
8
8
  summary: A library for performing Yadis service discovery
9
9
  require_paths:
10
10
  - lib