active-fedora 3.1.0.pre7 → 3.1.0.pre8

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.add_dependency("mediashelf-loggable")
28
28
  s.add_dependency("equivalent-xml")
29
29
  s.add_dependency("facets")
30
- s.add_dependency("rubydora", '~>0.1.7')
30
+ s.add_dependency("rubydora", '~>0.1.9')
31
31
  s.add_dependency("rdf")
32
32
  s.add_dependency("rdf-rdfxml")
33
33
  s.add_development_dependency("yard")
@@ -20,6 +20,7 @@ module ActiveFedora #:nodoc:
20
20
  autoload :RelationshipsHelper
21
21
  autoload :Datastream
22
22
  autoload :Delegating
23
+ autoload :DigitalObject
23
24
  autoload :Model
24
25
  autoload :MetadataDatastream
25
26
  autoload :MetadataDatastreamHelper
@@ -85,10 +85,10 @@ module ActiveFedora
85
85
  attrs = attrs.merge!({:pid=>RubydoraConnection.instance.nextid})
86
86
  end
87
87
  @new_object=true
88
- @inner_object = RubydoraConnection.instance.connection.find(attrs[:pid])
88
+ @inner_object = DigitalObject.find(self.class, attrs[:pid])
89
89
  else
90
90
  @new_object = attrs[:new_object] == false ? false : true
91
- @inner_object = RubydoraConnection.instance.connection.find(attrs[:pid])
91
+ @inner_object = DigitalObject.find(self.class, attrs[:pid])
92
92
  load_datastreams_from_fedora
93
93
  end
94
94
  configure_defined_datastreams
@@ -98,6 +98,10 @@ module ActiveFedora
98
98
  self.attributes=attributes
99
99
  end
100
100
 
101
+ def self.datastream_class_for_name(dsid)
102
+ ds_specs[dsid] ? ds_specs[dsid].first : ActiveFedora::Datastream
103
+ end
104
+
101
105
  #This method is used to specify the details of a datastream.
102
106
  #args must include :name. Note that this method doesn't actually
103
107
  #execute the block, but stores it at the class level, to be executed
@@ -196,19 +200,15 @@ module ActiveFedora
196
200
  def load_datastreams_from_fedora
197
201
  inner_object.datastreams.each do |dsid, datastream|
198
202
  ds_spec = self.class.ds_specs[dsid]
203
+ datastreams[dsid] = datastream
199
204
  if (ds_spec)
200
205
  klass = ds_spec.first
201
- datastreams[dsid] = klass.new(inner_object, dsid, true)
202
206
  datastreams[dsid].model = self if klass == RelsExtDatastream
203
207
 
204
208
  if ds_spec.last.class == Proc
205
209
  ds_spec.last.call(datastreams[dsid])
206
210
  end
207
211
  klass.from_xml(datastreams[dsid].content, datastreams[dsid]) ### TODO, this is loading eagerly, we could load it as needed
208
- ### TODO, if rubydora could know which klass to use, we could probably skip this step.
209
- else
210
- #TODO, this may be a perfomance hit and we may not need it.
211
- datastreams[dsid] =Datastream.new(inner_object, dsid)#, true)
212
212
  end
213
213
  end
214
214
  end
@@ -759,11 +759,11 @@ module ActiveFedora
759
759
 
760
760
  #return the owner id
761
761
  def owner_id
762
- @inner_object.owner_id
762
+ @inner_object.ownerId
763
763
  end
764
764
 
765
765
  def owner_id=(owner_id)
766
- @inner_object.owner_id=(owner_id)
766
+ @inner_object.ownerId=(owner_id)
767
767
  end
768
768
 
769
769
  #return the create_date of the inner object (unless it's a new object)
@@ -5,10 +5,10 @@ module ActiveFedora
5
5
 
6
6
  attr_accessor :dirty, :last_modified, :fields
7
7
 
8
- def initialize(digital_object, dsid, exists_in_fedora=false )
8
+ def initialize(digital_object, dsid)
9
9
  @fields={}
10
10
  @dirty = false
11
- super(digital_object, dsid)
11
+ super
12
12
  end
