active-fedora 13.3.0 → 14.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +106 -46
  3. data/.rubocop.yml +26 -12
  4. data/.rubocop_todo.yml +1 -1
  5. data/Gemfile +3 -3
  6. data/active-fedora.gemspec +11 -11
  7. data/lib/active_fedora/association_hash.rb +5 -2
  8. data/lib/active_fedora/associations/association.rb +2 -4
  9. data/lib/active_fedora/associations/association_scope.rb +1 -1
  10. data/lib/active_fedora/associations/basic_contains_association.rb +2 -2
  11. data/lib/active_fedora/associations/belongs_to_association.rb +1 -1
  12. data/lib/active_fedora/associations/builder/association.rb +3 -5
  13. data/lib/active_fedora/associations/builder/basic_contains.rb +1 -1
  14. data/lib/active_fedora/associations/builder/belongs_to.rb +3 -7
  15. data/lib/active_fedora/associations/builder/collection_association.rb +7 -7
  16. data/lib/active_fedora/associations/builder/directly_contains.rb +4 -6
  17. data/lib/active_fedora/associations/builder/directly_contains_one.rb +5 -6
  18. data/lib/active_fedora/associations/builder/has_and_belongs_to_many.rb +1 -1
  19. data/lib/active_fedora/associations/builder/has_many.rb +1 -1
  20. data/lib/active_fedora/associations/builder/has_subresource.rb +1 -1
  21. data/lib/active_fedora/associations/builder/indirectly_contains.rb +3 -6
  22. data/lib/active_fedora/associations/builder/singular_association.rb +1 -1
  23. data/lib/active_fedora/associations/collection_association.rb +3 -6
  24. data/lib/active_fedora/associations/container_proxy.rb +2 -0
  25. data/lib/active_fedora/associations/contains_association.rb +2 -2
  26. data/lib/active_fedora/associations/directly_contains_association.rb +7 -9
  27. data/lib/active_fedora/associations/directly_contains_one_association.rb +2 -2
  28. data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +1 -1
  29. data/lib/active_fedora/associations/has_many_association.rb +4 -2
  30. data/lib/active_fedora/associations/has_subresource_association.rb +2 -4
  31. data/lib/active_fedora/associations/indirectly_contains_association.rb +10 -12
  32. data/lib/active_fedora/associations/orders_association.rb +7 -14
  33. data/lib/active_fedora/associations/rdf.rb +2 -2
  34. data/lib/active_fedora/associations/record_composite.rb +1 -0
  35. data/lib/active_fedora/associations/singular_association.rb +3 -1
  36. data/lib/active_fedora/associations/singular_rdf.rb +1 -1
  37. data/lib/active_fedora/associations.rb +3 -3
  38. data/lib/active_fedora/attached_files.rb +5 -3
  39. data/lib/active_fedora/attribute_assignment.rb +2 -4
  40. data/lib/active_fedora/attribute_methods/read.rb +1 -1
  41. data/lib/active_fedora/attribute_methods/write.rb +4 -6
  42. data/lib/active_fedora/attribute_methods.rb +7 -7
  43. data/lib/active_fedora/attributes/property_builder.rb +1 -1
  44. data/lib/active_fedora/attributes.rb +1 -1
  45. data/lib/active_fedora/autosave_association.rb +4 -4
  46. data/lib/active_fedora/callbacks.rb +3 -3
  47. data/lib/active_fedora/change_set.rb +5 -7
  48. data/lib/active_fedora/cleaner.rb +1 -1
  49. data/lib/active_fedora/core/fedora_id_translator.rb +1 -3
  50. data/lib/active_fedora/core.rb +6 -13
  51. data/lib/active_fedora/errors.rb +3 -3
  52. data/lib/active_fedora/fedora.rb +3 -7
  53. data/lib/active_fedora/file/attributes.rb +5 -5
  54. data/lib/active_fedora/file.rb +1 -1
  55. data/lib/active_fedora/file_configurator.rb +16 -14
  56. data/lib/active_fedora/file_io.rb +2 -4
  57. data/lib/active_fedora/files_hash.rb +2 -2
  58. data/lib/active_fedora/fixity_service.rb +5 -5
  59. data/lib/active_fedora/identifiable.rb +2 -18
  60. data/lib/active_fedora/indexing/default_descriptors.rb +3 -5
  61. data/lib/active_fedora/indexing/descendant_fetcher.rb +3 -3
  62. data/lib/active_fedora/indexing/descriptor.rb +1 -1
  63. data/lib/active_fedora/indexing/field_mapper.rb +3 -5
  64. data/lib/active_fedora/indexing.rb +9 -5
  65. data/lib/active_fedora/indexing_service.rb +2 -2
  66. data/lib/active_fedora/inheritance.rb +1 -3
  67. data/lib/active_fedora/ldp_resource.rb +3 -3
  68. data/lib/active_fedora/loadable_from_json.rb +5 -3
  69. data/lib/active_fedora/model_classifier.rb +2 -2
  70. data/lib/active_fedora/nested_attributes.rb +11 -21
  71. data/lib/active_fedora/null_logger.rb +2 -0
  72. data/lib/active_fedora/orders/list_node.rb +2 -3
  73. data/lib/active_fedora/orders/ordered_list.rb +16 -22
  74. data/lib/active_fedora/orders/target_proxy.rb +1 -1
  75. data/lib/active_fedora/querying.rb +1 -1
  76. data/lib/active_fedora/rdf/fcrepo.rb +3 -0
  77. data/lib/active_fedora/rdf/field_map.rb +0 -1
  78. data/lib/active_fedora/rdf/persistence.rb +1 -1
  79. data/lib/active_fedora/reflection.rb +8 -11
  80. data/lib/active_fedora/relation/finder_methods.rb +6 -12
  81. data/lib/active_fedora/relation/spawn_methods.rb +1 -1
  82. data/lib/active_fedora/runtime_registry.rb +2 -4
  83. data/lib/active_fedora/scoping/default.rb +2 -4
  84. data/lib/active_fedora/scoping/named.rb +1 -3
  85. data/lib/active_fedora/scoping.rb +2 -2
  86. data/lib/active_fedora/serialization.rb +1 -1
  87. data/lib/active_fedora/solr_service.rb +1 -3
  88. data/lib/active_fedora/version.rb +1 -1
  89. data/lib/active_fedora/versionable.rb +2 -2
  90. data/lib/active_fedora/versions_graph.rb +4 -6
  91. data/lib/active_fedora/with_metadata/metadata_node.rb +1 -1
  92. data/lib/active_fedora/with_metadata.rb +1 -1
  93. data/lib/active_fedora.rb +5 -7
  94. data/lib/generators/active_fedora/config/solr/templates/solr/conf/solrconfig.xml +3 -1
  95. data/lib/tasks/active_fedora_dev.rake +5 -5
  96. metadata +25 -52
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5833c4a96e372ae86f5727ec33d965f054ba21567c177c0b4340ecc2d6e7bb84
4
- data.tar.gz: 86204eff86f88f343876d0974ac446b60d087945bb856a7ec4854d0f91f3adfa
3
+ metadata.gz: c5ea2bfd359fe8ac2103cc2f22d4bfacb564a5a6fe0964d6586120dbba785035
4
+ data.tar.gz: 64b28f342a53d4b2176ae4fbcdf502a7acd6e2f533bb68b71d2664e8fd95cf35
5
5
  SHA512:
