active-fedora 9.7.1 → 9.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +29 -2
- data/History.txt +5 -0
- data/active-fedora.gemspec +2 -2
- data/lib/active_fedora/autosave_association.rb +1 -1
- data/lib/active_fedora/nested_attributes.rb +1 -1
- data/lib/active_fedora/relation/finder_methods.rb +3 -3
- data/lib/active_fedora/scoping/named.rb +1 -0
- data/lib/active_fedora/solr_query_builder.rb +10 -3
- data/lib/active_fedora/version.rb +1 -1
- data/spec/integration/datastream_rdf_nested_attributes_spec.rb +3 -3
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +1 -1
- data/spec/integration/scoped_query_spec.rb +2 -1
- data/spec/samples/hydra-mods_article_datastream.rb +2 -4
- data/spec/unit/finder_methods_spec.rb +2 -2
- data/spec/unit/query_spec.rb +10 -10
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c903212b65a47dbc4d8bead4344376b8bbf354b1
|
4
|
+
data.tar.gz: ad8c00c8a9b6ece12d54255179838f0704a78e14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e349533000a57afd4a8bf6c189c553cf37cd90e6bd9e9b546557d45a497f88b4eace2de8a4434a039c855f7cb2c4668ca5a3254b064461239d6d72bd2a67585a
|
7
|
+
data.tar.gz: 11e2b687b719ff380e269938cdb25ee823c11b334d38e6f2dd244abcf35e9779e4483c3f9eae76e6181bae3fa721ddb277b5d045eab69c6b99fcf21460a61d0c
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require: rubocop-rspec
|
2
|
-
|
3
1
|
AllCops:
|
4
2
|
TargetRubyVersion: 2.2
|
5
3
|
DisplayCopNames: true
|
@@ -14,6 +12,7 @@ Lint/HandleExceptions:
|
|
14
12
|
- 'spec/unit/**/*'
|
15
13
|
- 'spec/integration/**/*'
|
16
14
|
- 'lib/active_fedora/cleaner.rb'
|
15
|
+
- 'lib/active_fedora/associations/builder/has_subresource.rb'
|
17
16
|
- 'lib/active_fedora/associations/builder/contains.rb'
|
18
17
|
|
19
18
|
Lint/AssignmentInCondition:
|
@@ -45,6 +44,9 @@ Metrics/CyclomaticComplexity:
|
|
45
44
|
- 'lib/active_fedora/file_configurator.rb'
|
46
45
|
- 'lib/active_fedora/file.rb'
|
47
46
|
- 'lib/active_fedora/datastreams/nokogiri_datastreams.rb'
|
47
|
+
- 'lib/active_fedora/attribute_methods.rb'
|
48
|
+
- 'lib/active_fedora/scoping/named.rb'
|
49
|
+
- 'lib/active_fedora/inheritance.rb'
|
48
50
|
|
49
51
|
Metrics/PerceivedComplexity:
|
50
52
|
Exclude:
|
@@ -58,6 +60,10 @@ Metrics/PerceivedComplexity:
|
|
58
60
|
- 'lib/active_fedora/associations/has_and_belongs_to_many_association.rb'
|
59
61
|
- 'lib/active_fedora/associations/builder/indirectly_contains.rb'
|
60
62
|
- 'lib/active_fedora/associations/builder/directly_contains_one.rb'
|
63
|
+
- 'lib/active_fedora/associations/collection_association.rb'
|
64
|
+
- 'lib/active_fedora/attribute_methods.rb'
|
65
|
+
- 'lib/active_fedora/scoping/named.rb'
|
66
|
+
- 'lib/active_fedora/inheritance.rb'
|
61
67
|
|
62
68
|
Metrics/ModuleLength:
|
63
69
|
Exclude:
|
@@ -67,6 +73,7 @@ Metrics/ModuleLength:
|
|
67
73
|
- 'lib/active_fedora/attributes.rb'
|
68
74
|
- 'lib/active_fedora/autosave_association.rb'
|
69
75
|
- 'lib/active_fedora/attached_files.rb'
|
76
|
+
- 'lib/active_fedora/nested_attributes.rb'
|
70
77
|
|
71
78
|
Metrics/ClassLength:
|
72
79
|
Exclude:
|
@@ -76,8 +83,13 @@ Metrics/ClassLength:
|
|
76
83
|
- 'lib/active_fedora/qualified_dublin_core_datastream.rb'
|
77
84
|
- 'lib/active_fedora/file_configurator.rb'
|
78
85
|
- 'lib/active_fedora/file.rb'
|
86
|
+
- 'lib/active_fedora/associations/association.rb'
|
87
|
+
- 'lib/active_fedora/associations/builder/association.rb'
|
79
88
|
- 'lib/active_fedora/associations/collection_proxy.rb'
|
80
89
|
- 'lib/active_fedora/associations/collection_association.rb'
|
90
|
+
- 'lib/active_fedora/reflection.rb'
|
91
|
+
- 'lib/active_fedora/orders/ordered_list.rb'
|
92
|
+
- 'lib/active_fedora/solr_service.rb'
|
81
93
|
|
82
94
|
Metrics/MethodLength:
|
83
95
|
Enabled: false
|
@@ -101,6 +113,7 @@ Style/AccessorMethodName:
|
|
101
113
|
|
102
114
|
Style/PredicateName:
|
103
115
|
Exclude:
|
116
|
+
- 'lib/active_fedora/attribute_methods.rb'
|
104
117
|
- 'lib/active_fedora/relation/finder_methods.rb'
|
105
118
|
- 'lib/active_fedora/versionable.rb'
|
106
119
|
- 'lib/active_fedora/reflection.rb'
|
@@ -113,10 +126,14 @@ Style/PredicateName:
|
|
113
126
|
- 'lib/active_fedora/attached_files.rb'
|
114
127
|
- 'lib/active_fedora/associations.rb'
|
115
128
|
- 'lib/active_fedora/association_hash.rb'
|
129
|
+
- 'lib/active_fedora/aggregation/list_source.rb'
|
130
|
+
- 'lib/active_fedora/associations/builder/aggregation.rb'
|
116
131
|
|
117
132
|
Style/GuardClause:
|
118
133
|
Exclude:
|
119
134
|
- 'lib/active_fedora/autosave_association.rb'
|
135
|
+
- 'lib/active_fedora/associations/builder/belongs_to.rb'
|
136
|
+
- 'lib/active_fedora/associations/builder/has_and_belongs_to_many.rb'
|
120
137
|
|
121
138
|
Style/TrivialAccessors:
|
122
139
|
Exclude:
|
@@ -203,6 +220,10 @@ Style/FileName:
|
|
203
220
|
- 'lib/active-fedora.rb'
|
204
221
|
- 'spec/samples/hydra-mods_article_datastream.rb'
|
205
222
|
|
223
|
+
Style/ZeroLengthPredicate:
|
224
|
+
Exclude:
|
225
|
+
- 'lib/active_fedora/file/attributes.rb'
|
226
|
+
|
206
227
|
Rails:
|
207
228
|
Enabled: true
|
208
229
|
|
@@ -216,6 +237,9 @@ Rails/Date:
|
|
216
237
|
Rails/TimeZone:
|
217
238
|
Enabled: false
|
218
239
|
|
240
|
+
RSpec/AnyInstance:
|
241
|
+
Enabled: false
|
242
|
+
|
219
243
|
RSpec/ExampleWording:
|
220
244
|
CustomTransform:
|
221
245
|
be: is
|
@@ -238,3 +262,6 @@ RSpec/DescribeClass:
|
|
238
262
|
RSpec/DescribedClass:
|
239
263
|
Exclude:
|
240
264
|
- 'spec/unit/finder_methods_spec.rb'
|
265
|
+
|
266
|
+
RSpec/NotToNot:
|
267
|
+
Enabled: false
|
data/History.txt
CHANGED
data/active-fedora.gemspec
CHANGED
@@ -32,8 +32,8 @@ Gem::Specification.new do |s|
|
|
32
32
|
s.add_development_dependency "rspec-its"
|
33
33
|
s.add_development_dependency "equivalent-xml"
|
34
34
|
s.add_development_dependency "simplecov", '~> 0.7.1'
|
35
|
-
s.add_development_dependency "rubocop", '~> 0.
|
36
|
-
s.add_development_dependency "rubocop-rspec", '~> 1.
|
35
|
+
s.add_development_dependency "rubocop", '~> 0.38.0'
|
36
|
+
s.add_development_dependency "rubocop-rspec", '~> 1.4.0'
|
37
37
|
|
38
38
|
s.files = `git ls-files`.split("\n")
|
39
39
|
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
@@ -75,7 +75,7 @@ module ActiveFedora
|
|
75
75
|
module AutosaveAssociation
|
76
76
|
extend ActiveSupport::Concern
|
77
77
|
|
78
|
-
ASSOCIATION_TYPES = %w(
|
78
|
+
ASSOCIATION_TYPES = %w(HasMany BelongsTo HasAndBelongsToMany DirectlyContains IndirectlyContains).freeze
|
79
79
|
|
80
80
|
module AssociationBuilderExtension #:nodoc:
|
81
81
|
def self.included(base)
|
@@ -113,7 +113,7 @@ module ActiveFedora
|
|
113
113
|
|
114
114
|
# Attribute hash keys that should not be assigned as normal attributes.
|
115
115
|
# These hash keys are nested attributes implementation details.
|
116
|
-
UNASSIGNABLE_KEYS = %w(
|
116
|
+
UNASSIGNABLE_KEYS = %w(id _destroy).freeze
|
117
117
|
|
118
118
|
def assign_nested_attributes_for_collection_association(association_name, attributes_collection)
|
119
119
|
options = nested_attributes_options[association_name]
|
@@ -260,13 +260,13 @@ module ActiveFedora
|
|
260
260
|
# @param [Hash<Symbol,String>] conditions
|
261
261
|
# @return [Array<String>]
|
262
262
|
def create_query_from_hash(conditions)
|
263
|
-
conditions.map { |key, value| condition_to_clauses(key, value) }.compact
|
263
|
+
conditions.map { |key, value| condition_to_clauses(key, value, ' OR ') }.compact
|
264
264
|
end
|
265
265
|
|
266
266
|
# @param [Symbol] key
|
267
267
|
# @param [String] value
|
268
|
-
def condition_to_clauses(key, value)
|
269
|
-
SolrQueryBuilder.construct_query([[field_name_for(key), value]])
|
268
|
+
def condition_to_clauses(key, value, join_with = SolrQueryBuilder.default_join_with)
|
269
|
+
SolrQueryBuilder.construct_query([[field_name_for(key), value]], join_with)
|
270
270
|
end
|
271
271
|
|
272
272
|
# If the key is a property name, turn it into a solr field
|
@@ -13,6 +13,7 @@ module ActiveFedora
|
|
13
13
|
#
|
14
14
|
# fruits = Fruit.all
|
15
15
|
# fruits = fruits.where(color: 'red') if options[:red_only]
|
16
|
+
# fruits = fruits.where(size: ['big', 'little']) # gets big or little fruit
|
16
17
|
# fruits = fruits.limit(10) if limited?
|
17
18
|
#
|
18
19
|
# You can define a scope that applies to all finders using
|
@@ -32,7 +32,7 @@ module ActiveFedora
|
|
32
32
|
# # => _query_:"{!raw f=has_model_ssim}info:fedora/afmodel:ComplexCollection" OR _query_:"{!raw f=has_model_ssim}info:fedora/afmodel:ActiveFedora_Base"
|
33
33
|
#
|
34
34
|
# construct_query_for_rel [[Book.reflect_on_association(:library), "foo/bar/baz"]]
|
35
|
-
def construct_query_for_rel(field_pairs, join_with =
|
35
|
+
def construct_query_for_rel(field_pairs, join_with = default_join_with)
|
36
36
|
field_pairs = field_pairs.to_a if field_pairs.is_a? Hash
|
37
37
|
construct_query(property_values_to_solr(field_pairs), join_with)
|
38
38
|
end
|
@@ -44,8 +44,15 @@ module ActiveFedora
|
|
44
44
|
# @example
|
45
45
|
# construct_query([['library_id_ssim', '123'], ['owner_ssim', 'Fred']])
|
46
46
|
# # => "_query_:\"{!raw f=library_id_ssim}123\" AND _query_:\"{!raw f=owner_ssim}Fred\""
|
47
|
-
def construct_query(field_pairs, join_with =
|
48
|
-
pairs_to_clauses(field_pairs)
|
47
|
+
def construct_query(field_pairs, join_with = default_join_with)
|
48
|
+
clauses = pairs_to_clauses(field_pairs)
|
49
|
+
return "" if clauses.count == 0
|
50
|
+
return clauses.first if clauses.count == 1
|
51
|
+
"(#{clauses.join(join_with)})"
|
52
|
+
end
|
53
|
+
|
54
|
+
def default_join_with
|
55
|
+
' AND '
|
49
56
|
end
|
50
57
|
|
51
58
|
private
|
@@ -91,8 +91,7 @@ describe "Nesting attribute behavior of RDFDatastream" do
|
|
91
91
|
}
|
92
92
|
# , "Hemings, Sally"
|
93
93
|
]
|
94
|
-
}
|
95
|
-
}
|
94
|
+
} }
|
96
95
|
end
|
97
96
|
|
98
97
|
describe "on lists" do
|
@@ -160,7 +159,8 @@ describe "Nesting attribute behavior of RDFDatastream" do
|
|
160
159
|
{ label: 'Alternator' },
|
161
160
|
{ label: 'Distributor' },
|
162
161
|
{ label: 'Transmission' },
|
163
|
-
{ label: 'Fuel Filter' }
|
162
|
+
{ label: 'Fuel Filter' }
|
163
|
+
] }
|
164
164
|
end
|
165
165
|
let(:replace_object_id) { subject.parts[1].rdf_subject.to_s }
|
166
166
|
let(:remove_object_id) { subject.parts[3].rdf_subject.to_s }
|
@@ -39,7 +39,7 @@ describe ActiveFedora::Querying do
|
|
39
39
|
result = ModelIntegrationSpec::Basic.all.to_a
|
40
40
|
expect(result).to be_instance_of(Array)
|
41
41
|
# this test is meaningless if the array length is zero
|
42
|
-
expect(result
|
42
|
+
expect(result).not_to be_empty
|
43
43
|
expect(result).to all(be_an(ModelIntegrationSpec::Basic))
|
44
44
|
end
|
45
45
|
end
|
@@ -67,6 +67,7 @@ describe ActiveFedora::Querying do
|
|
67
67
|
field = ActiveFedora::SolrQueryBuilder.solr_name('foo', type: :string)
|
68
68
|
expect(ModelIntegrationSpec::Basic.where(field => 'Beta')).to eq [test_instance1]
|
69
69
|
expect(ModelIntegrationSpec::Basic.where('foo' => 'Beta')).to eq [test_instance1]
|
70
|
+
expect(ModelIntegrationSpec::Basic.where('foo' => ['Beta', 'Alpha'])).to eq [test_instance1, test_instance2]
|
70
71
|
end
|
71
72
|
it "orders" do
|
72
73
|
expect(ModelIntegrationSpec::Basic.order(ActiveFedora::SolrQueryBuilder.solr_name('foo', :sortable) + ' asc')).to eq [test_instance2, test_instance1, test_instance3]
|
@@ -253,8 +253,7 @@ module Hydra
|
|
253
253
|
"edt" => "Editor",
|
254
254
|
"ill" => "Illustrator",
|
255
255
|
"oth" => "Other",
|
256
|
-
"trl" => "Translator"
|
257
|
-
}
|
256
|
+
"trl" => "Translator" }
|
258
257
|
end
|
259
258
|
|
260
259
|
def self.person_relator_terms
|
@@ -268,8 +267,7 @@ module Hydra
|
|
268
267
|
"res" => "Researcher",
|
269
268
|
"rth" => "Research team head",
|
270
269
|
"rtm" => "Research team member",
|
271
|
-
"trl" => "Translator"
|
272
|
-
}
|
270
|
+
"trl" => "Translator" }
|
273
271
|
end
|
274
272
|
|
275
273
|
def self.conference_relator_terms
|
@@ -43,8 +43,8 @@ describe ActiveFedora::FinderMethods do
|
|
43
43
|
|
44
44
|
context "when value is an array" do
|
45
45
|
let(:value) { ['one', 'four'] }
|
46
|
-
it { is_expected.to eq "_query_:\"{!raw f=library_id}one\" AND " \
|
47
|
-
"_query_:\"{!raw f=library_id}four\"" }
|
46
|
+
it { is_expected.to eq "(_query_:\"{!raw f=library_id}one\" AND " \
|
47
|
+
"_query_:\"{!raw f=library_id}four\")" }
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
data/spec/unit/query_spec.rb
CHANGED
@@ -78,8 +78,8 @@ describe ActiveFedora::Base do
|
|
78
78
|
let(:solr) { ActiveFedora::SolrService.instance.conn }
|
79
79
|
let(:expected_query) { "#{model_query} AND " \
|
80
80
|
"_query_:\"{!raw f=foo}bar\" AND " \
|
81
|
-
"_query_:\"{!raw f=baz}quix\"
|
82
|
-
"_query_:\"{!raw f=baz}quack\"" }
|
81
|
+
"(_query_:\"{!raw f=baz}quix\" OR " \
|
82
|
+
"_query_:\"{!raw f=baz}quack\")" }
|
83
83
|
let(:expected_params) { { params: { sort: [sort_query], fl: 'id', q: expected_query, qt: 'standard' } } }
|
84
84
|
let(:expected_sort_params) { { params: { sort: ["title_t desc"], fl: 'id', q: expected_query, qt: 'standard' } } }
|
85
85
|
let(:mock_docs) { [{ "id" => "changeme:30" }, { "id" => "changeme:22" }] }
|
@@ -137,8 +137,8 @@ describe ActiveFedora::Base do
|
|
137
137
|
let(:solr) { ActiveFedora::SolrService.instance.conn }
|
138
138
|
let(:expected_query) { "#{model_query} AND " \
|
139
139
|
"_query_:\"{!raw f=foo}bar\" AND " \
|
140
|
-
"_query_:\"{!raw f=baz}quix\"
|
141
|
-
"_query_:\"{!raw f=baz}quack\"" }
|
140
|
+
"(_query_:\"{!raw f=baz}quix\" OR " \
|
141
|
+
"_query_:\"{!raw f=baz}quack\")" }
|
142
142
|
let(:expected_params) { { params: { sort: [sort_query], fl: 'id', q: expected_query, qt: 'standard' } } }
|
143
143
|
let(:mock_docs) { [{ "id" => "changeme-30" }, { "id" => "changeme-22" }] }
|
144
144
|
|
@@ -158,8 +158,8 @@ describe ActiveFedora::Base do
|
|
158
158
|
let(:solr) { ActiveFedora::SolrService.instance.conn }
|
159
159
|
let(:expected_query) { "#{model_query} AND " \
|
160
160
|
"_query_:\"{!raw f=foo}bar\" AND " \
|
161
|
-
"_query_:\"{!raw f=baz}quix\"
|
162
|
-
"_query_:\"{!raw f=baz}quack\"" }
|
161
|
+
"(_query_:\"{!raw f=baz}quix\" OR " \
|
162
|
+
"_query_:\"{!raw f=baz}quack\")" }
|
163
163
|
let(:expected_params) { { params: { sort: [sort_query], fl: 'id', q: expected_query, qt: 'standard' } } }
|
164
164
|
let(:mock_docs) { double('docs') }
|
165
165
|
|
@@ -253,8 +253,8 @@ describe ActiveFedora::Base do
|
|
253
253
|
context "with a hash of conditions" do
|
254
254
|
let(:expected_query) { "#{model_query} AND " \
|
255
255
|
"_query_:\"{!raw f=foo}bar\" AND " \
|
256
|
-
"_query_:\"{!raw f=baz}quix\"
|
257
|
-
"_query_:\"{!raw f=baz}quack\"" }
|
256
|
+
"(_query_:\"{!raw f=baz}quix\" OR " \
|
257
|
+
"_query_:\"{!raw f=baz}quack\")" }
|
258
258
|
let(:conditions) { { foo: 'bar', baz: ['quix', 'quack'] } }
|
259
259
|
|
260
260
|
it "makes a query to solr and returns the results" do
|
@@ -265,8 +265,8 @@ describe ActiveFedora::Base do
|
|
265
265
|
context "with quotes in the params" do
|
266
266
|
let(:expected_query) { "#{model_query} AND " \
|
267
267
|
"_query_:\"{!raw f=foo}9\\\" Nails\" AND " \
|
268
|
-
"_query_:\"{!raw f=baz}7\\\" version\"
|
269
|
-
"_query_:\"{!raw f=baz}quack\"" }
|
268
|
+
"(_query_:\"{!raw f=baz}7\\\" version\" OR " \
|
269
|
+
"_query_:\"{!raw f=baz}quack\")" }
|
270
270
|
let(:conditions) { { foo: '9" Nails', baz: ['7" version', 'quack'] } }
|
271
271
|
|
272
272
|
it "escapes quotes" 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.7.
|
4
|
+
version: 9.7.2
|
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-01
|
13
|
+
date: 2016-07-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsolr
|
@@ -256,28 +256,28 @@ dependencies:
|
|
256
256
|
requirements:
|
257
257
|
- - "~>"
|
258
258
|
- !ruby/object:Gem::Version
|
259
|
-
version:
|
259
|
+
version: 0.38.0
|
260
260
|
type: :development
|
261
261
|
prerelease: false
|
262
262
|
version_requirements: !ruby/object:Gem::Requirement
|
263
263
|
requirements:
|
264
264
|
- - "~>"
|
265
265
|
- !ruby/object:Gem::Version
|
266
|
-
version:
|
266
|
+
version: 0.38.0
|
267
267
|
- !ruby/object:Gem::Dependency
|
268
268
|
name: rubocop-rspec
|
269
269
|
requirement: !ruby/object:Gem::Requirement
|
270
270
|
requirements:
|
271
271
|
- - "~>"
|
272
272
|
- !ruby/object:Gem::Version
|
273
|
-
version:
|
273
|
+
version: 1.4.0
|
274
274
|
type: :development
|
275
275
|
prerelease: false
|
276
276
|
version_requirements: !ruby/object:Gem::Requirement
|
277
277
|
requirements:
|
278
278
|
- - "~>"
|
279
279
|
- !ruby/object:Gem::Version
|
280
|
-
version:
|
280
|
+
version: 1.4.0
|
281
281
|
description: ActiveFedora provides for creating and managing objects in the Fedora
|
282
282
|
Repository Architecture.
|
283
283
|
email:
|
@@ -638,7 +638,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
638
638
|
version: '0'
|
639
639
|
requirements: []
|
640
640
|
rubyforge_project:
|
641
|
-
rubygems_version: 2.
|
641
|
+
rubygems_version: 2.6.4
|
642
642
|
signing_key:
|
643
643
|
specification_version: 4
|
644
644
|
summary: A convenience libary for manipulating documents in the Fedora Repository.
|