13
13
 
14
14
  # #Return the xml content representing this Datastream from Fedora
@@ -23,30 +23,6 @@ module ActiveFedora
23
23
  self.dirty = true
24
24
  end
25
25
 
26
- # def self.delete(parent_pid, dsid)
27
- # Fedora::Repository.instance.delete("%s/datastreams/%s"%[parent_pid, dsid])
28
- # end
29
-
30
- # def delete
31
- # self.class.delete(self.pid, self.dsid)
32
- # end
33
-
34
- # #get this datastreams identifier
35
- # def pid
36
- # self.attributes[:pid]
37
- # end
38
-
39
- # #set this datastreams parent identifier
40
- # def pid=(pid)
41
- # self.attributes[:pid] = pid
42
- # end
43
-
44
- # #set this datastreams identifier (note: sets both dsID and dsid)
45
- # def dsid=(dsid)
46
- # self.attributes[:dsID] = dsid
47
- # self.attributes[:dsid] = dsid
48
- # end
49
-
50
26
  def size
51
27
  self.profile['dsSize']
52
28
  end
@@ -8,8 +8,7 @@ module ActiveFedora
8
8
 
9
9
  def [] (key)
10
10
  if key == 'DC' && !has_key?(key)
11
- ds = Datastream.new(@obj.inner_object, key, true)
12
- ds.content
11
+ ds = Datastream.new(@obj.inner_object, key)
13
12
  self[key] = ds
14
13
  end
15
14
  super
@@ -18,7 +18,7 @@ module ActiveFedora
18
18
  attr_accessor :internal_solr_doc
19
19
  attr_reader :ng_xml
20
20
 
21
- def initialize(digital_object, dsid, exists_in_fedora=false)
21
+ def initialize(digital_object, dsid)
22
22
  super
23
23
  self.class.from_xml(nil, self)
24
24
  end
@@ -15,13 +15,13 @@ module ActiveFedora
15
15
 
16
16
  #Constructor. this class will call self.field for each DCTERM. In short, all DCTERMS fields will already exist
17
17
  #when this method returns. Each term is marked as a multivalue string.
18
- def initialize(digital_object, dsid, exists_in_fedora=false )
18
+ def initialize(digital_object, dsid )
19
19
  super(digital_object, dsid)
20
20
  DCTERMS.each do |el|
21
21
  field el, :string, :multiple=>true
22
22
  end
23
23
  ###TODO this is loading eagerly, but we could make it lazy
24
- self.class.from_xml(exists_in_fedora ? content : nil, self)
24
+ self.class.from_xml(content, self)
25
25
  self
26
26
  end
27
27
 
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "3.1.0.pre7"
2
+ VERSION = "3.1.0.pre8"
3
3
  end
@@ -89,9 +89,8 @@ describe ActiveFedora::Base do
89
89
  it "should set :dsid and :label when supplied" do
90
90
  mock_file = stub("File", :path=>'foo')
91
91
  mock_ds = stub_everything("Datastream")
92
- mock_ds.expects(:dsid=).with('__DSID__')
93
92
  mock_ds.expects(:dsLabel=).with('My Label')
94
- ActiveFedora::Datastream.expects(:new).with(@base.inner_object, 'DS1').returns(mock_ds)
93
+ ActiveFedora::Datastream.expects(:new).with(@base.inner_object, '__DSID__').returns(mock_ds)
95
94
  @base.expects(:add_datastream).with(mock_ds)
96
95
  @base.add_file_datastream(mock_file, :label => "My Label", :dsid => "__DSID__")
97
96
  end
@@ -28,7 +28,7 @@ describe ActiveFedora::Base do
28
28
 
29
29
  before(:each) do
30
30
  @mock_repo = mock("repository")
31
- Rubydora::DigitalObject.any_instance.expects(:repository).returns(@mock_repo).at_least_once
31
+ ActiveFedora::DigitalObject.any_instance.expects(:repository).returns(@mock_repo).at_least_once
32
32
  @this_pid = increment_pid.to_s