6
- metadata.gz: 70c86acbc2effa48e03911fc3a985918e5ce7004b7e02898ea841e95172db330a5c44a6cd3438513b76312d98b2dbe5b2116b4fdecfd978d15bf5715dbced3e4
7
- data.tar.gz: e473abc4f550bae98d519fd6e1617d6336e1427926702bc4d904e59cd9f49638b820b982350c174bd2f7f6f778ef3d53a196d46667e5c4bd1b3f285c99e7eaba
6
+ metadata.gz: 0dd1090c7c74aa2926172c858c32bc223120ffb29b75fa1b099f8a2f881e3cf4ca772c520b54241b6f72f5997aecb5149ce4a218339e8ce0d00ad4f3c42beec9
7
+ data.tar.gz: bb97c2be3c9b48fc185a1ce528234e1b7d96a497fa957810fd7c4546f087d4b6a4df7c6626e1340f74d2e5bd856a777d759ce98ddbb2a6c59e666c2bb31d398e
data/.circleci/config.yml CHANGED
@@ -47,41 +47,71 @@ jobs:
47
47
  workflows:
48
48
  ci:
49
49
  jobs:
50
+ # Ruby 3.2 releases
51
+ - bundle_lint_test:
52
+ name: ruby3-2_rails7-0
53
+ ruby_version: 3.2.0
54
+ rails_version: 7.0.4.1
55
+ - bundle_lint_test:
56
+ name: ruby3-2_rails6-1
57
+ ruby_version: 3.2.0
58
+ rails_version: 6.1.7.1
59
+ - bundle_lint_test:
60
+ name: ruby3-2_rails6-0
61
+ ruby_version: 3.2.0
62
+ rails_version: 6.0.6.1
63
+ # Ruby 3.1 releases
64
+ - bundle_lint_test:
65
+ name: ruby3-1_rails7-0
66
+ ruby_version: 3.1.3
67
+ rails_version: 7.0.4.1
68
+ - bundle_lint_test:
69
+ name: ruby3-1_rails6-1
70
+ ruby_version: 3.1.3
71
+ rails_version: 6.1.7.1
72
+ - bundle_lint_test:
73
+ name: ruby3-1_rails6-0
74
+ ruby_version: 3.1.3
75
+ rails_version: 6.0.6.1
76
+ # Ruby 3.0 releases
77
+ - bundle_lint_test:
78
+ name: ruby3-0_rails7-0
79
+ ruby_version: 3.0.5
80
+ rails_version: 7.0.4.1
81
+ - bundle_lint_test:
82
+ name: ruby3-0_rails6-1
83
+ ruby_version: 3.0.5
84
+ rails_version: 6.1.7.1
85
+ - bundle_lint_test:
86
+ name: ruby3-0_rails6-0
87
+ ruby_version: 3.0.5
88
+ rails_version: 6.0.6.1
50
89
  # Ruby 2.7 releases
