active-fedora 9.11.0 → 9.12.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/.rubocop.yml +1 -0
- data/lib/active_fedora.rb +6 -2
- data/lib/active_fedora/associations/collection_association.rb +6 -6
- data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +0 -1
- data/lib/active_fedora/associations/rdf.rb +6 -5
- data/lib/active_fedora/cleaner.rb +1 -1
- data/lib/active_fedora/fedora.rb +16 -0
- data/lib/active_fedora/file/streaming.rb +1 -1
- data/lib/active_fedora/runtime_registry.rb +9 -0
- data/lib/active_fedora/solr_hit.rb +1 -0
- data/lib/active_fedora/solr_service.rb +24 -14
- data/lib/active_fedora/version.rb +1 -1
- data/spec/integration/solr_hit_spec.rb +3 -2
- data/spec/unit/file/streaming_spec.rb +33 -0
- data/spec/unit/solr_service_spec.rb +37 -30
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02fb3ee9bf393052113ffdd4082e741bc155266c
|
4
|
+
data.tar.gz: 674c9e4a7a00220c1bb2011414dfdaf841b76100
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e8c4e554a899aa3109de27b30dfb1a64b0c3954cf2ad4c2e7c255413ed27bf8242ed8bd951f8364c18a92d49f346f800ffed9e52abc7af507143eff1e5631e2
|
7
|
+
data.tar.gz: e5d93de8c674af3aa2f27dc18a52c06bf35afd3a0e9ab0b4ad01522664015e86e8e83faa4938ec5dda2ee16df5f76bec22229f9c3c8557e6f89fcf7f41b87a58
|
data/.rubocop.yml
CHANGED
data/lib/active_fedora.rb
CHANGED
@@ -122,6 +122,7 @@ module ActiveFedora #:nodoc:
|
|
122
122
|
autoload :FinderMethods
|
123
123
|
end
|
124
124
|
|
125
|
+
autoload :RuntimeRegistry
|
125
126
|
autoload :Schema
|
126
127
|
autoload :Scoping
|
127
128
|
autoload :Serialization
|
@@ -170,6 +171,8 @@ module ActiveFedora #:nodoc:
|
|
170
171
|
end
|
171
172
|
end
|
172
173
|
|
174
|
+
extend Deprecation
|
175
|
+
|
173
176
|
class << self
|
174
177
|
attr_reader :fedora_config, :solr_config, :config_options
|
175
178
|
attr_accessor :configurator
|
@@ -231,11 +234,12 @@ module ActiveFedora #:nodoc:
|
|
231
234
|
end
|
232
235
|
|
233
236
|
def reset_fedora!
|
234
|
-
|
237
|
+
Deprecation.warn(ActiveFedora, 'ActiveFedora.reset_fedora! is deprecated; use ActiveFedora::Fedora.reset! instead. This will be removed in active-fedora 10.0')
|
238
|
+
ActiveFedora::Fedora.reset!
|
235
239
|
end
|
236
240
|
|
237
241
|
def fedora
|
238
|
-
|
242
|
+
ActiveFedora::Fedora.instance
|
239
243
|
end
|
240
244
|
|
241
245
|
delegate :predicate_config, to: :configurator
|
@@ -103,11 +103,11 @@ module ActiveFedora
|
|
103
103
|
other_array.each { |val| raise_on_type_mismatch!(val) }
|
104
104
|
|
105
105
|
load_target
|
106
|
-
|
107
|
-
|
106
|
+
deletions = @target - other_array
|
107
|
+
additions = other_array - @target
|
108
108
|
|
109
|
-
delete(
|
110
|
-
concat(
|
109
|
+
delete(deletions)
|
110
|
+
concat(additions)
|
111
111
|
end
|
112
112
|
|
113
113
|
def include?(record)
|
@@ -254,7 +254,7 @@ module ActiveFedora
|
|
254
254
|
end
|
255
255
|
|
256
256
|
def add_to_target(record, skip_callbacks = false)
|
257
|
-
#
|
257
|
+
# Start transaction
|
258
258
|
callback(:before_add, record) unless skip_callbacks
|
259
259
|
yield(record) if block_given?
|
260
260
|
|
@@ -266,7 +266,7 @@ module ActiveFedora
|
|
266
266
|
|
267
267
|
callback(:after_add, record) unless skip_callbacks
|
268
268
|
set_inverse_instance(record)
|
269
|
-
#
|
269
|
+
# End transaction
|
270
270
|
|
271
271
|
record
|
272
272
|
end
|
@@ -4,11 +4,12 @@ module ActiveFedora
|
|
4
4
|
def replace(values)
|
5
5
|
ids = Array(values).reject(&:blank?)
|
6
6
|
raise "can't modify frozen #{owner.class}" if owner.frozen?
|
7
|
-
|
8
|
-
ids.
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
current_objects = filtered_results
|
8
|
+
incoming_objects = ids.map { |id| ::RDF::URI(ActiveFedora::Base.id_to_uri(id)) }
|
9
|
+
deletions = current_objects - incoming_objects
|
10
|
+
additions = incoming_objects - current_objects
|
11
|
+
deletions.each { |object| owner.resource.delete([owner.rdf_subject, reflection.predicate, object]) }
|
12
|
+
additions.each { |object| owner.resource.insert([owner.rdf_subject, reflection.predicate, object]) }
|
12
13
|
owner.send(:attribute_will_change!, reflection.name)
|
13
14
|
end
|
14
15
|
|
data/lib/active_fedora/fedora.rb
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
module ActiveFedora
|
2
2
|
class Fedora
|
3
|
+
class << self
|
4
|
+
def register(options = {})
|
5
|
+
ActiveFedora::RuntimeRegistry.fedora_connection = Fedora.new(ActiveFedora.fedora_config.credentials.merge(options))
|
6
|
+
end
|
7
|
+
|
8
|
+
def instance
|
9
|
+
register unless ActiveFedora::RuntimeRegistry.fedora_connection
|
10
|
+
|
11
|
+
ActiveFedora::RuntimeRegistry.fedora_connection
|
12
|
+
end
|
13
|
+
|
14
|
+
def reset!
|
15
|
+
ActiveFedora::RuntimeRegistry.fedora_connection = nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
3
19
|
def initialize(config)
|
4
20
|
@config = config
|
5
21
|
end
|
@@ -24,7 +24,7 @@ module ActiveFedora::File::Streaming
|
|
24
24
|
|
25
25
|
def each(no_of_requests_limit = 3, &block)
|
26
26
|
raise ArgumentError, 'HTTP redirect too deep' if no_of_requests_limit == 0
|
27
|
-
Net::HTTP.start(uri.host, uri.port) do |http|
|
27
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: (uri.scheme == 'https')) do |http|
|
28
28
|
request = Net::HTTP::Get.new uri, headers
|
29
29
|
http.request request do |response|
|
30
30
|
case response
|
@@ -5,22 +5,34 @@ module ActiveFedora
|
|
5
5
|
class SolrService
|
6
6
|
extend Deprecation
|
7
7
|
|
8
|
-
|
8
|
+
attr_writer :conn
|
9
9
|
|
10
|
-
def initialize(
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
def initialize(options = {})
|
11
|
+
@options = { read_timeout: 120, open_timeout: 120, url: 'http://localhost:8080/solr' }.merge(options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def conn
|
15
|
+
@conn ||= RSolr.connect @options
|
15
16
|
end
|
16
17
|
|
17
18
|
class << self
|
18
|
-
def register(
|
19
|
-
|
19
|
+
def register(*args)
|
20
|
+
options = args.extract_options!
|
21
|
+
|
22
|
+
if args.length == 1
|
23
|
+
Deprecation.warn(SolrService, "SolrService.register with a host argument is deprecated. Use `SolrService.register(url: host)` instead. This will be removed in active-fedora 10.0")
|
24
|
+
|
25
|
+
host = args.first
|
26
|
+
options[:url] = host if host
|
27
|
+
elsif args.length > 1
|
28
|
+
raise ArgumentError, "wrong number of arguments (#{args.length} for 0..2)"
|
29
|
+
end
|
30
|
+
|
31
|
+
ActiveFedora::RuntimeRegistry.solr_service = new(options)
|
20
32
|
end
|
21
33
|
|
22
34
|
def reset!
|
23
|
-
|
35
|
+
ActiveFedora::RuntimeRegistry.solr_service = nil
|
24
36
|
end
|
25
37
|
|
26
38
|
def select_path
|
@@ -30,12 +42,11 @@ module ActiveFedora
|
|
30
42
|
def instance
|
31
43
|
# Register Solr
|
32
44
|
|
33
|
-
unless
|
34
|
-
register(ActiveFedora.solr_config
|
45
|
+
unless ActiveFedora::RuntimeRegistry.solr_service
|
46
|
+
register(ActiveFedora.solr_config)
|
35
47
|
end
|
36
48
|
|
37
|
-
|
38
|
-
Thread.current[:solr_service]
|
49
|
+
ActiveFedora::RuntimeRegistry.solr_service
|
39
50
|
end
|
40
51
|
|
41
52
|
def lazy_reify_solr_results(solr_results, opts = {})
|
@@ -150,5 +161,4 @@ module ActiveFedora
|
|
150
161
|
end
|
151
162
|
end
|
152
163
|
end # SolrService
|
153
|
-
class SolrNotInitialized < StandardError; end
|
154
164
|
end # ActiveFedora
|
@@ -24,8 +24,7 @@ describe ActiveFedora::SolrHit do
|
|
24
24
|
title: 'My Title'
|
25
25
|
) }
|
26
26
|
|
27
|
-
let(:
|
28
|
-
let(:doc) { { 'id' => 'test-123', 'has_model_ssim' => ['Foo'], 'object_profile_ssm' => profile } }
|
27
|
+
let(:doc) { obj.to_solr }
|
29
28
|
let(:solr_hit) { described_class.new(doc) }
|
30
29
|
|
31
30
|
after do
|
@@ -44,6 +43,8 @@ describe ActiveFedora::SolrHit do
|
|
44
43
|
describe "#instantiate_with_json" do
|
45
44
|
subject { solr_hit.instantiate_with_json }
|
46
45
|
|
46
|
+
it { is_expected.to be_persisted }
|
47
|
+
|
47
48
|
it "finds the document in solr" do
|
48
49
|
expect(subject).to be_instance_of Foo
|
49
50
|
expect(subject.title).to eq 'My Title'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveFedora::File::Streaming do
|
4
|
+
let(:test_class) do
|
5
|
+
tc = Class.new
|
6
|
+
tc.send(:include, described_class)
|
7
|
+
tc
|
8
|
+
end
|
9
|
+
let(:streamer) do
|
10
|
+
streamer = test_class.new
|
11
|
+
allow(streamer).to receive(:uri).and_return(uri)
|
12
|
+
allow(streamer).to receive(:authorization_key).and_return("authorization_key")
|
13
|
+
streamer
|
14
|
+
end
|
15
|
+
|
16
|
+
context "without ssl" do
|
17
|
+
let(:uri) { "http://localhost/file/1" }
|
18
|
+
|
19
|
+
it do
|
20
|
+
expect(Net::HTTP).to receive(:start).with('localhost', 80, use_ssl: false).and_return(nil)
|
21
|
+
streamer.stream.each
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "with ssl" do
|
26
|
+
let(:uri) { "https://localhost/file/1" }
|
27
|
+
|
28
|
+
it do
|
29
|
+
expect(Net::HTTP).to receive(:start).with('localhost', 443, use_ssl: true).and_return(nil)
|
30
|
+
streamer.stream.each
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -2,43 +2,50 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::SolrService do
|
4
4
|
before do
|
5
|
-
|
5
|
+
described_class.reset!
|
6
6
|
end
|
7
7
|
|
8
|
-
after
|
9
|
-
described_class.
|
8
|
+
after do
|
9
|
+
described_class.reset!
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
describe '#conn' do
|
13
|
+
it "takes a n-arg constructor and configure for localhost" do
|
14
|
+
expect(RSolr).to receive(:connect).with(read_timeout: 120, open_timeout: 120, url: 'http://localhost:8080/solr')
|
15
|
+
described_class.register.conn
|
16
|
+
end
|
17
|
+
it "accepts host arg into constructor" do
|
18
|
+
expect(RSolr).to receive(:connect).with(read_timeout: 120, open_timeout: 120, url: 'http://fubar')
|
19
|
+
Deprecation.silence(described_class) do
|
20
|
+
described_class.register('http://fubar').conn
|
21
|
+
end
|
22
|
+
end
|
23
|
+
it "clobbers options" do
|
24
|
+
expect(RSolr).to receive(:connect).with(read_timeout: 120, open_timeout: 120, url: 'http://localhost:8080/solr', autocommit: :off, foo: :bar)
|
25
|
+
described_class.register(autocommit: :off, foo: :bar).conn
|
26
|
+
end
|
23
27
|
end
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
it "tries to initialize if the service not initialized, and fail if it does not succeed" do
|
32
|
-
expect(Thread.current[:solr_service]).to be_nil
|
33
|
-
expect(described_class).to receive(:register)
|
34
|
-
expect(proc { described_class.instance }).to raise_error(ActiveFedora::SolrNotInitialized)
|
29
|
+
describe '#conn=' do
|
30
|
+
let(:new_connection) { double }
|
31
|
+
it 'is settable' do
|
32
|
+
described_class.instance.conn = new_connection
|
33
|
+
expect(described_class.instance.conn).to eq new_connection
|
34
|
+
end
|
35
35
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
|
37
|
+
describe '.instance' do
|
38
|
+
it "sets the threadlocal solr service" do
|
39
|
+
ss = described_class.register(autocommit: :off, foo: :bar)
|
40
|
+
expect(ActiveFedora::RuntimeRegistry.solr_service).to eq ss
|
41
|
+
expect(described_class.instance).to eq ss
|
42
|
+
end
|
43
|
+
it "passes on solr_config when initializing the service" do
|
44
|
+
allow(RSolr).to receive(:connect)
|
45
|
+
allow(ActiveFedora).to receive(:solr_config).and_return(url: 'http://fubar', update_path: 'update_test')
|
46
|
+
expect(described_class).to receive(:register).with(hash_including(url: 'http://fubar', update_path: 'update_test')).and_call_original
|
47
|
+
described_class.instance
|
48
|
+
end
|
42
49
|
end
|
43
50
|
|
44
51
|
describe '#construct_query_for_pids' do
|
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.
|
4
|
+
version: 9.12.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-04-
|
13
|
+
date: 2016-04-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsolr
|
@@ -522,6 +522,7 @@ files:
|
|
522
522
|
- lib/active_fedora/rspec_matchers/belong_to_associated_active_fedora_object_matcher.rb
|
523
523
|
- lib/active_fedora/rspec_matchers/have_many_associated_active_fedora_objects_matcher.rb
|
524
524
|
- lib/active_fedora/rspec_matchers/have_predicate_matcher.rb
|
525
|
+
- lib/active_fedora/runtime_registry.rb
|
525
526
|
- lib/active_fedora/schema.rb
|
526
527
|
- lib/active_fedora/schema_indexing_strategy.rb
|
527
528
|
- lib/active_fedora/scoping.rb
|
@@ -688,6 +689,7 @@ files:
|
|
688
689
|
- spec/unit/core_spec.rb
|
689
690
|
- spec/unit/default_model_mapper_spec.rb
|
690
691
|
- spec/unit/fedora_spec.rb
|
692
|
+
- spec/unit/file/streaming_spec.rb
|
691
693
|
- spec/unit/file_configurator_spec.rb
|
692
694
|
- spec/unit/file_path_builder_spec.rb
|
693
695
|
- spec/unit/file_spec.rb
|
@@ -763,9 +765,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
763
765
|
version: '0'
|
764
766
|
requirements: []
|
765
767
|
rubyforge_project:
|
766
|
-
rubygems_version: 2.
|
768
|
+
rubygems_version: 2.5.1
|
767
769
|
signing_key:
|
768
770
|
specification_version: 4
|
769
771
|
summary: A convenience libary for manipulating documents in the Fedora Repository.
|
770
772
|
test_files: []
|
771
|
-
has_rdoc:
|