atom-tools 0.9.0 → 0.9.1
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.
- data/README +3 -3
- data/Rakefile +1 -1
- data/bin/atom-client.rb +13 -10
- data/lib/atom/collection.rb +2 -2
- data/lib/atom/element.rb +5 -1
- data/lib/atom/entry.rb +9 -2
- data/lib/atom/feed.rb +11 -6
- data/lib/atom/http.rb +157 -38
- data/lib/atom/service.rb +170 -0
- data/lib/atom/text.rb +15 -2
- data/lib/atom/xml.rb +1 -1
- data/test/conformance/updated.rb +2 -1
- data/test/test_constructs.rb +45 -2
- data/test/test_feed.rb +27 -0
- data/test/test_http.rb +116 -20
- data/test/test_protocol.rb +77 -13
- data/test/test_xml.rb +15 -1
- metadata +3 -38
- data/bin/atom-server.rb~ +0 -71
- data/doc/classes/Atom/App.html +0 -217
- data/doc/classes/Atom/Author.html +0 -130
- data/doc/classes/Atom/Category.html +0 -128
- data/doc/classes/Atom/Collection.html +0 -322
- data/doc/classes/Atom/Content.html +0 -129
- data/doc/classes/Atom/Contributor.html +0 -119
- data/doc/classes/Atom/Element.html +0 -325
- data/doc/classes/Atom/Entry.html +0 -365
- data/doc/classes/Atom/Feed.html +0 -585
- data/doc/classes/Atom/HTTP.html +0 -374
- data/doc/classes/Atom/Link.html +0 -137
- data/doc/classes/Atom/Text.html +0 -229
- data/doc/classes/XHTML.html +0 -118
- data/doc/created.rid +0 -1
- data/doc/files/README.html +0 -213
- data/doc/files/lib/atom/app_rb.html +0 -110
- data/doc/files/lib/atom/collection_rb.html +0 -110
- data/doc/files/lib/atom/element_rb.html +0 -109
- data/doc/files/lib/atom/entry_rb.html +0 -111
- data/doc/files/lib/atom/feed_rb.html +0 -112
- data/doc/files/lib/atom/http_rb.html +0 -109
- data/doc/files/lib/atom/text_rb.html +0 -108
- data/doc/files/lib/atom/xml_rb.html +0 -110
- data/doc/files/lib/atom/yaml_rb.html +0 -109
- data/doc/fr_class_index.html +0 -39
- data/doc/fr_file_index.html +0 -36
- data/doc/fr_method_index.html +0 -62
- data/doc/index.html +0 -24
- data/doc/rdoc-style.css +0 -208
- data/lib/atom/app.rb +0 -87
data/test/test_protocol.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "test/unit"
|
2
2
|
|
3
|
-
require "atom/
|
3
|
+
require "atom/service"
|
4
4
|
|
5
5
|
class FakeHTTP
|
6
6
|
Response = Struct.new(:body, :code, :content_type)
|
@@ -20,8 +20,7 @@ end
|
|
20
20
|
|
21
21
|
class AtomProtocolTest < Test::Unit::TestCase
|
22
22
|
def test_introspection
|
23
|
-
|
24
|
-
service = <<END
|
23
|
+
doc = <<END
|
25
24
|
<service xmlns="http://purl.org/atom/app#"
|
26
25
|
xmlns:atom="http://www.w3.org/2005/Atom">
|
27
26
|
<workspace>
|
@@ -37,24 +36,89 @@ class AtomProtocolTest < Test::Unit::TestCase
|
|
37
36
|
</service>
|
38
37
|
END
|
39
38
|
|
40
|
-
http = FakeHTTP.new({ "http://example.com/service.xml" => service }, "application/atomserv+xml")
|
39
|
+
#http = FakeHTTP.new({ "http://example.com/service.xml" => service }, "application/atomserv+xml")
|
40
|
+
|
41
|
+
service = Atom::Service.new
|
42
|
+
service.parse doc
|
43
|
+
#service = Atom::Service.new "http://example.com/service.xml", http
|
44
|
+
|
45
|
+
ws = service.workspaces.first
|
46
|
+
assert_equal "My Blog", ws.title.to_s
|
41
47
|
|
48
|
+
coll = ws.collections.first
|
49
|
+
assert_equal URI.parse("http://example.org/myblog/entries"), coll.uri
|
50
|
+
assert_equal "Entries", coll.title.to_s
|
51
|
+
assert_equal "entry", coll.accepts
|
42
52
|
|
43
|
-
|
53
|
+
coll = ws.collections.last
|
54
|
+
assert_equal URI.parse("http://example.org/myblog/fotes"), coll.uri
|
55
|
+
assert_equal "Photos", coll.title.to_s
|
56
|
+
assert_equal "image/*", coll.accepts
|
44
57
|
|
45
|
-
|
46
|
-
|
47
|
-
assert_equal("Entries", coll.title.to_s)
|
48
|
-
assert_equal("entry", coll.accepts)
|
58
|
+
http = service.instance_variable_get(:@http)
|
59
|
+
assert_instance_of Atom::HTTP, http
|
49
60
|
|
50
|
-
|
51
|
-
assert_equal
|
52
|
-
assert_equal("Photos", coll.title.to_s)
|
53
|
-
assert_equal("image/*", coll.accepts)
|
61
|
+
# collections should inherit the service's HTTP object
|
62
|
+
assert_equal http, coll.instance_variable_get(:@http)
|
54
63
|
|
55
64
|
# XXX write a test for relative hrefs
|
56
65
|
end
|
57
66
|
|
67
|
+
def test_write_introspection
|
68
|
+
service = Atom::Service.new
|
69
|
+
|
70
|
+
ws = service.workspaces.new
|
71
|
+
|
72
|
+
ws.title = "Workspace 1"
|
73
|
+
|
74
|
+
coll = Atom::Collection.new "http://example.org/entries"
|
75
|
+
coll.title = "Entries"
|
76
|
+
ws.collections << coll
|
77
|
+
|
78
|
+
coll = Atom::Collection.new "http://example.org/audio"
|
79
|
+
coll.title = "Audio"
|
80
|
+
coll.accepts = "audio/*"
|
81
|
+
ws.collections << coll
|
82
|
+
|
83
|
+
nses = { "app" => Atom::PP_NS, "atom" => Atom::NS }
|
84
|
+
|
85
|
+
doc = REXML::Document.new(service.to_s)
|
86
|
+
|
87
|
+
assert_equal "http://purl.org/atom/app#", doc.root.namespace
|
88
|
+
|
89
|
+
ws = REXML::XPath.first( doc.root,
|
90
|
+
"/app:service/app:workspace",
|
91
|
+
nses )
|
92
|
+
|
93
|
+
title = REXML::XPath.first( ws, "./atom:title", nses)
|
94
|
+
|
95
|
+
assert_equal "Workspace 1", title.text
|
96
|
+
assert_equal "http://www.w3.org/2005/Atom", title.namespace
|
97
|
+
|
98
|
+
colls = REXML::XPath.match( ws, "./app:collection", nses)
|
99
|
+
assert_equal(2, colls.length)
|
100
|
+
|
101
|
+
entries = colls.first
|
102
|
+
|
103
|
+
assert_equal "http://example.org/entries", entries.attributes["href"]
|
104
|
+
|
105
|
+
title = REXML::XPath.first(entries, "./atom:title", nses)
|
106
|
+
assert_equal "Entries", title.text
|
107
|
+
|
108
|
+
accepts = REXML::XPath.first(entries, "./app:accepts", nses)
|
109
|
+
assert_nil accepts
|
110
|
+
|
111
|
+
audio = colls.last
|
112
|
+
|
113
|
+
assert_equal "http://example.org/audio", audio.attributes["href"]
|
114
|
+
|
115
|
+
title = REXML::XPath.first(audio, "./atom:title", nses)
|
116
|
+
assert_equal "Audio", title.text
|
117
|
+
|
118
|
+
accepts = REXML::XPath.first(audio, "./app:accepts", nses)
|
119
|
+
assert_equal "audio/*", accepts.text
|
120
|
+
end
|
121
|
+
|
58
122
|
def test_dont_specify_http_object
|
59
123
|
collection = Atom::Collection.new("http://necronomicorp.com/testatom?atom")
|
60
124
|
|
data/test/test_xml.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "test/unit"
|
2
2
|
|
3
3
|
# for entry.edit_url
|
4
|
-
require "atom/
|
4
|
+
require "atom/service"
|
5
5
|
|
6
6
|
class AtomTest < Test::Unit::TestCase
|
7
7
|
def test_text_type_text
|
@@ -287,6 +287,20 @@ END
|
|
287
287
|
assert_equal "", entry.content.to_s
|
288
288
|
end
|
289
289
|
|
290
|
+
def test_serialize_base
|
291
|
+
entry = Atom::Entry.new
|
292
|
+
|
293
|
+
entry.base = "http://necronomicorp.com/nil"
|
294
|
+
|
295
|
+
base = get_elements(entry).root.attributes["xml:base"]
|
296
|
+
assert_equal "http://necronomicorp.com/nil", base
|
297
|
+
|
298
|
+
entry.base = URI.parse("http://necronomicorp.com/nil")
|
299
|
+
|
300
|
+
base = get_elements(entry).root.attributes["xml:base"]
|
301
|
+
assert_equal "http://necronomicorp.com/nil", base
|
302
|
+
end
|
303
|
+
|
290
304
|
def test_relative_base
|
291
305
|
base_url = "http://www.tbray.org/ongoing/ongoing.atom"
|
292
306
|
doc = "<entry xmlns='http://www.w3.org/2005/Atom' xml:base='When/200x/2006/10/11/'/>"
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: atom-tools
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.9.
|
7
|
-
date: 2006-11-
|
6
|
+
version: 0.9.1
|
7
|
+
date: 2006-11-26 00:00:00 -07:00
|
8
8
|
summary: Tools for working with Atom Entries, Feeds and Collections
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -32,42 +32,7 @@ files:
|
|
32
32
|
- README
|
33
33
|
- Rakefile
|
34
34
|
- setup.rb
|
35
|
-
- bin/atom-server.rb~
|
36
35
|
- bin/atom-client.rb
|
37
|
-
- doc/files
|
38
|
-
- doc/index.html
|
39
|
-
- doc/rdoc-style.css
|
40
|
-
- doc/fr_method_index.html
|
41
|
-
- doc/fr_class_index.html
|
42
|
-
- doc/fr_file_index.html
|
43
|
-
- doc/created.rid
|
44
|
-
- doc/classes
|
45
|
-
- doc/files/lib
|
46
|
-
- doc/files/README.html
|
47
|
-
- doc/files/lib/atom
|
48
|
-
- doc/files/lib/atom/feed_rb.html
|
49
|
-
- doc/files/lib/atom/text_rb.html
|
50
|
-
- doc/files/lib/atom/xml_rb.html
|
51
|
-
- doc/files/lib/atom/yaml_rb.html
|
52
|
-
- doc/files/lib/atom/element_rb.html
|
53
|
-
- doc/files/lib/atom/app_rb.html
|
54
|
-
- doc/files/lib/atom/entry_rb.html
|
55
|
-
- doc/files/lib/atom/http_rb.html
|
56
|
-
- doc/files/lib/atom/collection_rb.html
|
57
|
-
- doc/classes/Atom
|
58
|
-
- doc/classes/XHTML.html
|
59
|
-
- doc/classes/Atom/Author.html
|
60
|
-
- doc/classes/Atom/Element.html
|
61
|
-
- doc/classes/Atom/App.html
|
62
|
-
- doc/classes/Atom/Feed.html
|
63
|
-
- doc/classes/Atom/Text.html
|
64
|
-
- doc/classes/Atom/Contributor.html
|
65
|
-
- doc/classes/Atom/HTTP.html
|
66
|
-
- doc/classes/Atom/Link.html
|
67
|
-
- doc/classes/Atom/Collection.html
|
68
|
-
- doc/classes/Atom/Content.html
|
69
|
-
- doc/classes/Atom/Category.html
|
70
|
-
- doc/classes/Atom/Entry.html
|
71
36
|
- test/test_constructs.rb
|
72
37
|
- test/runtests.rb
|
73
38
|
- test/test_feed.rb
|
@@ -85,8 +50,8 @@ files:
|
|
85
50
|
- lib/atom/yaml.rb
|
86
51
|
- lib/atom/feed.rb
|
87
52
|
- lib/atom/text.rb
|
88
|
-
- lib/atom/app.rb
|
89
53
|
- lib/atom/collection.rb
|
54
|
+
- lib/atom/service.rb
|
90
55
|
- lib/atom/entry.rb
|
91
56
|
- lib/atom/xml.rb
|
92
57
|
- lib/atom/element.rb
|
data/bin/atom-server.rb~
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
|
3
|
-
require "atom/pub-server"
|
4
|
-
require "webrick/httpserver"
|
5
|
-
require "atom/feed"
|
6
|
-
|
7
|
-
# syntax: ./atom-server <port> <path>
|
8
|
-
|
9
|
-
module Atom
|
10
|
-
# @docs must implement [], []=, next_id!
|
11
|
-
# including servlet must implement gen_id, url_to_key, key_to_url, do_GET
|
12
|
-
class MemoryCollection < WEBrick::HTTPServlet::AbstractServlet
|
13
|
-
include Atom::AtomPub
|
14
|
-
|
15
|
-
def initialize server, docs
|
16
|
-
super
|
17
|
-
|
18
|
-
@docs = docs
|
19
|
-
end
|
20
|
-
|
21
|
-
def gen_id key
|
22
|
-
key
|
23
|
-
end
|
24
|
-
|
25
|
-
def key_to_url req, key
|
26
|
-
req.script_name + "/" + key
|
27
|
-
end
|
28
|
-
|
29
|
-
def url_to_key url
|
30
|
-
url.split("/").last
|
31
|
-
end
|
32
|
-
|
33
|
-
def add_edit entry, key
|
34
|
-
edit = entry.links.new
|
35
|
-
edit["rel"] = "edit"
|
36
|
-
edit
|
37
|
-
end
|
38
|
-
|
39
|
-
def do_GET req, res
|
40
|
-
res.body = if req.path_info.empty? or req.path_info == "/"
|
41
|
-
feed = Atom::Feed.new
|
42
|
-
|
43
|
-
@docs.each do |key,doc|
|
44
|
-
entry = doc.to_atom_entry
|
45
|
-
add_edit(entry, key)["href"] = key_to_url(req, key)
|
46
|
-
feed << entry
|
47
|
-
end
|
48
|
-
|
49
|
-
feed.entries.first.to_s
|
50
|
-
else
|
51
|
-
key = url_to_key(req.request_uri.to_s)
|
52
|
-
entry = @docs[key].to_atom_entry
|
53
|
-
add_edit(entry, key)["href"] = key_to_url(req, key)
|
54
|
-
entry.to_s
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
h = WEBrick::HTTPServer.new(:Port => ARGV[0])
|
61
|
-
|
62
|
-
docs = {}
|
63
|
-
docs.instance_variable_set :@last_key, "0"
|
64
|
-
|
65
|
-
def docs.next_key!
|
66
|
-
@last_key.next!
|
67
|
-
end
|
68
|
-
|
69
|
-
h.mount(ARGV[1], Atom::MemoryCollection, docs)
|
70
|
-
|
71
|
-
h.start
|
data/doc/classes/Atom/App.html
DELETED
@@ -1,217 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>Class: Atom::App</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="classHeader">
|
50
|
-
<table class="header-table">
|
51
|
-
<tr class="top-aligned-row">
|
52
|
-
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">Atom::App</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../../files/lib/atom/app_rb.html">
|
59
|
-
lib/atom/app.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
<tr class="top-aligned-row">
|
66
|
-
<td><strong>Parent:</strong></td>
|
67
|
-
<td>
|
68
|
-
Object
|
69
|
-
</td>
|
70
|
-
</tr>
|
71
|
-
</table>
|
72
|
-
</div>
|
73
|
-
<!-- banner header -->
|
74
|
-
|
75
|
-
<div id="bodyContent">
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
<div id="contextContent">
|
80
|
-
|
81
|
-
<div id="description">
|
82
|
-
<p>
|
83
|
-
<a href="App.html">Atom::App</a> represents an Atom Publishing Protocol
|
84
|
-
introspection document.
|
85
|
-
</p>
|
86
|
-
|
87
|
-
</div>
|
88
|
-
|
89
|
-
|
90
|
-
</div>
|
91
|
-
|
92
|
-
<div id="method-list">
|
93
|
-
<h3 class="section-bar">Methods</h3>
|
94
|
-
|
95
|
-
<div class="name-list">
|
96
|
-
<a href="#M000006">new</a>
|
97
|
-
</div>
|
98
|
-
</div>
|
99
|
-
|
100
|
-
</div>
|
101
|
-
|
102
|
-
|
103
|
-
<!-- if includes -->
|
104
|
-
|
105
|
-
<div id="section">
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
<div id="attribute-list">
|
112
|
-
<h3 class="section-bar">Attributes</h3>
|
113
|
-
|
114
|
-
<div class="name-list">
|
115
|
-
<table>
|
116
|
-
<tr class="top-aligned-row context-row">
|
117
|
-
<td class="context-item-name">collections</td>
|
118
|
-
<td class="context-item-value"> [R] </td>
|
119
|
-
<td class="context-item-desc">
|
120
|
-
collections referred to by the introspection document
|
121
|
-
|
122
|
-
</td>
|
123
|
-
</tr>
|
124
|
-
</table>
|
125
|
-
</div>
|
126
|
-
</div>
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
<!-- if method_list -->
|
131
|
-
<div id="methods">
|
132
|
-
<h3 class="section-bar">Public Class methods</h3>
|
133
|
-
|
134
|
-
<div id="method-M000006" class="method-detail">
|
135
|
-
<a name="M000006"></a>
|
136
|
-
|
137
|
-
<div class="method-heading">
|
138
|
-
<a href="#M000006" class="method-signature">
|
139
|
-
<span class="method-name">new</span><span class="method-args">(introspection_url, http = Atom::HTTP.new)</span>
|
140
|
-
</a>
|
141
|
-
</div>
|
142
|
-
|
143
|
-
<div class="method-description">
|
144
|
-
<p>
|
145
|
-
retrieves and parses an Atom introspection document.
|
146
|
-
</p>
|
147
|
-
<p><a class="source-toggle" href="#"
|
148
|
-
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
149
|
-
<div class="method-source-code" id="M000006-source">
|
150
|
-
<pre>
|
151
|
-
<span class="ruby-comment cmt"># File lib/atom/app.rb, line 23</span>
|
152
|
-
23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">introspection_url</span>, <span class="ruby-identifier">http</span> = <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">new</span>)
|
153
|
-
24: <span class="ruby-identifier">i_url</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">introspection_url</span>)
|
154
|
-
25:
|
155
|
-
26: <span class="ruby-identifier">rxml</span> = <span class="ruby-keyword kw">nil</span>
|
156
|
-
27:
|
157
|
-
28: <span class="ruby-identifier">res</span> = <span class="ruby-identifier">http</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">i_url</span>)
|
158
|
-
29:
|
159
|
-
30: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">code</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"200"</span> <span class="ruby-comment cmt"># redirects, &c.</span>
|
160
|
-
31: <span class="ruby-identifier">raise</span> <span class="ruby-constant">WrongResponse</span>, <span class="ruby-node">"introspection document responded with unexpected code #{res.code}"</span>
|
161
|
-
32: <span class="ruby-keyword kw">end</span>
|
162
|
-
33:
|
163
|
-
34: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">content_type</span> <span class="ruby-operator">==</span> <span class="ruby-value str">"application/atomserv+xml"</span>
|
164
|
-
35: <span class="ruby-identifier">raise</span> <span class="ruby-constant">WrongMimetype</span>, <span class="ruby-value str">"this isn't an introspection document!"</span>
|
165
|
-
36: <span class="ruby-keyword kw">end</span>
|
166
|
-
37:
|
167
|
-
38: <span class="ruby-identifier">rxml</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">res</span>.<span class="ruby-identifier">body</span>)
|
168
|
-
39:
|
169
|
-
40: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">rxml</span>.<span class="ruby-identifier">root</span>.<span class="ruby-identifier">namespace</span> <span class="ruby-operator">==</span> <span class="ruby-constant">PP_NS</span>
|
170
|
-
41: <span class="ruby-identifier">raise</span> <span class="ruby-constant">WrongNamespace</span>, <span class="ruby-value str">"this isn't an introspection document!"</span>
|
171
|
-
42: <span class="ruby-keyword kw">end</span>
|
172
|
-
43:
|
173
|
-
44: <span class="ruby-comment cmt"># TODO: expose workspaces</span>
|
174
|
-
45: <span class="ruby-identifier">colls</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">XPath</span>.<span class="ruby-identifier">match</span>( <span class="ruby-identifier">rxml</span>,
|
175
|
-
46: <span class="ruby-value str">"/app:service/app:workspace/app:collection"</span>,
|
176
|
-
47: {<span class="ruby-value str">"app"</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">PP_NS</span>} )
|
177
|
-
48:
|
178
|
-
49: <span class="ruby-ivar">@collections</span> = []
|
179
|
-
50:
|
180
|
-
51: <span class="ruby-identifier">colls</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">collection</span><span class="ruby-operator">|</span>
|
181
|
-
52: <span class="ruby-comment cmt"># absolutize relative URLs</span>
|
182
|
-
53: <span class="ruby-identifier">url</span> = <span class="ruby-identifier">i_url</span> <span class="ruby-operator">+</span> <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">collection</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">"href"</span>])
|
183
|
-
54:
|
184
|
-
55: <span class="ruby-identifier">coll</span> = <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">Collection</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">url</span>, <span class="ruby-identifier">http</span>)
|
185
|
-
56:
|
186
|
-
57: <span class="ruby-comment cmt"># XXX this is a Text Construct, and should be parsed as such</span>
|
187
|
-
58: <span class="ruby-identifier">coll</span>.<span class="ruby-identifier">title</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">XPath</span>.<span class="ruby-identifier">first</span>( <span class="ruby-identifier">collection</span>,
|
188
|
-
59: <span class="ruby-value str">"./atom:title"</span>,
|
189
|
-
60: {<span class="ruby-value str">"app"</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">PP_NS</span>,
|
190
|
-
61: <span class="ruby-value str">"atom"</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">NS</span> } ).<span class="ruby-identifier">text</span>
|
191
|
-
62:
|
192
|
-
63: <span class="ruby-identifier">accepts</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">XPath</span>.<span class="ruby-identifier">first</span>( <span class="ruby-identifier">collection</span>,
|
193
|
-
64: <span class="ruby-value str">"./app:accept"</span>,
|
194
|
-
65: {<span class="ruby-value str">"app"</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Atom</span><span class="ruby-operator">::</span><span class="ruby-constant">PP_NS</span>} )
|
195
|
-
66: <span class="ruby-identifier">coll</span>.<span class="ruby-identifier">accepts</span> = (<span class="ruby-identifier">accepts</span> <span class="ruby-value">? </span><span class="ruby-identifier">accepts</span>.<span class="ruby-identifier">text</span> <span class="ruby-operator">:</span> <span class="ruby-value str">"entry"</span>)
|
196
|
-
67:
|
197
|
-
68: <span class="ruby-ivar">@collections</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">coll</span>
|
198
|
-
69: <span class="ruby-keyword kw">end</span>
|
199
|
-
70: <span class="ruby-keyword kw">end</span>
|
200
|
-
</pre>
|
201
|
-
</div>
|
202
|
-
</div>
|
203
|
-
</div>
|
204
|
-
|
205
|
-
|
206
|
-
</div>
|
207
|
-
|
208
|
-
|
209
|
-
</div>
|
210
|
-
|
211
|
-
|
212
|
-
<div id="validator-badges">
|
213
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
214
|
-
</div>
|
215
|
-
|
216
|
-
</body>
|
217
|
-
</html>
|