rubydora 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "jetty"]
2
+ path = jetty
3
+ url = git://github.com/projecthydra/hydra-jetty.git
data/Rakefile CHANGED
@@ -19,11 +19,9 @@ task :default => :spec
19
19
 
20
20
  desc "Run specs"
21
21
  RSpec::Core::RakeTask.new do |t|
22
- t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
23
22
  # Put spec opts in a file named .rspec in root
24
23
  end
25
24
 
26
-
27
25
  require 'rake/rdoctask'
28
26
  Rake::RDocTask.new do |rdoc|
29
27
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
@@ -38,3 +36,25 @@ desc "Open an irb session preloaded with this library"
38
36
  task :console do
39
37
  sh "irb -rubygems -I lib -r rubydora.rb"
40
38
  end
39
+
40
+ desc "Execute Continuous Integration build"
41
+ task :ci do
42
+ unless ENV['environment'] == 'test'
43
+ exec("rake ci environment=test")
44
+ end
45
+
46
+ require 'jettywrapper'
47
+ jetty_params = {
48
+ :jetty_home => File.expand_path(File.dirname(__FILE__) + '/jetty'),
49
+ :quiet => false,
50
+ :jetty_port => 8983,
51
+ :solr_home => File.expand_path(File.dirname(__FILE__) + '/jetty/solr'),
52
+ :fedora_home => File.expand_path(File.dirname(__FILE__) + '/jetty/fedora/default'),
53
+ :startup_wait => 30
54
+ }
55
+
56
+ error = Jettywrapper.wrap(jetty_params) do
57
+ Rake::Task['spec'].invoke
58
+ end
59
+ raise "test failures: #{error}" if error
60
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -160,9 +160,8 @@ module Rubydora
160
160
  def save
161
161
  run_callbacks :save do
162
162
  if self.new?
163
- run_callbacks :create do
164
- self.pid = repository.ingest to_api_params.merge(:pid => pid)
165
- end
163
+ self.pid = repository.ingest to_api_params.merge(:pid => pid)
164
+ @profile = nil #will cause a reload with updated data
166
165
  else
167
166
  p = to_api_params
168
167
  repository.modify_object p.merge(:pid => pid) unless p.empty?
@@ -170,18 +169,20 @@ module Rubydora
170
169
  end
171
170
 
172
171
  self.datastreams.select { |dsid, ds| ds.changed? }.each { |dsid, ds| ds.save }
173
- reset
174
172
  self
175
173
  end
176
174
 
177
175
  # Purge the object from Fedora
178
176
  # @return [Rubydora::DigitalObject] `self`
179
177
  def delete
178
+ my_pid = pid
180
179
  run_callbacks :destroy do
181
- repository.purge_object(:pid => pid)
182
- reset
183
- self
180
+ @datastreams = nil
181
+ @profile = nil
182
+ @pid = nil
183
+ nil
184
184
  end
185
+ repository.purge_object(:pid => my_pid) ##This can have a meaningful exception, don't put it in the callback
185
186
  end
186
187
 
187
188
  # repository reference from the digital object
@@ -215,25 +216,6 @@ module Rubydora
215
216
  OBJ_DEFAULT_ATTRIBUTES.dup
216
217
  end
217
218
 
218
- # reset all profile attributes
219
- # @return [Hash]
220
- def reset_profile_attributes
221
- @profile = nil
222
- @changed_attributes = {}
223
- end
224
-
225
- # reset the datastreams cache
226
- def reset_datastreams
227
- @datastreams = nil
228
- end
229
-
230
- # reset local data so that it is requested from Fedora
231
- def reset
232
- reset_profile_attributes
233
- reset_datastreams
234
- self
235
- end
236
-
237
219
  # instantiate a datastream object for a dsid
238
220
  # @param [String] dsid
239
221
  # @return [Datastream]
@@ -20,7 +20,12 @@ module Rubydora
20
20
  # @return [String]
21
21
  def next_pid options = {}
22
22
  options[:format] ||= 'xml'
23
- client[url_for(object_url() + "/nextPID", options)].post nil
23
+ begin
24
+ return client[url_for(object_url() + "/nextPID", options)].post nil
25
+ rescue => e
26
+ logger.error e.response
27
+ raise "Error getting nextPID. See logger for details"
28
+ end
24
29
  end
25
30
 
26
31
  # {include:RestApiClient::API_DOCUMENTATION}
@@ -30,7 +35,12 @@ module Rubydora
30
35
  raise "" if options[:terms] and options[:query]
31
36
  options[:resultFormat] ||= 'xml'
32
37
 
33
- client[object_url(nil, options)].get
38
+ begin
39
+ return client[object_url(nil, options)].get
40
+ rescue => e
41
+ logger.error e.response
42
+ raise "Error finding objects. See logger for details"
43
+ end
34
44
  end
