active-fedora 9.0.4 → 9.0.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/active-fedora.gemspec +1 -0
- data/lib/active_fedora/associations/builder/has_many.rb +1 -1
- data/lib/active_fedora/associations/contains_association.rb +3 -1
- data/lib/active_fedora/attached_files.rb +6 -3
- data/lib/active_fedora/change_set.rb +2 -2
- data/lib/active_fedora/fedora_attributes.rb +5 -1
- data/lib/active_fedora/file.rb +0 -15
- data/lib/active_fedora/nom_datastream.rb +6 -4
- data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +0 -4
- data/lib/active_fedora/version.rb +1 -1
- data/spec/integration/associations_spec.rb +31 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/base_spec.rb +15 -0
- data/spec/unit/change_set_spec.rb +4 -2
- data/spec/unit/simple_datastream_spec.rb +32 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 436ba8923ff37c5dd40860044ff513a17c7ad780
|
4
|
+
data.tar.gz: e9b48072342526acefc2ab0210a9da725057b118
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b58f0179c05783ff6897723088979c1605d5d4a1901b082e2893c6f1ef7b7023c701bd6a91fa345c9ce19833a0ce37a7040b250282ca07a2e8cd6e8f79fcdf8b
|
7
|
+
data.tar.gz: 47851b957993caf1586409266240480f8763b65643bcf41cc9269aaf717ffe010df2cd3ede6bf940aac648179bf20aa992a9920daf8266338e39a2578fb08d66
|
data/active-fedora.gemspec
CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
s.add_development_dependency "rake"
|
31
31
|
s.add_development_dependency "jettywrapper", ">= 2.0.0"
|
32
32
|
s.add_development_dependency "rspec", "~> 3.0"
|
33
|
+
s.add_development_dependency "rspec-its"
|
33
34
|
s.add_development_dependency "equivalent-xml"
|
34
35
|
s.add_development_dependency "simplecov", '~> 0.7.1'
|
35
36
|
|
@@ -53,7 +53,10 @@ module ActiveFedora
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
#
|
56
|
+
# Add an ActiveFedora::File to the object.
|
57
|
+
# @param [ActiveFedora::File] file
|
58
|
+
# @param [String] file_path
|
59
|
+
# @param [Hash] opts
|
57
60
|
# @return [String] path of the added datastream
|
58
61
|
def attach_file(file, file_path, opts={})
|
59
62
|
create_singleton_association(file_path)
|
@@ -80,9 +83,9 @@ module ActiveFedora
|
|
80
83
|
add_file(file, opts)
|
81
84
|
end
|
82
85
|
|
83
|
-
# Attach the given
|
86
|
+
# Attach the given stream/string to object
|
84
87
|
#
|
85
|
-
# @param [
|
88
|
+
# @param [IO, String] file the file to add
|
86
89
|
# @param [Hash] opts options: :dsid, :prefix, :mime_type
|
87
90
|
# @option opts [String] :path The file path
|
88
91
|
# @option opts [String] :prefix The path prefix (for auto-generated path)
|
@@ -19,8 +19,8 @@ module ActiveFedora
|
|
19
19
|
|
20
20
|
def changes
|
21
21
|
@changes ||= changed_attributes.each_with_object({}) do |key, result|
|
22
|
-
if
|
23
|
-
predicate = object.association(
|
22
|
+
if object.respond_to?(:association) && object.association(key.to_sym).present?
|
23
|
+
predicate = object.association(key.to_sym).reflection.predicate
|
24
24
|
result[predicate] = graph.query(predicate: predicate)
|
25
25
|
elsif object.class.properties.keys.include?(key)
|
26
26
|
predicate = graph.reflections.reflect_on_property(key).predicate
|
@@ -5,7 +5,7 @@ module ActiveFedora
|
|
5
5
|
included do
|
6
6
|
include ActiveTriples::Properties
|
7
7
|
include ActiveTriples::Reflection
|
8
|
-
delegate :rdf_subject, :get_values, to: :resource
|
8
|
+
delegate :rdf_subject, :get_values, :type, to: :resource
|
9
9
|
|
10
10
|
property :has_model, predicate: ActiveFedora::RDF::Fcrepo::Model.hasModel
|
11
11
|
property :create_date, predicate: ActiveFedora::RDF::Fcrepo4.created
|
@@ -76,6 +76,10 @@ module ActiveFedora
|
|
76
76
|
klass
|
77
77
|
end
|
78
78
|
end
|
79
|
+
|
80
|
+
def type(uri)
|
81
|
+
resource_class.configure type: uri
|
82
|
+
end
|
79
83
|
end
|
80
84
|
end
|
81
85
|
end
|
data/lib/active_fedora/file.rb
CHANGED
@@ -156,21 +156,6 @@ module ActiveFedora
|
|
156
156
|
super || content_changed?
|
157
157
|
end
|
158
158
|
|
159
|
-
|
160
|
-
class << self
|
161
|
-
def default_attributes
|
162
|
-
{}
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
def default_attributes
|
167
|
-
@default_attributes ||= self.class.default_attributes
|
168
|
-
end
|
169
|
-
|
170
|
-
def default_attributes= attributes
|
171
|
-
@default_attributes = default_attributes.merge attributes
|
172
|
-
end
|
173
|
-
|
174
159
|
def original_name= name
|
175
160
|
@original_name = name
|
176
161
|
end
|
@@ -18,10 +18,6 @@ module ActiveFedora
|
|
18
18
|
@terminology
|
19
19
|
end
|
20
20
|
|
21
|
-
def self.default_attributes
|
22
|
-
super.merge(:mimeType => 'text/xml')
|
23
|
-
end
|
24
|
-
|
25
21
|
def self.decorate_ng_xml(xml)
|
26
22
|
xml.set_terminology terminology_options, &terminology
|
27
23
|
xml.nom!
|
@@ -62,6 +58,12 @@ module ActiveFedora
|
|
62
58
|
def respond_to? *args
|
63
59
|
super || self.class.terminology.respond_to?(*args)
|
64
60
|
end
|
61
|
+
|
62
|
+
protected
|
63
|
+
|
64
|
+
def default_mime_type
|
65
|
+
'text/xml'
|
66
|
+
end
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
@@ -24,6 +24,37 @@ describe ActiveFedora::Base do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
end
|
27
|
+
|
28
|
+
describe "explicit foreign key" do
|
29
|
+
before do
|
30
|
+
class FooThing < ActiveFedora::Base
|
31
|
+
has_many :bars, :class_name=>'BarThing', :predicate=>ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, :as=>:foothing
|
32
|
+
end
|
33
|
+
|
34
|
+
class BarThing < ActiveFedora::Base
|
35
|
+
belongs_to :foothing, :class_name=>'FooThing', :predicate=>ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
after do
|
40
|
+
Object.send(:remove_const, :FooThing)
|
41
|
+
Object.send(:remove_const, :BarThing)
|
42
|
+
end
|
43
|
+
|
44
|
+
let(:foo) { FooThing.create }
|
45
|
+
let(:bar) { BarThing.create }
|
46
|
+
|
47
|
+
it "should associate from bar to foo" do
|
48
|
+
bar.foothing = foo
|
49
|
+
bar.save
|
50
|
+
expect(foo.bars).to eq [bar]
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should associate from foo to bar" do
|
54
|
+
foo.bars << bar
|
55
|
+
expect(bar.foothing).to eq foo
|
56
|
+
end
|
57
|
+
end
|
27
58
|
|
28
59
|
describe "complex example" do
|
29
60
|
before do
|
data/spec/spec_helper.rb
CHANGED
data/spec/unit/base_spec.rb
CHANGED
@@ -28,6 +28,21 @@ describe ActiveFedora::Base do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
describe ".type" do
|
32
|
+
before do
|
33
|
+
class FooHistory < ActiveFedora::Base
|
34
|
+
type ::RDF::URI.new('http://example.com/foo')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
after do
|
38
|
+
Object.send(:remove_const, :FooHistory)
|
39
|
+
end
|
40
|
+
|
41
|
+
subject { FooHistory.new().type }
|
42
|
+
|
43
|
+
it { is_expected.to eq [RDF::URI('http://example.com/foo')] }
|
44
|
+
end
|
45
|
+
|
31
46
|
describe 'descendants' do
|
32
47
|
it "should record the decendants" do
|
33
48
|
expect(ActiveFedora::Base.descendants).to include(ModsArticle, SpecialThing)
|
@@ -18,10 +18,12 @@ describe ActiveFedora::ChangeSet do
|
|
18
18
|
class Book < ActiveFedora::Base
|
19
19
|
belongs_to :library, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasConstituent
|
20
20
|
property :title, predicate: ::RDF::DC.title
|
21
|
+
property :alt_id, predicate: ::RDF::DC.identifier
|
21
22
|
end
|
22
23
|
|
23
24
|
base.library_id = 'foo'
|
24
25
|
base.title = ['bar']
|
26
|
+
base.alt_id = ['12345']
|
25
27
|
end
|
26
28
|
after do
|
27
29
|
Object.send(:remove_const, :Library)
|
@@ -36,8 +38,8 @@ describe ActiveFedora::ChangeSet do
|
|
36
38
|
|
37
39
|
it { is_expected.to be_kind_of Hash }
|
38
40
|
|
39
|
-
it "should have
|
40
|
-
expect(subject.size).to eq
|
41
|
+
it "should have three elements" do
|
42
|
+
expect(subject.size).to eq 3
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
@@ -62,5 +62,37 @@ describe ActiveFedora::SimpleDatastream do
|
|
62
62
|
expect(solr[ActiveFedora::SolrQueryBuilder.solr_name('creation_date', type: :date)]).to eq "2012-01-15"
|
63
63
|
end
|
64
64
|
end
|
65
|
+
|
66
|
+
describe "datastream configuration" do
|
67
|
+
let(:foo) do
|
68
|
+
ActiveFedora::Base.create! do |obj|
|
69
|
+
obj.add_file(%{<?xml version="1.0"?>\n<fields><fubar>test</fubar></fields>}, path:'someData')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
let(:resource) { Ldp::Resource::RdfSource.new(ActiveFedora.fedora.connection, foo.uri) }
|
73
|
+
let(:orm) { Ldp::Orm.new(resource) }
|
74
|
+
|
75
|
+
before do
|
76
|
+
class FooHistory < ActiveFedora::Base
|
77
|
+
has_metadata :type=>ActiveFedora::SimpleDatastream, :name=>"someData" do |m|
|
78
|
+
m.field "fubar", :string
|
79
|
+
end
|
80
|
+
has_attributes :fubar, datastream: 'someData', multiple: false
|
81
|
+
end
|
82
|
+
|
83
|
+
orm.graph.delete([orm.resource.subject_uri, ActiveFedora::RDF::Fcrepo::Model.hasModel, nil])
|
84
|
+
orm.graph.insert([orm.resource.subject_uri, ActiveFedora::RDF::Fcrepo::Model.hasModel, 'FooHistory'])
|
85
|
+
orm.save
|
86
|
+
foo.reload
|
87
|
+
foo.update_index
|
88
|
+
end
|
89
|
+
|
90
|
+
after do
|
91
|
+
Object.send(:remove_const, :FooHistory)
|
92
|
+
end
|
93
|
+
|
94
|
+
subject { FooHistory.find(foo.id) }
|
95
|
+
its(:fubar) { is_expected.to eq 'test' }
|
96
|
+
end
|
65
97
|
|
66
98
|
end
|
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: 9.0.
|
4
|
+
version: 9.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Zumwalt
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-03-
|
13
|
+
date: 2015-03-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsolr
|
@@ -222,6 +222,20 @@ dependencies:
|
|
222
222
|
- - "~>"
|
223
223
|
- !ruby/object:Gem::Version
|
224
224
|
version: '3.0'
|
225
|
+
- !ruby/object:Gem::Dependency
|
226
|
+
name: rspec-its
|
227
|
+
requirement: !ruby/object:Gem::Requirement
|
228
|
+
requirements:
|
229
|
+
- - ">="
|
230
|
+
- !ruby/object:Gem::Version
|
231
|
+
version: '0'
|
232
|
+
type: :development
|
233
|
+
prerelease: false
|
234
|
+
version_requirements: !ruby/object:Gem::Requirement
|
235
|
+
requirements:
|
236
|
+
- - ">="
|
237
|
+
- !ruby/object:Gem::Version
|
238
|
+
version: '0'
|
225
239
|
- !ruby/object:Gem::Dependency
|
226
240
|
name: equivalent-xml
|
227
241
|
requirement: !ruby/object:Gem::Requirement
|