33
33
  ActiveFedora::RubydoraConnection.instance.stubs(:nextid).returns(@this_pid)
34
34
 
@@ -74,8 +74,7 @@ describe ActiveFedora::Base do
74
74
 
75
75
  ### Methods for ActiveModel::Conversions
76
76
  it "should have to_param once it's saved" do
77
- @mock_repo.expects(:object).with(:pid => @this_pid).returns("")
78
-
77
+ @mock_repo.expects(:object).raises(RuntimeError)
79
78
  @test_object.to_param.should be_nil
80
79
  @test_object.expects(:create).returns(true)
81
80
  @test_object.save
@@ -84,7 +83,7 @@ describe ActiveFedora::Base do
84
83
  end
85
84
 
86
85
  it "should have to_key once it's saved" do
87
- @mock_repo.expects(:object).with(:pid => @this_pid).returns("")
86
+ @mock_repo.expects(:object).raises(RuntimeError)
88
87
  @test_object.to_key.should be_nil
89
88
  @test_object.expects(:create).returns(true)
90
89
  @test_object.save
@@ -113,15 +112,11 @@ describe ActiveFedora::Base do
113
112
  describe "has_metadata" do
114
113
  before :each do
115
114
  @mock_repo.expects(:datastreams).with(:pid => "monkey:99").returns("")
116
- @mock_repo.expects(:object).with(:pid => "monkey:99").returns("")
115
+ @mock_repo.expects(:object).with(:pid => "monkey:99").raises(RuntimeError)
117
116
  @mock_repo.expects(:ingest).with(:pid => "monkey:99").returns("monkey:99")
118
- @mock_repo.expects(:datastream_dissemination).with(:dsid => 'someData',:pid => 'monkey:99').returns('asdf')
119
117
  @mock_repo.expects(:add_datastream).with {|params| params[:dsid] == 'someData'}
120
- @mock_repo.expects(:datastream_dissemination).with(:dsid => 'withText',:pid => 'monkey:99').returns('asdf')
121
118
  @mock_repo.expects(:add_datastream).with {|params| params[:dsid] == 'withText'}
122
- @mock_repo.expects(:datastream_dissemination).with(:dsid => 'withText2',:pid => 'monkey:99').returns('asdf')
123
119
  @mock_repo.expects(:add_datastream).with {|params| params[:dsid] == 'withText2'}
124
- @mock_repo.expects(:datastream_dissemination).with(:dsid => 'RELS-EXT',:pid => 'monkey:99').returns('asdf')
125
120
  @mock_repo.expects(:add_datastream).with {|params| params[:dsid] == 'RELS-EXT'}
126
121
 
127
122
  @n = FooHistory.new(:pid=>"monkey:99")
@@ -276,10 +271,8 @@ describe ActiveFedora::Base do
276
271
 
277
272
 
278
273
  it "should return true and set persisted if object and datastreams all save successfully" do
279
- @mock_repo.expects(:datastream_dissemination).with(:dsid => 'RELS-EXT',:pid => @this_pid).returns('asdf')
280
-
281
274
  @mock_repo.expects(:ingest).with(:pid => @this_pid).returns(@this_pid)
282
- @mock_repo.expects(:object).with(:pid => @this_pid).returns("")
275
+ @mock_repo.expects(:object).with(:pid => @this_pid).raises(RuntimeError)
283
276
  @mock_repo.expects(:datastreams).with(:pid => @this_pid).returns("")
284
277
  @mock_repo.expects(:add_datastream).with {|params| params[:dsid] == 'RELS-EXT'}
285
278
  @test_object.persisted?.should be false
@@ -309,12 +302,8 @@ describe ActiveFedora::Base do
309
302
  to = FooHistory.new
310
303
  to.expects(:update_index)
311
304
  @mock_repo.expects(:ingest).with(:pid => @this_pid).returns(@this_pid)
312
- @mock_repo.expects(:object).with(:pid => @this_pid).returns("")
305
+ @mock_repo.expects(:object).with(:pid => @this_pid).raises(RuntimeError)
313
306
  @mock_repo.expects(:datastreams).with(:pid => @this_pid).returns("")
