sword2ruby 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +64 -8
- data/lib/sword2ruby/deposit_receipt.rb +14 -3
- data/lib/sword2ruby/service.rb +3 -1
- data/lib/sword2ruby/version.rb +1 -1
- data/sword2ruby.gemspec +3 -3
- data/sword2ruby.tmproj +221 -2
- metadata +34 -14
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -11,7 +11,7 @@ It was developed as part of the JISC Sword 2.0 project. For more information on
|
|
11
11
|
http://www.swordapp.org/. The Sword 2 specification can be found at:
|
12
12
|
http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377
|
13
13
|
|
14
|
-
This code lives at https://github.com/
|
14
|
+
This code lives at https://github.com/swordapp/sword2ruby
|
15
15
|
|
16
16
|
|
17
17
|
Requirements
|
@@ -27,17 +27,73 @@ In order to use the Sword2Ruby gem, you will require:-
|
|
27
27
|
|
28
28
|
Installation
|
29
29
|
------------
|
30
|
-
To install Sword2Ruby and its associated dependencies, make sure you have Bundler installed
|
31
|
-
|
30
|
+
To install Sword2Ruby and its associated dependencies, make sure you have Bundler installed (gem install bundler).
|
31
|
+
Then update your project's Gemfile to include a reference to Sword2Ruby:
|
32
32
|
|
33
|
-
|
33
|
+
gem 'sword2ruby'
|
34
|
+
|
35
|
+
Then, on the command line inside your project folder, run to install all necessary gems:
|
36
|
+
|
37
|
+
bundle install
|
34
38
|
|
35
|
-
|
39
|
+
Finally, ensure you require a reference to the gem in your code:
|
36
40
|
|
37
41
|
require 'sword2ruby'
|
38
|
-
|
39
|
-
at the top of your Ruby code.
|
42
|
+
|
40
43
|
|
41
44
|
Usage
|
42
45
|
-----
|
43
|
-
Refer to the Rdoc for full details of all the classes and their methods
|
46
|
+
Refer to the Rdoc for full details of all the classes and their methods:
|
47
|
+
http://www.rubydoc.info/github/CottageLabs/sword2ruby/master/frames
|
48
|
+
|
49
|
+
|
50
|
+
Example Walkthrough
|
51
|
+
-------------------
|
52
|
+
Make sure you have Ruby 1.9.3 (or perhaps later) running, and then run irb to enter the Ruby command line:
|
53
|
+
|
54
|
+
$ ruby -v
|
55
|
+
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]
|
56
|
+
$ irb
|
57
|
+
|
58
|
+
Now try and run the following statements to post a file to Sword and then update its title:-
|
59
|
+
|
60
|
+
#Example Sword2Ruby walkthrough
|
61
|
+
|
62
|
+
#Require the Sword2Ruby library
|
63
|
+
require 'Sword2Ruby'
|
64
|
+
|
65
|
+
#Print out the version number
|
66
|
+
puts "Running Sword2Ruby version #{Sword2Ruby::Version}"
|
67
|
+
|
68
|
+
#Define the authentication credentials for the connection
|
69
|
+
sword_user = Sword2Ruby::User.new('sword', 'sword')
|
70
|
+
|
71
|
+
#Define the connection object using the username and password
|
72
|
+
connection = Sword2Ruby::Connection.new(sword_user)
|
73
|
+
|
74
|
+
#Get the Service Document
|
75
|
+
service = Atom::Service.new('http://localhost:8080/sd-uri', connection)
|
76
|
+
|
77
|
+
#Print out some properties for the Service
|
78
|
+
puts "service.sword_version: #{service.sword_version}"
|
79
|
+
puts "service.sword_max_upload_size: #{service.sword_max_upload_size}"
|
80
|
+
puts "service.workspaces.count: #{service.workspaces.count}"
|
81
|
+
puts "service.collections.count: #{service.collections.count}"
|
82
|
+
|
83
|
+
#Get a collection
|
84
|
+
collection = service.collections.last
|
85
|
+
|
86
|
+
#Post a file to the collection
|
87
|
+
deposit_receipt = collection.post_media!(:filepath=>"test.txt", :content_type=>"text/plain")
|
88
|
+
|
89
|
+
#Print out the deposit receipt
|
90
|
+
puts "deposit_receipt.has_entry: #{deposit_receipt.has_entry}"
|
91
|
+
puts "deposit_receipt.entry.to_s: #{deposit_receipt.entry.to_s}"
|
92
|
+
|
93
|
+
#Update the title using the Deposit Receipt's title
|
94
|
+
deposit_receipt.entry.title = "New Title"
|
95
|
+
deposit_receipt.entry.put!
|
96
|
+
|
97
|
+
#Print out the URL to the webpage for the item
|
98
|
+
puts "deposit_receipt.entry.alternate_uri: #{deposit_receipt.entry.alternate_uri}"
|
99
|
+
|
@@ -31,10 +31,21 @@ module Sword2Ruby
|
|
31
31
|
@status_message = response.message
|
32
32
|
|
33
33
|
if response.body
|
34
|
+
|
34
35
|
#If a receipt was returned, parse it
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
begin
|
37
|
+
#ensure that there are not parse errors. If there are, warn, rather then raise
|
38
|
+
@entry = ::Atom::Entry.parse(response.body)
|
39
|
+
@has_entry = true
|
40
|
+
@entry.http = connection
|
41
|
+
rescue Exception => message
|
42
|
+
@has_entry = false
|
43
|
+
$stderr.puts "ERROR: An error occured processing the Response XML: #{message}"
|
44
|
+
rescue StandardError => error
|
45
|
+
@has_entry = false
|
46
|
+
$stderr.puts "WARN: The deposit was successful, but there was an issue with Response XML. It could be missing. (#{error})"
|
47
|
+
end
|
48
|
+
|
38
49
|
else
|
39
50
|
#if the receipt was not returned, try and retrieve it
|
40
51
|
if @location
|
data/lib/sword2ruby/service.rb
CHANGED
@@ -45,9 +45,11 @@ module Sword2Ruby
|
|
45
45
|
rxml = nil
|
46
46
|
|
47
47
|
res = connection.get(base, "Accept" => "application/atomsvc+xml")
|
48
|
-
|
48
|
+
|
49
49
|
|
50
50
|
if res.is_a? Net::HTTPSuccess
|
51
|
+
res.validate_content_type(["application/atomsvc+xml"])
|
52
|
+
|
51
53
|
service = self.class.parse(res.body, base, self)
|
52
54
|
|
53
55
|
#Update workspaces, collections and their feeds to use the Service's http connection
|
data/lib/sword2ruby/version.rb
CHANGED
data/sword2ruby.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = Sword2Ruby::VERSION
|
8
8
|
s.authors = ["Mark MacGillivray, Martyn Whitwell"]
|
9
9
|
s.email = ["martyn@cottagelabs.com"]
|
10
|
-
s.homepage = "https://github.com/
|
10
|
+
s.homepage = "https://github.com/swordapp/sword2ruby"
|
11
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
12
|
s.description = %q{The Sword2Ruby gem provides Sword client functionality when run against a Sword 2.0 compliant server.
|
13
13
|
It eases integration of Ruby applications with Sword servers, taking care of things like authentication,
|
@@ -15,9 +15,9 @@ Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
It was developed as part of the JISC Sword 2.0 project. For more information on Sword, see:
|
17
17
|
http://www.swordapp.org/. The Sword 2 specification can be found at:
|
18
|
-
http://
|
18
|
+
http://swordapp.org/sword-v2/sword-v2-specifications/
|
19
19
|
|
20
|
-
This code lives at https://github.com/
|
20
|
+
This code lives at https://github.com/swordapp/sword2ruby.}
|
21
21
|
|
22
22
|
s.rubyforge_project = "sword2ruby"
|
23
23
|
|
data/sword2ruby.tmproj
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
3
|
<plist version="1.0">
|
4
4
|
<dict>
|
5
|
+
<key>currentDocument</key>
|
6
|
+
<string>README.md</string>
|
5
7
|
<key>documents</key>
|
6
8
|
<array>
|
7
9
|
<dict>
|
@@ -18,10 +20,227 @@
|
|
18
20
|
<key>fileHierarchyDrawerWidth</key>
|
19
21
|
<integer>381</integer>
|
20
22
|
<key>metaData</key>
|
21
|
-
<dict
|
23
|
+
<dict>
|
24
|
+
<key>README.md</key>
|
25
|
+
<dict>
|
26
|
+
<key>caret</key>
|
27
|
+
<dict>
|
28
|
+
<key>column</key>
|
29
|
+
<integer>67</integer>
|
30
|
+
<key>line</key>
|
31
|
+
<integer>46</integer>
|
32
|
+
</dict>
|
33
|
+
<key>firstVisibleColumn</key>
|
34
|
+
<integer>0</integer>
|
35
|
+
<key>firstVisibleLine</key>
|
36
|
+
<integer>5</integer>
|
37
|
+
</dict>
|
38
|
+
<key>lib/sword2ruby/collection.rb</key>
|
39
|
+
<dict>
|
40
|
+
<key>caret</key>
|
41
|
+
<dict>
|
42
|
+
<key>column</key>
|
43
|
+
<integer>0</integer>
|
44
|
+
<key>line</key>
|
45
|
+
<integer>19</integer>
|
46
|
+
</dict>
|
47
|
+
<key>columnSelection</key>
|
48
|
+
<false/>
|
49
|
+
<key>firstVisibleColumn</key>
|
50
|
+
<integer>0</integer>
|
51
|
+
<key>firstVisibleLine</key>
|
52
|
+
<integer>0</integer>
|
53
|
+
<key>selectFrom</key>
|
54
|
+
<dict>
|
55
|
+
<key>column</key>
|
56
|
+
<integer>4</integer>
|
57
|
+
<key>line</key>
|
58
|
+
<integer>64</integer>
|
59
|
+
</dict>
|
60
|
+
<key>selectTo</key>
|
61
|
+
<dict>
|
62
|
+
<key>column</key>
|
63
|
+
<integer>0</integer>
|
64
|
+
<key>line</key>
|
65
|
+
<integer>19</integer>
|
66
|
+
</dict>
|
67
|
+
</dict>
|
68
|
+
<key>lib/sword2ruby/service.rb</key>
|
69
|
+
<dict>
|
70
|
+
<key>caret</key>
|
71
|
+
<dict>
|
72
|
+
<key>column</key>
|
73
|
+
<integer>24</integer>
|
74
|
+
<key>line</key>
|
75
|
+
<integer>32</integer>
|
76
|
+
</dict>
|
77
|
+
<key>firstVisibleColumn</key>
|
78
|
+
<integer>0</integer>
|
79
|
+
<key>firstVisibleLine</key>
|
80
|
+
<integer>10</integer>
|
81
|
+
</dict>
|
82
|
+
<key>lib/sword2ruby/utility.rb</key>
|
83
|
+
<dict>
|
84
|
+
<key>caret</key>
|
85
|
+
<dict>
|
86
|
+
<key>column</key>
|
87
|
+
<integer>8</integer>
|
88
|
+
<key>line</key>
|
89
|
+
<integer>55</integer>
|
90
|
+
</dict>
|
91
|
+
<key>columnSelection</key>
|
92
|
+
<false/>
|
93
|
+
<key>firstVisibleColumn</key>
|
94
|
+
<integer>0</integer>
|
95
|
+
<key>firstVisibleLine</key>
|
96
|
+
<integer>1</integer>
|
97
|
+
<key>selectFrom</key>
|
98
|
+
<dict>
|
99
|
+
<key>column</key>
|
100
|
+
<integer>27</integer>
|
101
|
+
<key>line</key>
|
102
|
+
<integer>55</integer>
|
103
|
+
</dict>
|
104
|
+
<key>selectTo</key>
|
105
|
+
<dict>
|
106
|
+
<key>column</key>
|
107
|
+
<integer>8</integer>
|
108
|
+
<key>line</key>
|
109
|
+
<integer>55</integer>
|
110
|
+
</dict>
|
111
|
+
</dict>
|
112
|
+
<key>spec/collection_spec.rb</key>
|
113
|
+
<dict>
|
114
|
+
<key>caret</key>
|
115
|
+
<dict>
|
116
|
+
<key>column</key>
|
117
|
+
<integer>3</integer>
|
118
|
+
<key>line</key>
|
119
|
+
<integer>32</integer>
|
120
|
+
</dict>
|
121
|
+
<key>firstVisibleColumn</key>
|
122
|
+
<integer>0</integer>
|
123
|
+
<key>firstVisibleLine</key>
|
124
|
+
<integer>0</integer>
|
125
|
+
</dict>
|
126
|
+
<key>spec/connection_spec.rb</key>
|
127
|
+
<dict>
|
128
|
+
<key>caret</key>
|
129
|
+
<dict>
|
130
|
+
<key>column</key>
|
131
|
+
<integer>2</integer>
|
132
|
+
<key>line</key>
|
133
|
+
<integer>10</integer>
|
134
|
+
</dict>
|
135
|
+
<key>firstVisibleColumn</key>
|
136
|
+
<integer>0</integer>
|
137
|
+
<key>firstVisibleLine</key>
|
138
|
+
<integer>0</integer>
|
139
|
+
</dict>
|
140
|
+
<key>spec/end_to_end_spec.rb</key>
|
141
|
+
<dict>
|
142
|
+
<key>caret</key>
|
143
|
+
<dict>
|
144
|
+
<key>column</key>
|
145
|
+
<integer>45</integer>
|
146
|
+
<key>line</key>
|
147
|
+
<integer>63</integer>
|
148
|
+
</dict>
|
149
|
+
<key>columnSelection</key>
|
150
|
+
<false/>
|
151
|
+
<key>firstVisibleColumn</key>
|
152
|
+
<integer>0</integer>
|
153
|
+
<key>firstVisibleLine</key>
|
154
|
+
<integer>42</integer>
|
155
|
+
<key>selectFrom</key>
|
156
|
+
<dict>
|
157
|
+
<key>column</key>
|
158
|
+
<integer>5</integer>
|
159
|
+
<key>line</key>
|
160
|
+
<integer>61</integer>
|
161
|
+
</dict>
|
162
|
+
<key>selectTo</key>
|
163
|
+
<dict>
|
164
|
+
<key>column</key>
|
165
|
+
<integer>45</integer>
|
166
|
+
<key>line</key>
|
167
|
+
<integer>63</integer>
|
168
|
+
</dict>
|
169
|
+
</dict>
|
170
|
+
<key>spec/service_spec.rb</key>
|
171
|
+
<dict>
|
172
|
+
<key>caret</key>
|
173
|
+
<dict>
|
174
|
+
<key>column</key>
|
175
|
+
<integer>0</integer>
|
176
|
+
<key>line</key>
|
177
|
+
<integer>35</integer>
|
178
|
+
</dict>
|
179
|
+
<key>firstVisibleColumn</key>
|
180
|
+
<integer>0</integer>
|
181
|
+
<key>firstVisibleLine</key>
|
182
|
+
<integer>0</integer>
|
183
|
+
</dict>
|
184
|
+
<key>spec/statement_spec.rb</key>
|
185
|
+
<dict>
|
186
|
+
<key>caret</key>
|
187
|
+
<dict>
|
188
|
+
<key>column</key>
|
189
|
+
<integer>0</integer>
|
190
|
+
<key>line</key>
|
191
|
+
<integer>49</integer>
|
192
|
+
</dict>
|
193
|
+
<key>firstVisibleColumn</key>
|
194
|
+
<integer>0</integer>
|
195
|
+
<key>firstVisibleLine</key>
|
196
|
+
<integer>0</integer>
|
197
|
+
</dict>
|
198
|
+
<key>spec/test_constants.rb</key>
|
199
|
+
<dict>
|
200
|
+
<key>caret</key>
|
201
|
+
<dict>
|
202
|
+
<key>column</key>
|
203
|
+
<integer>130</integer>
|
204
|
+
<key>line</key>
|
205
|
+
<integer>16</integer>
|
206
|
+
</dict>
|
207
|
+
<key>firstVisibleColumn</key>
|
208
|
+
<integer>0</integer>
|
209
|
+
<key>firstVisibleLine</key>
|
210
|
+
<integer>0</integer>
|
211
|
+
</dict>
|
212
|
+
<key>sword2ruby.gemspec</key>
|
213
|
+
<dict>
|
214
|
+
<key>caret</key>
|
215
|
+
<dict>
|
216
|
+
<key>column</key>
|
217
|
+
<integer>0</integer>
|
218
|
+
<key>line</key>
|
219
|
+
<integer>0</integer>
|
220
|
+
</dict>
|
221
|
+
<key>firstVisibleColumn</key>
|
222
|
+
<integer>0</integer>
|
223
|
+
<key>firstVisibleLine</key>
|
224
|
+
<integer>0</integer>
|
225
|
+
</dict>
|
226
|
+
</dict>
|
227
|
+
<key>openDocuments</key>
|
228
|
+
<array>
|
229
|
+
<string>spec/end_to_end_spec.rb</string>
|
230
|
+
<string>spec/service_spec.rb</string>
|
231
|
+
<string>spec/statement_spec.rb</string>
|
232
|
+
<string>spec/test_constants.rb</string>
|
233
|
+
<string>sword2ruby.gemspec</string>
|
234
|
+
<string>README.md</string>
|
235
|
+
<string>spec/collection_spec.rb</string>
|
236
|
+
<string>spec/connection_spec.rb</string>
|
237
|
+
<string>lib/sword2ruby/collection.rb</string>
|
238
|
+
<string>lib/sword2ruby/service.rb</string>
|
239
|
+
<string>lib/sword2ruby/utility.rb</string>
|
240
|
+
</array>
|
22
241
|
<key>showFileHierarchyDrawer</key>
|
23
242
|
<true/>
|
24
243
|
<key>windowFrame</key>
|
25
|
-
<string>{{
|
244
|
+
<string>{{796, 230}, {1046, 814}}</string>
|
26
245
|
</dict>
|
27
246
|
</plist>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sword2ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: rspec
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '2.8'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '2.8'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: atom-tools
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: 2.0.5
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.0.5
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: hpricot
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ~>
|
@@ -54,14 +69,19 @@ dependencies:
|
|
54
69
|
version: 0.8.3
|
55
70
|
type: :runtime
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.8.3
|
58
78
|
description: ! "The Sword2Ruby gem provides Sword client functionality when run against
|
59
79
|
a Sword 2.0 compliant server.\n It eases integration of Ruby applications with
|
60
80
|
Sword servers, taking care of things like authentication,\n deposit-receipts and
|
61
81
|
the parsing of Sword tags.\n\n It was developed as part of the JISC Sword 2.0 project.
|
62
82
|
For more information on Sword, see:\n http://www.swordapp.org/. The Sword 2 specification
|
63
|
-
can be found at: \n http://
|
64
|
-
|
83
|
+
can be found at: \n http://swordapp.org/sword-v2/sword-v2-specifications/\n\n This
|
84
|
+
code lives at https://github.com/swordapp/sword2ruby."
|
65
85
|
email:
|
66
86
|
- martyn@cottagelabs.com
|
67
87
|
executables: []
|
@@ -159,7 +179,7 @@ files:
|
|
159
179
|
- spec/test_constants.rb
|
160
180
|
- sword2ruby.gemspec
|
161
181
|
- sword2ruby.tmproj
|
162
|
-
homepage: https://github.com/
|
182
|
+
homepage: https://github.com/swordapp/sword2ruby
|
163
183
|
licenses: []
|
164
184
|
post_install_message:
|
165
185
|
rdoc_options: []
|
@@ -179,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
199
|
version: '0'
|
180
200
|
requirements: []
|
181
201
|
rubyforge_project: sword2ruby
|
182
|
-
rubygems_version: 1.8.
|
202
|
+
rubygems_version: 1.8.24
|
183
203
|
signing_key:
|
184
204
|
specification_version: 3
|
185
205
|
summary: Provides SWORD client functionality as per the SWORD 2.0 spec when run against
|