active-fedora 7.3.1 → 8.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +17 -7
  3. data/Gemfile +0 -3
  4. data/active-fedora.gemspec +5 -5
  5. data/gemfiles/rails3.gemfile +5 -0
  6. data/gemfiles/rails4.1.gemfile +5 -0
  7. data/gemfiles/rails4.gemfile +5 -0
  8. data/lib/active_fedora.rb +1 -1
  9. data/lib/active_fedora/associations/belongs_to_association.rb +8 -21
  10. data/lib/active_fedora/attributes.rb +13 -12
  11. data/lib/active_fedora/base.rb +1 -1
  12. data/lib/active_fedora/datastream.rb +3 -6
  13. data/lib/active_fedora/indexing.rb +1 -1
  14. data/lib/active_fedora/om_datastream.rb +1 -5
  15. data/lib/active_fedora/predicates.rb +2 -2
  16. data/lib/active_fedora/rdf.rb +6 -2
  17. data/lib/active_fedora/rdf/fcrepo.rb +326 -0
  18. data/lib/active_fedora/rdf/identifiable.rb +6 -3
  19. data/lib/active_fedora/rdf/indexing.rb +3 -15
  20. data/lib/active_fedora/rdf/persistence.rb +33 -0
  21. data/lib/active_fedora/rdf/project_hydra.rb +12 -0
  22. data/lib/active_fedora/rdf/rdf_datastream.rb +33 -15
  23. data/lib/active_fedora/rdf_xml_writer.rb +2 -2
  24. data/lib/active_fedora/relationship_graph.rb +8 -8
  25. data/lib/active_fedora/semantic_node.rb +3 -15
  26. data/lib/active_fedora/solr_digital_object.rb +2 -2
  27. data/lib/active_fedora/solr_service.rb +1 -8
  28. data/lib/active_fedora/version.rb +1 -1
  29. data/lib/generators/active_fedora/config/fedora/templates/fedora.yml +24 -0
  30. data/lib/tasks/active_fedora_dev.rake +1 -1
  31. data/spec/integration/belongs_to_association_spec.rb +0 -5
  32. data/spec/integration/json_serialization_spec.rb +1 -1
  33. data/spec/integration/load_from_solr_spec.rb +8 -1
  34. data/spec/integration/ntriples_datastream_spec.rb +18 -18
  35. data/spec/integration/om_datastream_spec.rb +2 -2
  36. data/spec/integration/rdf_nested_attributes_spec.rb +1 -1
  37. data/spec/integration/relation_delegation_spec.rb +3 -3
  38. data/spec/samples/hydra-mods_article_datastream.rb +0 -4
  39. data/spec/support/an_active_model.rb +0 -4
  40. data/spec/unit/active_fedora_spec.rb +3 -3
  41. data/spec/unit/attributes_spec.rb +37 -54
  42. data/spec/unit/base_extra_spec.rb +0 -9
  43. data/spec/unit/om_datastream_spec.rb +14 -14
  44. data/spec/unit/rdf_resource_datastream_spec.rb +59 -9
  45. data/spec/unit/rdf_vocab_spec.rb +30 -0
  46. data/spec/unit/solr_digital_object_spec.rb +2 -2
  47. data/spec/unit/solr_service_spec.rb +0 -6
  48. data/spec/unit/validations_spec.rb +4 -4
  49. metadata +27 -32
  50. data/lib/active_fedora/rdf/object_resource.rb +0 -20
@@ -66,7 +66,7 @@ describe ActiveFedora::RDFDatastream do
66
66
  end
67
67
 
68
68
  it "should set values" do
69
- subject.title = "blah"
69
+ subject.title = ["blah"]
70
70
  expect(subject.descMetadata.title).to eq ["blah"]
71
71
  end
72
72
 
@@ -105,7 +105,7 @@ describe ActiveFedora::RDFDatastream do
105
105
  end
106
106
 
107
107
  it "should be persisted" do
108
- expect(subject.descMetadata.resource.persisted?).to be_true
108
+ expect(subject.descMetadata.resource.persisted?).to be true
109
109
  end
110
110
 
111
111
  context "and it's reloaded" do
@@ -146,7 +146,7 @@ describe ActiveFedora::RDFDatastream do
146
146
  context "persisted to parent" do
147
147
  before do
148
148
  dummy = DummySubnode.new
149
- dummy.title = 'subbla'
149
+ dummy.title = ['subbla']
150
150
  subject.descMetadata.license = dummy
151
151
  end
152
152
 
@@ -163,7 +163,7 @@ describe ActiveFedora::RDFDatastream do
163
163
  DummySubnode.configure :repository => :default
164
164
  DummySubnode.any_instance.stub(:repository).and_return(RDF::Repository.new)
165
165
  dummy = DummySubnode.new(RDF::URI('http://example.org/dummy/blah'))