314
- @mock_repo.expects(:datastream_dissemination).with(:dsid => 'withText',:pid => @this_pid).returns('asdf')
315
- @mock_repo.expects(:datastream_dissemination).with(:dsid => 'withText2',:pid => @this_pid).returns('asdf')
316
- @mock_repo.expects(:datastream_dissemination).with(:dsid => 'RELS-EXT',:pid => @this_pid).returns('asdf')
317
- @mock_repo.expects(:datastream_dissemination).with(:dsid => 'someData',:pid => @this_pid).returns('asdf')
318
307
 
319
308
  @mock_repo.expects(:add_datastream).with {|params| params[:dsid] == 'withText2'}
320
309
  @mock_repo.expects(:add_datastream).with {|params| params[:dsid] == 'withText'}
@@ -328,15 +317,13 @@ describe ActiveFedora::Base do
328
317
  to.save
329
318
  end
330
319
  it "should call .save on any datastreams that are new" do
331
- @mock_repo.expects(:datastream_dissemination).with(:dsid => 'ds_to_add',:pid => @this_pid).returns('asdf')
332
- @mock_repo.expects(:datastream_dissemination).with(:dsid => 'RELS-EXT',:pid => @this_pid).returns('asdf')
333
320
  ds = ActiveFedora::Datastream.new(@test_object.inner_object, 'ds_to_add')
334
321
  ds.content = "DS CONTENT"
335
322
  @test_object.add_datastream(ds)
336
323
  ds.expects(:save)
337
324
  @test_object.instance_variable_set(:@new_object, false)
338
325
  @test_object.expects(:refresh)
339
- @mock_repo.expects(:object).with(:pid => @this_pid).returns("").at_least_once
326
+ @mock_repo.expects(:object).with(:pid => @this_pid).raises(RuntimeError).at_least_once
340
327
  @mock_repo.expects(:ingest).with(:pid => @test_object.pid)
341
328
  @mock_repo.expects(:datastreams).with(:pid => @test_object.pid).returns("")
342
329
  @mock_repo.expects(:add_datastream).with{ |x| x[:dsid] = "RELS-EXT"}
@@ -352,10 +339,6 @@ describe ActiveFedora::Base do
352
339
 
353
340
  @test_object.inner_object.expects(:new?).returns(true).twice
354
341
  @test_object.inner_object.expects(:datastreams).returns({'someData'=>mock('obj', :changed? => false)})
355
- @mock_repo.expects(:datastream_dissemination).with(:dsid => 'someData',:pid => @test_object.pid).returns('asdf')
356
- @mock_repo.expects(:datastream_dissemination).with(:dsid => 'withText',:pid => @test_object.pid).returns('asdf')
357
- @mock_repo.expects(:datastream_dissemination).with(:dsid => 'withText2',:pid => @test_object.pid).returns('asdf')
358
- @mock_repo.expects(:datastream_dissemination).with(:dsid => 'RELS-EXT',:pid => @test_object.pid).returns('asdf')
359
342
  @test_object.datastreams["someData"].should_not be_nil
360
343
  @test_object.datastreams['someData'].stubs(:changed?).returns(false)
361
344
  @test_object.datastreams['someData'].stubs(:new?).returns(false)
@@ -368,8 +351,6 @@ describe ActiveFedora::Base do
368
351
  it "should update solr index with all metadata if any MetadataDatastreams have changed" do
369
352
  @mock_repo.expects(:ingest).with(:pid => nil)
370
353
  @mock_repo.expects(:modify_datastream).with{ |x| x[:pid] == nil && x[:dsid] == 'RELS-EXT'}
371
- @mock_repo.expects(:datastream_dissemination).with(:dsid => 'RELS-EXT',:pid => nil).returns('asdf')
372
- @mock_repo.expects(:datastream_dissemination).with(:dsid => 'ds1',:pid => nil).returns('asdf')
373
354
  @mock_repo.expects(:add_datastream).with {|params| params[:dsid] == 'ds1'}
374
355
  @mock_repo.expects(:datastream).with{ |x| x[:dsid] == 'ds1'}.returns("").at_least_once #raises(RuntimeError, "Fake Not found")
