rubydora 1.6.4 → 1.6.5
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/.travis.yml +6 -2
- data/Gemfile +0 -4
- data/VERSION +1 -1
- data/gemfiles/gemfile.rails3 +11 -0
- data/gemfiles/gemfile.rails4 +10 -0
- data/lib/rubydora/datastream.rb +1 -1
- data/lib/rubydora/digital_object.rb +11 -1
- data/lib/rubydora/repository.rb +8 -0
- data/lib/rubydora/rest_api_client.rb +2 -2
- data/lib/rubydora/transactions.rb +1 -1
- data/rubydora.gemspec +1 -1
- data/spec/lib/digital_object_spec.rb +56 -2
- data/spec/lib/repository_spec.rb +11 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea2a3b27923102ca45aeac61f63e8ff703da0bcf
|
4
|
+
data.tar.gz: 86a57b2f001215a6198d3bb62ad55f04753edbf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c30a772eaaaefa0c0749b4692a8838b32b5ffcc19f96c2c221ee9b755e43097d36bd93ba930611005845605a1c33e57ed7fb99132ae0a898bcfc46eb0b5f0c5
|
7
|
+
data.tar.gz: 36b5c0476e15fa439cc3c41fd426497e1792491ce84cf1049096a459e99880ce24b496741f59416175c49899090999e2671bc06575aa832c3b5427605cbda161
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.6.
|
1
|
+
1.6.5
|
data/lib/rubydora/datastream.rb
CHANGED
@@ -100,7 +100,7 @@ module Rubydora
|
|
100
100
|
# @param [String] Datastream ID
|
101
101
|
# @param [Hash] default attribute values (used esp. for creating new datastreams)
|
102
102
|
def initialize digital_object, dsid, options = {}, default_instance_attributes = {}
|
103
|
-
|
103
|
+
run_callbacks :initialize do
|
104
104
|
@digital_object = digital_object
|
105
105
|
@dsid = dsid
|
106
106
|
@options = options
|
@@ -40,6 +40,12 @@ module Rubydora
|
|
40
40
|
RUBY
|
41
41
|
end
|
42
42
|
|
43
|
+
def state= val
|
44
|
+
raise ArgumentError, "Allowed values for state are 'I', 'A' and 'D'. You provided '#{val}'" unless ['I', 'A', 'D'].include?(val)
|
45
|
+
state_will_change! unless val == state
|
46
|
+
@state = val
|
47
|
+
end
|
48
|
+
|
43
49
|
# Find an existing Fedora object
|
44
50
|
#
|
45
51
|
# @param [String] pid
|
@@ -83,7 +89,7 @@ module Rubydora
|
|
83
89
|
# @param [Rubydora::Repository] repository context
|
84
90
|
# @param [Hash] options default attribute values (used esp. for creating new datastreams
|
85
91
|
def initialize pid, repository = nil, options = {}
|
86
|
-
|
92
|
+
run_callbacks :initialize do
|
87
93
|
self.pid = pid
|
88
94
|
@repository = repository
|
89
95
|
@options = options
|
@@ -160,6 +166,10 @@ module Rubydora
|
|
160
166
|
end
|
161
167
|
end
|
162
168
|
|
169
|
+
def object_xml
|
170
|
+
repository.object_xml(pid: pid)
|
171
|
+
end
|
172
|
+
|
163
173
|
def versions
|
164
174
|
versions_xml = repository.object_versions(:pid => pid)
|
165
175
|
versions_xml.gsub! '<fedoraObjectHistory', '<fedoraObjectHistory xmlns="http://www.fedora.info/definitions/1/0/access/"' unless versions_xml =~ /xmlns=/
|
data/lib/rubydora/repository.rb
CHANGED
@@ -28,6 +28,14 @@ module Rubydora
|
|
28
28
|
DigitalObject.find_or_initialize(pid, self)
|
29
29
|
end
|
30
30
|
|
31
|
+
# Reserve a new pid for the object
|
32
|
+
# @params [Hash] options
|
33
|
+
# @option options [String] :namespace the namespece for the pid
|
34
|
+
def mint(options={})
|
35
|
+
d = Nokogiri::XML(next_pid(options))
|
36
|
+
d.xpath('//fedora:pid', 'fedora' => 'http://www.fedora.info/definitions/1/0/management/').text
|
37
|
+
end
|
38
|
+
|
31
39
|
# High-level access to the Fedora find_objects API
|
32
40
|
#
|
33
41
|
# @params [String] query
|
@@ -33,10 +33,10 @@ module Rubydora
|
|
33
33
|
|
34
34
|
include Hooks
|
35
35
|
[:ingest, :modify_object, :purge_object, :set_datastream_options, :add_datastream, :modify_datastream, :purge_datastream, :add_relationship, :purge_relationship].each do |h|
|
36
|
-
define_hook "before_#{h}"
|
36
|
+
define_hook "before_#{h}".to_sym
|
37
37
|
end
|
38
38
|
|
39
|
-
define_hook
|
39
|
+
define_hook :after_ingest
|
40
40
|
include Transactions
|
41
41
|
end
|
42
42
|
|
data/rubydora.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_dependency "mime-types"
|
24
24
|
s.add_dependency "activesupport"
|
25
25
|
s.add_dependency "activemodel"
|
26
|
-
s.add_dependency "hooks", "~> 0.
|
26
|
+
s.add_dependency "hooks", "~> 0.3.0"
|
27
27
|
s.add_dependency "deprecation"
|
28
28
|
|
29
29
|
s.add_development_dependency("rake")
|
@@ -410,8 +410,53 @@ describe Rubydora::DigitalObject do
|
|
410
410
|
end
|
411
411
|
|
412
412
|
describe "#state" do
|
413
|
-
|
414
|
-
|
413
|
+
subject { Rubydora::DigitalObject.new 'pid', @mock_repository }
|
414
|
+
|
415
|
+
describe "getter" do
|
416
|
+
it "should return the value" do
|
417
|
+
subject.instance_variable_set("@state", 'asdf')
|
418
|
+
subject.state.should == 'asdf'
|
419
|
+
end
|
420
|
+
|
421
|
+
it "should look in the object profile" do
|
422
|
+
subject.should_receive(:profile) { { Rubydora::DigitalObject::OBJ_ATTRIBUTES[:state].to_s => 'qwerty' } }
|
423
|
+
subject.state.should == 'qwerty'
|
424
|
+
end
|
425
|
+
|
426
|
+
it "should fall-back to the set of default attributes" do
|
427
|
+
@mock_repository.should_receive(:object).with(:pid=>"pid").and_raise(RestClient::ResourceNotFound)
|
428
|
+
Rubydora::DigitalObject::OBJ_DEFAULT_ATTRIBUTES.should_receive(:[]).with(:state) { 'zxcv'}
|
429
|
+
subject.state.should == 'zxcv'
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
describe "setter" do
|
434
|
+
before do
|
435
|
+
subject.stub(:datastreams => [])
|
436
|
+
end
|
437
|
+
it "should mark the object as changed after setting" do
|
438
|
+
@mock_repository.should_receive(:object).with(:pid=>"pid").and_raise(RestClient::ResourceNotFound)
|
439
|
+
subject.state= 'D'
|
440
|
+
subject.should be_changed
|
441
|
+
end
|
442
|
+
|
443
|
+
it "should raise an error when setting an invalid value" do
|
444
|
+
expect {subject.state= 'Q'}.to raise_error ArgumentError, "Allowed values for state are 'I', 'A' and 'D'. You provided 'Q'"
|
445
|
+
end
|
446
|
+
|
447
|
+
it "should not mark the object as changed if the value does not change" do
|
448
|
+
subject.should_receive(:state) { 'A' }
|
449
|
+
subject.state= 'A'
|
450
|
+
subject.should_not be_changed
|
451
|
+
end
|
452
|
+
|
453
|
+
it "should appear in the save request" do
|
454
|
+
@mock_repository.should_receive(:ingest).with(hash_including(:state => 'A'))
|
455
|
+
@mock_repository.should_receive(:object).with(:pid=>"pid").and_raise(RestClient::ResourceNotFound)
|
456
|
+
subject.state='A'
|
457
|
+
subject.save
|
458
|
+
end
|
459
|
+
end
|
415
460
|
end
|
416
461
|
|
417
462
|
describe "#ownerId" do
|
@@ -433,4 +478,13 @@ describe Rubydora::DigitalObject do
|
|
433
478
|
it_behaves_like "an object attribute"
|
434
479
|
let(:method) { 'lastModifiedDate' }
|
435
480
|
end
|
481
|
+
|
482
|
+
describe "#object_xml" do
|
483
|
+
it "should return the FOXML record" do
|
484
|
+
xml = File.read(File.join(File.dirname(__FILE__), '..', 'fixtures', 'audit_trail.foxml.xml'))
|
485
|
+
@mock_repository.stub(:object_xml).with(hash_including(:pid => 'foo:bar')).and_return(xml)
|
486
|
+
@object = Rubydora::DigitalObject.new 'foo:bar', @mock_repository
|
487
|
+
@object.object_xml.should == @object.repository.object_xml(pid: 'foo:bar')
|
488
|
+
end
|
489
|
+
end
|
436
490
|
end
|
data/spec/lib/repository_spec.rb
CHANGED
@@ -31,6 +31,17 @@ describe Rubydora::Repository do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
describe "mint" do
|
35
|
+
before do
|
36
|
+
xml = "<resp xmlns:fedora=\"http://www.fedora.info/definitions/1/0/management/\"><fedora:pid>test:123</fedora:pid></resp>"
|
37
|
+
@repository.should_receive(:next_pid).and_return xml
|
38
|
+
end
|
39
|
+
it "should call nextPID" do
|
40
|
+
@repository.mint.should == 'test:123'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
34
45
|
describe "sparql" do
|
35
46
|
it "should return csv results for sparql queries" do
|
36
47
|
resource_index_query = ""
|
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.5
|
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-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fastercsv
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - ~>
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
117
|
+
version: 0.3.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - ~>
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
124
|
+
version: 0.3.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: deprecation
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -250,6 +250,8 @@ files:
|
|
250
250
|
- README.rdoc
|
251
251
|
- Rakefile
|
252
252
|
- VERSION
|
253
|
+
- gemfiles/gemfile.rails3
|
254
|
+
- gemfiles/gemfile.rails4
|
253
255
|
- lib/rubydora.rb
|
254
256
|
- lib/rubydora/array_with_callback.rb
|
255
257
|
- lib/rubydora/audit_trail.rb
|