barx 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/xri_parser.rb +1 -1
  2. data/lib/xri_resolver.rb +25 -2
  3. metadata +17 -17
data/lib/xri_parser.rb CHANGED
@@ -151,7 +151,7 @@ module XriParser
151
151
 
152
152
  def normalized
153
153
  if @root == '@' or @root == '='
154
- @root + @subsegments.to_s[1..-1]
154
+ @root + ((@subsegments.to_s[0,1] == '!') ? @subsegments.to_s : @subsegments.to_s[1..-1])
155
155
  else
156
156
  @root + @subsegments.to_s
157
157
  end
data/lib/xri_resolver.rb CHANGED
@@ -252,7 +252,11 @@ module XriResolver
252
252
  begin
253
253
  uri = @authority_uris.shift
254
254
  uri.path << '/'
255
- hxri = uri.merge(subsegment)
255
+ if subsegment[1..-1] == CGI.unescape(subsegment[1..-1])
256
+ hxri = uri.merge("#{subsegment[0,1]}#{CGI.escape(subsegment[1..-1])}")
257
+ else
258
+ hxri = uri.merge(subsegment)
259
+ end
256
260
  resolved = fetch_uri(hxri)
257
261
  xml = resolved.content.unpack("C*").pack("U*") #convert to UTF8
258
262
  rescue Exception => e
@@ -522,7 +526,7 @@ module XriResolver
522
526
  end
523
527
 
524
528
  newxrdeles = xrd.elements.partition do |x|
525
- after = xrd.elements['Query']
529
+ after = xrd.elements['Status'] || xrd.elements['Query']
526
530
  xrd.elements.index(x) <= xrd.elements.index(after)
527
531
  end
528
532
 
@@ -549,6 +553,20 @@ module XriResolver
549
553
  ## do SEP selection on last XRD
550
554
  seplist = SEPSelector.select(self, xrd_list.last, @req)
551
555
 
556
+ ## give XRD/[Ref|Redirect]s priority over XRD/Service/[Ref|Redirect]s per ED06
557
+ if xrd_list.last.elements['Ref'] or xrd_list.last.elements['Redirect']
558
+ xpath = "*[local-name()='Service']/*[(local-name()='Ref')|(local-name()='Redirect')]"
559
+ svclist = REXML::XPath.match(xrd_list.last, xpath, XRDNS).collect do |ele|
560
+ ele.name == 'Ref' ? noprefix(ele.text) : doappend(ele).text
561
+ end
562
+ unless svclist.empty?
563
+ xrds_list.delete_if do |xrds|
564
+ svclist.include?(noprefix(xrds.root.attributes['ref'] || xrds.root.attributes['redirect']))
565
+ end
566
+ end
567
+ seplist.clear
568
+ end
569
+
552
570
  if seplist.empty?
553
571
  ## no Service elements selected, so delete all Service/Ref(s) or Service/Redirect(s)
554
572
  xpath = "*[local-name()='Service']/*[(local-name()='Ref')|(local-name()='Redirect')]"
@@ -723,6 +741,11 @@ module XriResolver
723
741
  ## "SET Matched.x=TRUE"
724
742
  flag['Matched'][sel.name] = true
725
743
 
744
+ ## XRI Resolution WD11 ED07 Section 13.3.4
745
+ unless sel.text or sel.attributes['match']
746
+ sel.attributes << REXML::Attribute.new('match', 'null')
747
+ end
748
+
726
749
  ## determine match
727
750
  if sel.attributes['match'] and sel.attributes['match'] != 'content'
728
751
  ## determine match per XRI Resolution WD11 ED03 Section 10.3.2
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: barx
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.1
7
- date: 2007-10-20 00:00:00 +00:00
6
+ version: 0.1.2
7
+ date: 2007-11-04 00:00:00 -07:00
8
8
  summary: Provides XRI resolution services. Read more about XRI resolution at http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=xri.
9
9
  require_paths:
10
10
  - lib
@@ -29,36 +29,36 @@ post_install_message:
29
29
  authors:
30
30
  - Victor Grey and Kermit Snelson
31
31
  files:
32
- - test
33
- - lib
34
32
  - examples
33
+ - lib
35
34
  - MIT-LICENSE
36
35
  - README
36
+ - test
37
+ - lib/barx.rb
37
38
  - lib/httpclient
38
- - lib/httpclient/http.rb
39
- - lib/httpclient/cacert.p7s
40
- - lib/httpclient/cookie.rb
41
39
  - lib/httpclient.rb
42
40
  - lib/xri_parser.rb
43
41
  - lib/xri_resolver.rb
44
- - lib/barx.rb
42
+ - lib/httpclient/cacert.p7s
43
+ - lib/httpclient/cookie.rb
44
+ - lib/httpclient/http.rb
45
+ - test/authority_parser_profile.rb
46
+ - test/test_helper.rb
45
47
  - test/unit
46
- - test/unit/multi_stage_resolution_test.rb
47
- - test/unit/authority_parser_test.rb
48
+ - test/xrds_sources
48
49
  - test/unit/all.rb
50
+ - test/unit/authority_parser_test.rb
49
51
  - test/unit/input_param_parser_test.rb
52
+ - test/unit/multi_stage_resolution_test.rb
50
53
  - test/unit/sep_selection_test.rb
51
- - test/xrds_sources
52
- - test/xrds_sources/second_stage1
53
54
  - test/xrds_sources/empty_sels_no_append_qxri_sep
54
- - test/xrds_sources/sep1
55
55
  - test/xrds_sources/empty_sels_sep
56
56
  - test/xrds_sources/first_stage1
57
57
  - test/xrds_sources/no_svc_sep
58
- - test/test_helper.rb
59
- - test/authority_parser_profile.rb
60
- - examples/proxri
58
+ - test/xrds_sources/second_stage1
59
+ - test/xrds_sources/sep1
61
60
  - examples/dix
61
+ - examples/proxri
62
62
  - examples/README
63
63
  - examples/xrioid
64
64
  test_files: []