35
45
 
36
46
  # {include:RestApiClient::API_DOCUMENTATION}
@@ -40,7 +50,14 @@ module Rubydora
40
50
  def object options = {}
41
51
  pid = options.delete(:pid)
42
52
  options[:format] ||= 'xml'
43
- client[object_url(pid, options)].get
53
+ begin
54
+ return client[object_url(pid, options)].get
55
+ rescue RestClient::ResourceNotFound => e
56
+ raise e
57
+ rescue => e
58
+ logger.error e.response
59
+ raise "Error getting object #{pid}. See logger for details"
60
+ end
44
61
  end
45
62
 
46
63
  # {include:RestApiClient::API_DOCUMENTATION}
@@ -50,7 +67,12 @@ module Rubydora
50
67
  def ingest options = {}
51
68
  pid = options.delete(:pid) || 'new'
52
69
  file = options.delete(:file)
53
- client[object_url(pid, options)].post file, :content_type => 'text/xml'
70
+ begin
71
+ return client[object_url(pid, options)].post file, :content_type => 'text/xml'
72
+ rescue => e
73
+ logger.error e.response
74
+ raise "Error ingesting object #{pid}. See logger for details"
75
+ end
54
76
  end
55
77
 
56
78
  # {include:RestApiClient::API_DOCUMENTATION}
@@ -59,7 +81,12 @@ module Rubydora
59
81
  # @return [String]
60
82
  def modify_object options = {}
61
83
  pid = options.delete(:pid)
62
- client[object_url(pid, options)].put nil
84
+ begin
85
+ return client[object_url(pid, options)].put nil
86
+ rescue => e
87
+ logger.error e.response
88
+ raise "Error modifying object #{pid}. See logger for details"
89
+ end
63
90
  end
64
91
 
65
92
  # {include:RestApiClient::API_DOCUMENTATION}
@@ -68,7 +95,14 @@ module Rubydora
68
95
  # @return [String]
69
96
  def purge_object options = {}
70
97
  pid = options.delete(:pid)
71
- client[object_url(pid, options)].delete
98
+ begin
99
+ return client[object_url(pid, options)].delete
100
+ rescue RestClient::ResourceNotFound => e
101
+ raise e
102
+ rescue => e
103
+ logger.error e.response
104
+ raise "Error purging object #{pid}. See logger for details"
105
+ end
72
106
  end
73
107
 
74
108
  # {include:RestApiClient::API_DOCUMENTATION}
@@ -79,7 +113,12 @@ module Rubydora
79
113
  pid = options.delete(:pid)
80
114
  options[:format] ||= 'xml'
81
115
  raise "" unless pid
82
- client[url_for(object_url(pid) + "/versions", options)].get
116
+ begin
117
+ return client[url_for(object_url(pid) + "/versions", options)].get
118
+ rescue => e
119
+ logger.error e.response
120
+ raise "Error getting versions for object #{pid}. See logger for details"
121
+ end
83
122
  end
84
123
 
85
124
  # {include:RestApiClient::API_DOCUMENTATION}
@@ -90,7 +129,12 @@ module Rubydora
90
129
  pid = options.delete(:pid)
91
130
  raise "" unless pid
92
131
  options[:format] ||= 'xml'
93
- client[url_for(object_url(pid) + "/objectXML", options)].get
132
+ begin
133
+ return client[url_for(object_url(pid) + "/objectXML", options)].get
134
+ rescue => e
135
+ logger.error e.response
136
+ raise "Error getting objectXML for object #{pid}. See logger for details"
137
+ end
94
138
  end
95
139
 
96
140
  # {include:RestApiClient::API_DOCUMENTATION}
@@ -102,7 +146,14 @@ module Rubydora
102
146
  pid = options.delete(:pid)
103
147
  dsid = options.delete(:dsid)
104
148
  options[:format] ||= 'xml'
105
- client[datastream_url(pid, dsid, options)].get
149
+ begin
150
+ return client[datastream_url(pid, dsid, options)].get
151
+ rescue RestClient::ResourceNotFound => e
152
+ raise e
153
+ rescue => e
154
+ logger.error e.response
155
+ raise "Error getting datastream '#{dsid}' for object #{pid}. See logger for details"
156
+ end
106
157
  end
107
158
 
108
159
  alias_method :datastreams, :datastream
@@ -115,7 +166,12 @@ module Rubydora
115
166
  def set_datastream_options options = {}
116
167
  pid = options.delete(:pid)
117
168
  dsid = options.delete(:dsid)
118
- client[datastream_url(pid, dsid, options)].put nil
169
+ begin
170
+ return client[datastream_url(pid, dsid, options)].put nil
171
+ rescue => e
172
+ logger.error e.response
173
+ raise "Error setting datastream options on #{dsid} for object #{pid}. See logger for details"
174
+ end
119
175
  end
