rubydora 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -0
- data/VERSION +1 -1
- data/lib/rubydora/datastream.rb +6 -7
- data/lib/rubydora/rest_api_client.rb +4 -4
- data/spec/datastream_spec.rb +7 -0
- metadata +122 -172
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/lib/rubydora/datastream.rb
CHANGED
@@ -13,9 +13,9 @@ module Rubydora
|
|
13
13
|
attr_reader :digital_object, :dsid
|
14
14
|
|
15
15
|
# mapping datastream attributes (and api parameters) to datastream profile names
|
16
|
-
DS_ATTRIBUTES = {:controlGroup => :dsControlGroup, :dsLocation => :dsLocation, :altIDs => nil, :dsLabel => :dsLabel, :versionable => :dsVersionable, :dsState => :dsState, :formatURI => :dsFormatURI, :checksumType => :dsChecksumType, :checksum => :dsChecksum, :mimeType => :dsMIME, :logMessage => nil, :ignoreContent => nil, :lastModifiedDate => nil, :
|
16
|
+
DS_ATTRIBUTES = {:controlGroup => :dsControlGroup, :dsLocation => :dsLocation, :altIDs => nil, :dsLabel => :dsLabel, :versionable => :dsVersionable, :dsState => :dsState, :formatURI => :dsFormatURI, :checksumType => :dsChecksumType, :checksum => :dsChecksum, :mimeType => :dsMIME, :logMessage => nil, :ignoreContent => nil, :lastModifiedDate => nil, :content => nil}
|
17
17
|
|
18
|
-
define_attribute_methods DS_ATTRIBUTES.keys
|
18
|
+
define_attribute_methods DS_ATTRIBUTES.keys
|
19
19
|
|
20
20
|
# accessors for datastream attributes
|
21
21
|
DS_ATTRIBUTES.each do |attribute, profile_name|
|
@@ -68,6 +68,8 @@ module Rubydora
|
|
68
68
|
@content ||= repository.datastream_dissemination :pid => pid, :dsid => dsid
|
69
69
|
rescue RestClient::ResourceNotFound
|
70
70
|
end
|
71
|
+
|
72
|
+
(@content.read and @content.rewind if @content.is_a? IO) || @content
|
71
73
|
end
|
72
74
|
alias_method :read, :content
|
73
75
|
|
@@ -80,12 +82,9 @@ module Rubydora
|
|
80
82
|
# Set the content of the datastream
|
81
83
|
# @param [String or IO]
|
82
84
|
# @return [String or IO]
|
83
|
-
def content=
|
85
|
+
def content= new_content
|
84
86
|
content_will_change!
|
85
|
-
@
|
86
|
-
@content = content.dup
|
87
|
-
@content &&= @content.read if @content.respond_to? :read
|
88
|
-
@content &&= @content.to_s if @content.respond_to? :read
|
87
|
+
@content = new_content
|
89
88
|
end
|
90
89
|
|
91
90
|
# Retrieve the datastream profile as a hash (and cache it)
|
@@ -151,9 +151,9 @@ module Rubydora
|
|
151
151
|
def add_datastream options = {}
|
152
152
|
pid = options.delete(:pid)
|
153
153
|
dsid = options.delete(:dsid)
|
154
|
-
file = options.delete(:
|
154
|
+
file = options.delete(:content)
|
155
155
|
content_type = options.delete(:content_type) || options[:mimeType] || (MIME::Types.type_for(file.path).first if file.respond_to? :path) || 'text/plain'
|
156
|
-
client[datastream_url(pid, dsid, options)].post file, :content_type => content_type.to_s
|
156
|
+
client[datastream_url(pid, dsid, options)].post file, :content_type => content_type.to_s, :multipart => true
|
157
157
|
end
|
158
158
|
|
159
159
|
# {include:RestApiClient::API_DOCUMENTATION}
|
@@ -164,9 +164,9 @@ module Rubydora
|
|
164
164
|
def modify_datastream options = {}
|
165
165
|
pid = options.delete(:pid)
|
166
166
|
dsid = options.delete(:dsid)
|
167
|
-
file = options.delete(:
|
167
|
+
file = options.delete(:content)
|
168
168
|
content_type = options.delete(:content_type) || options[:mimeType] || (MIME::Types.type_for(file.path).first if file.respond_to? :path) || 'text/plain'
|
169
|
-
client[datastream_url(pid, dsid, options)].put file, :content_type => content_type.to_s
|
169
|
+
client[datastream_url(pid, dsid, options)].put file, :content_type => content_type.to_s, :multipart => true
|
170
170
|
end
|
171
171
|
|
172
172
|
# {include:RestApiClient::API_DOCUMENTATION}
|
data/spec/datastream_spec.rb
CHANGED
@@ -93,6 +93,13 @@ describe Rubydora::Datastream do
|
|
93
93
|
@datastream.save
|
94
94
|
end
|
95
95
|
|
96
|
+
it "should update the datastream when the content is changed" do
|
97
|
+
@mock_repository.should_receive(:datastream_dissemination).with(hash_including(:pid => 'pid', :dsid => 'dsid')).and_return('asdf')
|
98
|
+
@mock_repository.should_receive(:modify_datastream).with(hash_including(:content => 'test'))
|
99
|
+
@datastream.content = "test"
|
100
|
+
@datastream.save
|
101
|
+
end
|
102
|
+
|
96
103
|
it "should be marked as changed when the content is updated" do
|
97
104
|
@datastream.changed?.should be_false
|
98
105
|
@mock_repository.should_receive(:datastream_dissemination).with(hash_including(:pid => 'pid', :dsid => 'dsid')).and_return('test')
|
metadata
CHANGED
@@ -1,201 +1,155 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubydora
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 4
|
10
|
-
version: 0.1.4
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Chris Beer
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
22
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
-
none: false
|
24
|
-
requirements:
|
25
|
-
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
hash: 3
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
version: "0"
|
12
|
+
date: 2011-10-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
31
15
|
name: fastercsv
|
16
|
+
requirement: &2168473420 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
32
22
|
type: :runtime
|
33
23
|
prerelease: false
|
34
|
-
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
version_requirements: &id002 !ruby/object:Gem::Requirement
|
37
|
-
none: false
|
38
|
-
requirements:
|
39
|
-
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
hash: 3
|
42
|
-
segments:
|
43
|
-
- 0
|
44
|
-
version: "0"
|
24
|
+
version_requirements: *2168473420
|
25
|
+
- !ruby/object:Gem::Dependency
|
45
26
|
name: rest-client
|
27
|
+
requirement: &2168472960 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
46
33
|
type: :runtime
|
47
34
|
prerelease: false
|
48
|
-
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
version_requirements: &id003 !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
|
-
requirements:
|
53
|
-
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
hash: 3
|
56
|
-
segments:
|
57
|
-
- 0
|
58
|
-
version: "0"
|
35
|
+
version_requirements: *2168472960
|
36
|
+
- !ruby/object:Gem::Dependency
|
59
37
|
name: nokogiri
|
38
|
+
requirement: &2168472500 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
60
44
|
type: :runtime
|
61
45
|
prerelease: false
|
62
|
-
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
|
-
version_requirements: &id004 !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
hash: 3
|
70
|
-
segments:
|
71
|
-
- 0
|
72
|
-
version: "0"
|
46
|
+
version_requirements: *2168472500
|
47
|
+
- !ruby/object:Gem::Dependency
|
73
48
|
name: mime-types
|
49
|
+
requirement: &2168472040 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
74
55
|
type: :runtime
|
75
56
|
prerelease: false
|
76
|
-
|
77
|
-
- !ruby/object:Gem::Dependency
|
78
|
-
version_requirements: &id005 !ruby/object:Gem::Requirement
|
79
|
-
none: false
|
80
|
-
requirements:
|
81
|
-
- - ">="
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
hash: 3
|
84
|
-
segments:
|
85
|
-
- 0
|
86
|
-
version: "0"
|
57
|
+
version_requirements: *2168472040
|
58
|
+
- !ruby/object:Gem::Dependency
|
87
59
|
name: activesupport
|
60
|
+
requirement: &2168471620 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
88
66
|
type: :runtime
|
89
67
|
prerelease: false
|
90
|
-
|
91
|
-
- !ruby/object:Gem::Dependency
|
92
|
-
version_requirements: &id006 !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
|
-
requirements:
|
95
|
-
- - ">="
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
hash: 3
|
98
|
-
segments:
|
99
|
-
- 0
|
100
|
-
version: "0"
|
68
|
+
version_requirements: *2168471620
|
69
|
+
- !ruby/object:Gem::Dependency
|
101
70
|
name: activemodel
|
71
|
+
requirement: &2168471160 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
102
77
|
type: :runtime
|
103
78
|
prerelease: false
|
104
|
-
|
105
|
-
- !ruby/object:Gem::Dependency
|
106
|
-
version_requirements: &id007 !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
|
-
requirements:
|
109
|
-
- - ">="
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
hash: 3
|
112
|
-
segments:
|
113
|
-
- 0
|
114
|
-
version: "0"
|
79
|
+
version_requirements: *2168471160
|
80
|
+
- !ruby/object:Gem::Dependency
|
115
81
|
name: savon
|
82
|
+
requirement: &2168470720 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
116
88
|
type: :runtime
|
117
89
|
prerelease: false
|
118
|
-
|
119
|
-
- !ruby/object:Gem::Dependency
|
120
|
-
version_requirements: &id008 !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - ">="
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
hash: 3
|
126
|
-
segments:
|
127
|
-
- 0
|
128
|
-
version: "0"
|
90
|
+
version_requirements: *2168470720
|
91
|
+
- !ruby/object:Gem::Dependency
|
129
92
|
name: rake
|
93
|
+
requirement: &2168470260 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
130
99
|
type: :development
|
131
100
|
prerelease: false
|
132
|
-
|
133
|
-
- !ruby/object:Gem::Dependency
|
134
|
-
version_requirements: &id009 !ruby/object:Gem::Requirement
|
135
|
-
none: false
|
136
|
-
requirements:
|
137
|
-
- - ">="
|
138
|
-
- !ruby/object:Gem::Version
|
139
|
-
hash: 3
|
140
|
-
segments:
|
141
|
-
- 0
|
142
|
-
version: "0"
|
101
|
+
version_requirements: *2168470260
|
102
|
+
- !ruby/object:Gem::Dependency
|
143
103
|
name: shoulda
|
104
|
+
requirement: &2168469760 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
144
110
|
type: :development
|
145
111
|
prerelease: false
|
146
|
-
|
147
|
-
- !ruby/object:Gem::Dependency
|
148
|
-
version_requirements: &id010 !ruby/object:Gem::Requirement
|
149
|
-
none: false
|
150
|
-
requirements:
|
151
|
-
- - ">="
|
152
|
-
- !ruby/object:Gem::Version
|
153
|
-
hash: 3
|
154
|
-
segments:
|
155
|
-
- 0
|
156
|
-
version: "0"
|
112
|
+
version_requirements: *2168469760
|
113
|
+
- !ruby/object:Gem::Dependency
|
157
114
|
name: bundler
|
115
|
+
requirement: &2168469320 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
158
121
|
type: :development
|
159
122
|
prerelease: false
|
160
|
-
|
161
|
-
- !ruby/object:Gem::Dependency
|
162
|
-
version_requirements: &id011 !ruby/object:Gem::Requirement
|
163
|
-
none: false
|
164
|
-
requirements:
|
165
|
-
- - ">="
|
166
|
-
- !ruby/object:Gem::Version
|
167
|
-
hash: 3
|
168
|
-
segments:
|
169
|
-
- 0
|
170
|
-
version: "0"
|
123
|
+
version_requirements: *2168469320
|
124
|
+
- !ruby/object:Gem::Dependency
|
171
125
|
name: rspec
|
126
|
+
requirement: &2153014860 !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
172
132
|
type: :development
|
173
133
|
prerelease: false
|
174
|
-
|
175
|
-
- !ruby/object:Gem::Dependency
|
176
|
-
version_requirements: &id012 !ruby/object:Gem::Requirement
|
177
|
-
none: false
|
178
|
-
requirements:
|
179
|
-
- - ">="
|
180
|
-
- !ruby/object:Gem::Version
|
181
|
-
hash: 3
|
182
|
-
segments:
|
183
|
-
- 0
|
184
|
-
version: "0"
|
134
|
+
version_requirements: *2153014860
|
135
|
+
- !ruby/object:Gem::Dependency
|
185
136
|
name: yard
|
137
|
+
requirement: &2153014420 !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ! '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
186
143
|
type: :development
|
187
144
|
prerelease: false
|
188
|
-
|
189
|
-
description:
|
190
|
-
email:
|
145
|
+
version_requirements: *2153014420
|
146
|
+
description: ! 'Fedora Commons REST API ruby library : REQUIRES FCREPO 3.4+'
|
147
|
+
email:
|
191
148
|
- chris@cbeer.info
|
192
149
|
executables: []
|
193
|
-
|
194
150
|
extensions: []
|
195
|
-
|
196
151
|
extra_rdoc_files: []
|
197
|
-
|
198
|
-
files:
|
152
|
+
files:
|
199
153
|
- .gitignore
|
200
154
|
- Gemfile
|
201
155
|
- LICENSE.txt
|
@@ -231,41 +185,37 @@ files:
|
|
231
185
|
- spec/rest_api_client_spec.rb
|
232
186
|
- spec/soap_spec.rb
|
233
187
|
- spec/spec_helper.rb
|
234
|
-
has_rdoc: true
|
235
188
|
homepage: http://github.com/cbeer/rubydora
|
236
189
|
licenses: []
|
237
|
-
|
238
190
|
post_install_message:
|
239
191
|
rdoc_options: []
|
240
|
-
|
241
|
-
require_paths:
|
192
|
+
require_paths:
|
242
193
|
- lib
|
243
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
194
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
244
195
|
none: false
|
245
|
-
requirements:
|
246
|
-
- -
|
247
|
-
- !ruby/object:Gem::Version
|
248
|
-
|
249
|
-
segments:
|
196
|
+
requirements:
|
197
|
+
- - ! '>='
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: '0'
|
200
|
+
segments:
|
250
201
|
- 0
|
251
|
-
|
252
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
202
|
+
hash: -3635636805451402877
|
203
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
253
204
|
none: false
|
254
|
-
requirements:
|
255
|
-
- -
|
256
|
-
- !ruby/object:Gem::Version
|
257
|
-
|
258
|
-
segments:
|
205
|
+
requirements:
|
206
|
+
- - ! '>='
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
segments:
|
259
210
|
- 0
|
260
|
-
|
211
|
+
hash: -3635636805451402877
|
261
212
|
requirements: []
|
262
|
-
|
263
213
|
rubyforge_project:
|
264
|
-
rubygems_version: 1.
|
214
|
+
rubygems_version: 1.8.10
|
265
215
|
signing_key:
|
266
216
|
specification_version: 3
|
267
217
|
summary: Fedora Commons REST API ruby library
|
268
|
-
test_files:
|
218
|
+
test_files:
|
269
219
|
- spec/datastream_spec.rb
|
270
220
|
- spec/digital_object_spec.rb
|
271
221
|
- spec/ext_model_loader_spec.rb
|