90
+ - bundle_lint_test:
91
+ name: ruby2-7_rails7-0
92
+ ruby_version: 2.7.7
93
+ rails_version: 7.0.4.1
51
94
  - bundle_lint_test:
52
95
  name: ruby2-7_rails6-1
53
- ruby_version: 2.7.5
54
- rails_version: 6.1.6.1
96
+ ruby_version: 2.7.7
97
+ rails_version: 6.1.7.1
55
98
  - bundle_lint_test:
56
99
  name: ruby2-7_rails6-0
57
- ruby_version: 2.7.5
58
- rails_version: 6.0.4.7
100
+ ruby_version: 2.7.7
101
+ rails_version: 6.0.6.1
59
102
  - bundle_lint_test:
60
103
  name: ruby2-7_rails5-2
61
- ruby_version: 2.7.5
62
- rails_version: 5.2.4
104
+ ruby_version: 2.7.7
105
+ rails_version: 5.2.8.1
63
106
  # Ruby 2.6 releases
64
- - bundle_lint_test:
65
- name: ruby2-6_rails6-1
66
- ruby_version: 2.6.9
67
- rails_version: 6.1.6.1
68
107
  - bundle_lint_test:
69
108
  name: ruby2-6_rails6-0
70
- ruby_version: 2.6.9
71
- rails_version: 6.0.4.7
109
+ ruby_version: 2.6.10
110
+ rails_version: 6.0.6.1
72
111
  - bundle_lint_test:
73
112
  name: ruby2-6_rails5-2
74
- ruby_version: 2.6.9
75
- rails_version: 5.2.4
76
- # Ruby 2.5 releases
77
- - bundle_lint_test:
78
- name: ruby2-5_rails6.0
79
- ruby_version: 2.5.9
80
- rails_version: 6.0.4.7
81
- - bundle_lint_test:
82
- name: ruby2-5_rails5-2
83
- ruby_version: 2.5.9
84
- rails_version: 5.2.4
113
+ ruby_version: 2.6.10
114
+ rails_version: 5.2.8.1
85
115
 
86
116
  nightly:
87
117
  triggers:
@@ -92,38 +122,68 @@ workflows:
92
122
  only:
93
123
  - main
94
124
  jobs:
125
+ # Ruby 3.2 releases
126
+ - bundle_lint_test:
127
+ name: ruby3-2_rails7-0
128
+ ruby_version: 3.2.0
129
+ rails_version: 7.0.4.1
130
+ - bundle_lint_test:
131
+ name: ruby3-2_rails6-1
132
+ ruby_version: 3.2.0
133
+ rails_version: 6.1.7.1
134
+ - bundle_lint_test:
135
+ name: ruby3-2_rails6-0
136
+ ruby_version: 3.2.0
137
+ rails_version: 6.0.6.1
138
+ # Ruby 3.1 releases
139
+ - bundle_lint_test:
140
+ name: ruby3-1_rails7-0
141
+ ruby_version: 3.1.3
142
+ rails_version: 7.0.4.1
143
+ - bundle_lint_test:
144
+ name: ruby3-1_rails6-1
145
+ ruby_version: 3.1.3
146
+ rails_version: 6.1.7.1
147
+ - bundle_lint_test:
148
+ name: ruby3-1_rails6-0
149
+ ruby_version: 3.1.3
150
+ rails_version: 6.0.6.1
151
+ # Ruby 3.0 releases
152
+ - bundle_lint_test:
153
+ name: ruby3-0_rails7-0
154
+ ruby_version: 3.0.5
155
+ rails_version: 7.0.4.1
156
+ - bundle_lint_test:
157
+ name: ruby3-0_rails6-1
158
+ ruby_version: 3.0.5
159
+ rails_version: 6.1.7.1
160
+ - bundle_lint_test:
161
+ name: ruby3-0_rails6-0
162
+ ruby_version: 3.0.5
163
+ rails_version: 6.0.6.1
95
164
  # Ruby 2.7 releases