120
176
 
121
177
  # {include:RestApiClient::API_DOCUMENTATION}
@@ -128,7 +184,12 @@ module Rubydora
128
184
  dsid = options.delete(:dsid)
129
185
  raise ArgumentError, "Must supply dsid" unless dsid
130
186
  options[:format] ||= 'xml'
131
- client[url_for(datastream_url(pid, dsid) + "/versions", options)].get
187
+ begin
188
+ return client[url_for(datastream_url(pid, dsid) + "/versions", options)].get
189
+ rescue => e
190
+ logger.error e.response
191
+ raise "Error getting versions for datastream #{dsid} for object #{pid}. See logger for details"
192
+ end
132
193
  end
133
194
 
134
195
  # {include:RestApiClient::API_DOCUMENTATION}
@@ -140,7 +201,14 @@ module Rubydora
140
201
  pid = options.delete(:pid)
141
202
  dsid = options.delete(:dsid)
142
203
  raise "" unless dsid
143
- client[url_for(datastream_url(pid, dsid) + "/content", options)].get
204
+ begin
205
+ return client[url_for(datastream_url(pid, dsid) + "/content", options)].get
206
+ rescue RestClient::ResourceNotFound => e
207
+ raise e
208
+ rescue => e
209
+ logger.error e.response
210
+ raise "Error getting dissemination for datastream #{dsid} for object #{pid}. See logger for details"
211
+ end
144
212
  end
145
213
 
146
214
  # {include:RestApiClient::API_DOCUMENTATION}
@@ -153,7 +221,12 @@ module Rubydora
153
221
  dsid = options.delete(:dsid)
154
222
  file = options.delete(:content)
155
223
  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, :multipart => true
224
+ begin
225
+ return client[datastream_url(pid, dsid, options)].post file, :content_type => content_type.to_s, :multipart => true
226
+ rescue => e
227
+ logger.error e.response
228
+ raise "Error adding datastream #{dsid} for object #{pid}. See logger for details"
229
+ end
157
230
  end
158
231
 
159
232
  # {include:RestApiClient::API_DOCUMENTATION}
@@ -166,7 +239,13 @@ module Rubydora
166
239
  dsid = options.delete(:dsid)
167
240
  file = options.delete(:content)
168
241
  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, :multipart => true
242
+
243
+ begin
244
+ return client[datastream_url(pid, dsid, options)].put(file, {:content_type => content_type.to_s, :multipart => true})
245
+ rescue => e
246
+ logger.error e.response
247
+ raise "Error modifying datastream #{dsid} for #{pid}. See logger for details"
248
+ end
170
249
  end
171
250
 
172
251
  # {include:RestApiClient::API_DOCUMENTATION}
@@ -177,7 +256,12 @@ module Rubydora
177
256
  def purge_datastream options = {}
178
257
  pid = options.delete(:pid)
179
258
  dsid = options.delete(:dsid)
180
- client[datastream_url(pid, dsid, options)].delete
259
+ begin
260
+ client[datastream_url(pid, dsid, options)].delete
261
+ rescue => e
262
+ logger.error e.response
263
+ raise "Error purging datastream #{dsid} for #{pid}. See logger for details"
264
+ end
181
265
  end
182
266
 
183
267
  # {include:RestApiClient::API_DOCUMENTATION}
@@ -188,7 +272,12 @@ module Rubydora
188
272
  pid = options.delete(:pid) || options[:subject]
189
273
  raise "" unless pid
190
274
  options[:format] ||= 'xml'
191
- client[url_for(object_url(pid) + "/relationships", options)].get
275
+ begin
276
+ return client[url_for(object_url(pid) + "/relationships", options)].get
277
+ rescue => e
278
+ logger.error e.response
279
+ raise "Error getting relationships for #{pid}. See logger for details"
280
+ end
192
281
  end
193
282
 
194
283
  # {include:RestApiClient::API_DOCUMENTATION}
@@ -197,7 +286,12 @@ module Rubydora
197
286
  # @return [String]
198
287
  def add_relationship options = {}
199
288
  pid = options.delete(:pid) || options[:subject]
200
- client[url_for(object_url(pid) + "/relationships/new", options)].post nil
289
+ begin
290
+ return client[url_for(object_url(pid) + "/relationships/new", options)].post nil
291
+ rescue => e
292
+ logger.error e.response
293
+ raise "Error adding relationship for #{pid}. See logger for details"
294
+ end
201
295
  end
202
296
 
203
297
  # {include:RestApiClient::API_DOCUMENTATION}
@@ -206,7 +300,12 @@ module Rubydora
206
300
  # @return [String]
