sword2ruby 1.0.0
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/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +30 -0
- data/LICENCE +35 -0
- data/README.md +43 -0
- data/Rakefile +53 -0
- data/doc/Atom/Collection.html +837 -0
- data/doc/Atom/Element.html +197 -0
- data/doc/Atom/Entry.html +1795 -0
- data/doc/Atom/Feed.html +297 -0
- data/doc/Atom/Service.html +363 -0
- data/doc/Atom.html +158 -0
- data/doc/Gemfile.html +125 -0
- data/doc/Object.html +165 -0
- data/doc/REXML/Element.html +493 -0
- data/doc/REXML.html +158 -0
- data/doc/Rakefile.html +123 -0
- data/doc/Sword2Ruby/Atom.html +169 -0
- data/doc/Sword2Ruby/AutoDiscover.html +327 -0
- data/doc/Sword2Ruby/Connection.html +274 -0
- data/doc/Sword2Ruby/DepositReceipt.html +331 -0
- data/doc/Sword2Ruby/Exception.html +168 -0
- data/doc/Sword2Ruby/SwordAccept.html +169 -0
- data/doc/Sword2Ruby/SwordStatementOAIORE.html +277 -0
- data/doc/Sword2Ruby/User.html +272 -0
- data/doc/Sword2Ruby/Utility.html +1101 -0
- data/doc/Sword2Ruby.html +213 -0
- data/doc/created.rid +29 -0
- data/doc/images/add.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +118 -0
- data/doc/js/darkfish.js +153 -0
- data/doc/js/jquery.js +18 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/search.js +94 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/searcher.js +228 -0
- data/doc/rdoc.css +543 -0
- data/doc/spec/fixtures/example_txt.html +125 -0
- data/doc/table_of_contents.html +267 -0
- data/lib/sword2ruby/auto_discover.rb +71 -0
- data/lib/sword2ruby/collection.rb +261 -0
- data/lib/sword2ruby/connection.rb +37 -0
- data/lib/sword2ruby/constant.rb +35 -0
- data/lib/sword2ruby/deposit_receipt.rb +52 -0
- data/lib/sword2ruby/element.rb +12 -0
- data/lib/sword2ruby/entry.rb +602 -0
- data/lib/sword2ruby/exception.rb +7 -0
- data/lib/sword2ruby/feed.rb +34 -0
- data/lib/sword2ruby/rexml_element.rb +79 -0
- data/lib/sword2ruby/service.rb +79 -0
- data/lib/sword2ruby/sword_accept.rb +10 -0
- data/lib/sword2ruby/sword_statement_oai_ore.rb +38 -0
- data/lib/sword2ruby/user.rb +25 -0
- data/lib/sword2ruby/utility.rb +232 -0
- data/lib/sword2ruby/version.rb +4 -0
- data/lib/sword2ruby.rb +32 -0
- data/spec/auto_discover_spec.rb +30 -0
- data/spec/collection_spec.rb +33 -0
- data/spec/connection_spec.rb +21 -0
- data/spec/end_to_end_spec.rb +235 -0
- data/spec/fixtures/example.txt +3 -0
- data/spec/fixtures/snowflake.png +0 -0
- data/spec/fixtures/zip-test.zip +0 -0
- data/spec/service_spec.rb +38 -0
- data/spec/statement_spec.rb +53 -0
- data/spec/test_constants.rb +32 -0
- data/sword2ruby.gemspec +42 -0
- data/sword2ruby.tmproj +27 -0
- metadata +197 -0
@@ -0,0 +1,267 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
6
|
+
|
7
|
+
<title>Table of Contents - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">
|
10
|
+
|
11
|
+
<script type="text/javascript">
|
12
|
+
var rdoc_rel_prefix = "./";
|
13
|
+
</script>
|
14
|
+
|
15
|
+
<script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
|
16
|
+
<script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
|
17
|
+
<script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
|
18
|
+
<script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
|
19
|
+
<script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
|
20
|
+
<script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>
|
21
|
+
|
22
|
+
|
23
|
+
<body class="indexpage">
|
24
|
+
<h1>Table of Contents - RDoc Documentation</h1>
|
25
|
+
|
26
|
+
<h2>Pages</h2>
|
27
|
+
<ul>
|
28
|
+
<li class="file">
|
29
|
+
<a href="Gemfile.html">Gemfile</a>
|
30
|
+
</li>
|
31
|
+
<li class="file">
|
32
|
+
<a href="Rakefile.html">Rakefile</a>
|
33
|
+
</li>
|
34
|
+
<li class="file">
|
35
|
+
<a href="spec/fixtures/example_txt.html">example</a>
|
36
|
+
</li>
|
37
|
+
|
38
|
+
</ul>
|
39
|
+
|
40
|
+
<h2 id="classes">Classes/Modules</h2>
|
41
|
+
<ul>
|
42
|
+
<li class="module">
|
43
|
+
<a href="Sword2Ruby.html">Sword2Ruby</a>
|
44
|
+
</li>
|
45
|
+
<li class="module">
|
46
|
+
<a href="Sword2Ruby/Atom.html">Sword2Ruby::Atom</a>
|
47
|
+
</li>
|
48
|
+
<li class="class">
|
49
|
+
<a href="Sword2Ruby/AutoDiscover.html">Sword2Ruby::AutoDiscover</a>
|
50
|
+
</li>
|
51
|
+
<li class="class">
|
52
|
+
<a href="Sword2Ruby/Connection.html">Sword2Ruby::Connection</a>
|
53
|
+
</li>
|
54
|
+
<li class="class">
|
55
|
+
<a href="Sword2Ruby/DepositReceipt.html">Sword2Ruby::DepositReceipt</a>
|
56
|
+
</li>
|
57
|
+
<li class="class">
|
58
|
+
<a href="Sword2Ruby/Exception.html">Sword2Ruby::Exception</a>
|
59
|
+
</li>
|
60
|
+
<li class="class">
|
61
|
+
<a href="Sword2Ruby/SwordAccept.html">Sword2Ruby::SwordAccept</a>
|
62
|
+
</li>
|
63
|
+
<li class="class">
|
64
|
+
<a href="Sword2Ruby/SwordStatementOAIORE.html">Sword2Ruby::SwordStatementOAIORE</a>
|
65
|
+
</li>
|
66
|
+
<li class="class">
|
67
|
+
<a href="Sword2Ruby/User.html">Sword2Ruby::User</a>
|
68
|
+
</li>
|
69
|
+
<li class="class">
|
70
|
+
<a href="Sword2Ruby/Utility.html">Sword2Ruby::Utility</a>
|
71
|
+
</li>
|
72
|
+
<li class="module">
|
73
|
+
<a href="Atom.html">Atom</a>
|
74
|
+
</li>
|
75
|
+
<li class="class">
|
76
|
+
<a href="Atom/Collection.html">Atom::Collection</a>
|
77
|
+
</li>
|
78
|
+
<li class="class">
|
79
|
+
<a href="Atom/Element.html">Atom::Element</a>
|
80
|
+
</li>
|
81
|
+
<li class="class">
|
82
|
+
<a href="Atom/Entry.html">Atom::Entry</a>
|
83
|
+
</li>
|
84
|
+
<li class="class">
|
85
|
+
<a href="Atom/Feed.html">Atom::Feed</a>
|
86
|
+
</li>
|
87
|
+
<li class="class">
|
88
|
+
<a href="Atom/Service.html">Atom::Service</a>
|
89
|
+
</li>
|
90
|
+
<li class="module">
|
91
|
+
<a href="REXML.html">REXML</a>
|
92
|
+
</li>
|
93
|
+
<li class="class">
|
94
|
+
<a href="REXML/Element.html">REXML::Element</a>
|
95
|
+
</li>
|
96
|
+
<li class="class">
|
97
|
+
<a href="Object.html">Object</a>
|
98
|
+
</li>
|
99
|
+
|
100
|
+
</ul>
|
101
|
+
|
102
|
+
<h2 id="methods">Methods</h2>
|
103
|
+
<ul>
|
104
|
+
|
105
|
+
<li class="method"><a href="Sword2Ruby/Utility.html#method-c-check_argument_class">::check_argument_class — Sword2Ruby::Utility</a>
|
106
|
+
|
107
|
+
<li class="method"><a href="Sword2Ruby/Utility.html#method-c-check_uri">::check_uri — Sword2Ruby::Utility</a>
|
108
|
+
|
109
|
+
<li class="method"><a href="Sword2Ruby/Utility.html#method-c-find_element_attribute_value">::find_element_attribute_value — Sword2Ruby::Utility</a>
|
110
|
+
|
111
|
+
<li class="method"><a href="Sword2Ruby/Utility.html#method-c-find_element_boolean">::find_element_boolean — Sword2Ruby::Utility</a>
|
112
|
+
|
113
|
+
<li class="method"><a href="Sword2Ruby/Utility.html#method-c-find_element_by_href">::find_element_by_href — Sword2Ruby::Utility</a>
|
114
|
+
|
115
|
+
<li class="method"><a href="Sword2Ruby/Utility.html#method-c-find_element_by_name">::find_element_by_name — Sword2Ruby::Utility</a>
|
116
|
+
|
117
|
+
<li class="method"><a href="Sword2Ruby/Utility.html#method-c-find_element_by_scheme_and_term">::find_element_by_scheme_and_term — Sword2Ruby::Utility</a>
|
118
|
+
|
119
|
+
<li class="method"><a href="Sword2Ruby/Utility.html#method-c-find_element_integer">::find_element_integer — Sword2Ruby::Utility</a>
|
120
|
+
|
121
|
+
<li class="method"><a href="Sword2Ruby/Utility.html#method-c-find_element_text">::find_element_text — Sword2Ruby::Utility</a>
|
122
|
+
|
123
|
+
<li class="method"><a href="Sword2Ruby/Utility.html#method-c-find_element_time">::find_element_time — Sword2Ruby::Utility</a>
|
124
|
+
|
125
|
+
<li class="method"><a href="Sword2Ruby/Utility.html#method-c-find_elements_attribute_value">::find_elements_attribute_value — Sword2Ruby::Utility</a>
|
126
|
+
|
127
|
+
<li class="method"><a href="Sword2Ruby/Utility.html#method-c-find_elements_by_namespace">::find_elements_by_namespace — Sword2Ruby::Utility</a>
|
128
|
+
|
129
|
+
<li class="method"><a href="Sword2Ruby/Utility.html#method-c-find_elements_by_scheme">::find_elements_by_scheme — Sword2Ruby::Utility</a>
|
130
|
+
|
131
|
+
<li class="method"><a href="Sword2Ruby/Utility.html#method-c-find_elements_text">::find_elements_text — Sword2Ruby::Utility</a>
|
132
|
+
|
133
|
+
<li class="method"><a href="Sword2Ruby/Utility.html#method-c-find_link_uri">::find_link_uri — Sword2Ruby::Utility</a>
|
134
|
+
|
135
|
+
<li class="method"><a href="Sword2Ruby/Utility.html#method-c-find_links">::find_links — Sword2Ruby::Utility</a>
|
136
|
+
|
137
|
+
<li class="method"><a href="Sword2Ruby/Utility.html#method-c-find_links_all_types">::find_links_all_types — Sword2Ruby::Utility</a>
|
138
|
+
|
139
|
+
<li class="method"><a href="Sword2Ruby/AutoDiscover.html#method-c-new">::new — Sword2Ruby::AutoDiscover</a>
|
140
|
+
|
141
|
+
<li class="method"><a href="Sword2Ruby/Connection.html#method-c-new">::new — Sword2Ruby::Connection</a>
|
142
|
+
|
143
|
+
<li class="method"><a href="Sword2Ruby/DepositReceipt.html#method-c-new">::new — Sword2Ruby::DepositReceipt</a>
|
144
|
+
|
145
|
+
<li class="method"><a href="Sword2Ruby/User.html#method-c-new">::new — Sword2Ruby::User</a>
|
146
|
+
|
147
|
+
<li class="method"><a href="Sword2Ruby/SwordStatementOAIORE.html#method-c-new">::new — Sword2Ruby::SwordStatementOAIORE</a>
|
148
|
+
|
149
|
+
<li class="method"><a href="Atom/Service.html#method-c-new">::new — Atom::Service</a>
|
150
|
+
|
151
|
+
<li class="method"><a href="Sword2Ruby/Utility.html#method-c-read_file">::read_file — Sword2Ruby::Utility</a>
|
152
|
+
|
153
|
+
<li class="method"><a href="Sword2Ruby/Utility.html#method-c-to_boolean">::to_boolean — Sword2Ruby::Utility</a>
|
154
|
+
|
155
|
+
<li class="method"><a href="Atom/Entry.html#method-i-add_dublin_core_extension-21">#add_dublin_core_extension! — Atom::Entry</a>
|
156
|
+
|
157
|
+
<li class="method"><a href="Atom/Entry.html#method-i-alternate_uri">#alternate_uri — Atom::Entry</a>
|
158
|
+
|
159
|
+
<li class="method"><a href="Atom/Collection.html#method-i-app_accept">#app_accept — Atom::Collection</a>
|
160
|
+
|
161
|
+
<li class="method"><a href="Atom/Collection.html#method-i-app_accept_alternate_multipart_related">#app_accept_alternate_multipart_related — Atom::Collection</a>
|
162
|
+
|
163
|
+
<li class="method"><a href="Atom/Collection.html#method-i-collection_uri">#collection_uri — Atom::Collection</a>
|
164
|
+
|
165
|
+
<li class="method"><a href="Atom/Entry.html#method-i-delete-21">#delete! — Atom::Entry</a>
|
166
|
+
|
167
|
+
<li class="method"><a href="Atom/Entry.html#method-i-delete_dublin_core_extension-21">#delete_dublin_core_extension! — Atom::Entry</a>
|
168
|
+
|
169
|
+
<li class="method"><a href="Atom/Entry.html#method-i-delete_media-21">#delete_media! — Atom::Entry</a>
|
170
|
+
|
171
|
+
<li class="method"><a href="Atom/Entry.html#method-i-dublin_core_extensions">#dublin_core_extensions — Atom::Entry</a>
|
172
|
+
|
173
|
+
<li class="method"><a href="Atom/Entry.html#method-i-edit_media_links">#edit_media_links — Atom::Entry</a>
|
174
|
+
|
175
|
+
<li class="method"><a href="Atom/Entry.html#method-i-entry_edit_uri">#entry_edit_uri — Atom::Entry</a>
|
176
|
+
|
177
|
+
<li class="method"><a href="Atom/Entry.html#method-i-media_entry_uri">#media_entry_uri — Atom::Entry</a>
|
178
|
+
|
179
|
+
<li class="method"><a href="Atom/Entry.html#method-i-media_resource_links">#media_resource_links — Atom::Entry</a>
|
180
|
+
|
181
|
+
<li class="method"><a href="Atom/Entry.html#method-i-post-21">#post! — Atom::Entry</a>
|
182
|
+
|
183
|
+
<li class="method"><a href="Atom/Collection.html#method-i-post-21">#post! — Atom::Collection</a>
|
184
|
+
|
185
|
+
<li class="method"><a href="Atom/Entry.html#method-i-post_media-21">#post_media! — Atom::Entry</a>
|
186
|
+
|
187
|
+
<li class="method"><a href="Atom/Collection.html#method-i-post_media-21">#post_media! — Atom::Collection</a>
|
188
|
+
|
189
|
+
<li class="method"><a href="Atom/Collection.html#method-i-post_multipart-21">#post_multipart! — Atom::Collection</a>
|
190
|
+
|
191
|
+
<li class="method"><a href="Atom/Entry.html#method-i-post_multipart-21">#post_multipart! — Atom::Entry</a>
|
192
|
+
|
193
|
+
<li class="method"><a href="Atom/Entry.html#method-i-put-21">#put! — Atom::Entry</a>
|
194
|
+
|
195
|
+
<li class="method"><a href="Atom/Entry.html#method-i-put_media-21">#put_media! — Atom::Entry</a>
|
196
|
+
|
197
|
+
<li class="method"><a href="Atom/Entry.html#method-i-put_multipart-21">#put_multipart! — Atom::Entry</a>
|
198
|
+
|
199
|
+
<li class="method"><a href="REXML/Element.html#method-i-rdf_about">#rdf_about — REXML::Element</a>
|
200
|
+
|
201
|
+
<li class="method"><a href="Atom/Service.html#method-i-service_document_uri">#service_document_uri — Atom::Service</a>
|
202
|
+
|
203
|
+
<li class="method"><a href="Atom/Collection.html#method-i-sword_accept_packagings">#sword_accept_packagings — Atom::Collection</a>
|
204
|
+
|
205
|
+
<li class="method"><a href="Atom/Collection.html#method-i-sword_collection_policy">#sword_collection_policy — Atom::Collection</a>
|
206
|
+
|
207
|
+
<li class="method"><a href="REXML/Element.html#method-i-sword_deposited_by">#sword_deposited_by — REXML::Element</a>
|
208
|
+
|
209
|
+
<li class="method"><a href="Atom/Entry.html#method-i-sword_deposited_by">#sword_deposited_by — Atom::Entry</a>
|
210
|
+
|
211
|
+
<li class="method"><a href="REXML/Element.html#method-i-sword_deposited_on">#sword_deposited_on — REXML::Element</a>
|
212
|
+
|
213
|
+
<li class="method"><a href="Atom/Entry.html#method-i-sword_deposited_on">#sword_deposited_on — Atom::Entry</a>
|
214
|
+
|
215
|
+
<li class="method"><a href="Atom/Entry.html#method-i-sword_deposited_on_behalf_of">#sword_deposited_on_behalf_of — Atom::Entry</a>
|
216
|
+
|
217
|
+
<li class="method"><a href="REXML/Element.html#method-i-sword_deposited_on_behalf_of">#sword_deposited_on_behalf_of — REXML::Element</a>
|
218
|
+
|
219
|
+
<li class="method"><a href="Atom/Entry.html#method-i-sword_derived_resource_links">#sword_derived_resource_links — Atom::Entry</a>
|
220
|
+
|
221
|
+
<li class="method"><a href="Atom/Entry.html#method-i-sword_edit_uri">#sword_edit_uri — Atom::Entry</a>
|
222
|
+
|
223
|
+
<li class="method"><a href="Atom/Service.html#method-i-sword_max_upload_size">#sword_max_upload_size — Atom::Service</a>
|
224
|
+
|
225
|
+
<li class="method"><a href="Atom/Collection.html#method-i-sword_mediation">#sword_mediation — Atom::Collection</a>
|
226
|
+
|
227
|
+
<li class="method"><a href="REXML/Element.html#method-i-sword_original_deposit">#sword_original_deposit — REXML::Element</a>
|
228
|
+
|
229
|
+
<li class="method"><a href="Atom/Entry.html#method-i-sword_original_deposit_category">#sword_original_deposit_category — Atom::Entry</a>
|
230
|
+
|
231
|
+
<li class="method"><a href="Atom/Entry.html#method-i-sword_original_deposit_uri">#sword_original_deposit_uri — Atom::Entry</a>
|
232
|
+
|
233
|
+
<li class="method"><a href="Atom/Entry.html#method-i-sword_packagings">#sword_packagings — Atom::Entry</a>
|
234
|
+
|
235
|
+
<li class="method"><a href="REXML/Element.html#method-i-sword_packagings">#sword_packagings — REXML::Element</a>
|
236
|
+
|
237
|
+
<li class="method"><a href="Atom/Collection.html#method-i-sword_services">#sword_services — Atom::Collection</a>
|
238
|
+
|
239
|
+
<li class="method"><a href="Atom/Feed.html#method-i-sword_state">#sword_state — Atom::Feed</a>
|
240
|
+
|
241
|
+
<li class="method"><a href="REXML/Element.html#method-i-sword_state">#sword_state — REXML::Element</a>
|
242
|
+
|
243
|
+
<li class="method"><a href="Atom/Feed.html#method-i-sword_state_categories">#sword_state_categories — Atom::Feed</a>
|
244
|
+
|
245
|
+
<li class="method"><a href="REXML/Element.html#method-i-sword_state_description">#sword_state_description — REXML::Element</a>
|
246
|
+
|
247
|
+
<li class="method"><a href="Atom/Feed.html#method-i-sword_state_description">#sword_state_description — Atom::Feed</a>
|
248
|
+
|
249
|
+
<li class="method"><a href="Atom/Entry.html#method-i-sword_statement_links">#sword_statement_links — Atom::Entry</a>
|
250
|
+
|
251
|
+
<li class="method"><a href="Atom/Collection.html#method-i-sword_treatment">#sword_treatment — Atom::Collection</a>
|
252
|
+
|
253
|
+
<li class="method"><a href="Atom/Entry.html#method-i-sword_treatment">#sword_treatment — Atom::Entry</a>
|
254
|
+
|
255
|
+
<li class="method"><a href="Atom/Entry.html#method-i-sword_verbose_description">#sword_verbose_description — Atom::Entry</a>
|
256
|
+
|
257
|
+
<li class="method"><a href="Atom/Service.html#method-i-sword_version">#sword_version — Atom::Service</a>
|
258
|
+
|
259
|
+
</ul>
|
260
|
+
|
261
|
+
|
262
|
+
<footer id="validator-badges">
|
263
|
+
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
264
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
|
265
|
+
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
266
|
+
</footer>
|
267
|
+
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'hpricot'
|
3
|
+
|
4
|
+
module Sword2Ruby
|
5
|
+
#AutoDiscover requires the hpricot[https://github.com/hpricot/hpricot/wiki] gem.
|
6
|
+
class AutoDiscover
|
7
|
+
|
8
|
+
#The Deposit Endpoint URI string discovered in the HTML document, or nil if it could not be discovered.
|
9
|
+
#
|
10
|
+
#For more information, see the Sword2 specification: {section 13.2. "For Deposit Endpoints"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#autodiscovery_deposit].
|
11
|
+
attr_reader :deposit_endpoint_uri
|
12
|
+
|
13
|
+
#An array of Atom Entry Edit URI hashes discovered in the HTML document, or an empty array [ ] if none found.
|
14
|
+
#===Example
|
15
|
+
# [ {:href=>"http://some.url.org/edit/mycollection", type=>nil} ]
|
16
|
+
#
|
17
|
+
#For more information, see the Sword2 specification: {section 13.3. "For Resources"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#autodiscovery_resources].
|
18
|
+
#attr_reader :resource_edit_uris
|
19
|
+
attr_reader :entry_edit_uris
|
20
|
+
#alias :media_entry_uris :entry_edit_uris
|
21
|
+
|
22
|
+
#An array of Sword Statement URI hashes discovered in the HTML document, or an empty array [ ] if none found.
|
23
|
+
#===Example
|
24
|
+
# [ {:href=>"http://some.url.org/myfeed.atom", type=>"application/atom+xml;type=feed"},
|
25
|
+
# {:href=>"http://some.url.org/myfeed.rdf", type=>"application/rdf+xml"} ]
|
26
|
+
#
|
27
|
+
#For more information, see the Sword2 specification: {section 13.3. "For Resources"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#autodiscovery_resources].
|
28
|
+
attr_reader :sword_statement_links
|
29
|
+
|
30
|
+
#The Service Document URI string discovered in the HTML document, or nil if it could not be discovered.
|
31
|
+
#
|
32
|
+
#For more information, see the Sword2 specification: {section 13.1. "For Service Documents"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#autodiscovery_servicedocuments].
|
33
|
+
attr_reader :service_document_uri
|
34
|
+
|
35
|
+
#Perform an Auto-Discovery on the URI supplied (which should point to an html document).
|
36
|
+
#The document will be retreived and parsed using hpricot.
|
37
|
+
#Service Document, Deposit Endpoint and Resource URIs will be extracted where identified.
|
38
|
+
#
|
39
|
+
#For more information, see the Sword2 specification: {section 13 "Auto-Discovery"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#autodiscovery].
|
40
|
+
def initialize(discover_uri)
|
41
|
+
doc = Hpricot(open(discover_uri))
|
42
|
+
|
43
|
+
@service_document_uri = get_attribute(doc.at("//link[@rel='http://purl.org/net/sword/discovery/service-document']"), "href")
|
44
|
+
@service_document_uri ||= get_attribute(doc.at("//link[@rel='sword']"), "href") #Old sword 1.3
|
45
|
+
|
46
|
+
@deposit_endpoint_uri = get_attribute(doc.at("//link[@rel='http://purl.org/net/sword/terms/deposit']"), "href")
|
47
|
+
|
48
|
+
@entry_edit_uris = []
|
49
|
+
@sword_statement_links = []
|
50
|
+
|
51
|
+
doc.search("//link[@rel='http://purl.org/net/sword/terms/edit']").each do |e|
|
52
|
+
@entry_edit_uris << {:href => get_attribute(e, "href"), :type=> get_attribute(e, "type")}
|
53
|
+
end
|
54
|
+
|
55
|
+
doc.search("//link[@rel='http://purl.org/net/sword/terms/statement']").each do |e|
|
56
|
+
@sword_statement_links << {:href => get_attribute(e, "href"), :type=> get_attribute(e, "type")}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
private
|
62
|
+
def get_attribute(item, attribute)
|
63
|
+
if item.nil?
|
64
|
+
return nil
|
65
|
+
else
|
66
|
+
return item[attribute]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end #class
|
71
|
+
end #module
|
@@ -0,0 +1,261 @@
|
|
1
|
+
require "base64"
|
2
|
+
require 'atom/element'
|
3
|
+
require 'atom/collection'
|
4
|
+
|
5
|
+
|
6
|
+
module Sword2Ruby
|
7
|
+
|
8
|
+
|
9
|
+
#Extensions to the atom-tools[https://github.com/bct/atom-tools/wiki] Atom::Collection class to support Sword2 operations.
|
10
|
+
#These methods are additive to those supplied by the atom-tools gem.
|
11
|
+
#
|
12
|
+
#Please see the {atom-tools documentation}[http://rdoc.info/github/bct/atom-tools/master/frames] for a complete list of attributes and methods.
|
13
|
+
class ::Atom::Collection < ::Atom::Element
|
14
|
+
|
15
|
+
#Special sword_accepts to override usual accept
|
16
|
+
elements ['app', ATOM_PUBLISHING_PROTOCOL_NAMESPACE], :accept, :sword_accepts, Sword2Ruby::SwordAccept
|
17
|
+
|
18
|
+
#This method returns the URI string from the @href attribute of the Collection,
|
19
|
+
#or nil if it is not defined.
|
20
|
+
def collection_uri
|
21
|
+
@href
|
22
|
+
end
|
23
|
+
|
24
|
+
#This method returns the string value of the <sword:collectionPolicy>[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#protocoloperations_retreivingservicedocument],
|
25
|
+
#or nil if it is not defined in the service document.
|
26
|
+
def sword_collection_policy
|
27
|
+
Utility.find_element_text(extensions, "sword:collectionPolicy")
|
28
|
+
end
|
29
|
+
|
30
|
+
#This method returns the boolean value of the <sword:mediation>[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#protocoloperations_retreivingservicedocument] tag,
|
31
|
+
#or false if it is not defined in the service document.
|
32
|
+
def sword_mediation
|
33
|
+
Utility.find_element_boolean(extensions, "sword:mediation") || false
|
34
|
+
end
|
35
|
+
|
36
|
+
#This method returns the string value of the <sword:treatment>[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#protocoloperations_retreivingservicedocument] tag,
|
37
|
+
#or nil if it is not defined in the service document.
|
38
|
+
def sword_treatment
|
39
|
+
Utility.find_element_text(extensions, "sword:treatment")
|
40
|
+
end
|
41
|
+
|
42
|
+
#This method returns an array of the string values of the <sword:acceptPackaging>[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#protocoloperations_retreivingservicedocument] tags,
|
43
|
+
#or an empty array [ ] if none are defined in the service document.
|
44
|
+
def sword_accept_packagings
|
45
|
+
Utility.find_elements_text(extensions, "sword:acceptPackaging")
|
46
|
+
end
|
47
|
+
|
48
|
+
#This method returns an array of the string values of the <sword:service>[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#protocoloperations_retreivingservicedocument] tags,
|
49
|
+
#or an empty array [ ] if none are defined in the service document.
|
50
|
+
def sword_services
|
51
|
+
Utility.find_elements_text(extensions, "sword:service")
|
52
|
+
end
|
53
|
+
|
54
|
+
#This method returns the string value of the <app:accept>[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#protocoloperations_retreivingservicedocument] tag,
|
55
|
+
#or nil if it not defined in the service document.
|
56
|
+
def app_accept
|
57
|
+
sword_accepts.find{|a| a.alternate.nil? }
|
58
|
+
end
|
59
|
+
|
60
|
+
#This method returns the string value of the <app:accept alternate="multipart-related">[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#protocoloperations_retreivingservicedocument] tag,
|
61
|
+
#or nil if it not defined in the service document.
|
62
|
+
def app_accept_alternate_multipart_related
|
63
|
+
sword_accepts.find{|a| a.alternate == "multipart-related" }
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
#CRUD methods
|
68
|
+
|
69
|
+
#This method creates a new entry in the collection by posting an Atom entry to the collection URI.
|
70
|
+
#The method will return a Sword2Ruby::DepositReceipt object, or raise a Sword2Ruby::Exception in the case of an error.
|
71
|
+
#===Parameters (passed as a hash collection)
|
72
|
+
#:entry:: an Atom::Entry to be added to the collection
|
73
|
+
#:slug:: (optional) string value indicating the suggested identifier of the new entry
|
74
|
+
#:collection_uri:: (optional) the collection URI to post to. If not supplied, this will default to the current collection's URI as specified in the @href attribute.
|
75
|
+
#:in_progress:: (optional) boolean value indicating whether the new entry will be completed at a later date
|
76
|
+
#:on_behalf_of:: (optional) string value indicating username on whos behalf the submission is being performed
|
77
|
+
#:connection:: (optional) Sword2Ruby::Connection object used to perform the operation. If not supplied, the existing collection's connection will be used.
|
78
|
+
#Note that you should call <b><collection>.feed.updated!</b> followed by <b><collection>.feed.update!</b> after making updates to a collection.
|
79
|
+
#
|
80
|
+
#For more information, see the Sword2 specification: {section 6.3.3. "Creating a Resource with an Atom Entry"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#protocoloperations_creatingresource_entry].
|
81
|
+
def post!(params = {})
|
82
|
+
Utility.check_argument_class('params', params, Hash)
|
83
|
+
defaults = {
|
84
|
+
:entry => nil,
|
85
|
+
:slug => nil,
|
86
|
+
:collection_uri => collection_uri,
|
87
|
+
:in_progress => nil,
|
88
|
+
:on_behalf_of => nil,
|
89
|
+
:connection => @http
|
90
|
+
}
|
91
|
+
options = defaults.merge(params)
|
92
|
+
|
93
|
+
#Validate parameters
|
94
|
+
Utility.check_argument_class(':entry', options[:entry], ::Atom::Entry)
|
95
|
+
Utility.check_argument_class(':slug', options[:slug], String) if options[:slug]
|
96
|
+
Utility.check_argument_class(':collection_uri', options[:collection_uri], String)
|
97
|
+
Utility.check_argument_class(':on_behalf_of', options[:on_behalf_of], String) if options[:on_behalf_of]
|
98
|
+
Utility.check_argument_class(':connection', options[:connection], Sword2Ruby::Connection)
|
99
|
+
|
100
|
+
headers = {"Content-Type" => "application/atom+xml;type=entry" }
|
101
|
+
headers["Slug"] = options[:slug] if options[:slug]
|
102
|
+
headers["In-Progress"] = options[:in_progress].to_s.downcase if (options[:in_progress] == true || options[:in_progress] == false)
|
103
|
+
headers["On-Behalf-Of"] = options[:on_behalf_of] if options[:on_behalf_of]
|
104
|
+
|
105
|
+
response = options[:connection].post(options[:collection_uri], options[:entry].to_s, headers)
|
106
|
+
if response.is_a? Net::HTTPSuccess
|
107
|
+
return DepositReceipt.new(response, options[:connection])
|
108
|
+
else
|
109
|
+
raise Sword2Ruby::Exception.new("Failed to do post!(#{options[:collection_uri]}): server returned code #{response.code} #{response.message}")
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
#This method creates a new entry in the collection by posting a file to the collection URI.
|
115
|
+
#An MD5-digest will be calculated automatically from the file and sent to the server with the request.
|
116
|
+
#The method will return a Sword2Ruby::DepositReceipt object, or raise a Sword2Ruby::Exception in the case of an error.
|
117
|
+
#===Parameters (passed as a hash collection)
|
118
|
+
#:filepath:: a filepath string indicating the file to be posted. The file must be readable by the process.
|
119
|
+
#:content_type:: the mime content-type string of the file, e.g. "application/zip" or "text/plain"
|
120
|
+
#:packaging:: (optional) the Sword packaging string of the file, e.g. "http://purl.org/net/sword/package/METSDSpaceSIP"
|
121
|
+
#:slug:: (optional) the suggested identifier of the new entry
|
122
|
+
#:collection_uri:: (optional) the collection URI to post to. If not supplied, this will default to the current collection's URI as specified in the @href attribute.
|
123
|
+
#:in_progress:: (optional) boolean value indicating whether the new entry will be completed at a later date
|
124
|
+
#:on_behalf_of:: (optional) username on whos behalf the submission is being performed
|
125
|
+
#:connection:: (optional) Sword2Ruby::Connection object used to perform the operation. If not supplied, the existing collection's connection will be used.
|
126
|
+
#Note that you should call <b><collection>.feed.updated!</b> followed by <b><collection>.feed.update!</b> after making updates to a collection.
|
127
|
+
#
|
128
|
+
#For more information, see the Sword2 specification: {section 6.3.1. "Creating a Resource with a Binary File Deposit"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#protocoloperations_creatingresource_binary].
|
129
|
+
def post_media!(params = {})
|
130
|
+
Utility.check_argument_class('params', params, Hash)
|
131
|
+
defaults = {
|
132
|
+
:filepath => nil,
|
133
|
+
:content_type => nil,
|
134
|
+
:packaging => nil,
|
135
|
+
:slug => nil,
|
136
|
+
:collection_uri => collection_uri,
|
137
|
+
:in_progress => nil,
|
138
|
+
:on_behalf_of => nil,
|
139
|
+
:connection => @http
|
140
|
+
}
|
141
|
+
options = defaults.merge(params)
|
142
|
+
|
143
|
+
#Validate parameters
|
144
|
+
Utility.check_argument_class(':filepath', options[:filepath], String)
|
145
|
+
Utility.check_argument_class(':content_type', options[:content_type], String)
|
146
|
+
Utility.check_argument_class(':packaging', options[:packaging], String) if options[:packaging]
|
147
|
+
Utility.check_argument_class(':slug', options[:slug], String) if options[:slug]
|
148
|
+
Utility.check_argument_class(':collection_uri', options[:collection_uri], String)
|
149
|
+
Utility.check_argument_class(':on_behalf_of', options[:on_behalf_of], String) if options[:on_behalf_of]
|
150
|
+
Utility.check_argument_class(':connection', options[:connection], Sword2Ruby::Connection)
|
151
|
+
|
152
|
+
filename, md5, data = Utility.read_file(options[:filepath])
|
153
|
+
|
154
|
+
headers = {"Content-Type" => options[:content_type]}
|
155
|
+
headers["Content-Disposition"] = "attachment; filename=#{filename}"
|
156
|
+
headers["Content-MD5"] = md5
|
157
|
+
headers["Packaging"] = options[:packaging] if options[:packaging]
|
158
|
+
headers["Slug"] = options[:slug] if options[:slug]
|
159
|
+
headers["In-Progress"] = options[:in_progress].to_s.downcase if (options[:in_progress] == true || options[:in_progress] == false)
|
160
|
+
headers["On-Behalf-Of"] = options[:on_behalf_of] if options[:on_behalf_of]
|
161
|
+
|
162
|
+
response = options[:connection].post(options[:collection_uri], data, headers)
|
163
|
+
|
164
|
+
if response.is_a? Net::HTTPSuccess
|
165
|
+
return DepositReceipt.new(response, options[:connection])
|
166
|
+
else
|
167
|
+
raise Sword2Ruby::Exception.new("Failed to do post_media!(#{options[:collection_uri]}): server returned #{response.code} #{response.message}")
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
#This method creates a new entry in the collection by posting a file and atom-entry to the collection URI.
|
173
|
+
#An MD5-digest will be calculated automatically from the file and sent to the server with the request.
|
174
|
+
#The method will return a Sword2Ruby::DepositReceipt object, or raise a Sword2Ruby::Exception in the case of an error.
|
175
|
+
#===Parameters (passed as a hash collection)
|
176
|
+
#:entry:: an Atom::Entry to be added to the collection
|
177
|
+
#:filepath:: a filepath string indicating the file to be posted. The file must be readable by the process.
|
178
|
+
#:content_type:: the mime content-type string of the file, e.g. "application/zip" or "text/plain"
|
179
|
+
#:packaging:: (optional) the Sword packaging string of the file, e.g. "http://purl.org/net/sword/package/METSDSpaceSIP"
|
180
|
+
#:slug:: (optional) the suggested identifier of the new entry
|
181
|
+
#:collection_uri:: (optional) the collection URI to post to. If not supplied, this will default to the current collection's URI as specified in the @href attribute.
|
182
|
+
#:in_progress:: (optional) boolean value indicating whether the new entry will be completed at a later date
|
183
|
+
#:on_behalf_of:: (optional) username on whos behalf the submission is being performed
|
184
|
+
#:connection:: (optional) Sword2Ruby::Connection object used to perform the operation. If not supplied, the existing collection's connection will be used.
|
185
|
+
#Note that you should call <b><collection>.feed.updated!</b> followed by <b><collection>.feed.update!</b> after making updates to a collection.
|
186
|
+
#
|
187
|
+
#For more information, see the Sword2 specification: {section 6.3.2. "Creating a Resource with a Multipart Deposit"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#protocoloperations_creatingresource_multipart].
|
188
|
+
def post_multipart!(params = {})
|
189
|
+
Utility.check_argument_class('params', params, Hash)
|
190
|
+
defaults = {
|
191
|
+
:entry => nil,
|
192
|
+
:filepath => nil,
|
193
|
+
:content_type => nil,
|
194
|
+
:packaging => nil,
|
195
|
+
:slug => nil,
|
196
|
+
:collection_uri => collection_uri,
|
197
|
+
:in_progress => nil,
|
198
|
+
:on_behalf_of => nil,
|
199
|
+
:connection => @http
|
200
|
+
}
|
201
|
+
options = defaults.merge(params)
|
202
|
+
|
203
|
+
#Validate parameters
|
204
|
+
Utility.check_argument_class(':entry', options[:entry], ::Atom::Entry)
|
205
|
+
Utility.check_argument_class(':filepath', options[:filepath], String)
|
206
|
+
Utility.check_argument_class(':content_type', options[:content_type], String)
|
207
|
+
Utility.check_argument_class(':packaging', options[:packaging], String) if options[:packaging]
|
208
|
+
Utility.check_argument_class('slug', options[:slug], String) if options[:slug]
|
209
|
+
Utility.check_argument_class(':collection_uri', options[:collection_uri], String)
|
210
|
+
Utility.check_argument_class(':on_behalf_of', options[:on_behalf_of], String) if options[:on_behalf_of]
|
211
|
+
Utility.check_argument_class(':connection', options[:connection], Sword2Ruby::Connection)
|
212
|
+
|
213
|
+
tmp = ""
|
214
|
+
boundary = "========" + Time.now.to_i.to_s + "=="
|
215
|
+
filename, md5, data = Utility.read_file(options[:filepath])
|
216
|
+
|
217
|
+
headers = {"Content-Type" => 'multipart/related; boundary="' + boundary + '"; type="application/atom+xml"'}
|
218
|
+
headers["Slug"] = options[:slug] if options[:slug]
|
219
|
+
headers["In-Progress"] = options[:in_progress].to_s.downcase if (options[:in_progress] == true || options[:in_progress] == false)
|
220
|
+
headers["On-Behalf-Of"] = options[:on_behalf_of] if options[:on_behalf_of]
|
221
|
+
headers["MIME-Version"] = "1.0"
|
222
|
+
|
223
|
+
|
224
|
+
# write boundary identifer to temp
|
225
|
+
tmp << "--#{boundary}\r\n"
|
226
|
+
|
227
|
+
# write entry relevant headers to temp
|
228
|
+
tmp << "Content-Type: application/atom+xml; charset=\"utf-8\"\r\n"
|
229
|
+
tmp << "Content-Disposition: attachment; name=atom\r\n"
|
230
|
+
tmp << "MIME-Version: 1.0\r\n\r\n"
|
231
|
+
|
232
|
+
# write entry to temp
|
233
|
+
tmp << options[:entry].to_s + "\r\n"
|
234
|
+
|
235
|
+
# write boundary identifier to temp
|
236
|
+
tmp << "--#{boundary}\r\n"
|
237
|
+
|
238
|
+
# write media part relevant headers to temp
|
239
|
+
tmp << "Content-Type: #{options[:content_type]}\r\n"
|
240
|
+
tmp << "Content-Disposition: attachment; name=payload; filename=#{filename}\r\n"
|
241
|
+
tmp << "Content-MD5: #{md5}\r\n"
|
242
|
+
tmp << "Packaging: #{options[:packaging]}\r\n" if options[:packaging]
|
243
|
+
tmp << "MIME-Version: 1.0\r\n\r\n"
|
244
|
+
|
245
|
+
# write the file base64 encoded to temp
|
246
|
+
tmp << Base64.encode64(data)
|
247
|
+
|
248
|
+
# write boundary identifier to temp
|
249
|
+
tmp << "--#{boundary}--\r\n" #The last two dashes (--) are important!
|
250
|
+
|
251
|
+
response = options[:connection].post(options[:collection_uri], tmp, headers)
|
252
|
+
|
253
|
+
if response.is_a? Net::HTTPSuccess
|
254
|
+
return DepositReceipt.new(response, options[:connection])
|
255
|
+
else
|
256
|
+
raise Sword2Ruby::Exception.new("Failed to do post_multipart!(#{options[:collection_uri]}): server returned #{response.code} #{response.message}")
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
end #class
|
261
|
+
end #module
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'atom/http'
|
2
|
+
|
3
|
+
module Sword2Ruby
|
4
|
+
|
5
|
+
#The Connection class inherits from the Atom::HTTP class to ensure authentication credentials are used on Sword operations.
|
6
|
+
#
|
7
|
+
#Please see the {atom-tools documentation}[http://rdoc.info/github/bct/atom-tools/master/frames] for a complete list of attributes and methods (including post, get, put, delete etc).
|
8
|
+
class Connection < ::Atom::HTTP
|
9
|
+
|
10
|
+
#The Sword2Ruby::User credentials object this connection is using, or nil for anonymous communication
|
11
|
+
attr_reader :user_credentials
|
12
|
+
|
13
|
+
#Boolean value indicating whether authentication is used
|
14
|
+
attr_reader :use_authentication
|
15
|
+
|
16
|
+
#Creates a new Connection object
|
17
|
+
#===Parameters
|
18
|
+
#user_credentials:: (optional) a Sword2Ruby::User object with the username and password
|
19
|
+
def initialize(user_credentials = nil)
|
20
|
+
unless user_credentials.nil?
|
21
|
+
Utility.check_argument_class('user_credentials', user_credentials, User)
|
22
|
+
end
|
23
|
+
@user_credentials = user_credentials
|
24
|
+
@use_authentication = @user_credentials && @user_credentials.username && @user_credentials.password
|
25
|
+
|
26
|
+
super() #initialize the base (Atom::HTTP) class
|
27
|
+
|
28
|
+
if @use_authentication
|
29
|
+
self.user = @user_credentials.username
|
30
|
+
self.pass = @user_credentials.password
|
31
|
+
self.always_auth = :basic
|
32
|
+
end
|
33
|
+
|
34
|
+
end #initialize
|
35
|
+
|
36
|
+
end #class
|
37
|
+
end #module
|