active-fedora 11.0.0.rc6 → 11.0.0.rc7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/active-fedora.gemspec +0 -3
- data/lib/active_fedora.rb +0 -10
- data/lib/active_fedora/associations/has_many_association.rb +1 -1
- data/lib/active_fedora/attributes.rb +1 -1
- data/lib/active_fedora/base.rb +3 -7
- data/lib/active_fedora/querying.rb +1 -1
- data/lib/active_fedora/rdf.rb +0 -1
- data/lib/active_fedora/version.rb +1 -1
- data/spec/integration/attached_files_spec.rb +14 -4
- data/spec/integration/file_spec.rb +22 -23
- data/spec/integration/versionable_spec.rb +0 -254
- data/spec/spec_helper.rb +0 -7
- data/spec/unit/attached_files_spec.rb +10 -7
- data/spec/unit/base_spec.rb +3 -1
- data/spec/unit/has_many_association_spec.rb +23 -8
- data/spec/unit/inheritance_spec.rb +11 -7
- data/spec/unit/model_classifier_spec.rb +1 -1
- data/spec/unit/rdf/indexing_service_spec.rb +9 -9
- data/spec/unit/solr_config_options_spec.rb +12 -15
- metadata +2 -67
- data/lib/active_fedora/datastreams.rb +0 -6
- data/lib/active_fedora/datastreams/nokogiri_datastreams.rb +0 -119
- data/lib/active_fedora/nom_datastream.rb +0 -73
- data/lib/active_fedora/om_datastream.rb +0 -118
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +0 -158
- data/lib/active_fedora/rdf/datastream_indexing.rb +0 -49
- data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +0 -13
- data/lib/active_fedora/rdf/rdf_datastream.rb +0 -173
- data/lib/active_fedora/rdf/rdfxml_datastream.rb +0 -13
- data/spec/integration/complex_rdf_datastream_spec.rb +0 -227
- data/spec/integration/datastream_rdf_nested_attributes_spec.rb +0 -180
- data/spec/integration/ntriples_datastream_spec.rb +0 -215
- data/spec/integration/om_datastream_spec.rb +0 -78
- data/spec/samples/hydra-mods_article_datastream.rb +0 -515
- data/spec/samples/models/mods_article.rb +0 -9
- data/spec/samples/samples.rb +0 -2
- data/spec/unit/nom_datastream_spec.rb +0 -60
- data/spec/unit/ntriples_datastream_spec.rb +0 -167
- data/spec/unit/om_datastream_spec.rb +0 -294
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +0 -119
- data/spec/unit/rdf_datastream_spec.rb +0 -84
- data/spec/unit/rdf_resource_datastream_spec.rb +0 -208
- data/spec/unit/rdfxml_datastream_spec.rb +0 -106
@@ -1,119 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ActiveFedora::QualifiedDublinCoreDatastream do
|
4
|
-
DC_ELEMENTS = [:contributor, :coverage, :creator, :date, :description, :identifier, :language, :publisher, :relation, :rights, :source].freeze
|
5
|
-
|
6
|
-
let(:sample_xml) do "<dc xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:dcterms='http://purl.org/dc/terms/'>
|
7
|
-
<dcterms:type xsi:type='DCMITYPE'>sound</dcterms:type>
|
8
|
-
<dcterms:medium>medium</dcterms:medium>
|
9
|
-
<dcterms:rights>rights</dcterms:rights>
|
10
|
-
<dcterms:language>English</dcterms:language>
|
11
|
-
<dcterms:temporal>tmp</dcterms:temporal>
|
12
|
-
<dcterms:subject>kw1</dcterms:subject>
|
13
|
-
<dcterms:subject>kw2</dcterms:subject>
|
14
|
-
<dcterms:creator>creator</dcterms:creator>
|
15
|
-
<dcterms:creator>creator</dcterms:creator>
|
16
|
-
<dcterms:contributor>contributor</dcterms:contributor>
|
17
|
-
<dcterms:coverage>coverage</dcterms:coverage>
|
18
|
-
<dcterms:identifier>identifier</dcterms:identifier>
|
19
|
-
<dcterms:relation>relation</dcterms:relation>
|
20
|
-
<dcterms:source>source</dcterms:source>
|
21
|
-
<dcterms:title>title</dcterms:title>
|
22
|
-
<dcterms:extent>extent</dcterms:extent>
|
23
|
-
<dcterms:format>audio/x-wav</dcterms:format>
|
24
|
-
<dcterms:subject xsi:type='LCSH'>sh1</dcterms:subject>
|
25
|
-
<dcterms:subject xsi:type='LCSH'>sh2</dcterms:subject>
|
26
|
-
<dcterms:spatial>sp1</dcterms:spatial>
|
27
|
-
<dcterms:spatial>sp2</dcterms:spatial>
|
28
|
-
<dcterms:publisher>jwa</dcterms:publisher>
|
29
|
-
<dcterms:alternative>alt</dcterms:alternative>
|
30
|
-
<dcterms:description>desc</dcterms:description>
|
31
|
-
<dcterms:date>datestr</dcterms:date>
|
32
|
-
</dc>"
|
33
|
-
end
|
34
|
-
before do
|
35
|
-
@test_ds = described_class.new
|
36
|
-
@test_ds.content = sample_xml
|
37
|
-
end
|
38
|
-
|
39
|
-
it "creates the right number of fields" do
|
40
|
-
expect(ActiveFedora::QualifiedDublinCoreDatastream::DCTERMS.size).to eq 54
|
41
|
-
end
|
42
|
-
|
43
|
-
it "has unmodifiable constants" do
|
44
|
-
expect { ActiveFedora::QualifiedDublinCoreDatastream::DCTERMS << :foo }.to raise_error(RuntimeError, /can't modify frozen array/i)
|
45
|
-
end
|
46
|
-
|
47
|
-
it "defaults dc elements to :multiple=>true" do
|
48
|
-
@test_ds.fields.values.each do |s|
|
49
|
-
expect(s.key?(:multiple)).to be true
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe '#new' do
|
54
|
-
it 'provides #new' do
|
55
|
-
expect(described_class).to respond_to(:new)
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "model methods" do
|
59
|
-
DC_ELEMENTS.each do |el|
|
60
|
-
it "should respond to getters and setters for #{el} element" do
|
61
|
-
pending if el == :type
|
62
|
-
value = "Hey #{el}"
|
63
|
-
@test_ds.send("#{el}=", value)
|
64
|
-
expect(@test_ds.send(el).first).to eq value # Looking at first because creator has 2 nodes
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe '.to_xml' do
|
71
|
-
it 'outputs the fields hash as Qualified Dublin Core XML' do
|
72
|
-
@test_ds = described_class.new
|
73
|
-
|
74
|
-
@test_ds.field :publisher
|
75
|
-
@test_ds.field :creator
|
76
|
-
@test_ds.field :title
|
77
|
-
|
78
|
-
@test_ds.publisher = ["publisher1"]
|
79
|
-
@test_ds.creator = ["creator1", "creator2"]
|
80
|
-
@test_ds.title = ["title1"]
|
81
|
-
|
82
|
-
expect(@test_ds.to_xml).to be_equivalent_to('
|
83
|
-
<dc xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
84
|
-
<dcterms:publisher>publisher1</dcterms:publisher>
|
85
|
-
<dcterms:creator>creator1</dcterms:creator>
|
86
|
-
<dcterms:creator>creator2</dcterms:creator>
|
87
|
-
<dcterms:title>title1</dcterms:title>
|
88
|
-
</dc>')
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe "#to_solr" do
|
93
|
-
it "has title" do
|
94
|
-
@test_ds = described_class.new
|
95
|
-
@test_ds.title = "War and Peace"
|
96
|
-
solr = @test_ds.to_solr
|
97
|
-
expect(solr[ActiveFedora.index_field_mapper.solr_name('title', type: :string)]).to eq "War and Peace"
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
describe 'custom fields' do
|
102
|
-
subject(:datastream) { described_class.new }
|
103
|
-
it 'grabs the term' do
|
104
|
-
sample_xml = "<dc xmlns:dcterms='http://purl.org/dc/terms/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><dcterms:cust>custom</dcterms:cust></dc>"
|
105
|
-
datastream.content = sample_xml
|
106
|
-
datastream.field :cust
|
107
|
-
expect(datastream.cust).to eq ['custom']
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
describe "#field should accept :path option" do
|
112
|
-
subject(:datastream) { described_class.new }
|
113
|
-
it "is able to map :dc_type to the path 'type'" do
|
114
|
-
datastream.content = sample_xml
|
115
|
-
datastream.field :dc_type, :string, path: "type", multiple: true
|
116
|
-
expect(datastream.dc_type).to eq ['sound']
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe ActiveFedora::RDFDatastream do
|
5
|
-
describe "a new instance" do
|
6
|
-
subject { described_class.new }
|
7
|
-
it { should be_metadata }
|
8
|
-
it { should_not be_content_changed }
|
9
|
-
end
|
10
|
-
|
11
|
-
describe "an instance that exists in the datastore, but hasn't been loaded" do
|
12
|
-
before do
|
13
|
-
class MyDatastream < ActiveFedora::NtriplesRDFDatastream
|
14
|
-
property :title, predicate: ::RDF::Vocab::DC.title
|
15
|
-
property :description, predicate: ::RDF::Vocab::DC.description
|
16
|
-
end
|
17
|
-
class MyObj < ActiveFedora::Base
|
18
|
-
has_subresource 'descMetadata', class_name: 'MyDatastream'
|
19
|
-
end
|
20
|
-
@obj = MyObj.new
|
21
|
-
@obj.descMetadata.title = 'Foobar'
|
22
|
-
@obj.save
|
23
|
-
end
|
24
|
-
after do
|
25
|
-
@obj.destroy
|
26
|
-
Object.send(:remove_const, :MyDatastream)
|
27
|
-
Object.send(:remove_const, :MyObj)
|
28
|
-
end
|
29
|
-
|
30
|
-
subject(:desc_metadata) { @obj.reload.descMetadata }
|
31
|
-
|
32
|
-
it "does not load the descMetadata datastream when calling content_changed?" do
|
33
|
-
expect(desc_metadata).to_not receive(:retrieve_content)
|
34
|
-
expect(desc_metadata).to_not be_content_changed
|
35
|
-
end
|
36
|
-
|
37
|
-
it "allows asserting an empty string" do
|
38
|
-
desc_metadata.title = ['']
|
39
|
-
expect(desc_metadata.title).to eq ['']
|
40
|
-
end
|
41
|
-
|
42
|
-
it "clears stuff" do
|
43
|
-
desc_metadata.title = ['one', 'two', 'three']
|
44
|
-
desc_metadata.title.clear
|
45
|
-
expect(desc_metadata.graph.query([desc_metadata.rdf_subject, ::RDF::Vocab::DC.title, nil]).first).to be_nil
|
46
|
-
end
|
47
|
-
|
48
|
-
it "has a list of fields" do
|
49
|
-
expect(MyDatastream.fields).to eq [:title, :description]
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "deserialize" do
|
54
|
-
subject(:datastream) { ActiveFedora::NtriplesRDFDatastream.new }
|
55
|
-
it "is able to handle non-utf-8 characters" do
|
56
|
-
# see https://github.com/ruby-rdf/rdf/issues/142
|
57
|
-
data = "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n\xE2\x80\x99 \" .\n".force_encoding('ASCII-8BIT')
|
58
|
-
|
59
|
-
result = datastream.deserialize(data)
|
60
|
-
expect(result.dump(:ntriples)).to eq "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe 'content=' do
|
65
|
-
let(:ds) { ActiveFedora::NtriplesRDFDatastream.new }
|
66
|
-
it "is able to handle non-utf-8 characters" do
|
67
|
-
data = "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n\xE2\x80\x99 \" .\n".force_encoding('ASCII-8BIT')
|
68
|
-
ds.content = data
|
69
|
-
expect(ds.resource.dump(:ntriples)).to eq "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n"
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe 'legacy non-utf-8 characters' do
|
74
|
-
let(:ds) do
|
75
|
-
ActiveFedora::NtriplesRDFDatastream.new.tap do |datastream|
|
76
|
-
allow(datastream).to receive(:new_record?).and_return(false)
|
77
|
-
allow(datastream).to receive(:remote_content).and_return("<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n\xE2\x80\x99 \" .\n".force_encoding('ASCII-8BIT'))
|
78
|
-
end
|
79
|
-
end
|
80
|
-
it "does not error on access" do
|
81
|
-
expect(ds.resource.dump(:ntriples)).to eq "<info:fedora/scholarsphere:qv33rx50r> <http://purl.org/dc/terms/description> \"\\n’ \" .\n"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
@@ -1,208 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ActiveFedora::RDFDatastream do
|
4
|
-
before do
|
5
|
-
class DummySubnode < ActiveTriples::Resource
|
6
|
-
property :title, predicate: ::RDF::Vocab::DC[:title], class_name: ::RDF::Literal
|
7
|
-
property :relation, predicate: ::RDF::Vocab::DC[:relation]
|
8
|
-
end
|
9
|
-
|
10
|
-
class DummyResource < ActiveFedora::RDFDatastream
|
11
|
-
property :title, predicate: ::RDF::Vocab::DC[:title], class_name: ::RDF::Literal
|
12
|
-
property :license, predicate: ::RDF::Vocab::DC[:license], class_name: DummySubnode
|
13
|
-
property :creator, predicate: ::RDF::Vocab::DC[:creator], class_name: 'DummyAsset'
|
14
|
-
|
15
|
-
def serialization_format
|
16
|
-
:ntriples
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class DummyAsset < ActiveFedora::Base
|
21
|
-
has_subresource 'descMetadata', class_name: 'DummyResource'
|
22
|
-
property :something, predicate: ::RDF::URI('http://example.com/thing')
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
after do
|
27
|
-
Object.send(:remove_const, "DummyAsset")
|
28
|
-
Object.send(:remove_const, "DummyResource")
|
29
|
-
Object.send(:remove_const, "DummySubnode")
|
30
|
-
end
|
31
|
-
|
32
|
-
subject(:resource) { DummyResource.new("#{ActiveFedora.fedora.host}/test/test:1") }
|
33
|
-
|
34
|
-
describe "attribute setting" do
|
35
|
-
context "on text attributes" do
|
36
|
-
before do
|
37
|
-
resource.title = "bla"
|
38
|
-
end
|
39
|
-
|
40
|
-
it "lets you access" do
|
41
|
-
expect(resource.title).to eq ["bla"]
|
42
|
-
end
|
43
|
-
|
44
|
-
it "marks it as changed" do
|
45
|
-
expect(resource).to be_changed
|
46
|
-
end
|
47
|
-
|
48
|
-
context "after it is persisted" do
|
49
|
-
before do
|
50
|
-
resource.save
|
51
|
-
resource.reload
|
52
|
-
end
|
53
|
-
|
54
|
-
it "is persisted" do
|
55
|
-
expect(resource.resource).to be_persisted
|
56
|
-
end
|
57
|
-
|
58
|
-
context "and it's reloaded" do
|
59
|
-
before do
|
60
|
-
resource.reload
|
61
|
-
end
|
62
|
-
|
63
|
-
it "is accessible after being saved" do
|
64
|
-
expect(resource.title).to eq ["bla"]
|
65
|
-
end
|
66
|
-
|
67
|
-
it "serializes to content" do
|
68
|
-
expect(resource.content).not_to be_blank
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context "and it is found again" do
|
73
|
-
before do
|
74
|
-
@object = DummyResource.new(resource.uri)
|
75
|
-
end
|
76
|
-
|
77
|
-
it "serializes to content" do
|
78
|
-
expect(@object.content).not_to be_blank
|
79
|
-
end
|
80
|
-
|
81
|
-
it "is accessible after being saved" do
|
82
|
-
expect(@object.title).to eq ["bla"]
|
83
|
-
end
|
84
|
-
|
85
|
-
it "has datastream content" do
|
86
|
-
expect(@object.remote_content).not_to be_blank
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
context "on rdf resource attributes" do
|
93
|
-
context "persisted to parent" do
|
94
|
-
before do
|
95
|
-
dummy = DummySubnode.new
|
96
|
-
dummy.title = 'subbla'
|
97
|
-
resource.license = dummy
|
98
|
-
end
|
99
|
-
|
100
|
-
it "lets you access" do
|
101
|
-
expect(resource.license.first.title).to eq ['subbla']
|
102
|
-
end
|
103
|
-
|
104
|
-
it "marks it as changed" do
|
105
|
-
expect(resource).to be_changed
|
106
|
-
end
|
107
|
-
end
|
108
|
-
context "persisted to repository" do
|
109
|
-
before do
|
110
|
-
allow_any_instance_of(DummySubnode).to receive(:repository).and_return(RDF::Repository.new)
|
111
|
-
dummy = DummySubnode.new(RDF::URI('http://example.org/dummy/blah'))
|
112
|
-
dummy.title = 'subbla'
|
113
|
-
# We want to have to manually persist to the repository.
|
114
|
-
# Parent objects shouldn't be persisting children they share with other parents
|
115
|
-
dummy.persist!
|
116
|
-
resource.license = dummy
|
117
|
-
end
|
118
|
-
|
119
|
-
it "lets you access" do
|
120
|
-
expect(resource.license.first.title).to eq ['subbla']
|
121
|
-
end
|
122
|
-
|
123
|
-
it "marks it as changed" do
|
124
|
-
expect(resource).to be_changed
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
describe "relationships" do
|
131
|
-
before do
|
132
|
-
@new_object = DummyAsset.create(something: ["subbla"])
|
133
|
-
resource.title = ["bla"]
|
134
|
-
resource.creator = @new_object
|
135
|
-
end
|
136
|
-
|
137
|
-
it "can set sub-properties to AF objects" do
|
138
|
-
expect(resource.creator).to eq [@new_object]
|
139
|
-
end
|
140
|
-
|
141
|
-
it "has accessible relationship attributes" do
|
142
|
-
expect(resource.creator.first.something).to eq ["subbla"]
|
143
|
-
end
|
144
|
-
|
145
|
-
it "lets me get to an AF:Base object" do
|
146
|
-
resource.save
|
147
|
-
new_resource = DummyResource.new(resource.uri)
|
148
|
-
expect(new_resource.creator.first).to be_kind_of(ActiveFedora::Base)
|
149
|
-
end
|
150
|
-
|
151
|
-
context "when the AF:Base object is deleted" do
|
152
|
-
before do
|
153
|
-
resource.save
|
154
|
-
@resource = DummyResource.new(resource.uri)
|
155
|
-
@new_object.destroy
|
156
|
-
end
|
157
|
-
it "gives back an ActiveTriples::Resource" do
|
158
|
-
expect(@resource.creator.first).to be_kind_of(ActiveTriples::Resource)
|
159
|
-
expect(@resource.creator.first.rdf_subject).to eq @new_object.resource.rdf_subject
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
it "allows for deep attributes to be set directly" do
|
164
|
-
resource.creator.first.something = ["Bla"]
|
165
|
-
expect(resource.creator.first.something).to eq ["Bla"]
|
166
|
-
end
|
167
|
-
|
168
|
-
context "when the subject is set with base_uri" do
|
169
|
-
before do
|
170
|
-
@old_uri = DummyResource.resource_class.base_uri
|
171
|
-
DummyResource.resource_class.configure base_uri: 'http://example.org/'
|
172
|
-
new_object = DummyAsset.new
|
173
|
-
new_object.save
|
174
|
-
resource.creator = new_object
|
175
|
-
end
|
176
|
-
after do
|
177
|
-
DummyResource.resource_class.configure base_uri: @old_uri
|
178
|
-
end
|
179
|
-
|
180
|
-
it "lets me get to an AF:Base object" do
|
181
|
-
resource.save
|
182
|
-
new_resource = DummyResource.new(resource.uri)
|
183
|
-
expect(new_resource.creator.first).to be_kind_of(ActiveFedora::Base)
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
context "when the object with a relationship is saved" do
|
188
|
-
before do
|
189
|
-
resource.save
|
190
|
-
end
|
191
|
-
|
192
|
-
it "is retrievable" do
|
193
|
-
expect(resource.creator.first.something).to eq ["subbla"]
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
context "when the object with a relationship is frozen" do
|
198
|
-
before do
|
199
|
-
resource.save
|
200
|
-
resource.freeze
|
201
|
-
end
|
202
|
-
|
203
|
-
it "is retrievable" do
|
204
|
-
expect(resource.creator.first.something).to eq ["subbla"]
|
205
|
-
end
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
@@ -1,106 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ActiveFedora::RDFXMLDatastream do
|
4
|
-
describe "a new instance" do
|
5
|
-
subject(:my_datastream) { MyRdfxmlDatastream.new }
|
6
|
-
before(:each) do
|
7
|
-
class MyRdfxmlDatastream < ActiveFedora::RDFXMLDatastream
|
8
|
-
property :publisher, predicate: ::RDF::Vocab::DC.publisher
|
9
|
-
end
|
10
|
-
allow(my_datastream).to receive(:id).and_return('test:1')
|
11
|
-
end
|
12
|
-
|
13
|
-
after(:each) do
|
14
|
-
Object.send(:remove_const, :MyRdfxmlDatastream)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "saves and reload" do
|
18
|
-
my_datastream.publisher = ["St. Martin's Press"]
|
19
|
-
expect(my_datastream.serialize).to match(/<rdf:RDF/)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "a complex data model" do
|
24
|
-
before do
|
25
|
-
class DAMS < RDF::Vocabulary("http://library.ucsd.edu/ontology/dams#")
|
26
|
-
property :title
|
27
|
-
property :relatedTitle
|
28
|
-
property :type
|
29
|
-
property :date
|
30
|
-
property :beginDate
|
31
|
-
property :endDate
|
32
|
-
property :language
|
33
|
-
property :typeOfResource
|
34
|
-
property :otherResource
|
35
|
-
property :RelatedResource
|
36
|
-
property :description
|
37
|
-
property :uri
|
38
|
-
property :relationship
|
39
|
-
property :Relationship
|
40
|
-
property :role
|
41
|
-
property :name
|
42
|
-
property :assembledCollection
|
43
|
-
property :Object
|
44
|
-
property :value
|
45
|
-
end
|
46
|
-
|
47
|
-
module RDF
|
48
|
-
# This enables RDF to respond_to? :value
|
49
|
-
def self.value
|
50
|
-
self[:value]
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
class MyDatastream < ActiveFedora::RDFXMLDatastream
|
55
|
-
property :resource_type, predicate: DAMS.typeOfResource
|
56
|
-
property :title, predicate: DAMS.title, class_name: 'Description'
|
57
|
-
|
58
|
-
rdf_subject { |ds| RDF::URI.new(ds.about) }
|
59
|
-
|
60
|
-
attr_accessor :about
|
61
|
-
|
62
|
-
def initialize(options = {})
|
63
|
-
@about = options.delete(:about)
|
64
|
-
super
|
65
|
-
end
|
66
|
-
|
67
|
-
class Description < ActiveTriples::Resource
|
68
|
-
configure type: DAMS.Description
|
69
|
-
property :value, predicate: ::RDF.value do |index|
|
70
|
-
index.as :searchable
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
after do
|
77
|
-
Object.send(:remove_const, :MyDatastream)
|
78
|
-
Object.send(:remove_const, :DAMS)
|
79
|
-
end
|
80
|
-
|
81
|
-
describe "a new instance" do
|
82
|
-
let(:my_datastream) { MyDatastream.new(about: "http://library.ucsd.edu/ark:/20775/") }
|
83
|
-
it "has a subject" do
|
84
|
-
expect(my_datastream.rdf_subject.to_s).to eq "http://library.ucsd.edu/ark:/20775/"
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe "an instance with content" do
|
89
|
-
let(:my_datastream) do
|
90
|
-
my_datastream = MyDatastream.new(about: "http://library.ucsd.edu/ark:/20775/")
|
91
|
-
my_datastream.content = File.new('spec/fixtures/damsObjectModel.xml').read
|
92
|
-
my_datastream
|
93
|
-
end
|
94
|
-
it "has a subject" do
|
95
|
-
expect(my_datastream.rdf_subject.to_s).to eq "http://library.ucsd.edu/ark:/20775/"
|
96
|
-
end
|
97
|
-
it "has mimeType" do
|
98
|
-
expect(my_datastream.mime_type).to eq 'text/xml'
|
99
|
-
end
|
100
|
-
it "has fields" do
|
101
|
-
expect(my_datastream.resource_type).to eq ["image"]
|
102
|
-
expect(my_datastream.title.first.value).to eq ["example title"]
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|