166
- dummy.title = 'subbla'
166
+ dummy.title = ['subbla']
167
167
  # We want to have to manually persist to the repository.
168
168
  # Parent objects shouldn't be persisting children they share with other parents
169
169
  dummy.persist!
@@ -196,9 +196,9 @@ describe ActiveFedora::RDFDatastream do
196
196
  describe "relationships" do
197
197
  before do
198
198
  @new_object = DummyAsset.new
199
- @new_object.title = "subbla"
199
+ @new_object.title = ["subbla"]
200
200
  @new_object.save
201
- subject.title = "bla"
201
+ subject.title = ["bla"]
202
202
  subject.descMetadata.creator = @new_object
203
203
  end
204
204
 
@@ -224,7 +224,7 @@ describe ActiveFedora::RDFDatastream do
224
224
  end
225
225
 
226
226
  it "should allow for deep attributes to be set directly" do
227
- subject.descMetadata.creator.first.title = "Bla"
227
+ subject.descMetadata.creator.first.title = ["Bla"]
228
228
  expect(subject.descMetadata.creator.first.title).to eq ["Bla"]
229
229
  end
230
230
 
@@ -270,12 +270,12 @@ describe ActiveFedora::RDFDatastream do
270
270
  context 'when the object has no Rdf::Resource' do
271
271
  before do
272
272
  class DummyOmAsset < ActiveFedora::Base
273
- has_metadata :name => 'descMetadata', :type => OmDatastream
273
+ has_metadata :name => 'descMetadata', :type => ActiveFedora::OmDatastream
274
274
  end
275
275
 
276
276
  @new_object = DummyOmAsset.new
277
277
  @new_object.save
278
- subject.title = "bla"
278
+ subject.title = ["bla"]
279
279
  subject.descMetadata.creator = @new_object
280
280
  subject.save
281
281
  subject.reload
@@ -293,6 +293,56 @@ describe ActiveFedora::RDFDatastream do
293
293
  expect{@new_object.resource << RDF::Statement.new(RDF::Node.new, RDF::DC.title, 'title')
294
294
  }.to raise_error TypeError
295
295
  end
296
+ end
297
+ end
298
+
299
+ context 'with custom resource' do
300
+ before do
301
+
302
+ class DummyATResource < ActiveTriples::Resource
303
+ configure :base_uri => 'http://example.org/at/obj#', :type => RDF::OWL.Thing
304
+ property :title, :predicate => RDF::DC.alternative
305
+ property :my_special_property, :predicate => RDF::DC.spatial
306
+ end
307
+
308
+ DummyResource.resource_class DummyATResource
309
+ end
310
+
311
+ after do
312
+ Object.send(:remove_const, "DummyATResource")
313
+ end
314
+
315
+ it 'lets me specify a resource class' do
316
+ expect(DummyResource.resource_class < DummyATResource).to be_true
317
+ end
318
+
319
+ it 'creates underlying resource of type resource_class' do
320
+ expect(subject.resource).to be_a DummyATResource
321
+ end
322
+
323
+ it 'has properties from resource_class' do
324
+ expect(subject.resource.class.properties).to include :my_special_property.to_s
325
+ end
326
+
327
+ it 'favors property configuration from datastream' do
328
+ expect(subject.resource.class.properties['title'].predicate).to eq RDF::DC.title
329
+ end
330
+
331
+ it 'exposes resource propreties to parent object via datastream' do
332
+ subject.resource.title = 'Wizard of Oz'
333
+ expect(subject.title).to eq subject.resource.title
334
+ end
335
+
336
+ it 'applies base_uri from resource class' do
337
+ expect(subject.resource.class.base_uri).to eq DummyATResource.base_uri
338
+ end
339
+
340
+ it 'applies rdf type from resource class' do
341
+ expect(subject.resource.class.type).to eq DummyATResource.type
342
+ end
343
+
344
+ it 'refuses to change resource_class once set' do
345
+ expect { DummyResource.resource_class(ActiveTriples::Resource) }.to raise_error ArgumentError
296
346
  end
297
347
  end
298
348
  end
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe ActiveFedora::RDF do
5
+ describe ActiveFedora::RDF::Fcrepo do
6
+ it "should register the vocabularies" do
7
+ namespaces = [
8
+ "info:fedora/fedora-system:def/model#",
9
+ "info:fedora/fedora-system:def/view#",
10
+ "info:fedora/fedora-system:def/relations-external#",
11
+ "info:fedora/fedora-system:"
12
+ ]
13
+ namespaces.each do |namespace|
14
+ vocab = RDF::Vocabulary.find(namespace)
15
+ expect(vocab.superclass).to be(RDF::StrictVocabulary)
16
+ end
17
+ end
18
+ end
19
+ describe ActiveFedora::RDF::ProjectHydra do
20
+ it "should register the vocabularies" do
21
+ namespaces = [
22
+ "http://projecthydra.org/ns/relations#"
23
+ ]
24
+ namespaces.each do |namespace|
25
+ vocab = RDF::Vocabulary.find(namespace)
26
+ expect(vocab.superclass).to be(RDF::StrictVocabulary)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -47,10 +47,10 @@ describe ActiveFedora::SolrDigitalObject do
47
47
  expect(subject.fetch('author')).to be_empty