165
+ - bundle_lint_test:
166
+ name: ruby2-7_rails7-0
167
+ ruby_version: 2.7.7
168
+ rails_version: 7.0.4.1
96
169
  - bundle_lint_test:
97
170
  name: ruby2-7_rails6-1
98
- ruby_version: 2.7.5
99
- rails_version: 6.1.6.1
171
+ ruby_version: 2.7.7
172
+ rails_version: 6.1.7.1
100
173
  - bundle_lint_test:
101
174
  name: ruby2-7_rails6-0
102
- ruby_version: 2.7.5
103
- rails_version: 6.0.4.7
175
+ ruby_version: 2.7.7
176
+ rails_version: 6.0.6.1
104
177
  - bundle_lint_test:
105
178
  name: ruby2-7_rails5-2
106
- ruby_version: 2.7.5
107
- rails_version: 5.2.4
179
+ ruby_version: 2.7.7
180
+ rails_version: 5.2.8.1
108
181
  # Ruby 2.6 releases
109
- - bundle_lint_test:
110
- name: ruby2-6_rails6-1
111
- ruby_version: 2.6.9
112
- rails_version: 6.1.6.1
113
182
  - bundle_lint_test:
114
183
  name: ruby2-6_rails6-0
115
- ruby_version: 2.6.9
116
- rails_version: 6.0.4.7
184
+ ruby_version: 2.6.10
185
+ rails_version: 6.0.6.1
117
186
  - bundle_lint_test:
118
187
  name: ruby2-6_rails5-2
119
- ruby_version: 2.6.9
120
- rails_version: 5.2.4
121
- # Ruby 2.5 releases
122
- - bundle_lint_test:
123
- name: ruby2-5_rails6.0
124
- ruby_version: 2.5.9
125
- rails_version: 6.0.4.7
126
- - bundle_lint_test:
127
- name: ruby2-5_rails5-2
128
- ruby_version: 2.5.9
129
- rails_version: 5.2.4
188
+ ruby_version: 2.6.10
189
+ rails_version: 5.2.8.1
data/.rubocop.yml CHANGED
@@ -1,18 +1,13 @@
1
- require: rubocop-rspec
1
+ inherit_gem:
2
+ bixby: bixby_default.yml
2
3
 
3
4
  inherit_from:
4
5
  - .rubocop_todo.yml
5
6
 
6
- AllCops:
7
- TargetRubyVersion: 2.2
8
- DisplayCopNames: true
9
- Include:
10
- - '**/Rakefile'
11
- Exclude:
12
- - 'script/**/*'
13
- - 'vendor/**/*'
7
+ Style/FrozenStringLiteralComment:
8
+ Enabled: false
14
9
 
15
- Lint/HandleExceptions:
10
+ Lint/SuppressedException:
16
11
  Exclude:
17
12
  - 'spec/unit/**/*'
18
13
  - 'spec/integration/**/*'
@@ -22,12 +17,19 @@ Lint/HandleExceptions:
22
17
  Lint/AssignmentInCondition:
23
18
  Enabled: false
24
19
 
25
- Metrics/LineLength:
20
+ Layout/LineLength:
26
21
  Enabled: false
27
22
 
28
23
  Metrics/AbcSize:
29
24
  Enabled: false
30
25
 
26
+ Metrics/BlockLength:
27
+ Exclude:
28
+ - 'lib/active_fedora.rb'
29
+ - 'lib/active_fedora/nested_attributes.rb'
30
+ - 'lib/active_fedora/rspec_matchers/**/*'
31
+ - 'lib/tasks/**/*'
32
+
31
33
  Metrics/BlockNesting:
32
34
  Exclude:
33
35
  - 'lib/active_fedora/autosave_association.rb'
@@ -173,7 +175,7 @@ Style/Lambda:
173
175
  - 'spec/**/*'
174
176
 
175
177
  Layout/IndentationConsistency:
176
- EnforcedStyle: rails
178
+ EnforcedStyle: indented_internal_methods
177
179
 
178
180
  Style/CollectionMethods:
179
181
  PreferredMethods:
@@ -240,6 +242,15 @@ Rails/Date:
240
242
  Rails/TimeZone:
241
243
  Enabled: false
242
244
 
245
+ Rails/FilePath:
246
+ Enabled: false
247
+
248
+ Rails/ActiveRecordAliases:
249
+ Enabled: false
250
+
251
+ Rails/SkipsModelValidations:
252
+ Enabled: false
253
+
243
254
  RSpec/AnyInstance:
244
255
  Enabled: false
245
256
 
@@ -271,3 +282,6 @@ RSpec/NotToNot:
271
282
 
272
283
  RSpec/MessageSpies:
273
284
  Enabled: false
285
+
286
+ Security/MarshalLoad:
287
+ Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -16,5 +16,5 @@ Style/PercentLiteralDelimiters:
16
16
  # Offense count: 1
17
17
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
18
18
  # URISchemes: http, https
19
- Metrics/LineLength:
19
+ Layout/LineLength:
20
20
  Max: 82
data/Gemfile CHANGED
@@ -11,14 +11,14 @@ if ENV['RAILS_VERSION']
11
11
  gem 'activemodel', ENV['RAILS_VERSION']
12
12
  gem 'rails', ENV['RAILS_VERSION']
13
13
  else
14
- gem 'activemodel', '~> 6.0.4', '< 7'
15
- gem 'rails', '~> 6.0.4', '< 7'
14
+ gem 'activemodel', '>= 6.0', '< 8'
15
+ gem 'rails', '>= 6.0', '< 8'
16
16
  end
17
17
 
18
18
  group :test do
19
- gem 'simplecov', require: false
20
19
  gem 'coveralls', require: false
21
20
  gem 'rspec_junit_formatter'
21
+ gem 'simplecov', require: false
22
22
  end
23
23
 
24
24
  gem 'jruby-openssl', platform: :jruby
@@ -1,5 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
4
  require "active_fedora/version"
4
5
 
5
6
  Gem::Specification.new do |s|
@@ -8,39 +9,38 @@ Gem::Specification.new do |s|
8
9
  s.platform = Gem::Platform::RUBY
9
10
  s.authors = ["Matt Zumwalt", "McClain Looney", "Justin Coyne"]
10
11
  s.email = ["samvera-tech@googlegroups.com"]