375
356
  @test_object.inner_object.expects(:new?).returns(true).twice
@@ -390,7 +371,7 @@ describe ActiveFedora::Base do
390
371
  @test_object.save
391
372
  end
392
373
  it "should NOT update solr index if no MetadataDatastreams have changed" do
393
- Rubydora::DigitalObject.any_instance.stubs(:save)
374
+ ActiveFedora::DigitalObject.any_instance.stubs(:save)
394
375
  mock1 = mock("ds1")
395
376
  mock1.expects( :changed?).returns(false).at_least_once
396
377
  mock1.expects(:serialize!)
@@ -408,8 +389,6 @@ describe ActiveFedora::Base do
408
389
  @test_object.expects(:refresh)
409
390
  @test_object.instance_variable_set(:@new_object, false)
410
391
 
411
- @mock_repo.expects(:object).with(:pid => @this_pid).returns("")
412
-
413
392
  @test_object.save
414
393
  end
415
394
  it "should update solr index if relationships have changed" do
@@ -15,7 +15,9 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
15
15
 
16
16
  before(:each) do
17
17
  ActiveFedora::RubydoraConnection.instance.stubs(:nextid).returns("_nextid_")
18
+ ActiveFedora::QualifiedDublinCoreDatastream.any_instance.expects(:content).at_least_once
18
19
  @test_ds = ActiveFedora::QualifiedDublinCoreDatastream.new(nil, nil)
20
+
19
21
  end
20
22
  it "from_xml should parse everything correctly" do
21
23
  #originally just tested that lcsh encoding and stuff worked, but the other stuff is worth testing
@@ -89,7 +89,7 @@ describe ActiveFedora do
89
89
  @test_object.save
90
90
  end
91
91
  it "should prevent Base.delete from deleting the corresponding Solr document if false" do
92
- Rubydora::DigitalObject.any_instance.expects(:delete)
92
+ ActiveFedora::DigitalObject.any_instance.expects(:delete)
93
93
  ActiveFedora::SolrService.instance.conn.expects(:delete).with(@test_object.pid).never
94
94
  @test_object.delete
95
95
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-fedora
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1923832023
4
+ hash: 1923832009
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
9
  - 0
10
10
  - pre
11
- - 7
12
- version: 3.1.0.pre7
11
+ - 8
12
+ version: 3.1.0.pre8
13
13
  platform: ruby
14
14
  authors:
15
15
  - Matt Zumwalt
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2011-10-14 00:00:00 -05:00
21
+ date: 2011-10-18 00:00:00 -05:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -211,12 +211,12 @@ dependencies:
211
211
  requirements:
212
212
  - - ~>
213
213
  - !ruby/object:Gem::Version
214
- hash: 21
214
+ hash: 9
215
215
  segments:
216
216
  - 0
217
217
  - 1
218
- - 7
219
- version: 0.1.7
218
+ - 9
219
+ version: 0.1.9
220
220
  type: :runtime
221
221
  version_requirements: *id013
222
222
  - !ruby/object:Gem::Dependency
@@ -548,7 +548,6 @@ files:
548
548
  - COPYING.txt
549
549
  - COYING.LESSER.txt
550
550
  - Gemfile
551
- - Gemfile.lock
552
551
  - History.txt
553
552
  - LICENSE
554
553
  - License.txt