48
48
  end
49
49
  it "should grab values" do
50
- expect(subject.fetch('title')).to eq 'foo'
50
+ expect(subject.fetch('title')).to eq ['foo']
51
51
  end
52
52
  it "should grab values" do
53
- expect(subject.fetch('title')).to eq 'foo'
53
+ expect(subject.fetch('title')).to eq ['foo']
54
54
  end
55
55
 
56
56
  it "should raise an error if the field isn't indexed" do
@@ -109,12 +109,6 @@ describe ActiveFedora::SolrService do
109
109
  end
110
110
  end
111
111
 
112
- describe '#escape_uri_for_query' do
113
- it "should escape : with a backslash" do
114
- ActiveFedora::SolrService.escape_uri_for_query("my:pid").should == 'my\:pid'
115
- end
116
- end
117
-
118
112
  describe ".query" do
119
113
  it "should call solr" do
120
114
  mock_conn = double("Connection")
@@ -24,14 +24,14 @@ describe ActiveFedora::Base do
24
24
 
25
25
  describe "a valid object" do
26
26
  before do
27
- subject.attributes={ fubar:'here', swank:'long enough'}
27
+ subject.attributes = { fubar: ['here'], swank: 'long enough' }
28
28
  end
29
29
 
30
30
  it { should be_valid}
31
31
  end
32
32
  describe "an invalid object" do
33
33
  before do
34
- subject.attributes={ swank:'smal'}
34
+ subject.attributes = { swank: 'smal' }
35
35
  end
36
36
  it "should have errors" do
37
37
  subject.should_not be_valid
@@ -42,8 +42,8 @@ describe ActiveFedora::Base do
42
42
 
43
43
  describe "required terms" do
44
44
  it "should be required" do
45
- subject.required?(:fubar).should be_true
46
- subject.required?(:swank).should be_false
45
+ subject.required?(:fubar).should be true
46
+ subject.required?(:swank).should be false
47
47
  end
48
48
  end
49
49
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-fedora
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.3.1
4
+ version: 8.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Zumwalt
@@ -10,28 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-02-09 00:00:00.000000000 Z
13
+ date: 2014-12-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rsolr
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ">="
19
+ - - "~>"
20
20
  - !ruby/object:Gem::Version
21
21
  version: 1.0.10
22
- - - "<"
23
- - !ruby/object:Gem::Version
24
- version: '3'
25
22
  type: :runtime
26
23
  prerelease: false
27
24
  version_requirements: !ruby/object:Gem::Requirement
28
25
  requirements:
29
- - - ">="
26
+ - - "~>"
30
27
  - !ruby/object:Gem::Version
31
28
  version: 1.0.10
32
- - - "<"
33
- - !ruby/object:Gem::Version
34
- version: '3'
35
29
  - !ruby/object:Gem::Dependency
36
30
  name: om
37
31
  requirement: !ruby/object:Gem::Requirement
@@ -78,50 +72,44 @@ dependencies:
78
72
  name: rubydora
79
73
  requirement: !ruby/object:Gem::Requirement
80
74
  requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- version: 1.8.0
84
- - - "<"
75
+ - - "~>"
85
76
  - !ruby/object:Gem::Version
86
- version: '3'
77
+ version: '1.8'
87
78
  type: :runtime
88
79
  prerelease: false
89
80
  version_requirements: !ruby/object:Gem::Requirement
90
81
  requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- version: 1.8.0
94
- - - "<"
82
+ - - "~>"
95
83
  - !ruby/object:Gem::Version
96
- version: '3'
84
+ version: '1.8'
97
85
  - !ruby/object:Gem::Dependency
98
86
  name: active-triples
99
87
  requirement: !ruby/object:Gem::Requirement
100
88
  requirements:
101
89
  - - "~>"
102
90
  - !ruby/object:Gem::Version
103
- version: 0.2.2
91
+ version: 0.4.0
104
92
  type: :runtime
105
93
  prerelease: false
106
94
  version_requirements: !ruby/object:Gem::Requirement
107
95
  requirements:
108
96
  - - "~>"
109
97
  - !ruby/object:Gem::Version
110
- version: 0.2.2
98
+ version: 0.4.0
111
99
  - !ruby/object:Gem::Dependency
112
100
  name: rdf-rdfxml