207
301
  def purge_relationship options = {}
208
302
  pid = options.delete(:pid) || options[:subject]
209
- client[url_for(object_url(pid) + "/relationships", options)].delete
303
+ begin
304
+ return client[url_for(object_url(pid) + "/relationships", options)].delete
305
+ rescue => e
306
+ logger.error e.response
307
+ raise "Error purging relationships for #{pid}. See logger for details"
308
+ end
210
309
  end
211
310
 
212
311
  # {include:RestApiClient::API_DOCUMENTATION}
@@ -220,7 +319,12 @@ module Rubydora
220
319
  sdef = options.delete(:sdef)
221
320
  method = options.delete(:method)
222
321
  options[:format] ||= 'xml' unless pid and sdef and method
223
- client[dissemination_url(pid,sdef,method,options)].get
322
+ begin
323
+ return client[dissemination_url(pid,sdef,method,options)].get
324
+ rescue => e
325
+ logger.error e.response
326
+ raise "Error getting dissemination for #{pid}. See logger for details"
327
+ end
224
328
  end
225
329
 
226
330
  # Generate a REST API compatible URI
data/rubydora.gemspec CHANGED
@@ -29,4 +29,5 @@ Gem::Specification.new do |s|
29
29
  s.add_development_dependency("bundler")
30
30
  s.add_development_dependency("rspec")
31
31
  s.add_development_dependency("yard")
32
+ s.add_development_dependency("jettywrapper")
32
33
  end
File without changes
@@ -1,6 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Rubydora::DigitalObject do
4
+ before do
5
+ @mock_repository = mock(Rubydora::Repository)
6
+
7
+ end
4
8
  describe "new" do
5
9
  it "should load a DigitalObject instance" do
6
10
  Rubydora::DigitalObject.new("pid").should be_a_kind_of(Rubydora::DigitalObject)
@@ -9,7 +13,6 @@ describe Rubydora::DigitalObject do
9
13
 
10
14
  describe "profile" do
11
15
  before(:each) do
12
- @mock_repository = mock(Rubydora::Repository)
13
16
  @object = Rubydora::DigitalObject.new 'pid', @mock_repository
14
17
  end
15
18
 
@@ -29,8 +32,7 @@ describe Rubydora::DigitalObject do
29
32
 
30
33
  describe "new" do
31
34
  before(:each) do
32
- @mock_repository = mock(Rubydora::Repository)
33
- @mock_repository.should_receive(:object).any_number_of_times.and_raise ""
35
+ @mock_repository.stub(:object) { raise "" }
34
36
  @object = Rubydora::DigitalObject.new 'pid', @mock_repository
35
37
  end
36
38
 
@@ -39,7 +41,7 @@ describe Rubydora::DigitalObject do
39
41
  end
40
42
 
41
43
  it "should call ingest on save" do
42
- @object.should_receive(:datastreams).and_return({})
44
+ @object.stub(:datastreams) { {} }
43
45
  @mock_repository.should_receive(:ingest).with(hash_including(:pid => 'pid')).and_return('pid')
44
46
  @object.save
45
47
  end
@@ -55,14 +57,12 @@ describe Rubydora::DigitalObject do
55
57
 
56
58
  describe "create" do
57
59
  it "should call the Fedora REST API to create a new object" do
58
- @mock_repository = mock(Rubydora::Repository)
59
60
  @mock_repository.should_receive(:ingest).with(instance_of(Hash)).and_return("pid")
60
61
  obj = Rubydora::DigitalObject.create "pid", { :a => 1, :b => 2}, @mock_repository
61
62
  obj.should be_a_kind_of(Rubydora::DigitalObject)
62
63
  end
63
64
 
64
65
  it "should return a new object with the Fedora response pid when no pid is provided" do
65
- @mock_repository = mock(Rubydora::Repository)
66
66
  @mock_repository.should_receive(:ingest).with(instance_of(Hash)).and_return("pid")
67
67
  obj = Rubydora::DigitalObject.create "new", { :a => 1, :b => 2}, @mock_repository
68
68
  obj.should be_a_kind_of(Rubydora::DigitalObject)
@@ -72,7 +72,6 @@ describe Rubydora::DigitalObject do
72
72
 
73
73
  describe "retreive" do
74
74
  before(:each) do
75
- @mock_repository = mock(Rubydora::Repository)
76
75
  @mock_repository.stub :datastreams do |hash|
77
76
  "<objectDatastreams><datastream dsid='a'></datastream>><datastream dsid='b'></datastream>><datastream dsid='c'></datastream></objectDatastreams>"
78
77
  end
@@ -125,12 +124,12 @@ describe Rubydora::DigitalObject do
125
124
 
126
125
  describe "save" do
127
126
  before(:each) do
