rubydora 1.6.1 → 1.6.2
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.
- checksums.yaml +4 -4
- data/History.textile +5 -0
- data/VERSION +1 -1
- data/lib/rubydora/datastream.rb +22 -21
- data/lib/rubydora/repository.rb +9 -2
- data/lib/rubydora/rest_api_client.rb +1 -0
- data/rubydora.gemspec +2 -1
- data/spec/lib/integration_test_spec.rb +12 -0
- data/spec/lib/rest_api_client_spec.rb +8 -3
- data/spec/spec_helper.rb +3 -0
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a5b245a875f22288d000657c72694c89601fd52
|
4
|
+
data.tar.gz: bccc0e54f0a6c6a208cbff50ce97ccec33ce36aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a25f822e7db26590892d49f6b36aa51e4f6241db5ffc9b1d6add176af57619b3740c3b26ecaafcbe9119861f31d433c27e108ff785858fb27051ff8f137f7242
|
7
|
+
data.tar.gz: aec54491026595a746447295f391ceb17f1ae012ab92334f57f07170f819f99f93387b399338d50c7d0512a7ee6f7febccf18c0d72084f58419afbf355515ce8
|
data/History.textile
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
h3. 1.6.2 (29 April 2013)
|
2
|
+
* Handle 401 (no access) from Fedora in a graceful manner
|
3
|
+
* Expose methods relating to control group (e.g. external?, redirect?, managed?, inline?)
|
4
|
+
* validate that a pid is passed as one of the arguments to RestApiClient#export
|
5
|
+
|
1
6
|
h3. 1.6.1
|
2
7
|
* Removed break which caused Enumerator to never terminate
|
3
8
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.6.
|
1
|
+
1.6.2
|
data/lib/rubydora/datastream.rb
CHANGED
@@ -359,6 +359,28 @@ module Rubydora
|
|
359
359
|
attribute_will_change! :profile
|
360
360
|
end
|
361
361
|
|
362
|
+
# @return [boolean] is this an external datastream?
|
363
|
+
def external?
|
364
|
+
controlGroup == 'E'
|
365
|
+
end
|
366
|
+
|
367
|
+
# @return [boolean] is this a redirect datastream?
|
368
|
+
def redirect?
|
369
|
+
controlGroup == 'R'
|
370
|
+
end
|
371
|
+
|
372
|
+
# @return [boolean] is this a managed datastream?
|
373
|
+
def managed?
|
374
|
+
controlGroup == 'M'
|
375
|
+
end
|
376
|
+
|
377
|
+
# @return [boolean] is this an inline datastream?
|
378
|
+
def inline?
|
379
|
+
controlGroup == 'X'
|
380
|
+
end
|
381
|
+
|
382
|
+
|
383
|
+
|
362
384
|
protected
|
363
385
|
# datastream parameters
|
364
386
|
# @return [Hash]
|
@@ -409,27 +431,6 @@ module Rubydora
|
|
409
431
|
URI.parse(val) unless val.nil?
|
410
432
|
end
|
411
433
|
|
412
|
-
# @return [boolean] is this an external datastream?
|
413
|
-
def external?
|
414
|
-
controlGroup == 'E'
|
415
|
-
end
|
416
|
-
|
417
|
-
# @return [boolean] is this a redirect datastream?
|
418
|
-
def redirect?
|
419
|
-
controlGroup == 'R'
|
420
|
-
end
|
421
|
-
|
422
|
-
# @return [boolean] is this a managed datastream?
|
423
|
-
def managed?
|
424
|
-
controlGroup == 'M'
|
425
|
-
end
|
426
|
-
|
427
|
-
# @return [boolean] is this an inline datastream?
|
428
|
-
def inline?
|
429
|
-
controlGroup == 'X'
|
430
|
-
end
|
431
|
-
|
432
|
-
|
433
434
|
private
|
434
435
|
|
435
436
|
# Rack::Test::UploadedFile is often set via content=, however it's not an IO, though it wraps an io object.
|
data/lib/rubydora/repository.rb
CHANGED
@@ -28,7 +28,7 @@ module Rubydora
|
|
28
28
|
#
|
29
29
|
# @params [String] query
|
30
30
|
# @params [Hash] options
|
31
|
-
# @yield [DigitalObject] Yield a DigitalObject for each search result
|
31
|
+
# @yield [DigitalObject] Yield a DigitalObject for each search result, skipping forbidden objects
|
32
32
|
def search query, options = {}, &block
|
33
33
|
return to_enum(:search, query, options).to_a unless block_given?
|
34
34
|
|
@@ -42,7 +42,14 @@ module Rubydora
|
|
42
42
|
response = self.find_objects(options.merge(:query => query, :resultFormat => 'xml', :pid => true).merge(sessionOptions))
|
43
43
|
|
44
44
|
doc = Nokogiri::XML(response)
|
45
|
-
doc.xpath('//xmlns:objectFields/xmlns:pid', doc.namespaces).each
|
45
|
+
doc.xpath('//xmlns:objectFields/xmlns:pid', doc.namespaces).each do |pid|
|
46
|
+
begin
|
47
|
+
obj = self.find(pid.text);
|
48
|
+
rescue RestClient::Unauthorized
|
49
|
+
next
|
50
|
+
end
|
51
|
+
block.call(obj)
|
52
|
+
end
|
46
53
|
|
47
54
|
sessionToken = doc.xpath('//xmlns:listSession/xmlns:token', doc.namespaces).text
|
48
55
|
end until sessionToken.nil? or sessionToken.empty? or doc.xpath('//xmlns:resultList/xmlns:objectFields', doc.namespaces).empty?
|
@@ -122,6 +122,7 @@ module Rubydora
|
|
122
122
|
def export options = {}
|
123
123
|
query_options = options.dup
|
124
124
|
pid = query_options.delete(:pid)
|
125
|
+
raise ArgumentError, "Must have a pid" unless pid
|
125
126
|
client[export_object_url(pid, query_options)].get
|
126
127
|
rescue Exception => exception
|
127
128
|
rescue_with_handler(exception) || raise
|
data/rubydora.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.email = ["chris@cbeer.info"]
|
10
10
|
s.summary = %q{Fedora Commons REST API ruby library }
|
11
11
|
s.description = %q{Fedora Commons REST API ruby library}
|
12
|
-
s.homepage = "http://github.com/
|
12
|
+
s.homepage = "http://github.com/projecthydra/rubydora"
|
13
13
|
|
14
14
|
s.files = `git ls-files`.split("\n")
|
15
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -32,4 +32,5 @@ Gem::Specification.new do |s|
|
|
32
32
|
s.add_development_dependency("rspec")
|
33
33
|
s.add_development_dependency("yard")
|
34
34
|
s.add_development_dependency("jettywrapper")
|
35
|
+
s.add_development_dependency("webmock")
|
35
36
|
end
|
@@ -413,6 +413,18 @@ describe "Integration testing against a live Fedora repository", :integration =>
|
|
413
413
|
pids.should include('test:1', 'test:2')
|
414
414
|
end
|
415
415
|
|
416
|
+
it "should skip forbidden objects" do
|
417
|
+
# lets say the object test:2 is forbidden
|
418
|
+
stub = stub_http_request(:get, /.*test:2.*/).to_return(:status => 401)
|
419
|
+
objects = []
|
420
|
+
lambda { objects = @repository.search('pid~test:*') }.should_not raise_error
|
421
|
+
pids = objects.map {|obj| obj.pid }
|
422
|
+
pids.should include('test:1')
|
423
|
+
pids.should_not include('test:2')
|
424
|
+
stub.should have_been_requested
|
425
|
+
WebMock.reset!
|
426
|
+
end
|
427
|
+
|
416
428
|
end
|
417
429
|
|
418
430
|
it "should not destroy content when datastream properties are changed" do
|
@@ -109,9 +109,14 @@ describe Rubydora::RestApiClient do
|
|
109
109
|
@mock_repository.ingest :pid => 'mypid'
|
110
110
|
end
|
111
111
|
|
112
|
-
|
113
|
-
|
114
|
-
|
112
|
+
describe "export" do
|
113
|
+
it "should work on the happy path" do
|
114
|
+
RestClient::Request.should_receive(:execute).with(hash_including(:url => "http://example.org/objects/mypid/export"))
|
115
|
+
@mock_repository.export :pid => 'mypid'
|
116
|
+
end
|
117
|
+
it "should require a pid" do
|
118
|
+
lambda { @mock_repository.export }.should raise_error ArgumentError, "Must have a pid"
|
119
|
+
end
|
115
120
|
end
|
116
121
|
|
117
122
|
it "modify_object" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubydora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fastercsv
|
@@ -220,6 +220,20 @@ dependencies:
|
|
220
220
|
- - '>='
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: webmock
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - '>='
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - '>='
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
223
237
|
description: Fedora Commons REST API ruby library
|
224
238
|
email:
|
225
239
|
- chris@cbeer.info
|
@@ -260,7 +274,7 @@ files:
|
|
260
274
|
- spec/lib/rest_api_client_spec.rb
|
261
275
|
- spec/lib/transactions_spec.rb
|
262
276
|
- spec/spec_helper.rb
|
263
|
-
homepage: http://github.com/
|
277
|
+
homepage: http://github.com/projecthydra/rubydora
|
264
278
|
licenses: []
|
265
279
|
metadata: {}
|
266
280
|
post_install_message:
|
@@ -279,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
279
293
|
version: '0'
|
280
294
|
requirements: []
|
281
295
|
rubyforge_project:
|
282
|
-
rubygems_version: 2.0.
|
296
|
+
rubygems_version: 2.0.3
|
283
297
|
signing_key:
|
284
298
|
specification_version: 4
|
285
299
|
summary: Fedora Commons REST API ruby library
|