active-fedora 9.9.0 → 9.10.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 +20 -6
- data/.travis.yml +2 -6
- data/History.txt +146 -0
- data/active-fedora.gemspec +11 -8
- data/lib/active_fedora/associations/association.rb +44 -14
- data/lib/active_fedora/associations/association_scope.rb +6 -2
- data/lib/active_fedora/associations/basic_contains_association.rb +2 -3
- data/lib/active_fedora/associations/belongs_to_association.rb +23 -14
- data/lib/active_fedora/associations/builder/association.rb +95 -41
- data/lib/active_fedora/associations/builder/belongs_to.rb +30 -2
- data/lib/active_fedora/associations/builder/collection_association.rb +36 -4
- data/lib/active_fedora/associations/builder/contains.rb +10 -5
- data/lib/active_fedora/associations/builder/directly_contains.rb +6 -8
- data/lib/active_fedora/associations/builder/directly_contains_one.rb +27 -20
- data/lib/active_fedora/associations/builder/has_and_belongs_to_many.rb +7 -3
- data/lib/active_fedora/associations/builder/has_many.rb +8 -45
- data/lib/active_fedora/associations/builder/indirectly_contains.rb +6 -8
- data/lib/active_fedora/associations/builder/property.rb +6 -12
- data/lib/active_fedora/associations/builder/singular_association.rb +3 -5
- data/lib/active_fedora/associations/builder/singular_property.rb +5 -4
- data/lib/active_fedora/associations/collection_association.rb +22 -26
- data/lib/active_fedora/associations/collection_proxy.rb +1 -1
- data/lib/active_fedora/associations/contained_finder.rb +1 -2
- data/lib/active_fedora/associations/directly_contains_one_association.rb +2 -3
- data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +1 -1
- data/lib/active_fedora/associations/has_many_association.rb +24 -5
- data/lib/active_fedora/associations/rdf.rb +1 -20
- data/lib/active_fedora/associations.rb +1 -1
- data/lib/active_fedora/attached_files.rb +2 -2
- data/lib/active_fedora/attribute_assignment.rb +55 -0
- data/lib/active_fedora/attribute_methods/read.rb +29 -44
- data/lib/active_fedora/attribute_methods/write.rb +16 -19
- data/lib/active_fedora/attribute_methods.rb +149 -29
- data/lib/active_fedora/attributes.rb +6 -18
- data/lib/active_fedora/autosave_association.rb +8 -12
- data/lib/active_fedora/base.rb +2 -2
- data/lib/active_fedora/caching_connection.rb +1 -1
- data/lib/active_fedora/callbacks.rb +9 -9
- data/lib/active_fedora/common.rb +67 -0
- data/lib/active_fedora/core.rb +11 -23
- data/lib/active_fedora/default_model_mapper.rb +24 -0
- data/lib/active_fedora/errors.rb +42 -0
- data/lib/active_fedora/fedora.rb +1 -1
- data/lib/active_fedora/file/attributes.rb +9 -10
- data/lib/active_fedora/file.rb +19 -56
- data/lib/active_fedora/file_persistence.rb +27 -0
- data/lib/active_fedora/indexing.rb +15 -9
- data/lib/active_fedora/indexing_service.rb +4 -4
- data/lib/active_fedora/inheritance.rb +34 -0
- data/lib/active_fedora/ldp_resource.rb +1 -0
- data/lib/active_fedora/model.rb +18 -16
- data/lib/active_fedora/model_classifier.rb +77 -0
- data/lib/active_fedora/nested_attributes.rb +145 -18
- data/lib/active_fedora/persistence.rb +23 -5
- data/lib/active_fedora/predicates.rb +3 -0
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +1 -1
- data/lib/active_fedora/query_result_builder.rb +12 -28
- data/lib/active_fedora/querying.rb +1 -1
- data/lib/active_fedora/rdf/datastream_indexing.rb +1 -1
- data/lib/active_fedora/reflection.rb +212 -80
- data/lib/active_fedora/relation/calculations.rb +1 -5
- data/lib/active_fedora/relation/finder_methods.rb +39 -26
- data/lib/active_fedora/relation.rb +17 -0
- data/lib/active_fedora/scoping/default.rb +117 -0
- data/lib/active_fedora/scoping/named.rb +152 -4
- data/lib/active_fedora/scoping.rb +85 -2
- data/lib/active_fedora/simple_datastream.rb +1 -1
- data/lib/active_fedora/solr_hit.rb +71 -0
- data/lib/active_fedora/solr_instance_loader.rb +12 -36
- data/lib/active_fedora/solr_query_builder.rb +20 -25
- data/lib/active_fedora/solr_service.rb +24 -13
- data/lib/active_fedora/type/boolean.rb +23 -0
- data/lib/active_fedora/type/value.rb +118 -0
- data/lib/active_fedora/type.rb +8 -0
- data/lib/active_fedora/validations.rb +14 -5
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora/versionable.rb +8 -7
- data/lib/active_fedora/with_metadata/metadata_node.rb +2 -1
- data/lib/active_fedora.rb +35 -15
- data/lib/generators/active_fedora/config/fedora/fedora_generator.rb +4 -0
- data/lib/generators/active_fedora/config/fedora/templates/.fcrepo_wrapper +3 -0
- data/lib/generators/active_fedora/config/solr/solr_generator.rb +4 -0
- data/lib/generators/active_fedora/config/solr/templates/.solr_wrapper +5 -0
- data/lib/generators/active_fedora/config/solr/templates/solr/config/solrconfig.xml +15 -0
- data/solr/config/solrconfig.xml +15 -0
- data/spec/config_helper.rb +0 -5
- data/spec/integration/associations_spec.rb +5 -5
- data/spec/integration/attached_files_spec.rb +4 -4
- data/spec/integration/base_spec.rb +4 -4
- data/spec/integration/bug_spec.rb +0 -1
- data/spec/integration/collection_association_spec.rb +34 -3
- data/spec/integration/file_spec.rb +2 -2
- data/spec/integration/full_featured_model_spec.rb +4 -4
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +1 -1
- data/spec/integration/has_many_associations_spec.rb +30 -1
- data/spec/integration/indirect_container_spec.rb +1 -1
- data/spec/integration/nested_attribute_spec.rb +6 -0
- data/spec/integration/ntriples_datastream_spec.rb +4 -4
- data/spec/integration/om_datastream_spec.rb +7 -7
- data/spec/integration/persistence_spec.rb +1 -1
- data/spec/integration/relation_delegation_spec.rb +1 -1
- data/spec/integration/scoped_query_spec.rb +13 -13
- data/spec/integration/solr_hit_spec.rb +52 -0
- data/spec/samples/hydra-mods_article_datastream.rb +2 -2
- data/spec/spec_helper.rb +5 -9
- data/spec/unit/active_fedora_spec.rb +0 -26
- data/spec/unit/attributes_spec.rb +13 -7
- data/spec/unit/base_spec.rb +20 -0
- data/spec/unit/builder/has_and_belongs_to_many_spec.rb +2 -3
- data/spec/unit/callback_spec.rb +3 -8
- data/spec/unit/collection_proxy_spec.rb +1 -1
- data/spec/unit/default_model_mapper_spec.rb +39 -0
- data/spec/unit/file_spec.rb +21 -2
- data/spec/unit/finder_methods_spec.rb +30 -6
- data/spec/unit/has_and_belongs_to_many_association_spec.rb +4 -4
- data/spec/unit/has_many_association_spec.rb +25 -3
- data/spec/unit/indexing_spec.rb +17 -3
- data/spec/unit/model_classifier_spec.rb +49 -0
- data/spec/unit/model_spec.rb +0 -9
- data/spec/unit/ntriples_datastream_spec.rb +16 -16
- data/spec/unit/om_datastream_spec.rb +7 -7
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -1
- data/spec/unit/query_result_builder_spec.rb +4 -10
- data/spec/unit/query_spec.rb +28 -28
- data/spec/unit/rdf/indexing_service_spec.rb +16 -16
- data/spec/unit/reflection_spec.rb +2 -2
- data/spec/unit/scoping_spec.rb +67 -0
- data/spec/unit/simple_datastream_spec.rb +2 -2
- data/spec/unit/solr_config_options_spec.rb +29 -32
- data/spec/unit/solr_hit_spec.rb +58 -0
- data/spec/unit/solr_query_builder_spec.rb +9 -1
- data/spec/unit/solr_service_spec.rb +19 -3
- data/spec/unit/validations_spec.rb +1 -1
- metadata +82 -20
- data/spec/support/freeze_mocks.rb +0 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8497f7de37069e9bfe075f4b7f9ac67a0e3c7d68
|
|
4
|
+
data.tar.gz: cb858eb8a45c08fec2dea7578b854cc51b4b5401
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6307a89a0b6417ef313efda00a37466cd0ef1f8a9bbb18dafb5f7fbbedc7dd87598f3213619604e6dac06f55eb985dc87c0b99b3f3e33369d213e038bbf56f02
|
|
7
|
+
data.tar.gz: d084f99333f8059f504b6735fde1bab7ace4868de441b2f48ced69d876a7271570007c9452acb4f10f22f05e39efa513130eb09562d1a8ad8d2151fbe7d60a0d
|
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
|
|
@@ -45,6 +43,9 @@ Metrics/CyclomaticComplexity:
|
|
|
45
43
|
- 'lib/active_fedora/file_configurator.rb'
|
|
46
44
|
- 'lib/active_fedora/file.rb'
|
|
47
45
|
- 'lib/active_fedora/datastreams/nokogiri_datastreams.rb'
|
|
46
|
+
- 'lib/active_fedora/attribute_methods.rb'
|
|
47
|
+
- 'lib/active_fedora/scoping/named.rb'
|
|
48
|
+
- 'lib/active_fedora/inheritance.rb'
|
|
48
49
|
|
|
49
50
|
Metrics/PerceivedComplexity:
|
|
50
51
|
Exclude:
|
|
@@ -58,6 +59,10 @@ Metrics/PerceivedComplexity:
|
|
|
58
59
|
- 'lib/active_fedora/associations/has_and_belongs_to_many_association.rb'
|
|
59
60
|
- 'lib/active_fedora/associations/builder/indirectly_contains.rb'
|
|
60
61
|
- 'lib/active_fedora/associations/builder/directly_contains_one.rb'
|
|
62
|
+
- 'lib/active_fedora/associations/collection_association.rb'
|
|
63
|
+
- 'lib/active_fedora/attribute_methods.rb'
|
|
64
|
+
- 'lib/active_fedora/scoping/named.rb'
|
|
65
|
+
- 'lib/active_fedora/inheritance.rb'
|
|
61
66
|
|
|
62
67
|
Metrics/ModuleLength:
|
|
63
68
|
Exclude:
|
|
@@ -67,6 +72,7 @@ Metrics/ModuleLength:
|
|
|
67
72
|
- 'lib/active_fedora/attributes.rb'
|
|
68
73
|
- 'lib/active_fedora/autosave_association.rb'
|
|
69
74
|
- 'lib/active_fedora/attached_files.rb'
|
|
75
|
+
- 'lib/active_fedora/nested_attributes.rb'
|
|
70
76
|
|
|
71
77
|
Metrics/ClassLength:
|
|
72
78
|
Exclude:
|
|
@@ -76,8 +82,11 @@ Metrics/ClassLength:
|
|
|
76
82
|
- 'lib/active_fedora/qualified_dublin_core_datastream.rb'
|
|
77
83
|
- 'lib/active_fedora/file_configurator.rb'
|
|
78
84
|
- 'lib/active_fedora/file.rb'
|
|
85
|
+
- 'lib/active_fedora/associations/association.rb'
|
|
86
|
+
- 'lib/active_fedora/associations/builder/association.rb'
|
|
79
87
|
- 'lib/active_fedora/associations/collection_proxy.rb'
|
|
80
88
|
- 'lib/active_fedora/associations/collection_association.rb'
|
|
89
|
+
- 'lib/active_fedora/reflection.rb'
|
|
81
90
|
|
|
82
91
|
Metrics/MethodLength:
|
|
83
92
|
Enabled: false
|
|
@@ -101,6 +110,7 @@ Style/AccessorMethodName:
|
|
|
101
110
|
|
|
102
111
|
Style/PredicateName:
|
|
103
112
|
Exclude:
|
|
113
|
+
- 'lib/active_fedora/attribute_methods.rb'
|
|
104
114
|
- 'lib/active_fedora/relation/finder_methods.rb'
|
|
105
115
|
- 'lib/active_fedora/versionable.rb'
|
|
106
116
|
- 'lib/active_fedora/reflection.rb'
|
|
@@ -204,10 +214,8 @@ Style/FileName:
|
|
|
204
214
|
- 'spec/samples/hydra-mods_article_datastream.rb'
|
|
205
215
|
|
|
206
216
|
Style/ZeroLengthPredicate:
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
Performance/RedundantMerge:
|
|
210
|
-
Enabled: false # https://github.com/bbatsov/rubocop/issues/2781
|
|
217
|
+
Exclude:
|
|
218
|
+
- 'lib/active_fedora/file/attributes.rb'
|
|
211
219
|
|
|
212
220
|
Rails:
|
|
213
221
|
Enabled: true
|
|
@@ -222,6 +230,9 @@ Rails/Date:
|
|
|
222
230
|
Rails/TimeZone:
|
|
223
231
|
Enabled: false
|
|
224
232
|
|
|
233
|
+
RSpec/AnyInstance:
|
|
234
|
+
Enabled: false
|
|
235
|
+
|
|
225
236
|
RSpec/ExampleWording:
|
|
226
237
|
CustomTransform:
|
|
227
238
|
be: is
|
|
@@ -244,3 +255,6 @@ RSpec/DescribeClass:
|
|
|
244
255
|
RSpec/DescribedClass:
|
|
245
256
|
Exclude:
|
|
246
257
|
- 'spec/unit/finder_methods_spec.rb'
|
|
258
|
+
|
|
259
|
+
RSpec/NotToNot:
|
|
260
|
+
Enabled: false
|
data/.travis.yml
CHANGED
|
@@ -2,17 +2,13 @@ language: ruby
|
|
|
2
2
|
cache: bundler
|
|
3
3
|
sudo: false
|
|
4
4
|
rvm:
|
|
5
|
-
- 2.
|
|
6
|
-
matrix:
|
|
7
|
-
include:
|
|
8
|
-
- rvm: 2.1
|
|
9
|
-
env: "RAILS_VERSION=4.2.4"
|
|
5
|
+
- 2.3.0
|
|
10
6
|
|
|
11
7
|
notifications:
|
|
12
8
|
irc: "irc.freenode.org#projecthydra"
|
|
13
9
|
|
|
14
10
|
env:
|
|
15
|
-
- "RAILS_VERSION=4.
|
|
11
|
+
- "RAILS_VERSION=4.2.6"
|
|
16
12
|
|
|
17
13
|
global_env:
|
|
18
14
|
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
data/History.txt
CHANGED
|
@@ -1,3 +1,149 @@
|
|
|
1
|
+
v9.10.0
|
|
2
|
+
2016-03-24: Continued alignment of associations with upstream changes [Chris
|
|
3
|
+
Beer]
|
|
4
|
+
|
|
5
|
+
2016-03-24: ActiveFedora::File.mime_type should be updatable [Chris Colvard]
|
|
6
|
+
|
|
7
|
+
2016-03-23: Update reflections and associations to reflect upstream changes
|
|
8
|
+
[Chris Beer]
|
|
9
|
+
|
|
10
|
+
2016-03-23: Generate default configs for fcrepo_wrapper [Justin Coyne]
|
|
11
|
+
|
|
12
|
+
2016-03-23: Generate solr_wrapper config file [Justin Coyne]
|
|
13
|
+
|
|
14
|
+
2016-03-22: Bump version to 9.10.0.pre2 [Justin Coyne]
|
|
15
|
+
|
|
16
|
+
2016-03-19: Update scoping with latest upstream changes [Chris Beer]
|
|
17
|
+
|
|
18
|
+
2016-03-22: Deprecate delegating attributes to associated objects [Justin Coyne]
|
|
19
|
+
|
|
20
|
+
2016-03-22: Add AttributeAssignment module from upstream [Chris Beer]
|
|
21
|
+
|
|
22
|
+
2016-03-21: Update AF::AttributeMethods with upstream changes [Chris Beer]
|
|
23
|
+
|
|
24
|
+
2016-03-21: Extract ActiveFedora::Common to share methods between AF::Base and
|
|
25
|
+
AF::File [Chris Beer]
|
|
26
|
+
|
|
27
|
+
2016-03-18: Update AF::File update callbacks to align with Rails [Chris Beer]
|
|
28
|
+
|
|
29
|
+
2016-03-18: Extract ActiveFedora::FilePersistence, so ActiveFedora::File can
|
|
30
|
+
work with AF::Callbacks [Chris Beer]
|
|
31
|
+
|
|
32
|
+
2016-03-18: Prefix internal create_ and update_record callbacks with an
|
|
33
|
+
underscore [Chris Beer]
|
|
34
|
+
|
|
35
|
+
2016-03-18: Add create_or_update to provide save callbacks [Chris Beer]
|
|
36
|
+
|
|
37
|
+
2016-03-18: Add ActiveFedora::Persistence#destroy! [Chris Beer]
|
|
38
|
+
|
|
39
|
+
2016-03-20: Correctly find the size of a collection in memory [Justin Coyne]
|
|
40
|
+
|
|
41
|
+
2016-03-18: Bump version to 9.10.0.pre1 [Justin Coyne]
|
|
42
|
+
|
|
43
|
+
2016-03-18: Update Validations with latest upstream changes [Chris Beer]
|
|
44
|
+
|
|
45
|
+
2016-03-18: Delegate count to the scope [Justin Coyne]
|
|
46
|
+
|
|
47
|
+
2016-03-18: Update nested attributes with upstream improvements [Chris Beer]
|
|
48
|
+
|
|
49
|
+
2016-03-18: Update reflection methods to match new upstream names [Chris Beer]
|
|
50
|
+
|
|
51
|
+
2016-03-18: Add explicit ActiveModel dependency [Chris Beer]
|
|
52
|
+
|
|
53
|
+
2016-03-18: Update minimum versions of ruby and activesupport [Chris Beer]
|
|
54
|
+
|
|
55
|
+
2016-03-17: Extract Builder::Association.create_reflection [Chris Beer]
|
|
56
|
+
|
|
57
|
+
2016-03-17: Delegate responsibility for cleaning up dependencies to association
|
|
58
|
+
instances [Chris Beer]
|
|
59
|
+
|
|
60
|
+
2016-03-17: validate dependent options [Chris Beer]
|
|
61
|
+
|
|
62
|
+
2016-03-17: Port .dangerous_attribute_method? from Rails [Chris Beer]
|
|
63
|
+
|
|
64
|
+
2016-03-17: Migrate valid_options from a class attribute to a method [Chris
|
|
65
|
+
Beer]
|
|
66
|
+
|
|
67
|
+
2016-03-17: Convert Assocations::Builder.macro from a class variable to a class
|
|
68
|
+
method [Chris Beer]
|
|
69
|
+
|
|
70
|
+
2016-03-15: Add default scopes [Justin Coyne]
|
|
71
|
+
|
|
72
|
+
2016-03-16: Unconditionally run coverage reports when running tests [Chris Beer]
|
|
73
|
+
|
|
74
|
+
2016-03-16: Remove or deprecate unused code [Chris Beer]
|
|
75
|
+
|
|
76
|
+
2016-03-16: Silence SolrQueryBuilder deprecation warnings when running tests
|
|
77
|
+
[Chris Beer]
|
|
78
|
+
|
|
79
|
+
2016-03-16: Update relation calculations to use SolrService.count [Chris Beer]
|
|
80
|
+
|
|
81
|
+
2016-03-16: Extract SolrService.get to send requests to Solr and get the
|
|
82
|
+
original response [Chris Beer]
|
|
83
|
+
|
|
84
|
+
2016-03-16: Use field queries instead of raw queries [Chris Beer]
|
|
85
|
+
|
|
86
|
+
2016-03-16: Deprecate ActiveFedora::SolrQueryBuilder.raw_query in favor of
|
|
87
|
+
.construct_query [Chris Beer]
|
|
88
|
+
|
|
89
|
+
2016-03-16: Deprecate ActiveFedora::SolrQueryBuilder.solr_name in favor of using
|
|
90
|
+
ActiveFedora.index_field_mapper directly [Chris Beer]
|
|
91
|
+
|
|
92
|
+
2016-03-15: Extract SolrHit class to wrap Solr response documents [Chris Beer]
|
|
93
|
+
|
|
94
|
+
2016-03-15: Deprecate unused methods [Justin Coyne]
|
|
95
|
+
|
|
96
|
+
2016-03-15: ActiveFedora depends on Solrizer [Justin Coyne]
|
|
97
|
+
|
|
98
|
+
2016-03-15: Don't rely on exceptions for flow control [Justin Coyne]
|
|
99
|
+
|
|
100
|
+
2016-03-15: Update testing versions of Ruby and Rails [Justin Coyne]
|
|
101
|
+
|
|
102
|
+
2016-03-15: Push .search_by_id into ActiveFedora::FinderMethod [Chris Beer]
|
|
103
|
+
|
|
104
|
+
2016-03-15: Rename find_with_conditions and find_in_batches to
|
|
105
|
+
search_with_conditions and search_in_batches [Chris Beer]
|
|
106
|
+
|
|
107
|
+
2016-03-11: Provide class-level accessors in place of global constants for
|
|
108
|
+
configuration [Chris Beer]
|
|
109
|
+
|
|
110
|
+
2016-03-11: Use ActiveFedora.index_field_mapper instead of accessing Solrizer
|
|
111
|
+
directly [Chris Beer]
|
|
112
|
+
|
|
113
|
+
2016-03-11: Use the same logic for lazy_reify_solr_results and
|
|
114
|
+
reify_solr_results [Chris Beer]
|
|
115
|
+
|
|
116
|
+
2016-03-10: Move indexer to a class attribute [Justin Coyne]
|
|
117
|
+
|
|
118
|
+
2016-03-09: Decompose ActiveFedora::Model into a generic model mapper and a
|
|
119
|
+
classifier [Chris Beer]
|
|
120
|
+
|
|
121
|
+
2016-03-09: Add DefaultModelMapper class to encapsulate model selection logic
|
|
122
|
+
[Chris Beer]
|
|
123
|
+
|
|
124
|
+
2016-03-09: Use ActiveFedora.model_mapper accessor to get the type to class
|
|
125
|
+
mapper [Chris Beer]
|
|
126
|
+
|
|
127
|
+
2016-03-09: Unify class lookup for Fedora types to ActiveFedora models [Chris
|
|
128
|
+
Beer]
|
|
129
|
+
|
|
130
|
+
2016-03-09: Move ActiveFedora.class_from_string into ActiveFedora::Model [Chris
|
|
131
|
+
Beer]
|
|
132
|
+
|
|
133
|
+
2016-03-09: Remove require of rubocop-rspec [Justin Coyne]
|
|
134
|
+
|
|
135
|
+
2016-03-09: Pin rake to ~> 10.0 [Justin Coyne]
|
|
136
|
+
|
|
137
|
+
2016-03-09: Update test to support ActiveModel 4.2.6 [Justin Coyne]
|
|
138
|
+
|
|
139
|
+
2016-03-08: Update to use ldp 0.5 [Chris Beer]
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
v9.9.1
|
|
143
|
+
2016-03-05: Restore autocommit in the update handler [Justin Coyne]
|
|
144
|
+
|
|
145
|
+
2016-03-04: Update rubocop [Chris Beer]
|
|
146
|
+
|
|
1
147
|
v9.9.0
|
|
2
148
|
2016-02-15: Update development configs to use environment variables [Justin
|
|
3
149
|
Coyne]
|
data/active-fedora.gemspec
CHANGED
|
@@ -12,29 +12,32 @@ Gem::Specification.new do |s|
|
|
|
12
12
|
s.summary = %q{A convenience libary for manipulating documents in the Fedora Repository.}
|
|
13
13
|
s.description = %q{ActiveFedora provides for creating and managing objects in the Fedora Repository Architecture.}
|
|
14
14
|
s.license = "APACHE2"
|
|
15
|
-
s.required_ruby_version
|
|
15
|
+
s.required_ruby_version = '~> 2.0'
|
|
16
16
|
|
|
17
|
-
s.add_dependency 'rsolr',
|
|
17
|
+
s.add_dependency 'rsolr', '~> 1.0', '>= 1.0.10'
|
|
18
|
+
s.add_dependency 'solrizer', '~> 3.4'
|
|
18
19
|
s.add_dependency 'om', '~> 3.1'
|
|
19
20
|
s.add_dependency 'nom-xml', '>= 0.5.1'
|
|
20
|
-
s.add_dependency "activesupport", '>= 4.
|
|
21
|
+
s.add_dependency "activesupport", '>= 4.2', '< 6'
|
|
22
|
+
s.add_dependency "activemodel", '>= 4.2', '< 6'
|
|
21
23
|
s.add_dependency "active-triples", '~> 0.7.1'
|
|
22
24
|
s.add_dependency "rdf-rdfxml", '~> 1.1'
|
|
23
25
|
s.add_dependency "linkeddata"
|
|
24
26
|
s.add_dependency "deprecation"
|
|
25
|
-
s.add_dependency "ldp", '~> 0.
|
|
27
|
+
s.add_dependency "ldp", '~> 0.5.0'
|
|
26
28
|
|
|
27
29
|
s.add_development_dependency "rdoc"
|
|
28
30
|
s.add_development_dependency "yard"
|
|
29
|
-
|
|
31
|
+
# Pin rake to 10.0 due to https://github.com/lsegal/yard/issues/947
|
|
32
|
+
s.add_development_dependency "rake", '~> 10.0'
|
|
30
33
|
s.add_development_dependency "solr_wrapper", "~> 0.4"
|
|
31
34
|
s.add_development_dependency 'fcrepo_wrapper', '~> 0.2'
|
|
32
35
|
s.add_development_dependency "rspec", "~> 3.0"
|
|
33
36
|
s.add_development_dependency "rspec-its"
|
|
34
37
|
s.add_development_dependency "equivalent-xml"
|
|
35
|
-
s.add_development_dependency "simplecov", '~> 0.
|
|
36
|
-
s.add_development_dependency "rubocop", '~> 0.
|
|
37
|
-
s.add_development_dependency "rubocop-rspec", '~> 1.
|
|
38
|
+
s.add_development_dependency "simplecov", '~> 0.8'
|
|
39
|
+
s.add_development_dependency "rubocop", '~> 0.37'
|
|
40
|
+
s.add_development_dependency "rubocop-rspec", '~> 1.4'
|
|
38
41
|
|
|
39
42
|
s.files = `git ls-files`.split("\n")
|
|
40
43
|
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
|
@@ -18,7 +18,7 @@ module ActiveFedora
|
|
|
18
18
|
@owner = owner
|
|
19
19
|
@reflection = reflection
|
|
20
20
|
reset
|
|
21
|
-
|
|
21
|
+
reset_scope
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
# Resets the \loaded flag to +false+ and sets the \target to +nil+.
|
|
@@ -32,7 +32,7 @@ module ActiveFedora
|
|
|
32
32
|
# Reloads the \target and returns +self+ on success.
|
|
33
33
|
def reload
|
|
34
34
|
reset
|
|
35
|
-
|
|
35
|
+
reset_scope
|
|
36
36
|
load_target
|
|
37
37
|
self unless @target.nil?
|
|
38
38
|
end
|
|
@@ -76,7 +76,11 @@ module ActiveFedora
|
|
|
76
76
|
# by scope.scoping { ... } or with_scope { ... } etc, which affects the scope which
|
|
77
77
|
# actually gets built.
|
|
78
78
|
def association_scope
|
|
79
|
-
@association_scope ||= AssociationScope.
|
|
79
|
+
@association_scope ||= AssociationScope.scope(self) if klass
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def reset_scope
|
|
83
|
+
@association_scope = nil
|
|
80
84
|
end
|
|
81
85
|
|
|
82
86
|
# Set the inverse association, if possible
|
|
@@ -111,12 +115,17 @@ module ActiveFedora
|
|
|
111
115
|
@target = find_target if (@stale_state && stale_target?) || find_target?
|
|
112
116
|
loaded! unless loaded?
|
|
113
117
|
target
|
|
118
|
+
rescue ActiveFedora::ObjectNotFoundError
|
|
119
|
+
reset
|
|
114
120
|
end
|
|
115
121
|
|
|
116
|
-
def initialize_attributes(record) #:nodoc:
|
|
122
|
+
def initialize_attributes(record, except_from_scope_attributes = nil) #:nodoc:
|
|
123
|
+
except_from_scope_attributes ||= {}
|
|
117
124
|
skip_assign = [reflection.foreign_key].compact
|
|
118
|
-
|
|
119
|
-
|
|
125
|
+
assigned_keys = record.changed
|
|
126
|
+
assigned_keys += except_from_scope_attributes.keys.map(&:to_s)
|
|
127
|
+
attributes = create_scope.except(*(assigned_keys - skip_assign))
|
|
128
|
+
record.assign_attributes(attributes)
|
|
120
129
|
set_inverse_instance(record)
|
|
121
130
|
end
|
|
122
131
|
|
|
@@ -126,6 +135,25 @@ module ActiveFedora
|
|
|
126
135
|
!loaded? && (!owner.new_record? || foreign_key_present?) && klass
|
|
127
136
|
end
|
|
128
137
|
|
|
138
|
+
def creation_attributes
|
|
139
|
+
attributes = {}
|
|
140
|
+
|
|
141
|
+
if (reflection.has_one? || reflection.collection?) && !options[:through]
|
|
142
|
+
attributes[reflection.foreign_key] = owner[reflection.active_record_primary_key]
|
|
143
|
+
|
|
144
|
+
if reflection.options[:as]
|
|
145
|
+
attributes[reflection.type] = owner.class.base_class.name
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
attributes
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Sets the owner attributes on the given record
|
|
153
|
+
def set_owner_attributes(record)
|
|
154
|
+
creation_attributes.each { |key, value| record[key] = value }
|
|
155
|
+
end
|
|
156
|
+
|
|
129
157
|
# Returns true if there is a foreign key present on the owner which
|
|
130
158
|
# references the target. This is used to determine whether we can load
|
|
131
159
|
# the target if the owner is currently a new record (and therefore
|
|
@@ -140,10 +168,16 @@ module ActiveFedora
|
|
|
140
168
|
# Raises ActiveFedora::AssociationTypeMismatch unless +record+ is of
|
|
141
169
|
# the kind of the class of the associated objects. Meant to be used as
|
|
142
170
|
# a sanity check when you are about to assign an associated record.
|
|
143
|
-
def raise_on_type_mismatch(record)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
171
|
+
def raise_on_type_mismatch!(record)
|
|
172
|
+
unless record.is_a?(reflection.klass)
|
|
173
|
+
fresh_class = reflection.class_name.safe_constantize
|
|
174
|
+
unless fresh_class && record.is_a?(fresh_class)
|
|
175
|
+
message = "#{reflection.class_name}(##{reflection.klass.object_id}) expected, got #{record.class}(##{record.class.object_id})"
|
|
176
|
+
raise ActiveFedora::AssociationTypeMismatch, message
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
type_validator.validate!(self, record)
|
|
147
181
|
end
|
|
148
182
|
|
|
149
183
|
def type_validator
|
|
@@ -176,10 +210,6 @@ module ActiveFedora
|
|
|
176
210
|
initialize_attributes(record)
|
|
177
211
|
end
|
|
178
212
|
end
|
|
179
|
-
|
|
180
|
-
def run_type_validator(record)
|
|
181
|
-
type_validator.validate!(self, record)
|
|
182
|
-
end
|
|
183
213
|
end
|
|
184
214
|
end
|
|
185
215
|
end
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
module ActiveFedora
|
|
2
2
|
module Associations
|
|
3
3
|
class AssociationScope #:nodoc:
|
|
4
|
+
def self.scope(association)
|
|
5
|
+
new(association).scope
|
|
6
|
+
end
|
|
7
|
+
|
|
4
8
|
attr_reader :association
|
|
5
9
|
|
|
6
10
|
delegate :klass, :owner, :reflection, :interpolate, to: :association
|
|
@@ -19,10 +23,10 @@ module ActiveFedora
|
|
|
19
23
|
|
|
20
24
|
def add_constraints(scope)
|
|
21
25
|
chain.each_with_index do |reflection, i|
|
|
22
|
-
if reflection.
|
|
26
|
+
if reflection.macro == :belongs_to
|
|
23
27
|
# Create a partial solr query using the ids. We may add additional filters such as class_name later
|
|
24
28
|
scope = scope.where(ActiveFedora::SolrQueryBuilder.construct_query_for_ids([owner[reflection.foreign_key]]))
|
|
25
|
-
elsif reflection.
|
|
29
|
+
elsif reflection.macro == :has_and_belongs_to_many
|
|
26
30
|
else
|
|
27
31
|
scope = scope.where(ActiveFedora::SolrQueryBuilder.construct_query_for_rel(association.send(:find_reflection) => owner.id))
|
|
28
32
|
end
|
|
@@ -18,7 +18,7 @@ module ActiveFedora
|
|
|
18
18
|
|
|
19
19
|
private
|
|
20
20
|
|
|
21
|
-
def raise_on_type_mismatch(record)
|
|
21
|
+
def raise_on_type_mismatch!(record)
|
|
22
22
|
return if record.is_a? LoadableFromJson::SolrBackedMetadataFile
|
|
23
23
|
super
|
|
24
24
|
end
|
|
@@ -35,8 +35,7 @@ module ActiveFedora
|
|
|
35
35
|
|
|
36
36
|
def replace(record)
|
|
37
37
|
if record
|
|
38
|
-
raise_on_type_mismatch(record)
|
|
39
|
-
run_type_validator(record)
|
|
38
|
+
raise_on_type_mismatch!(record)
|
|
40
39
|
@updated = true
|
|
41
40
|
end
|
|
42
41
|
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
module ActiveFedora
|
|
2
2
|
module Associations
|
|
3
3
|
class BelongsToAssociation < SingularAssociation #:nodoc:
|
|
4
|
+
def handle_dependency
|
|
5
|
+
target.send(options[:dependent]) if load_target
|
|
6
|
+
end
|
|
7
|
+
|
|
4
8
|
def replace(record)
|
|
5
9
|
if record
|
|
6
|
-
raise_on_type_mismatch(record)
|
|
7
|
-
|
|
8
|
-
# update_counters(record)
|
|
10
|
+
raise_on_type_mismatch!(record)
|
|
11
|
+
update_counters_on_replace(record)
|
|
9
12
|
replace_keys(record)
|
|
10
13
|
set_inverse_instance(record)
|
|
11
14
|
@updated = true
|
|
12
15
|
else
|
|
13
|
-
|
|
16
|
+
decrement_counters
|
|
14
17
|
remove_keys
|
|
15
18
|
end
|
|
16
19
|
|
|
@@ -26,8 +29,24 @@ module ActiveFedora
|
|
|
26
29
|
@updated
|
|
27
30
|
end
|
|
28
31
|
|
|
32
|
+
def decrement_counters # :nodoc:
|
|
33
|
+
# noop
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def increment_counters # :nodoc:
|
|
37
|
+
# noop
|
|
38
|
+
end
|
|
39
|
+
|
|
29
40
|
private
|
|
30
41
|
|
|
42
|
+
def find_target?
|
|
43
|
+
!loaded? && foreign_key_present? && klass
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def update_counters_on_replace(_record)
|
|
47
|
+
# noop
|
|
48
|
+
end
|
|
49
|
+
|
|
31
50
|
def replace_keys(record)
|
|
32
51
|
owner[reflection.foreign_key] = record.id
|
|
33
52
|
end
|
|
@@ -36,16 +55,6 @@ module ActiveFedora
|
|
|
36
55
|
owner[reflection.foreign_key] = nil
|
|
37
56
|
end
|
|
38
57
|
|
|
39
|
-
# Constructs a query that checks solr for the correct id & class_name combination
|
|
40
|
-
def construct_query(ids)
|
|
41
|
-
# Some descendants of ActiveFedora::Base are anonymous classes. They don't have names. Filter them out.
|
|
42
|
-
candidate_classes = klass.descendants.select(&:name)
|
|
43
|
-
candidate_classes += [klass] unless klass == ActiveFedora::Base
|
|
44
|
-
model_pairs = candidate_classes.each_with_object([]) { |klass, arr| arr << [:has_model, klass.to_class_uri] }
|
|
45
|
-
'(' + ActiveFedora::SolrQueryBuilder.construct_query_for_ids(ids) + ') AND (' +
|
|
46
|
-
ActiveFedora::SolrQueryBuilder.construct_query_for_rel(model_pairs, 'OR') + ')'
|
|
47
|
-
end
|
|
48
|
-
|
|
49
58
|
def foreign_key_present?
|
|
50
59
|
owner[reflection.foreign_key]
|
|
51
60
|
end
|