128
- @mock_repository = mock(Rubydora::Repository)
129
- @mock_repository.should_receive(:object).any_number_of_times.with({:pid => 'pid'}).and_return <<-XML
127
+ @mock_repository.stub(:object) { <<-XML
130
128
  <objectProfile>
131
129
  <not>empty</not>
132
130
  </objectProfile>
133
131
  XML
132
+ }
134
133
 
135
134
  @object = Rubydora::DigitalObject.new 'pid', @mock_repository
136
135
  end
@@ -194,19 +193,10 @@ describe Rubydora::DigitalObject do
194
193
  @mock_repository.should_receive(:modify_object).with(hash_including(:pid => 'pid'))
195
194
  @object.save
196
195
  end
197
-
198
- it "should reset the object state on save" do
199
- @object.label = "asdf"
200
- @object.should_receive(:datastreams).and_return({})
201
- @mock_repository.should_receive(:modify_object).with(hash_including(:pid => 'pid'))
202
- @object.profile.should_not be_nil
203
- expect { @object.save }.to change { @object.instance_variable_get('@profile') }.to nil
204
- end
205
196
  end
206
197
 
207
198
  describe "delete" do
208
199
  before(:each) do
209
- @mock_repository = mock()
210
200
  @object = Rubydora::DigitalObject.new 'pid', @mock_repository
211
201
  end
212
202
 
@@ -218,11 +208,11 @@ describe Rubydora::DigitalObject do
218
208
 
219
209
  describe "models" do
220
210
  before(:each) do
221
- @mock_repository = mock(Rubydora::Repository)
222
- @mock_repository.should_receive(:object).any_number_of_times.with({:pid => 'pid'}).and_return <<-XML
211
+ @mock_repository.stub(:object) { <<-XML
223
212
  <objectProfile>
224
213
  </objectProfile>
225
214
  XML
215
+ }
226
216
  @object = Rubydora::DigitalObject.new 'pid', @mock_repository
227
217
  end
228
218
 
@@ -256,11 +246,11 @@ describe Rubydora::DigitalObject do
256
246
 
257
247
  describe "relations" do
258
248
  before(:each) do
259
- @mock_repository = mock()
260
- @mock_repository.should_receive(:object).any_number_of_times.with({:pid => 'pid'}).and_return <<-XML
249
+ @mock_repository.stub(:object) { <<-XML
261
250
  <objectProfile>
262
251
  </objectProfile>
263
252
  XML
253
+ }
264
254
  @object = Rubydora::DigitalObject.new 'pid', @mock_repository
265
255
  end
266
256
 
@@ -296,7 +286,6 @@ describe Rubydora::DigitalObject do
296
286
 
297
287
  describe "to_api_params" do
298
288
  before(:each) do
299
- @mock_repository = mock(Rubydora::Repository)
300
289
  @object = Rubydora::DigitalObject.new 'pid', @mock_repository
301
290
  end
302
291
  it "should compile parameters to hash" do
File without changes
@@ -102,6 +102,20 @@ describe "Integration testing against a live Fedora repository" do
102
102
  obj.datastreams["empty_ds"].new?.should == true
103
103
  end
104
104
 
105
+ it "should update datastream attributes without changing the content" do
106
+ obj = @repository.find('test:1')
107
+ obj.datastreams["my_ds"].content = "XXX"
108
+ obj.save
109
+
110
+ obj = @repository.find('test:1')
111
+ obj.datastreams["my_ds"].dsLabel = "New Label"
112
+ obj.save
113
+
114
+ obj = @repository.find('test:1')
115
+ obj.datastreams["my_ds"].content.should == "XXX"
116
+ obj.datastreams["my_ds"].dsLabel.should == "New Label"
117
+ end
118
+
105
119
 
106
120
  after(:all) do
107
121
  @repository.find('test:1').delete rescue nil
File without changes
@@ -1,8 +1,11 @@
1
1
  require 'spec_helper'
2
+ require 'loggable'
2
3
 
3
4
  describe Rubydora::RestApiClient do
4
5
  class MockRepository
5
6
  include Rubydora::RestApiClient
7
+ include Loggable
8
+
6
9
 
7
10
  attr_accessor :config
8
11
  end
@@ -25,10 +28,16 @@ describe Rubydora::RestApiClient do
25
28
  @mock_repository.find_objects :query => 'a'
26
29
  end
27
30
 
31
+
28
32
  it "should show object properties" do
29
33
  RestClient::Request.should_receive(:execute).with(hash_including(:url => "http://example.org/objects/z?format=xml"))
30
34
  @mock_repository.object :pid => 'z'
31
35
  end