11
- s.homepage = %q{https://github.com/samvera/active_fedora}
12
- s.summary = %q{A convenience libary for manipulating documents in the Fedora Repository.}
13
- s.description = %q{ActiveFedora provides for creating and managing objects in the Fedora Repository Architecture.}
12
+ s.homepage = 'https://github.com/samvera/active_fedora'
13
+ s.summary = 'A convenience libary for manipulating documents in the Fedora Repository.'
14
+ s.description = 'ActiveFedora provides for creating and managing objects in the Fedora Repository Architecture.'
14
15
  s.license = "Apache-2.0"
15
- s.required_ruby_version = '~> 2.4'
16
+ s.metadata = { "rubygems_mfa_required" => "true" }
17
+ s.required_ruby_version = '>= 2.6'
16
18
 
17
19
  s.add_dependency "activemodel", '>= 5.1'
18
20
  s.add_dependency "activesupport", '>= 5.1'
19
21
  s.add_dependency "active-triples", '>= 0.11.0', '< 2.0.0'
20
22
  s.add_dependency "deprecation"
21
- s.add_dependency 'faraday', '~> 0.12'
23
+ s.add_dependency 'faraday', '~> 1.0'
22
24
  s.add_dependency 'faraday-encoding', '>= 0.0.5'
23
25
  s.add_dependency "ldp", '>= 0.7.0', '< 2'
24
26
  s.add_dependency 'rsolr', '>= 1.1.2', '< 3'
25
27
  s.add_dependency "ruby-progressbar", '~> 1.0'
26
28
 
29
+ s.add_development_dependency "bixby"
27
30
  s.add_development_dependency "equivalent-xml"
28
31
  s.add_development_dependency 'fcrepo_wrapper', '~> 0.2'
29
32
  s.add_development_dependency "github_changelog_generator"
30
33
  s.add_development_dependency "rdoc"
31
- s.add_development_dependency "psych", "< 4" # Restricted because 4.0+ do not work with rubocop 0.56.x
32
34
  s.add_development_dependency "rails"
33
35
  s.add_development_dependency "rake"
34
36
  s.add_development_dependency "rspec", "~> 3.5"
35
37
  s.add_development_dependency "rspec-its"
36
- s.add_development_dependency "rubocop", '~> 0.56.0'
37
- s.add_development_dependency "rubocop-rspec", '~> 1.12.0'
38
38
  s.add_development_dependency "simplecov", '~> 0.8'
39
- s.add_development_dependency "solr_wrapper", "~> 2.0"
39
+ s.add_development_dependency "solr_wrapper", "~> 4.0"
40
40
  s.add_development_dependency "yard"
41
41
 
42
42
  s.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR).select { |f| File.dirname(f) !~ %r{\A"?spec\/?} }
43
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
43
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
44
44
  s.extra_rdoc_files = [
45
45
  "LICENSE",
46
46
  "README.md"
@@ -11,11 +11,11 @@ module ActiveFedora
11
11
  end
12
12
 
13
13
  def [](name)
14
- association(name).reader if association(name)
14
+ association(name)&.reader
15
15
  end
16
16
 
17
17
  def []=(name, object)
18
- association(name).writer(object) if association(name)
18
+ association(name)&.writer(object)
19
19
  end
20
20
 
21
21
  def association(name)
@@ -84,6 +84,7 @@ module ActiveFedora
84
84
  super
85
85
  end
86
86
  end
87
+
87
88
  ##
88
89
  # Represents the result of merging two association hashes.
89
90
  # @note As the keys can come from multiple models, the attributes become
@@ -91,11 +92,13 @@ module ActiveFedora
91
92
  class Merged < AssociationHash
92
93
  attr_reader :first, :second
93
94
 
95
+ # rubocop:disable Lint/MissingSuper
94
96
  def initialize(first, second)
95
97
  @first = first
96
98
  @base = first.base
97
99
  @second = second
98
100
  end
101
+ # rubocop:enable Lint/MissingSuper
99
102
 
100
103
  def [](name)
101
104
  first[name] || second[name]
@@ -119,7 +119,7 @@ module ActiveFedora
119
119
  reset
120
120
  end
121
121
 
122
- def initialize_attributes(record, except_from_scope_attributes = nil) #:nodoc:
122
+ def initialize_attributes(record, except_from_scope_attributes = nil) # :nodoc:
123
123
  except_from_scope_attributes ||= {}
124
124
  skip_assign = [reflection.foreign_key].compact
125
125
  assigned_keys = record.changed
@@ -141,9 +141,7 @@ module ActiveFedora
141
141
  if (reflection.has_one? || reflection.collection?) && !options[:through]
142
142
  attributes[reflection.foreign_key] = owner[reflection.active_record_primary_key]
143
143
 
144
- if reflection.options[:as]
145
- attributes[reflection.type] = owner.class.base_class.name
146
- end
144
+ attributes[reflection.type] = owner.class.base_class.name if reflection.options[:as]
147
145
  end
148
146
 
149
147
  attributes
@@ -1,6 +1,6 @@
1
1
  module ActiveFedora
2
2
  module Associations
3
- class AssociationScope #:nodoc:
3
+ class AssociationScope # :nodoc:
4
4
  def self.scope(association)
5
5
  new(association).scope
6
6
  end
@@ -1,8 +1,8 @@
1
1
  module ActiveFedora
2
2
  module Associations
3
- class BasicContainsAssociation < ContainsAssociation #:nodoc:
3
+ class BasicContainsAssociation < ContainsAssociation # :nodoc:
4
4
  def find_target
5
- uris = owner.resource.query(predicate: options[:predicate])
5
+ uris = owner.resource.query({ predicate: options[:predicate] })
6
6
  .map { |r| r.object.to_s }
7
7
 
8
8
  uris.map { |object_uri| klass.find(klass.uri_to_id(object_uri)) }
@@ -1,6 +1,6 @@
1
1
  module ActiveFedora
2
2
  module Associations
3
- class BelongsToAssociation < SingularAssociation #:nodoc:
3
+ class BelongsToAssociation < SingularAssociation # :nodoc:
4
4
  def handle_dependency
5
5
  target.send(options[:dependent]) if load_target
6
6
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveFedora::Associations::Builder
2
- class Association #:nodoc:
2
+ class Association # :nodoc:
3
3
  class << self
4
4
  attr_accessor :extensions
5
5
  end
@@ -36,7 +36,7 @@ module ActiveFedora::Associations::Builder
36
36
  def self.build_scope(scope, extension)
37
37
  new_scope = scope
38
38
 
39
- new_scope = proc { instance_exec(&scope) } if scope && scope.arity.zero?
39
+ new_scope = proc { instance_exec(&scope) } if scope&.arity&.zero?
40
40
 
41
41
  new_scope = wrap_scope new_scope, extension if extension
42
42
 
@@ -114,9 +114,7 @@ module ActiveFedora::Associations::Builder
114
114
  end
115
115
 
116
116
  def self.check_dependent_options(dependent)
117
- unless valid_dependent_options.include? dependent
118
- raise ArgumentError, "The :dependent option must be one of #{valid_dependent_options}, but is :#{dependent}"
119
- end
117
+ raise ArgumentError, "The :dependent option must be one of #{valid_dependent_options}, but is :#{dependent}" unless valid_dependent_options.include? dependent
120
118
  end
121
119
 
122
120
  def self.add_destroy_callbacks(model, reflection)
@@ -1,5 +1,5 @@
1
1
  module ActiveFedora::Associations::Builder
2
- class BasicContains < CollectionAssociation #:nodoc:
2
+ class BasicContains < CollectionAssociation # :nodoc:
3
3
  def self.macro
4
4
  :is_a_container
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveFedora::Associations::Builder
2
- class BelongsTo < SingularAssociation #:nodoc:
2
+ class BelongsTo < SingularAssociation # :nodoc:
3
3
  def self.macro
4
4
  :belongs_to
5
5
  end
@@ -19,9 +19,7 @@ module ActiveFedora::Associations::Builder
19
19
  end
20
20
 
21
21
  def self.define_validations(model, reflection)
22
- if reflection.options.key?(:required)
23
- reflection.options[:optional] = !reflection.options.delete(:required)
24
- end
22
+ reflection.options[:optional] = !reflection.options.delete(:required) if reflection.options.key?(:required)
25
23
 
26
24
  required = if reflection.options[:optional].nil?
27
25
  model.belongs_to_required_by_default
@@ -31,9 +29,7 @@ module ActiveFedora::Associations::Builder
31
29
 
32
30
  super
33
31
 
34
- if required
35
- model.validates_presence_of reflection.name, message: :required
36
- end
32
+ model.validates_presence_of reflection.name, message: :required if required
37
33
  end
38
34
  end
39
35
  end
@@ -1,6 +1,6 @@
1
1
  require 'active_fedora/associations'
2
2
  module ActiveFedora::Associations::Builder
3
- class CollectionAssociation < Association #:nodoc:
3
+ class CollectionAssociation < Association # :nodoc:
4
4
  CALLBACKS = [:before_add, :after_add, :before_remove, :after_remove].freeze
5
5
 
6
6
  def self.valid_options(options)
@@ -15,11 +15,11 @@ module ActiveFedora::Associations::Builder
15
15
  end
16
16
 
17
17
  def self.define_extensions(model, name)
18
- if block_given?
19
- extension_module_name = "#{model.name.demodulize}#{name.to_s.camelize}AssociationExtension"
20
- extension = Module.new(&Proc.new)
21
- model.parent.const_set(extension_module_name, extension)
22
- end
18
+ return unless block_given?
19
+
20
+ extension_module_name = "#{model.name.demodulize}#{name.to_s.camelize}AssociationExtension"
21
+ extension = Module.new(&Proc.new)
22
+ model.parent.const_set(extension_module_name, extension)
23
23
  end
24
24
 
25
25
  def self.define_callback(model, callback_name, name, options)
@@ -44,7 +44,7 @@ module ActiveFedora::Associations::Builder
44
44
 
45
45
  def self.wrap_scope(scope, mod)
46
46
  if scope
47
- if scope.arity > 0
47
+ if scope.arity.positive?
48
48
  proc { |owner| instance_exec(owner, &scope).extending(mod) }
49
49
  else
50
50
  proc { instance_exec(&scope).extending(mod) }
@@ -1,5 +1,5 @@
1
1
  module ActiveFedora::Associations::Builder
2
- class DirectlyContains < CollectionAssociation #:nodoc:
2
+ class DirectlyContains < CollectionAssociation # :nodoc:
3
3
  def self.macro
4
4
  :directly_contains
5
5
  end
@@ -10,11 +10,9 @@ module ActiveFedora::Associations::Builder
10
10
 
11
11
  def self.validate_options(options)
12
12
  super
13
- if !options[:has_member_relation] && !options[:is_member_of_relation]
14
- raise ArgumentError, "You must specify a :has_member_relation or :is_member_of_relation predicate for #{name}"
15
- elsif !options[:has_member_relation].is_a?(RDF::URI) && !options[:is_member_of_relation].is_a?(RDF::URI)
16
- raise ArgumentError, "Predicate must be a kind of RDF::URI"
17
- end
13
+
14
+ raise ArgumentError, "You must specify a :has_member_relation or :is_member_of_relation predicate for #{name}" if !options[:has_member_relation] && !options[:is_member_of_relation]
15
+ raise ArgumentError, "Predicate must be a kind of RDF::URI" if !options[:has_member_relation].is_a?(RDF::URI) && !options[:is_member_of_relation].is_a?(RDF::URI)
18
16
  end
19
17
  end
20
18
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveFedora::Associations::Builder
2
- class DirectlyContainsOne < SingularAssociation #:nodoc:
2
+ class DirectlyContainsOne < SingularAssociation # :nodoc:
3
3
  def self.macro
4
4
  :directly_contains_one
5
5
  end
@@ -9,15 +9,13 @@ module ActiveFedora::Associations::Builder
9
9
  end
10
10
 
11
11
  def self.create_reflection(model, name, scope, options, extension = nil)
12
- if options[:through]
13
- inherit_options_from_association(model, options, options[:through])
14
- else
15
- raise ArgumentError, "you must specify a :through option on #{name}. #{name} will use the container from that directly_contains association."
16
- end
12
+ raise ArgumentError, "you must specify a :through option on #{name}. #{name} will use the container from that directly_contains association." unless options[:through]
13
+ inherit_options_from_association(model, options, options[:through])
17
14
 
18
15
  super
19
16
  end
20
17
 
18
+ # rubocop:disable Style/GuardClause
21
19
  def self.validate_options(options)
22
20
  super
23
21
  if options[:class_name] == "ActiveFedora::File"
@@ -31,6 +29,7 @@ module ActiveFedora::Associations::Builder
31
29
  return if options[:type].is_a?(RDF::URI)
32
30
  raise ArgumentError, "You must specify a Type and it must be a kind of RDF::URI"
33
31
  end
32
+ # rubocop:enable Style/GuardClause
34
33
 
35
34
  # Inherits :has_member_relation from the association corresponding to association_name
36
35
  # @param [Symbol] association_name of the association to inherit from
@@ -1,5 +1,5 @@
1
1
  module ActiveFedora::Associations::Builder
2
- class HasAndBelongsToMany < CollectionAssociation #:nodoc:
2
+ class HasAndBelongsToMany < CollectionAssociation # :nodoc:
3
3
  def self.macro
4
4
  :has_and_belongs_to_many
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveFedora::Associations::Builder
2
- class HasMany < CollectionAssociation #:nodoc:
2
+ class HasMany < CollectionAssociation # :nodoc:
3
3
  def self.macro
4
4
  :has_many
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveFedora::Associations::Builder
2
- class HasSubresource < SingularAssociation #:nodoc:
2
+ class HasSubresource < SingularAssociation # :nodoc:
3
3
  def self.macro
4
4
  :has_subresource
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveFedora::Associations::Builder
2
- class IndirectlyContains < CollectionAssociation #:nodoc:
2
+ class IndirectlyContains < CollectionAssociation # :nodoc:
3
3
  def self.macro
4
4
  :indirectly_contains
5
5
  end
@@ -18,12 +18,9 @@ module ActiveFedora::Associations::Builder
18
18
 
19
19
  def self.validate_options(options)
20
20
  super
21
- if !options[:has_member_relation] && !options[:is_member_of_relation]
22
- raise ArgumentError, "You must specify a predicate for #{name}"
23
- elsif !options[:has_member_relation].is_a?(RDF::URI) && !options[:is_member_of_relation].is_a?(RDF::URI)
24
- raise ArgumentError, "Predicate must be a kind of RDF::URI"
25
- end
26
21
 
22
+ raise ArgumentError, "You must specify a predicate for #{name}" if !options[:has_member_relation] && !options[:is_member_of_relation]
23
+ raise ArgumentError, "Predicate must be a kind of RDF::URI" if !options[:has_member_relation].is_a?(RDF::URI) && !options[:is_member_of_relation].is_a?(RDF::URI)
27
24
  raise ArgumentError, "Missing :through option" unless options[:through]
28
25
  raise ArgumentError, "Missing :foreign_key option" unless options[:foreign_key]
29
26
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveFedora::Associations::Builder
2
- class SingularAssociation < Association #:nodoc:
2
+ class SingularAssociation < Association # :nodoc:
3
3
  def self.valid_options(options)
4
4
  super + [:dependent, :inverse_of, :required]
5
5
  end