113
101
  requirement: !ruby/object:Gem::Requirement
114
102
  requirements:
115
103
  - - "~>"
116
104
  - !ruby/object:Gem::Version
117
- version: '1.1'
105
+ version: 1.1.0
118
106
  type: :runtime
119
107
  prerelease: false
120
108
  version_requirements: !ruby/object:Gem::Requirement
121
109
  requirements:
122
110
  - - "~>"
123
111
  - !ruby/object:Gem::Version
124
- version: '1.1'
112
+ version: 1.1.0
125
113
  - !ruby/object:Gem::Dependency
126
114
  name: deprecation
127
115
  requirement: !ruby/object:Gem::Requirement
@@ -210,16 +198,16 @@ dependencies:
210
198
  name: rspec-its
211
199
  requirement: !ruby/object:Gem::Requirement
212
200
  requirements:
213
- - - "~>"
201
+ - - ">="
214
202
  - !ruby/object:Gem::Version
215
- version: 1.0.1
203
+ version: '0'
216
204
  type: :development
217
205
  prerelease: false
218
206
  version_requirements: !ruby/object:Gem::Requirement
219
207
  requirements:
220
- - - "~>"
208
+ - - ">="
221
209
  - !ruby/object:Gem::Version
222
- version: 1.0.1
210
+ version: '0'
223
211
  - !ruby/object:Gem::Dependency
224
212
  name: equivalent-xml
225
213
  requirement: !ruby/object:Gem::Requirement
@@ -306,6 +294,9 @@ files:
306
294
  - config/solr.yml
307
295
  - config/solr_mappings_af_0.1.yml
308
296
  - config/solr_mappings_bl_2.4.yml
297
+ - gemfiles/rails3.gemfile
298
+ - gemfiles/rails4.1.gemfile
299
+ - gemfiles/rails4.gemfile
309
300
  - lib/active-fedora.rb
310
301
  - lib/active_fedora.rb
311
302
  - lib/active_fedora/association_relation.rb
@@ -358,10 +349,12 @@ files:
358
349
  - lib/active_fedora/querying.rb
359
350
  - lib/active_fedora/railtie.rb
360
351
  - lib/active_fedora/rdf.rb
352
+ - lib/active_fedora/rdf/fcrepo.rb
361
353
  - lib/active_fedora/rdf/identifiable.rb
362
354
  - lib/active_fedora/rdf/indexing.rb
363
355
  - lib/active_fedora/rdf/ntriples_rdf_datastream.rb
364
- - lib/active_fedora/rdf/object_resource.rb
356
+ - lib/active_fedora/rdf/persistence.rb
357
+ - lib/active_fedora/rdf/project_hydra.rb
365
358
  - lib/active_fedora/rdf/rdf_datastream.rb
366
359
  - lib/active_fedora/rdf/rdfxml_rdf_datastream.rb
367
360
  - lib/active_fedora/rdf_xml_writer.rb
@@ -521,6 +514,7 @@ files:
521
514
  - spec/unit/query_spec.rb
522
515
  - spec/unit/rdf_datastream_spec.rb
523
516
  - spec/unit/rdf_resource_datastream_spec.rb
517
+ - spec/unit/rdf_vocab_spec.rb
524
518
  - spec/unit/rdf_xml_writer_spec.rb
525
519
  - spec/unit/rdfxml_rdf_datastream_spec.rb
526
520
  - spec/unit/relationship_graph_spec.rb
@@ -555,13 +549,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
555
549
  version: 1.9.3
556
550
  required_rubygems_version: !ruby/object:Gem::Requirement
557
551
  requirements:
558
- - - ">="
552
+ - - ">"
559
553
  - !ruby/object:Gem::Version
560
- version: '0'
554
+ version: 1.3.1
561
555
  requirements: []
562
556
  rubyforge_project:
563
- rubygems_version: 2.6.8
557
+ rubygems_version: 2.2.2
564
558
  signing_key:
565
559
  specification_version: 4
566
560
  summary: A convenience libary for manipulating documents in the Fedora Repository.
567
561
  test_files: []
562
+ has_rdoc:
@@ -1,20 +0,0 @@
1
- module ActiveFedora::Rdf
2
- ##
3
- # A class of RdfResources to act as the primary/root resource associated
4
- # with a Datastream and ActiveFedora::Base object.
5
- #
6
- # @see ActiveFedora::RDFDatastream
7
- class ObjectResource < ActiveTriples::Resource
8
- configure :base_uri => 'info:fedora/'
9
- attr_accessor :datastream
10
-
11
- def persist!
12
- return false unless datastream and datastream.respond_to? :digital_object
13
- @persisted ||= datastream.digital_object.save
14
- end
15
-
16
- def persisted?
17
- @persisted ||= (not datastream.new?)
18
- end
19
- end
20
- end