36
+
37
+ it "should raise not found exception when retrieving object" do
38
+ RestClient::Request.should_receive(:execute).with(hash_including(:url => "http://example.org/objects/z?format=xml")).and_raise( RestClient::ResourceNotFound)
39
+ lambda {@mock_repository.object(:pid => 'z')}.should raise_error RestClient::ResourceNotFound
40
+ end
32
41
 
33
42
  it "ingest" do
34
43
  RestClient::Request.should_receive(:execute).with(hash_including(:url => "http://example.org/objects/new"))
@@ -53,6 +62,11 @@ describe Rubydora::RestApiClient do
53
62
  @mock_repository.purge_object :pid => 'mypid'
54
63
  end
55
64
 
65
+ it "should raise not found exception when purging" do
66
+ RestClient::Request.should_receive(:execute).with(hash_including(:url => "http://example.org/objects/mypid")).and_raise( RestClient::ResourceNotFound)
67
+ lambda {@mock_repository.purge_object(:pid => 'mypid')}.should raise_error RestClient::ResourceNotFound
68
+ end
69
+
56
70
  it "object_versions" do
57
71
  RestClient::Request.should_receive(:execute).with(hash_including(:url => "http://example.org/objects/mypid/versions?format=xml"))
58
72
  @mock_repository.object_versions :pid => 'mypid'
@@ -73,10 +87,19 @@ describe Rubydora::RestApiClient do
73
87
  @mock_repository.datastream :pid => 'mypid', :dsid => 'aaa'
74
88
  end
75
89
 
90
+ it "should raise not found exception when getting a datastream" do
91
+ RestClient::Request.should_receive(:execute).with(hash_including(:url => "http://example.org/objects/mypid/datastreams/aaa?format=xml")).and_raise( RestClient::ResourceNotFound)
92
+ lambda {@mock_repository.datastream :pid => 'mypid', :dsid => 'aaa'}.should raise_error RestClient::ResourceNotFound
93
+ end
94
+
76
95
  it "datastream_dissemination" do
77
96
  RestClient::Request.should_receive(:execute).with(hash_including(:url => "http://example.org/objects/mypid/datastreams/aaa/content"))
78
97
  @mock_repository.datastream_dissemination :pid => 'mypid', :dsid => 'aaa'
79
98
  end
99
+ it "should raise not found exception when retrieving datastream_dissemination" do
100
+ RestClient::Request.should_receive(:execute).with(hash_including(:url => "http://example.org/objects/mypid/datastreams/aaa/content")).and_raise( RestClient::ResourceNotFound)
101
+ lambda {@mock_repository.datastream_dissemination :pid => 'mypid', :dsid => 'aaa'}.should raise_error RestClient::ResourceNotFound
102
+ end
80
103
 
81
104
  it "add_datastream" do
82
105
  RestClient::Request.should_receive(:execute).with(hash_including(:url => "http://example.org/objects/mypid/datastreams/aaa"))
File without changes
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubydora
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 17
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 2
8
- - 2
9
- segments_generated: true
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chris Beer
@@ -15,177 +15,191 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-29 00:00:00 -04:00
18
+ date: 2011-11-02 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: fastercsv
23
- requirement: &id001 !ruby/object:Gem::Requirement
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
26
  none: false
25
27
  requirements:
26
28
  - - ">="
27
29
  - !ruby/object:Gem::Version
30
+ hash: 3
28
31
  segments:
29
32
  - 0
30
- segments_generated: true
31
33
  version: "0"
32
- type: :runtime
33
- prerelease: false
34
- version_requirements: *id001
34
+ requirement: *id001
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: rest-client
37
- requirement: &id002 !ruby/object:Gem::Requirement
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
40
  none: false
39
41
  requirements:
40
42
  - - ">="
41
43
  - !ruby/object:Gem::Version
44
+ hash: 3
42
45
  segments:
43
46
  - 0
44
- segments_generated: true
45
47
  version: "0"
46
- type: :runtime
47
- prerelease: false
48
- version_requirements: *id002
48
+ requirement: *id002
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: nokogiri
51
- requirement: &id003 !ruby/object:Gem::Requirement
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
52
54
  none: false
53
55
  requirements:
54
56
  - - ">="
55
57
  - !ruby/object:Gem::Version
58
+ hash: 3
56
59
  segments:
57
60
  - 0
58
- segments_generated: true
59
61
  version: "0"
60
- type: :runtime
61
- prerelease: false
62
- version_requirements: *id003
62
+ requirement: *id003
63
63
  - !ruby/object:Gem::Dependency
64
64
  name: mime-types
65
- requirement: &id004 !ruby/object:Gem::Requirement
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: &id004 !ruby/object:Gem::Requirement
66
68
  none: false
67
69
  requirements:
68
70
  - - ">="
69
71
  - !ruby/object:Gem::Version