@@ -1,139 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- active-fedora (3.1.0.pre7)
5
- activeresource (~> 3.0.0)
6
- activesupport (~> 3.0.0)
7
- equivalent-xml
8
- facets
9
- mediashelf-loggable
10
- mime-types (>= 1.16)
11
- multipart-post (= 1.1.2)
12
- nokogiri
13
- om (>= 1.0)
14
- rdf
15
- rdf-rdfxml
16
- rubydora (~> 0.1.7)
17
- solr-ruby (>= 0.0.6)
18
- solrizer (> 1.0.0)
19
- xml-simple (>= 1.0.12)
20
-
21
- GEM
22
- remote: http://rubygems.org/
23
- specs:
24
- RedCloth (4.2.8)
25
- activemodel (3.0.10)
26
- activesupport (= 3.0.10)
27
- builder (~> 2.1.2)
28
- i18n (~> 0.5.0)
29
- activeresource (3.0.10)
30
- activemodel (= 3.0.10)
31
- activesupport (= 3.0.10)
32
- activesupport (3.0.10)
33
- addressable (2.2.6)
34
- akami (1.0.0)
35
- gyoku (>= 0.4.0)
36
- builder (2.1.2)
37
- childprocess (0.2.2)
38
- ffi (~> 1.0.6)
39
- columnize (0.3.4)
40
- daemons (1.1.4)
41
- equivalent-xml (0.2.8)
42
- nokogiri (>= 1.4.3)
43
- facets (2.9.2)
44
- fastercsv (1.5.4)
45
- ffi (1.0.9)
46
- gyoku (0.4.4)
47
- builder (>= 2.1.2)
48
- httpi (0.9.5)
49
- rack
50
- i18n (0.5.0)
51
- jettywrapper (1.0.1)
52
- activesupport (>= 3.0.0)
53
- childprocess
54
- i18n
55
- logger
56
- mediashelf-loggable
57
- linecache (0.46)
58
- rbx-require-relative (> 0.0.4)
59
- logger (1.2.8)
60
- mediashelf-loggable (0.4.7)
61
- metaclass (0.0.1)
62
- mime-types (1.16)
63
- mocha (0.10.0)
64
- metaclass (~> 0.0.1)
65
- multipart-post (1.1.2)
66
- nokogiri (1.5.0)
67
- nori (1.0.2)
68
- om (1.4.2)
69
- mediashelf-loggable
70
- nokogiri (>= 1.4.2)
71
- rack (1.3.4)
72
- rake (0.9.2)
73
- rbx-require-relative (0.0.5)
74
- rcov (0.9.11)
75
- rdf (0.3.4.1)
76
- addressable (>= 2.2.6)
77
- rdf-rdfxml (0.3.5)
78
- nokogiri (>= 1.4.4)
79
- rdf (>= 0.3.4)
80
- rest-client (1.6.7)
81
- mime-types (>= 1.16)
82
- rsolr (1.0.2)
83
- builder (>= 2.1.2)
84
- rspec (1.3.2)
85
- ruby-debug (0.10.4)
86
- columnize (>= 0.1)
87
- ruby-debug-base (~> 0.10.4.0)
88
- ruby-debug-base (0.10.4)
89
- linecache (>= 0.3)
90
- rubydora (0.1.7)
91
- activemodel
92
- activesupport
93
- fastercsv
94
- mime-types
95
- nokogiri
96
- rest-client
97
- savon
98
- savon (0.9.7)
99
- akami (~> 1.0)
100
- builder (>= 2.1.2)
101
- gyoku (>= 0.4.0)
102
- httpi (~> 0.9)
103
- nokogiri (>= 1.4.0)
104
- nori (~> 1.0)
105
- wasabi (~> 2.0)
106
- solr-ruby (0.0.8)
107
- solrizer (1.1.2)
108
- daemons
109
- mediashelf-loggable
110
- nokogiri
111
- om (>= 1.4.0)
112
- stomp
113
- xml-simple
114
- solrizer-fedora (1.1.3)
115
- active-fedora (>= 2.3.0)
116
- fastercsv
117
- rsolr
118
- solr-ruby (>= 0.0.6)
119
- solrizer (>= 1.0.0)
120
- stomp (1.1.9)
121
- wasabi (2.0.0)
122
- nokogiri (>= 1.4.0)
123
- xml-simple (1.1.1)
124
- yard (0.7.2)
125
-
126
- PLATFORMS
127
- ruby
128
-
129
- DEPENDENCIES
130
- RedCloth
131
- active-fedora!
132
- jettywrapper (>= 1.0.1)
133
- mocha (>= 0.9.8)
134
- rake
135
- rcov
136
- rspec (< 2.0.0)
137
- ruby-debug
138
- solrizer-fedora (>= 1.1.3)
139
- yard