rubydora 1.6.4 → 1.6.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 763537753ba63badc5604ff8c0e8973d2c9c66e2
4
- data.tar.gz: 6ba0d875a73f459ef3d77d426eaebbc0992b50a1
3
+ metadata.gz: ea2a3b27923102ca45aeac61f63e8ff703da0bcf
4
+ data.tar.gz: 86a57b2f001215a6198d3bb62ad55f04753edbf3
5
5
  SHA512:
6
- metadata.gz: 1d4a724ddddd121e7276a6b001a633dca5d1b233c72bf7c724740f38f455cf1a44c268e3dc604638b0700c54981ce816a314fa8e827a1279d6bae928188c7a05
7
- data.tar.gz: 5abd3a54fb74151c19dd37df480b694447a6a85c7e70e89c3d720023e128afe391c4c8d81c0209db80465023477ccf35f09d4f93e6da86f6ea7e699a9c25580a
6
+ metadata.gz: 7c30a772eaaaefa0c0749b4692a8838b32b5ffcc19f96c2c221ee9b755e43097d36bd93ba930611005845605a1c33e57ed7fb99132ae0a898bcfc46eb0b5f0c5
7
+ data.tar.gz: 36b5c0476e15fa439cc3c41fd426497e1792491ce84cf1049096a459e99880ce24b496741f59416175c49899090999e2671bc06575aa832c3b5427605cbda161
data/.travis.yml CHANGED
@@ -1,7 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "1.9.3"
4
- - "2.0.0"
3
+ - 1.9.3
4
+ - 2.0.0
5
+
6
+ gemfile:
7
+ - gemfiles/gemfile.rails3
8
+ - gemfiles/gemfile.rails4
5
9
 
6
10
  notifications:
7
11
  irc: "irc.freenode.org#projecthydra"
data/Gemfile CHANGED
@@ -2,10 +2,6 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'activemodel', ">= 3.1.1"
6
- gem 'backports'
7
-
8
- gem 'rcov', :platform => :mri_18
9
5
  gem 'simplecov', :platform => :mri_19
10
6
  gem 'simplecov-rcov', :platform => :mri_19
11
7
  gem 'jruby-openssl', :platform => :jruby
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.4
1
+ 1.6.5
@@ -0,0 +1,11 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec :path=>"../"
4
+
5
+ gem 'activemodel', '~> 3.2.13'
6
+
7
+ group :development, :test do
8
+ gem 'rcov', :platform => :mri_18
9
+ gem 'simplecov', :platform => :mri_19
10
+ gem 'simplecov-rcov', :platform => :mri_19
11
+ end
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec :path=>"../"
4
+
5
+ gem 'activemodel', '4.0.0.rc1'
6
+
7
+ group :development, :test do
8
+ gem 'simplecov', :platform => :mri_19
9
+ gem 'simplecov-rcov', :platform => :mri_19
10
+ end
@@ -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
- _run_initialize_callbacks do
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
- _run_initialize_callbacks do
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=/
@@ -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 "after_ingest"
39
+ define_hook :after_ingest
40
40
  include Transactions
41
41
  end
42
42
 
@@ -99,7 +99,7 @@ module Rubydora
99
99
  class Transaction
100
100
  attr_reader :repository
101
101
  include Hooks
102
- define_hook "after_rollback"
102
+ define_hook :after_rollback
103
103
 
104
104
  def initialize repository, &block
105
105
  @repository = repository
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.2.2"
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
- it_behaves_like "an object attribute"
414
- let(:method) { 'state' }
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
@@ -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
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-05-28 00:00:00.000000000 Z
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.2.2
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.2.2
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