72
+ hash: 3
70
73
  segments:
71
74
  - 0
72
- segments_generated: true
73
75
  version: "0"
74
- type: :runtime
75
- prerelease: false
76
- version_requirements: *id004
76
+ requirement: *id004
77
77
  - !ruby/object:Gem::Dependency
78
78
  name: activesupport
79
- requirement: &id005 !ruby/object:Gem::Requirement
79
+ type: :runtime
80
+ prerelease: false
81
+ version_requirements: &id005 !ruby/object:Gem::Requirement
80
82
  none: false
81
83
  requirements:
82
84
  - - ">="
83
85
  - !ruby/object:Gem::Version
86
+ hash: 3
84
87
  segments:
85
88
  - 0
86
- segments_generated: true
87
89
  version: "0"
88
- type: :runtime
89
- prerelease: false
90
- version_requirements: *id005
90
+ requirement: *id005
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: activemodel
93
- requirement: &id006 !ruby/object:Gem::Requirement
93
+ type: :runtime
94
+ prerelease: false
95
+ version_requirements: &id006 !ruby/object:Gem::Requirement
94
96
  none: false
95
97
  requirements:
96
98
  - - ">="
97
99
  - !ruby/object:Gem::Version
100
+ hash: 3
98
101
  segments:
99
102
  - 0
100
- segments_generated: true
101
103
  version: "0"
102
- type: :runtime
103
- prerelease: false
104
- version_requirements: *id006
104
+ requirement: *id006
105
105
  - !ruby/object:Gem::Dependency
106
106
  name: savon
107
- requirement: &id007 !ruby/object:Gem::Requirement
107
+ type: :runtime
108
+ prerelease: false
109
+ version_requirements: &id007 !ruby/object:Gem::Requirement
108
110
  none: false
109
111
  requirements:
110
112
  - - ">="
111
113
  - !ruby/object:Gem::Version
114
+ hash: 3
112
115
  segments:
113
116
  - 0
114
- segments_generated: true
115
117
  version: "0"
116
- type: :runtime
117
- prerelease: false
118
- version_requirements: *id007
118
+ requirement: *id007
119
119
  - !ruby/object:Gem::Dependency
120
120
  name: rake
121
- requirement: &id008 !ruby/object:Gem::Requirement
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: &id008 !ruby/object:Gem::Requirement
122
124
  none: false
123
125
  requirements:
124
126
  - - ">="
125
127
  - !ruby/object:Gem::Version
128
+ hash: 3
126
129
  segments:
127
130
  - 0
128
- segments_generated: true
129
131
  version: "0"
130
- type: :development
131
- prerelease: false
132
- version_requirements: *id008
132
+ requirement: *id008
133
133
  - !ruby/object:Gem::Dependency
134
134
  name: shoulda
135
- requirement: &id009 !ruby/object:Gem::Requirement
135
+ type: :development
136
+ prerelease: false
137
+ version_requirements: &id009 !ruby/object:Gem::Requirement
136
138
  none: false
137
139
  requirements:
138
140
  - - ">="
139
141
  - !ruby/object:Gem::Version
142
+ hash: 3
140
143
  segments:
141
144
  - 0
142
- segments_generated: true
143
145
  version: "0"
144
- type: :development
145
- prerelease: false
146
- version_requirements: *id009
146
+ requirement: *id009
147
147
  - !ruby/object:Gem::Dependency
148
148
  name: bundler
149
- requirement: &id010 !ruby/object:Gem::Requirement
149
+ type: :development
150
+ prerelease: false
151
+ version_requirements: &id010 !ruby/object:Gem::Requirement
150
152
  none: false
151
153
  requirements:
152
154
  - - ">="
153
155
  - !ruby/object:Gem::Version
156
+ hash: 3
154
157
  segments:
155
158
  - 0
156
- segments_generated: true
157
159
  version: "0"
158
- type: :development
159
- prerelease: false
160
- version_requirements: *id010
160
+ requirement: *id010
161
161
  - !ruby/object:Gem::Dependency
162
162
  name: rspec
163
- requirement: &id011 !ruby/object:Gem::Requirement
163
+ type: :development
164
+ prerelease: false
165
+ version_requirements: &id011 !ruby/object:Gem::Requirement
164
166
  none: false
165
167
  requirements:
166
168
  - - ">="
167
169
  - !ruby/object:Gem::Version
170
+ hash: 3
168
171
  segments:
169
172
  - 0
170
- segments_generated: true
171
173
  version: "0"
172
- type: :development
173
- prerelease: false
174
- version_requirements: *id011
174
+ requirement: *id011
175
175
  - !ruby/object:Gem::Dependency
176
176
  name: yard
