active-fedora 10.2.1 → 10.3.0
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/lib/active_fedora/associations/has_many_association.rb +1 -1
- data/lib/active_fedora/core.rb +7 -7
- data/lib/active_fedora/fedora.rb +6 -2
- data/lib/active_fedora/indexing.rb +1 -1
- data/lib/active_fedora/version.rb +1 -1
- data/spec/unit/base_spec.rb +1 -1
- data/spec/unit/core/fedora_id_translator_spec.rb +2 -2
- data/spec/unit/core/fedora_uri_translator_spec.rb +2 -2
- data/spec/unit/core_spec.rb +5 -5
- data/spec/unit/file_spec.rb +2 -2
- data/spec/unit/has_many_association_spec.rb +24 -9
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3f4e8471f5df940e6d52c76f150fd1532aff2e7d
|
|
4
|
+
data.tar.gz: 79be63a9635f81dfe7a0017fe8890900e4ff598c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c2ff90b7a1a95255a21f55d72c55a488087087147629b29615380a041ba8da465a61274e850b52299955951f7a85bf398e4d0709db552cfb418d4ad2693b524f
|
|
7
|
+
data.tar.gz: 193eac22abf48bb8b3817d92d36fb25f977155648ee8f7c2493d271be6d01c4b2f0d4b587c501b2fe668a0f82d0e7cd0a4eba16af506d84da7136c5664ca0ff6
|
|
@@ -83,7 +83,7 @@ module ActiveFedora
|
|
|
83
83
|
protected
|
|
84
84
|
|
|
85
85
|
def find_polymorphic_inverse(record)
|
|
86
|
-
record.reflections.values.find { |r| !r.has_many? && r.
|
|
86
|
+
record.reflections.values.find { |r| !r.has_many? && r.predicate == reflection.predicate }
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
# Deletes the records according to the <tt>:dependent</tt> option.
|
data/lib/active_fedora/core.rb
CHANGED
|
@@ -26,7 +26,7 @@ module ActiveFedora
|
|
|
26
26
|
def initialize(attributes_or_id = nil, &_block)
|
|
27
27
|
init_internals
|
|
28
28
|
attributes = initialize_attributes(attributes_or_id)
|
|
29
|
-
@ldp_source = build_ldp_resource(attributes.delete(
|
|
29
|
+
@ldp_source = build_ldp_resource(attributes.delete('id'.freeze))
|
|
30
30
|
raise IllegalOperation, "Attempting to recreate existing ldp_source: `#{ldp_source.subject}'" unless ldp_source.new?
|
|
31
31
|
assert_content_model
|
|
32
32
|
load_attached_files
|
|
@@ -150,15 +150,15 @@ module ActiveFedora
|
|
|
150
150
|
case attributes_or_id
|
|
151
151
|
when String
|
|
152
152
|
Deprecation.warn(Core, "calling #{self.class}.new with a string is deprecated. Pass a hash with id instead.")
|
|
153
|
-
|
|
154
|
-
when Hash
|
|
155
|
-
attributes = attributes_or_id.with_indifferent_access
|
|
153
|
+
{ 'id': attributes_or_id }
|
|
156
154
|
when NilClass
|
|
157
|
-
|
|
155
|
+
{}
|
|
158
156
|
else
|
|
159
|
-
|
|
157
|
+
unless attributes_or_id.respond_to?(:stringify_keys)
|
|
158
|
+
raise ArgumentError, "#{attributes_or_id.class} is not acceptable"
|
|
159
|
+
end
|
|
160
|
+
attributes_or_id.stringify_keys
|
|
160
161
|
end
|
|
161
|
-
attributes
|
|
162
162
|
end
|
|
163
163
|
end
|
|
164
164
|
end
|
data/lib/active_fedora/fedora.rb
CHANGED
|
@@ -23,11 +23,15 @@ module ActiveFedora
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def host
|
|
26
|
-
@config[:url]
|
|
26
|
+
@config[:url].sub(/\/$/, BLANK)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def base_path
|
|
30
|
-
@config[:base_path] ||
|
|
30
|
+
@config[:base_path] || SLASH
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def base_uri
|
|
34
|
+
host + base_path.sub(/\/$/, BLANK)
|
|
31
35
|
end
|
|
32
36
|
|
|
33
37
|
def user
|
|
@@ -84,7 +84,7 @@ module ActiveFedora
|
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
def reindex_everything
|
|
87
|
-
descendants = descendant_uris(ActiveFedora
|
|
87
|
+
descendants = descendant_uris(ActiveFedora.fedora.base_uri)
|
|
88
88
|
descendants.shift # Discard the root uri
|
|
89
89
|
descendants.each do |uri|
|
|
90
90
|
logger.debug "Re-index everything ... #{uri}"
|
data/spec/unit/base_spec.rb
CHANGED
|
@@ -260,7 +260,7 @@ describe ActiveFedora::Base do
|
|
|
260
260
|
end
|
|
261
261
|
|
|
262
262
|
it "updates the resource" do
|
|
263
|
-
expect(test_object.resource.rdf_subject).to eq ::RDF::URI.new("#{ActiveFedora.fedora.
|
|
263
|
+
expect(test_object.resource.rdf_subject).to eq ::RDF::URI.new("#{ActiveFedora.fedora.base_uri}/#{@this_id}")
|
|
264
264
|
expect(test_object.title).to eq ['foo']
|
|
265
265
|
end
|
|
266
266
|
end
|
|
@@ -4,7 +4,7 @@ RSpec.describe ActiveFedora::Core::FedoraIdTranslator do
|
|
|
4
4
|
describe ".call" do
|
|
5
5
|
let(:result) { described_class.call(id) }
|
|
6
6
|
context "when given an id" do
|
|
7
|
-
let(:good_uri) { ActiveFedora.fedora.
|
|
7
|
+
let(:good_uri) { ActiveFedora.fedora.base_uri + "/banana" }
|
|
8
8
|
let(:id) { "banana" }
|
|
9
9
|
it "returns a fedora URI" do
|
|
10
10
|
expect(result).to eq good_uri
|
|
@@ -18,7 +18,7 @@ RSpec.describe ActiveFedora::Core::FedoraIdTranslator do
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
context "with characters that need escaping" do
|
|
21
|
-
let(:good_uri) { ActiveFedora.fedora.
|
|
21
|
+
let(:good_uri) { ActiveFedora.fedora.base_uri + "/%5Bfrob%5D" }
|
|
22
22
|
let(:id) { "[frob]" }
|
|
23
23
|
it "returns a good fedora URI" do
|
|
24
24
|
expect(result).to eq good_uri
|
|
@@ -4,13 +4,13 @@ RSpec.describe ActiveFedora::Core::FedoraUriTranslator do
|
|
|
4
4
|
describe ".call" do
|
|
5
5
|
let(:result) { described_class.call(uri) }
|
|
6
6
|
context "when given a Fedora URI" do
|
|
7
|
-
let(:uri) { ActiveFedora.fedora.
|
|
7
|
+
let(:uri) { ActiveFedora.fedora.base_uri + "/6" }
|
|
8
8
|
it "returns the id" do
|
|
9
9
|
expect(result).to eq '6'
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
context "when given a URI missing a slash" do
|
|
13
|
-
let(:uri) { ActiveFedora.fedora.
|
|
13
|
+
let(:uri) { ActiveFedora.fedora.base_uri + "602-a" }
|
|
14
14
|
it "returns the id" do
|
|
15
15
|
expect(result).to eq "602-a"
|
|
16
16
|
end
|
data/spec/unit/core_spec.rb
CHANGED
|
@@ -109,7 +109,7 @@ describe ActiveFedora::Base do
|
|
|
109
109
|
subject { described_class.id_to_uri(id) }
|
|
110
110
|
|
|
111
111
|
context "with no custom proc is set" do
|
|
112
|
-
it {
|
|
112
|
+
it { is_expected.to eq "#{ActiveFedora.fedora.base_uri}/123456w" }
|
|
113
113
|
it "justs call #translate_id_to_uri" do
|
|
114
114
|
allow(described_class).to receive(:translate_id_to_uri).and_call_original
|
|
115
115
|
allow(ActiveFedora::Core::FedoraIdTranslator).to receive(:call).and_call_original
|
|
@@ -122,11 +122,11 @@ describe ActiveFedora::Base do
|
|
|
122
122
|
|
|
123
123
|
context "when custom proc is set" do
|
|
124
124
|
before do
|
|
125
|
-
described_class.translate_id_to_uri = lambda { |id| "#{ActiveFedora.fedora.
|
|
125
|
+
described_class.translate_id_to_uri = lambda { |id| "#{ActiveFedora.fedora.base_uri}/foo/#{id}" }
|
|
126
126
|
end
|
|
127
127
|
after { described_class.translate_id_to_uri = nil }
|
|
128
128
|
|
|
129
|
-
it {
|
|
129
|
+
it { is_expected.to eq "#{ActiveFedora.fedora.base_uri}/foo/123456w" }
|
|
130
130
|
end
|
|
131
131
|
|
|
132
132
|
context "with an empty base path" do
|
|
@@ -145,8 +145,8 @@ describe ActiveFedora::Base do
|
|
|
145
145
|
end
|
|
146
146
|
|
|
147
147
|
describe "uri_to_id" do
|
|
148
|
-
let(:uri) { "#{ActiveFedora.fedora.
|
|
149
|
-
subject { described_class.uri_to_id(uri) }
|
|
148
|
+
let(:uri) { "#{ActiveFedora.fedora.base_uri}/foo/123456w" }
|
|
149
|
+
subject(:uri_id) { described_class.uri_to_id(uri) }
|
|
150
150
|
|
|
151
151
|
context "with no custom proc is set" do
|
|
152
152
|
it { should eq 'foo/123456w' }
|
data/spec/unit/file_spec.rb
CHANGED
|
@@ -51,14 +51,14 @@ describe ActiveFedora::File do
|
|
|
51
51
|
context "and it's initialized with the URI" do
|
|
52
52
|
let(:file) { described_class.new(parent.uri + "/FOO1") }
|
|
53
53
|
it "works" do
|
|
54
|
-
expect(subject.to_s).to eq "#{ActiveFedora.fedora.
|
|
54
|
+
expect(subject.to_s).to eq "#{ActiveFedora.fedora.base_uri}/1234/FOO1"
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
context "and it's initialized with an ID" do
|
|
59
59
|
let(:file) { described_class.new(parent.id + "/FOO1") }
|
|
60
60
|
it "works" do
|
|
61
|
-
expect(subject.to_s).to eq "#{ActiveFedora.fedora.
|
|
61
|
+
expect(subject.to_s).to eq "#{ActiveFedora.fedora.base_uri}/1234/FOO1"
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
end
|
|
@@ -32,19 +32,34 @@ describe ActiveFedora::Associations::HasManyAssociation do
|
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
describe "
|
|
36
|
-
before do
|
|
37
|
-
# :books must come first, so that we can test that is being passed over in favor of :contents
|
|
38
|
-
Page.has_many :books, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
|
39
|
-
Page.has_and_belongs_to_many :contents, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
|
40
|
-
end
|
|
35
|
+
describe "#find_polymorphic_inverse" do
|
|
41
36
|
let(:book_reflection) { ActiveFedora::Reflection.create(:has_many, 'pages', nil, { predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf }, Book) }
|
|
42
37
|
let(:association) { described_class.new(book, book_reflection) }
|
|
43
38
|
|
|
44
|
-
subject { association.send(:find_polymorphic_inverse, page) }
|
|
39
|
+
subject(:inverse) { association.send(:find_polymorphic_inverse, page) }
|
|
40
|
+
|
|
41
|
+
context "when a has_many is present" do
|
|
42
|
+
before do
|
|
43
|
+
# :books must come first, so that we can test that is being passed over in favor of :contents
|
|
44
|
+
Page.has_many :books, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
|
45
|
+
Page.has_and_belongs_to_many :contents, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "finds the HABTM reflection" do
|
|
49
|
+
expect(inverse.name).to eq :contents
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
context "when multiple belongs_to are present" do
|
|
54
|
+
before do
|
|
55
|
+
# :foo must come first, so that we can test that is being passed over in favor of :bar
|
|
56
|
+
Page.belongs_to :foo, predicate: ::RDF::Vocab::DC.isPartOf, class_name: 'ActiveFedora::Base'
|
|
57
|
+
Page.belongs_to :bar, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'ActiveFedora::Base'
|
|
58
|
+
end
|
|
45
59
|
|
|
46
|
-
|
|
47
|
-
|
|
60
|
+
it "finds the belongs_to reflection" do
|
|
61
|
+
expect(inverse.name).to eq :bar
|
|
62
|
+
end
|
|
48
63
|
end
|
|
49
64
|
end
|
|
50
65
|
|
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: 10.
|
|
4
|
+
version: 10.3.0
|
|
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: 2016-
|
|
13
|
+
date: 2016-11-21 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: rsolr
|
|
@@ -748,7 +748,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
748
748
|
version: '0'
|
|
749
749
|
requirements: []
|
|
750
750
|
rubyforge_project:
|
|
751
|
-
rubygems_version: 2.5.1
|
|
751
|
+
rubygems_version: 2.4.5.1
|
|
752
752
|
signing_key:
|
|
753
753
|
specification_version: 4
|
|
754
754
|
summary: A convenience libary for manipulating documents in the Fedora Repository.
|