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,235 @@
|
|
1
|
+
require 'test_constants'
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
describe "End to End test for SimpleSwordServer" do
|
6
|
+
|
7
|
+
#Define some variables
|
8
|
+
current_service = nil
|
9
|
+
current_collection = nil
|
10
|
+
current_feed = nil
|
11
|
+
current_slug = nil
|
12
|
+
current_sword_edit_uri = nil
|
13
|
+
current_entry_edit_uri = nil
|
14
|
+
current_edit_media_uri = nil
|
15
|
+
current_alternate_uri = nil
|
16
|
+
current_sword_statement_links = nil
|
17
|
+
|
18
|
+
it "Retrieve Service Document" do
|
19
|
+
current_service = Atom::Service.new(TEST_SERVICE_DOCUMENT_URI_VALID, TEST_CONNECTION_VALID);
|
20
|
+
current_service.service_document_uri.should == TEST_SERVICE_DOCUMENT_URI_VALID
|
21
|
+
current_service.sword_version.should == TEST_SWORD_VERSION
|
22
|
+
current_service.sword_max_upload_size.should >= 0
|
23
|
+
current_service.workspaces.count.should >= 1 #There should always be atleast 1 workspace
|
24
|
+
current_service.collections.count.should >= 1 #There should always be atleast 1 collection
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
it "Retrieve the Collection" do
|
29
|
+
current_collection = Sword2Ruby::Utility.find_element_by_href(current_service.collections, TEST_COLLECTION_HREF)
|
30
|
+
|
31
|
+
if current_collection.nil?
|
32
|
+
puts "\n-----\n"
|
33
|
+
puts "ERROR:\tCould not find collection #{TEST_COLLECTION_HREF} in the service document (#{current_service.service_document_uri}).\n"
|
34
|
+
puts "\tYou should check the value of TEST_COLLECTION_HREF in spec/test_constants.rb.\n"
|
35
|
+
puts "\tHow about using TEST_COLLECTION_HREF=\"#{current_service.collections.first.href}\" instead?\n"
|
36
|
+
puts "-----\n"
|
37
|
+
end
|
38
|
+
current_collection.should_not be_nil
|
39
|
+
current_collection.href.should == TEST_COLLECTION_HREF # Double check we have found the intended collection
|
40
|
+
end
|
41
|
+
|
42
|
+
it "Retrieve the Collection feed" do
|
43
|
+
current_feed = current_collection.feed
|
44
|
+
current_feed.update!
|
45
|
+
current_feed.entries.count.should >= 0
|
46
|
+
end
|
47
|
+
|
48
|
+
it "Create a new entry with an Atom post (no file)" do
|
49
|
+
entry = Atom::Entry.new()
|
50
|
+
entry.title = "Test Entry created by Sword2Ruby end-to-end test"
|
51
|
+
entry.summary = "This entry was created during a test on #{Time.now}"
|
52
|
+
entry.add_dublin_core_extension!("publisher", "Publisher Test 01")
|
53
|
+
entry.add_dublin_core_extension!("audience", "Audience Test 01")
|
54
|
+
entry.updated = Time.now
|
55
|
+
|
56
|
+
#Generate a slug based on the date and time
|
57
|
+
current_slug = "sword2ruby_test_#{Time.now.strftime("%FT%H-%M-%S")}"
|
58
|
+
|
59
|
+
deposit_receipt = current_collection.post!(:entry=>entry, :slug=>current_slug, :in_progress=>true)
|
60
|
+
current_feed.updated! #Flag feed that it has been updated
|
61
|
+
|
62
|
+
#There SHOULD be a deposit receipt entry received from the Sword server
|
63
|
+
deposit_receipt.has_entry.should == true
|
64
|
+
deposit_receipt.entry.should_not be_nil
|
65
|
+
|
66
|
+
#There MAY be an alternate entry page
|
67
|
+
current_alternate_uri = deposit_receipt.entry.alternate_uri
|
68
|
+
|
69
|
+
#There MUST be an Atom Entry Edit / Media Entry / Edit-URI value
|
70
|
+
current_entry_edit_uri = deposit_receipt.entry.entry_edit_uri
|
71
|
+
current_entry_edit_uri.should_not be_nil
|
72
|
+
|
73
|
+
#There MUST be at least one Edit Media Link / Media Resource URI / EM-URI
|
74
|
+
edit_media_links = deposit_receipt.entry.edit_media_links
|
75
|
+
edit_media_links.count.should >= 1
|
76
|
+
current_edit_media_uri = edit_media_links.first.href
|
77
|
+
|
78
|
+
#There MUST be a Sword Edit URI / SE-URI
|
79
|
+
current_sword_edit_uri = deposit_receipt.entry.sword_edit_uri
|
80
|
+
current_sword_edit_uri.should_not be_nil
|
81
|
+
|
82
|
+
#There SHOULD be a single original deposit link - EXCEPT in this case we have not deposited a file, so it SHOULD be nil
|
83
|
+
sword_original_deposit_uri = deposit_receipt.entry.sword_original_deposit_uri
|
84
|
+
sword_original_deposit_uri.should be_nil
|
85
|
+
|
86
|
+
#There SHOULD be zero or more derived resources - EXCEPT in this case, so it SHOULD be an empty array []
|
87
|
+
sword_derived_resource_links = deposit_receipt.entry.sword_derived_resource_links
|
88
|
+
sword_derived_resource_links.count.should == 0
|
89
|
+
|
90
|
+
#There MAY be one or more links to Sword statements
|
91
|
+
current_sword_statement_links = deposit_receipt.entry.sword_statement_links
|
92
|
+
current_sword_statement_links.count.should >= 0
|
93
|
+
|
94
|
+
#There MAY be some sword packagings
|
95
|
+
sword_packagings = deposit_receipt.entry.sword_packagings
|
96
|
+
sword_packagings.count.should >= 0
|
97
|
+
|
98
|
+
#There MUST be a sword treatment
|
99
|
+
sword_treatment = deposit_receipt.entry.sword_treatment
|
100
|
+
sword_treatment.should_not be_nil
|
101
|
+
|
102
|
+
#There MAY be a verbose description
|
103
|
+
sword_verbose_description = deposit_receipt.entry.sword_verbose_description
|
104
|
+
|
105
|
+
#There MAY be dublin core metadata
|
106
|
+
dublin_core_extensions = deposit_receipt.entry.dublin_core_extensions
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
it "Test Entry.post" do
|
111
|
+
#Now post a metadata update to the working entry
|
112
|
+
update_entry = Atom::Entry.new()
|
113
|
+
update_entry.title = "Extra title added to existing entry"
|
114
|
+
update_entry.add_dublin_core_extension!("provenance", "Provenance Test 01")
|
115
|
+
deposit_receipt = update_entry.post!(:sword_edit_uri => current_sword_edit_uri, :connection => TEST_CONNECTION_VALID)
|
116
|
+
|
117
|
+
#There SHOULD be a deposit receipt entry received from the Sword server
|
118
|
+
deposit_receipt.has_entry.should == true
|
119
|
+
deposit_receipt.entry.should_not be_nil
|
120
|
+
|
121
|
+
#The updated entry should include the new Dublin Core provenance value
|
122
|
+
Sword2Ruby::Utility.find_element_text(deposit_receipt.entry.dublin_core_extensions, "dcterms:provenance").should == "Provenance Test 01"
|
123
|
+
|
124
|
+
#"Add a file to the existing entry via deposit receipt" do
|
125
|
+
deposit_receipt.entry.post_media!(:filepath => "spec/fixtures/example.txt", :content_type=>"text/plain")
|
126
|
+
#There SHOULD be a deposit receipt entry received from the Sword server
|
127
|
+
deposit_receipt.has_entry.should == true
|
128
|
+
deposit_receipt.entry.should_not be_nil
|
129
|
+
end
|
130
|
+
|
131
|
+
it "Entry.post_media" do
|
132
|
+
deposit_receipt = Atom::Entry.new().post_media!(:filepath => "spec/fixtures/snowflake.png", :content_type=>"image/png", :edit_media_uri => current_edit_media_uri, :connection => TEST_CONNECTION_VALID)
|
133
|
+
|
134
|
+
#There SHOULD be a deposit receipt entry received from the Sword server
|
135
|
+
deposit_receipt.has_entry.should == true
|
136
|
+
deposit_receipt.entry.should_not be_nil
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
it "Entry.post_multipart" do
|
141
|
+
#Now post a metadata update to the working entry
|
142
|
+
update_entry = Atom::Entry.new()
|
143
|
+
update_entry.title = "Another extra title added to existing entry"
|
144
|
+
update_entry.add_dublin_core_extension!("contributor", "Contributor 01")
|
145
|
+
deposit_receipt = update_entry.post_multipart!(:sword_edit_uri => current_sword_edit_uri, :filepath => "spec/fixtures/snowflake.png", :content_type=>"image/png", :connection => TEST_CONNECTION_VALID)
|
146
|
+
|
147
|
+
#There SHOULD be a deposit receipt entry received from the Sword server
|
148
|
+
deposit_receipt.has_entry.should == true
|
149
|
+
deposit_receipt.entry.should_not be_nil
|
150
|
+
|
151
|
+
|
152
|
+
#The updated entry should include the new Dublin Core Contributor value
|
153
|
+
Sword2Ruby::Utility.find_element_text(deposit_receipt.entry.dublin_core_extensions, "dcterms:contributor").should == "Contributor 01"
|
154
|
+
#The updated entry should include the existing Dublin Core provenance value
|
155
|
+
Sword2Ruby::Utility.find_element_text(deposit_receipt.entry.dublin_core_extensions, "dcterms:provenance").should == "Provenance Test 01"
|
156
|
+
end
|
157
|
+
|
158
|
+
it "Entry.put" do
|
159
|
+
#Now PUT a metadata update to the working entry
|
160
|
+
update_entry = Atom::Entry.new()
|
161
|
+
update_entry.title = "Replaced Title"
|
162
|
+
update_entry.add_dublin_core_extension!("contributor", "Contributor 02")
|
163
|
+
deposit_receipt = update_entry.put!(:entry_edit_uri => current_entry_edit_uri, :connection => TEST_CONNECTION_VALID)
|
164
|
+
|
165
|
+
#There SHOULD be a deposit receipt entry received from the Sword server
|
166
|
+
deposit_receipt.has_entry.should == true
|
167
|
+
deposit_receipt.entry.should_not be_nil
|
168
|
+
|
169
|
+
|
170
|
+
#The updated entry should include the updated Dublin Core Contributor value
|
171
|
+
Sword2Ruby::Utility.find_element_text(deposit_receipt.entry.dublin_core_extensions, "dcterms:contributor").should == "Contributor 02"
|
172
|
+
#The updated entry should have deleted the old provenance value
|
173
|
+
Sword2Ruby::Utility.find_element_text(deposit_receipt.entry.dublin_core_extensions, "dcterms:provenance").should be_nil
|
174
|
+
end
|
175
|
+
|
176
|
+
it "Entry.put_media" do
|
177
|
+
update_entry = Atom::Entry.new()
|
178
|
+
deposit_receipt = update_entry.put_media!(:filepath => "spec/fixtures/snowflake.png", :content_type=>"image/png", :edit_media_uri => current_edit_media_uri, :connection => TEST_CONNECTION_VALID)
|
179
|
+
|
180
|
+
#There ISN'T a deposit receipt entry received from the Sword server
|
181
|
+
deposit_receipt.has_entry.should == false
|
182
|
+
deposit_receipt.entry.should be_nil
|
183
|
+
end
|
184
|
+
|
185
|
+
it "Entry.put_multipart" do
|
186
|
+
update_entry = Atom::Entry.new()
|
187
|
+
update_entry.title = "Replaced Title"
|
188
|
+
update_entry.add_dublin_core_extension!("contributor", "Contributor 03")
|
189
|
+
deposit_receipt = update_entry.put_multipart!(:entry_edit_uri => current_entry_edit_uri, :filepath => "spec/fixtures/snowflake.png", :content_type=>"image/png", :connection => TEST_CONNECTION_VALID)
|
190
|
+
|
191
|
+
#There SHOULD be a deposit receipt entry received from the Sword server
|
192
|
+
deposit_receipt.has_entry.should == true
|
193
|
+
deposit_receipt.entry.should_not be_nil
|
194
|
+
|
195
|
+
#The updated entry should include the updated Dublin Core Contributor value
|
196
|
+
Sword2Ruby::Utility.find_element_text(deposit_receipt.entry.dublin_core_extensions, "dcterms:contributor").should == "Contributor 03"
|
197
|
+
#The updated entry should have deleted the old provenance value
|
198
|
+
Sword2Ruby::Utility.find_element_text(deposit_receipt.entry.dublin_core_extensions, "dcterms:provenance").should be_nil
|
199
|
+
end
|
200
|
+
|
201
|
+
it "AutoDiscover" do
|
202
|
+
autodiscover = Sword2Ruby::AutoDiscover.new(current_alternate_uri)
|
203
|
+
#Check the discovered entry edit uri matches the known entry edit uri
|
204
|
+
autodiscover.entry_edit_uris.first[:href].should == current_entry_edit_uri
|
205
|
+
|
206
|
+
#Check the discovered statement links count matches the known statement links count
|
207
|
+
current_sword_statement_links.count.should == autodiscover.sword_statement_links.count
|
208
|
+
|
209
|
+
#For each known statement link, check the href matches the discovered statement link
|
210
|
+
current_sword_statement_links.each do |current|
|
211
|
+
autodiscover.sword_statement_links.find{|discovered| discovered[:type] == current.type}[:href].should == current.href
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
|
216
|
+
it "Entry.delete_media" do
|
217
|
+
update_entry = Atom::Entry.new()
|
218
|
+
deposit_receipt = update_entry.delete_media!(:edit_media_uri => current_edit_media_uri, :connection => TEST_CONNECTION_VALID)
|
219
|
+
|
220
|
+
#There SHOULD NOT be a deposit receipt entry received from the Sword server
|
221
|
+
deposit_receipt.has_entry.should == false
|
222
|
+
deposit_receipt.entry.should be_nil
|
223
|
+
end
|
224
|
+
|
225
|
+
it "Entry.delete" do
|
226
|
+
update_entry = Atom::Entry.new()
|
227
|
+
deposit_receipt = update_entry.delete!(:entry_edit_uri => current_entry_edit_uri, :connection => TEST_CONNECTION_VALID)
|
228
|
+
|
229
|
+
#There SHOULD NOT be a deposit receipt entry received from the Sword server
|
230
|
+
deposit_receipt.has_entry.should == false
|
231
|
+
deposit_receipt.entry.should be_nil
|
232
|
+
end
|
233
|
+
|
234
|
+
|
235
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#service_spec.rb
|
2
|
+
|
3
|
+
require 'test_constants'
|
4
|
+
|
5
|
+
describe ::Atom::Service do
|
6
|
+
|
7
|
+
it "initialise without parameters" do
|
8
|
+
expect{ Atom::Service.new()}.to raise_error(ArgumentError);
|
9
|
+
end
|
10
|
+
|
11
|
+
it "initialise with invalid URI type" do
|
12
|
+
expect{ Atom::Service.new(123456)}.to raise_error(ArgumentError);
|
13
|
+
end
|
14
|
+
|
15
|
+
it "initialise with invalid URI protocol" do
|
16
|
+
expect{ Atom::Service.new(TEST_SERVICE_DOCUMENT_URI_INVALID_PROTOCOL)}.to raise_error(URI::InvalidURIError);
|
17
|
+
end
|
18
|
+
|
19
|
+
it "initialise with malformed URI" do
|
20
|
+
expect{ Atom::Service.new(TEST_SERVICE_DOCUMENT_URI_MALFORMED)}.to raise_error(URI::InvalidURIError);
|
21
|
+
end
|
22
|
+
|
23
|
+
it "initialise with valid URI, missing connection" do
|
24
|
+
expect { Atom::Service.new(TEST_SERVICE_DOCUMENT_URI_VALID) }.to raise_error(Atom::Unauthorized)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "initialise with valid URI, refresh with invalid username/password" do
|
28
|
+
expect { Atom::Service.new(TEST_SERVICE_DOCUMENT_URI_VALID, TEST_CONNECTION_INVALID) }.to raise_error(Atom::Unauthorized)
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
it "initialise with valid URI, refresh with valid username/password" do
|
33
|
+
service = ::Atom::Service.new(TEST_SERVICE_DOCUMENT_URI_VALID, TEST_CONNECTION_VALID)
|
34
|
+
service.collections.count.should >= 1 #Test that the service has at least 1 collection
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#auto_discover_spec.rb
|
2
|
+
require "rexml/document"
|
3
|
+
|
4
|
+
require 'test_constants'
|
5
|
+
|
6
|
+
|
7
|
+
describe "Atom and RDF Statements" do
|
8
|
+
|
9
|
+
it "Testing Atom Statement" do
|
10
|
+
|
11
|
+
statement = Atom::Feed.new(TEST_ATOM_STATEMENT_URI, TEST_CONNECTION_VALID)
|
12
|
+
statement.update!
|
13
|
+
|
14
|
+
# there may or may not be media items associated with this statement
|
15
|
+
statement.entries.count.should >= 0
|
16
|
+
|
17
|
+
#The statement should have a category
|
18
|
+
statement.sword_state_categories.count.should >= 1
|
19
|
+
|
20
|
+
|
21
|
+
#If there are entries, loop through and validate each one
|
22
|
+
statement.entries.each do |entry|
|
23
|
+
entry.sword_packagings.count.should >= 1
|
24
|
+
entry.sword_deposited_on.should_not be_nil
|
25
|
+
entry.sword_deposited_by.should_not be_nil
|
26
|
+
entry.sword_original_deposit_category.should_not be_nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
it "Testing RDF OAI-ORE Statement" do
|
32
|
+
statement = Sword2Ruby::SwordStatementOAIORE.new(TEST_RDF_STATEMENT_URI, TEST_CONNECTION_VALID)
|
33
|
+
|
34
|
+
statement.rdf_descriptions.count.should >= 1
|
35
|
+
|
36
|
+
# loop through and validate each description
|
37
|
+
statement.rdf_descriptions.each do |description|
|
38
|
+
|
39
|
+
#not much to validate as any of these could be nil
|
40
|
+
puts "\n"
|
41
|
+
puts " description.sword_packagings: #{description.sword_packagings}"
|
42
|
+
puts " description.sword_deposited_on: #{description.sword_deposited_on}"
|
43
|
+
puts " description.sword_deposited_by: #{description.sword_deposited_by}"
|
44
|
+
puts " description.sword_deposited_on_behalf_of: #{description.sword_deposited_on_behalf_of}"
|
45
|
+
puts " description.sword_original_deposit: #{description.sword_original_deposit}"
|
46
|
+
puts " description.sword_state: #{description.sword_state}"
|
47
|
+
puts " description.sword_state_description: #{description.sword_state_description}"
|
48
|
+
puts "\n"
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'sword2ruby';
|
2
|
+
|
3
|
+
#:nodoc:
|
4
|
+
|
5
|
+
#These are constants used by the unit tests
|
6
|
+
|
7
|
+
#CHANGE THESE VALUES TO MATCH YOUR TEST SERVER!
|
8
|
+
#In order to run the tests, make sure you update the URLs, usernames and passwords to match you setup
|
9
|
+
TEST_USERNAME_VALID = 'sword'
|
10
|
+
TEST_PASSWORD_VALID = 'sword'
|
11
|
+
TEST_AUTODISCOVER_SERVICE_HTML_URI = 'http://localhost:8080/'
|
12
|
+
TEST_AUTODISCOVER_COLLECTION_HTML_URI = 'http://localhost:8080/html/067cadb4-fad2-4be6-8f04-a5f5997a7399'
|
13
|
+
TEST_AUTODISCOVER_ENTRY_HTML_URI = 'http://localhost:8080/html/067cadb4-fad2-4be6-8f04-a5f5997a7399/sword2ruby_test_2012-04-04T11-16-11'
|
14
|
+
TEST_SERVICE_DOCUMENT_URI_VALID = 'http://localhost:8080/sd-uri'
|
15
|
+
TEST_COLLECTION_HREF = 'http://localhost:8080/col-uri/067cadb4-fad2-4be6-8f04-a5f5997a7399'
|
16
|
+
TEST_ATOM_STATEMENT_URI = "http://localhost:8080/state-uri/067cadb4-fad2-4be6-8f04-a5f5997a7399/sword2ruby_test_2012-04-09T19-22-45.atom"
|
17
|
+
TEST_RDF_STATEMENT_URI = "http://localhost:8080/state-uri/067cadb4-fad2-4be6-8f04-a5f5997a7399/sword2ruby_test_2012-04-09T19-22-45.rdf"
|
18
|
+
|
19
|
+
#------------------------------------------------
|
20
|
+
#No need to set anything from here onwards
|
21
|
+
TEST_USERNAME_INVALID = 'invalid-username'
|
22
|
+
TEST_PASSWORD_INVALID = 'invalid-password'
|
23
|
+
|
24
|
+
TEST_SERVICE_DOCUMENT_URI_INVALID_PROTOCOL = 'ftp://localhost:8080/service-doc'
|
25
|
+
TEST_SERVICE_DOCUMENT_URI_MALFORMED = 'http: this is wrong';
|
26
|
+
|
27
|
+
TEST_USER_VALID = Sword2Ruby::User.new(TEST_USERNAME_VALID, TEST_PASSWORD_VALID);
|
28
|
+
TEST_CONNECTION_VALID = Sword2Ruby::Connection.new(TEST_USER_VALID);
|
29
|
+
TEST_USER_INVALID = Sword2Ruby::User.new(TEST_USERNAME_INVALID, TEST_PASSWORD_INVALID);
|
30
|
+
TEST_CONNECTION_INVALID = Sword2Ruby::Connection.new(TEST_USER_INVALID);
|
31
|
+
|
32
|
+
TEST_SWORD_VERSION = '2.0'
|
data/sword2ruby.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "sword2ruby/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "sword2ruby"
|
7
|
+
s.version = Sword2Ruby::VERSION
|
8
|
+
s.authors = ["Mark MacGillivray, Martyn Whitwell"]
|
9
|
+
s.email = ["martyn@cottagelabs.com"]
|
10
|
+
s.homepage = "https://github.com/CottageLabs/sword2ruby"
|
11
|
+
s.summary = %q{Provides SWORD client functionality as per the SWORD 2.0 spec when run against a SWORD 2.0 compliant server.}
|
12
|
+
s.description = %q{The Sword2Ruby gem provides Sword client functionality when run against a Sword 2.0 compliant server.
|
13
|
+
It eases integration of Ruby applications with Sword servers, taking care of things like authentication,
|
14
|
+
deposit-receipts and the parsing of Sword tags.
|
15
|
+
|
16
|
+
It was developed as part of the JISC Sword 2.0 project. For more information on Sword, see:
|
17
|
+
http://www.swordapp.org/. The Sword 2 specification can be found at:
|
18
|
+
http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377
|
19
|
+
|
20
|
+
This code lives at https://github.com/CottageLabs/sword2ruby.}
|
21
|
+
|
22
|
+
s.rubyforge_project = "sword2ruby"
|
23
|
+
|
24
|
+
# The files included in the gem.
|
25
|
+
s.files = `git ls-files`.split("\n")
|
26
|
+
|
27
|
+
# Files that are used for testing the gem.
|
28
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
29
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
30
|
+
s.require_paths = ["lib"]
|
31
|
+
|
32
|
+
|
33
|
+
#Development Dependencies
|
34
|
+
s.add_development_dependency "rake"
|
35
|
+
s.add_development_dependency "rspec", "~> 2.8"
|
36
|
+
|
37
|
+
|
38
|
+
#Runtime Dependencies
|
39
|
+
s.add_runtime_dependency "atom-tools", "~> 2.0.5"
|
40
|
+
s.add_runtime_dependency "hpricot", "~> 0.8.3"
|
41
|
+
|
42
|
+
end
|
data/sword2ruby.tmproj
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>documents</key>
|
6
|
+
<array>
|
7
|
+
<dict>
|
8
|
+
<key>expanded</key>
|
9
|
+
<true/>
|
10
|
+
<key>name</key>
|
11
|
+
<string>sword2ruby</string>
|
12
|
+
<key>regexFolderFilter</key>
|
13
|
+
<string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
|
14
|
+
<key>sourceDirectory</key>
|
15
|
+
<string></string>
|
16
|
+
</dict>
|
17
|
+
</array>
|
18
|
+
<key>fileHierarchyDrawerWidth</key>
|
19
|
+
<integer>381</integer>
|
20
|
+
<key>metaData</key>
|
21
|
+
<dict/>
|
22
|
+
<key>showFileHierarchyDrawer</key>
|
23
|
+
<true/>
|
24
|
+
<key>windowFrame</key>
|
25
|
+
<string>{{401, 191}, {815, 1213}}</string>
|
26
|
+
</dict>
|
27
|
+
</plist>
|
metadata
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sword2ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mark MacGillivray, Martyn Whitwell
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: &70241851554260 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70241851554260
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &70241851553660 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.8'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70241851553660
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: atom-tools
|
38
|
+
requirement: &70241851553100 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.0.5
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70241851553100
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: hpricot
|
49
|
+
requirement: &70241851552380 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.8.3
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70241851552380
|
58
|
+
description: ! "The Sword2Ruby gem provides Sword client functionality when run against
|
59
|
+
a Sword 2.0 compliant server.\n It eases integration of Ruby applications with
|
60
|
+
Sword servers, taking care of things like authentication,\n deposit-receipts and
|
61
|
+
the parsing of Sword tags.\n\n It was developed as part of the JISC Sword 2.0 project.
|
62
|
+
For more information on Sword, see:\n http://www.swordapp.org/. The Sword 2 specification
|
63
|
+
can be found at: \n http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377\n\n
|
64
|
+
\ This code lives at https://github.com/CottageLabs/sword2ruby."
|
65
|
+
email:
|
66
|
+
- martyn@cottagelabs.com
|
67
|
+
executables: []
|
68
|
+
extensions: []
|
69
|
+
extra_rdoc_files: []
|
70
|
+
files:
|
71
|
+
- .gitignore
|
72
|
+
- Gemfile
|
73
|
+
- Gemfile.lock
|
74
|
+
- LICENCE
|
75
|
+
- README.md
|
76
|
+
- Rakefile
|
77
|
+
- doc/Atom.html
|
78
|
+
- doc/Atom/Collection.html
|
79
|
+
- doc/Atom/Element.html
|
80
|
+
- doc/Atom/Entry.html
|
81
|
+
- doc/Atom/Feed.html
|
82
|
+
- doc/Atom/Service.html
|
83
|
+
- doc/Gemfile.html
|
84
|
+
- doc/Object.html
|
85
|
+
- doc/REXML.html
|
86
|
+
- doc/REXML/Element.html
|
87
|
+
- doc/Rakefile.html
|
88
|
+
- doc/Sword2Ruby.html
|
89
|
+
- doc/Sword2Ruby/Atom.html
|
90
|
+
- doc/Sword2Ruby/AutoDiscover.html
|
91
|
+
- doc/Sword2Ruby/Connection.html
|
92
|
+
- doc/Sword2Ruby/DepositReceipt.html
|
93
|
+
- doc/Sword2Ruby/Exception.html
|
94
|
+
- doc/Sword2Ruby/SwordAccept.html
|
95
|
+
- doc/Sword2Ruby/SwordStatementOAIORE.html
|
96
|
+
- doc/Sword2Ruby/User.html
|
97
|
+
- doc/Sword2Ruby/Utility.html
|
98
|
+
- doc/created.rid
|
99
|
+
- doc/images/add.png
|
100
|
+
- doc/images/brick.png
|
101
|
+
- doc/images/brick_link.png
|
102
|
+
- doc/images/bug.png
|
103
|
+
- doc/images/bullet_black.png
|
104
|
+
- doc/images/bullet_toggle_minus.png
|
105
|
+
- doc/images/bullet_toggle_plus.png
|
106
|
+
- doc/images/date.png
|
107
|
+
- doc/images/delete.png
|
108
|
+
- doc/images/find.png
|
109
|
+
- doc/images/loadingAnimation.gif
|
110
|
+
- doc/images/macFFBgHack.png
|
111
|
+
- doc/images/package.png
|
112
|
+
- doc/images/page_green.png
|
113
|
+
- doc/images/page_white_text.png
|
114
|
+
- doc/images/page_white_width.png
|
115
|
+
- doc/images/plugin.png
|
116
|
+
- doc/images/ruby.png
|
117
|
+
- doc/images/tag_blue.png
|
118
|
+
- doc/images/tag_green.png
|
119
|
+
- doc/images/transparent.png
|
120
|
+
- doc/images/wrench.png
|
121
|
+
- doc/images/wrench_orange.png
|
122
|
+
- doc/images/zoom.png
|
123
|
+
- doc/index.html
|
124
|
+
- doc/js/darkfish.js
|
125
|
+
- doc/js/jquery.js
|
126
|
+
- doc/js/navigation.js
|
127
|
+
- doc/js/search.js
|
128
|
+
- doc/js/search_index.js
|
129
|
+
- doc/js/searcher.js
|
130
|
+
- doc/rdoc.css
|
131
|
+
- doc/spec/fixtures/example_txt.html
|
132
|
+
- doc/table_of_contents.html
|
133
|
+
- lib/sword2ruby.rb
|
134
|
+
- lib/sword2ruby/auto_discover.rb
|
135
|
+
- lib/sword2ruby/collection.rb
|
136
|
+
- lib/sword2ruby/connection.rb
|
137
|
+
- lib/sword2ruby/constant.rb
|
138
|
+
- lib/sword2ruby/deposit_receipt.rb
|
139
|
+
- lib/sword2ruby/element.rb
|
140
|
+
- lib/sword2ruby/entry.rb
|
141
|
+
- lib/sword2ruby/exception.rb
|
142
|
+
- lib/sword2ruby/feed.rb
|
143
|
+
- lib/sword2ruby/rexml_element.rb
|
144
|
+
- lib/sword2ruby/service.rb
|
145
|
+
- lib/sword2ruby/sword_accept.rb
|
146
|
+
- lib/sword2ruby/sword_statement_oai_ore.rb
|
147
|
+
- lib/sword2ruby/user.rb
|
148
|
+
- lib/sword2ruby/utility.rb
|
149
|
+
- lib/sword2ruby/version.rb
|
150
|
+
- spec/auto_discover_spec.rb
|
151
|
+
- spec/collection_spec.rb
|
152
|
+
- spec/connection_spec.rb
|
153
|
+
- spec/end_to_end_spec.rb
|
154
|
+
- spec/fixtures/example.txt
|
155
|
+
- spec/fixtures/snowflake.png
|
156
|
+
- spec/fixtures/zip-test.zip
|
157
|
+
- spec/service_spec.rb
|
158
|
+
- spec/statement_spec.rb
|
159
|
+
- spec/test_constants.rb
|
160
|
+
- sword2ruby.gemspec
|
161
|
+
- sword2ruby.tmproj
|
162
|
+
homepage: https://github.com/CottageLabs/sword2ruby
|
163
|
+
licenses: []
|
164
|
+
post_install_message:
|
165
|
+
rdoc_options: []
|
166
|
+
require_paths:
|
167
|
+
- lib
|
168
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
+
none: false
|
176
|
+
requirements:
|
177
|
+
- - ! '>='
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
180
|
+
requirements: []
|
181
|
+
rubyforge_project: sword2ruby
|
182
|
+
rubygems_version: 1.8.10
|
183
|
+
signing_key:
|
184
|
+
specification_version: 3
|
185
|
+
summary: Provides SWORD client functionality as per the SWORD 2.0 spec when run against
|
186
|
+
a SWORD 2.0 compliant server.
|
187
|
+
test_files:
|
188
|
+
- spec/auto_discover_spec.rb
|
189
|
+
- spec/collection_spec.rb
|
190
|
+
- spec/connection_spec.rb
|
191
|
+
- spec/end_to_end_spec.rb
|
192
|
+
- spec/fixtures/example.txt
|
193
|
+
- spec/fixtures/snowflake.png
|
194
|
+
- spec/fixtures/zip-test.zip
|
195
|
+
- spec/service_spec.rb
|
196
|
+
- spec/statement_spec.rb
|
197
|
+
- spec/test_constants.rb
|