177
- requirement: &id012 !ruby/object:Gem::Requirement
177
+ type: :development
178
+ prerelease: false
179
+ version_requirements: &id012 !ruby/object:Gem::Requirement
178
180
  none: false
179
181
  requirements:
180
182
  - - ">="
181
183
  - !ruby/object:Gem::Version
184
+ hash: 3
182
185
  segments:
183
186
  - 0
184
- segments_generated: true
185
187
  version: "0"
188
+ requirement: *id012
189
+ - !ruby/object:Gem::Dependency
190
+ name: jettywrapper
186
191
  type: :development
187
192
  prerelease: false
188
- version_requirements: *id012
193
+ version_requirements: &id013 !ruby/object:Gem::Requirement
194
+ none: false
195
+ requirements:
196
+ - - ">="
197
+ - !ruby/object:Gem::Version
198
+ hash: 3
199
+ segments:
200
+ - 0
201
+ version: "0"
202
+ requirement: *id013
189
203
  description: "Fedora Commons REST API ruby library : REQUIRES FCREPO 3.4+"
190
204
  email:
191
205
  - chris@cbeer.info
@@ -197,6 +211,7 @@ extra_rdoc_files: []
197
211
 
198
212
  files:
199
213
  - .gitignore
214
+ - .gitmodules
200
215
  - Gemfile
201
216
  - LICENSE.txt
202
217
  - README.rdoc
@@ -220,16 +235,16 @@ files:
220
235
  - lib/rubydora/soap.rb
221
236
  - lib/rubydora/version.rb
222
237
  - rubydora.gemspec
223
- - spec/datastream_spec.rb
224
- - spec/digital_object_spec.rb
225
- - spec/ext_model_loader_spec.rb
226
- - spec/ext_solr_spec.rb
227
- - spec/extension_parameters_spec.rb
228
- - spec/integration_test_spec.rb
229
- - spec/repository_spec.rb
230
- - spec/resource_index_spec.rb
231
- - spec/rest_api_client_spec.rb
232
- - spec/soap_spec.rb
238
+ - spec/lib/datastream_spec.rb
239
+ - spec/lib/digital_object_spec.rb
240
+ - spec/lib/ext_model_loader_spec.rb
241
+ - spec/lib/ext_solr_spec.rb
242
+ - spec/lib/extension_parameters_spec.rb
243
+ - spec/lib/integration_test_spec.rb
244
+ - spec/lib/repository_spec.rb
245
+ - spec/lib/resource_index_spec.rb
246
+ - spec/lib/rest_api_client_spec.rb
247
+ - spec/lib/soap_spec.rb
233
248
  - spec/spec_helper.rb
234
249
  has_rdoc: true
235
250
  homepage: http://github.com/cbeer/rubydora
@@ -245,37 +260,35 @@ required_ruby_version: !ruby/object:Gem::Requirement
245
260
  requirements:
246
261
  - - ">="
247
262
  - !ruby/object:Gem::Version
248
- hash: -3650604307215364376
263
+ hash: 3
249
264
  segments:
250
265
  - 0
251
- segments_generated: true
252
266
  version: "0"
253
267
  required_rubygems_version: !ruby/object:Gem::Requirement
254
268
  none: false
255
269
  requirements:
256
270
  - - ">="
257
271
  - !ruby/object:Gem::Version
258
- hash: -3650604307215364376
272
+ hash: 3
259
273
  segments:
260
274
  - 0
261
- segments_generated: true
262
275
  version: "0"
263
276
  requirements: []
264
277
 
265
278
  rubyforge_project:
266
- rubygems_version: 1.3.7
279
+ rubygems_version: 1.6.2
267
280
  signing_key:
268
281
  specification_version: 3
269
282
  summary: Fedora Commons REST API ruby library
270
283
  test_files:
271
- - spec/datastream_spec.rb
272
- - spec/digital_object_spec.rb
273
- - spec/ext_model_loader_spec.rb
274
- - spec/ext_solr_spec.rb
275
- - spec/extension_parameters_spec.rb
276
- - spec/integration_test_spec.rb
277
- - spec/repository_spec.rb
278
- - spec/resource_index_spec.rb
279
- - spec/rest_api_client_spec.rb
280
- - spec/soap_spec.rb
284
+ - spec/lib/datastream_spec.rb
285
+ - spec/lib/digital_object_spec.rb
286
+ - spec/lib/ext_model_loader_spec.rb
287
+ - spec/lib/ext_solr_spec.rb
288
+ - spec/lib/extension_parameters_spec.rb
289
+ - spec/lib/integration_test_spec.rb
290
+ - spec/lib/repository_spec.rb
291
+ - spec/lib/resource_index_spec.rb
292
+ - spec/lib/rest_api_client_spec.rb
293
+ - spec/lib/soap_spec.rb
281
294
  - spec/spec_helper.rb