active-fedora 9.7.0 → 9.8.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.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +10 -9
  4. data/History.txt +18 -0
  5. data/README.md +12 -13
  6. data/Rakefile +1 -1
  7. data/active-fedora.gemspec +2 -1
  8. data/config/fedora.yml +2 -2
  9. data/config/solr.yml +5 -5
  10. data/lib/active_fedora/association_hash.rb +2 -2
  11. data/lib/active_fedora/associations/builder/collection_association.rb +1 -1
  12. data/lib/active_fedora/associations/builder/has_many.rb +1 -1
  13. data/lib/active_fedora/associations/collection_association.rb +1 -1
  14. data/lib/active_fedora/associations/collection_proxy.rb +4 -4
  15. data/lib/active_fedora/associations/directly_contains_one_association.rb +3 -7
  16. data/lib/active_fedora/associations/has_many_association.rb +22 -29
  17. data/lib/active_fedora/associations/indirectly_contains_association.rb +1 -1
  18. data/lib/active_fedora/autosave_association.rb +1 -1
  19. data/lib/active_fedora/base.rb +1 -1
  20. data/lib/active_fedora/callbacks.rb +1 -1
  21. data/lib/active_fedora/change_set.rb +1 -2
  22. data/lib/active_fedora/datastreams/nokogiri_datastreams.rb +6 -6
  23. data/lib/active_fedora/file.rb +5 -4
  24. data/lib/active_fedora/file_configurator.rb +6 -11
  25. data/lib/active_fedora/fixity_service.rb +1 -1
  26. data/lib/active_fedora/indexing/map.rb +2 -1
  27. data/lib/active_fedora/indexing_service.rb +3 -3
  28. data/lib/active_fedora/ldp_cache.rb +1 -1
  29. data/lib/active_fedora/model.rb +9 -10
  30. data/lib/active_fedora/nested_attributes.rb +1 -1
  31. data/lib/active_fedora/nom_datastream.rb +5 -5
  32. data/lib/active_fedora/om_datastream.rb +2 -2
  33. data/lib/active_fedora/persistence.rb +2 -2
  34. data/lib/active_fedora/qualified_dublin_core_datastream.rb +1 -1
  35. data/lib/active_fedora/rdf/fcrepo.rb +6 -0
  36. data/lib/active_fedora/rdf/field_map.rb +4 -2
  37. data/lib/active_fedora/rdf/persistence.rb +2 -2
  38. data/lib/active_fedora/rdf/rdf_datastream.rb +1 -1
  39. data/lib/active_fedora/reflection.rb +3 -3
  40. data/lib/active_fedora/relation.rb +2 -2
  41. data/lib/active_fedora/solr_query_builder.rb +93 -91
  42. data/lib/active_fedora/solr_service.rb +2 -2
  43. data/lib/active_fedora/version.rb +1 -1
  44. data/lib/active_fedora/versionable.rb +14 -12
  45. data/lib/active_fedora/versions_graph.rb +1 -1
  46. data/lib/active_fedora.rb +2 -2
  47. data/lib/generators/active_fedora/config/fedora/templates/fedora.yml +2 -2
  48. data/lib/generators/active_fedora/config/solr/solr_generator.rb +0 -1
  49. data/lib/generators/active_fedora/config/solr/templates/solr.yml +2 -2
  50. data/lib/tasks/active_fedora_dev.rake +13 -8
  51. data/solr/config/_rest_managed.json +3 -0
  52. data/solr/config/admin-extra.html +31 -0
  53. data/solr/config/elevate.xml +36 -0
  54. data/solr/config/mapping-ISOLatin1Accent.txt +246 -0
  55. data/solr/config/protwords.txt +21 -0
  56. data/solr/config/schema.xml +372 -0
  57. data/solr/config/scripts.conf +24 -0
  58. data/solr/config/solrconfig.xml +419 -0
  59. data/solr/config/spellings.txt +2 -0
  60. data/solr/config/stopwords.txt +58 -0
  61. data/solr/config/stopwords_en.txt +58 -0
  62. data/solr/config/synonyms.txt +31 -0
  63. data/solr/config/xslt/example.xsl +132 -0
  64. data/solr/config/xslt/example_atom.xsl +67 -0
  65. data/solr/config/xslt/example_rss.xsl +66 -0
  66. data/solr/config/xslt/luke.xsl +337 -0
  67. data/spec/integration/complex_rdf_datastream_spec.rb +8 -8
  68. data/spec/integration/full_featured_model_spec.rb +1 -1
  69. data/spec/integration/ntriples_datastream_spec.rb +12 -1
  70. data/spec/integration/rdf_nested_attributes_spec.rb +51 -20
  71. data/spec/integration/scoped_query_spec.rb +2 -2
  72. data/spec/integration/versionable_spec.rb +1 -3
  73. data/spec/unit/active_fedora_spec.rb +0 -3
  74. data/spec/unit/base_spec.rb +1 -1
  75. data/spec/unit/forbidden_attributes_protection_spec.rb +1 -1
  76. data/spec/unit/ntriples_datastream_spec.rb +21 -11
  77. data/spec/unit/persistence_spec.rb +1 -1
  78. data/spec/unit/predicates_spec.rb +1 -1
  79. data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -1
  80. data/spec/unit/solr_config_options_spec.rb +3 -3
  81. data/spec/unit/sparql_insert_spec.rb +1 -1
  82. metadata +38 -11
  83. data/config/solr_mappings_af_0.1.yml +0 -9
  84. data/config/solr_mappings_bl_2.4.yml +0 -17
  85. data/lib/generators/active_fedora/config/solr/templates/jetty.yml +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02451c4f7df1542ec57c845259cc21eefd0aff2b
4
- data.tar.gz: a689c5b349b6e55b1e63af345f1e81eac669e51a
3
+ metadata.gz: eb7bb622089037ec0a49870417c31aedf0b2b3c1
4
+ data.tar.gz: 077acf9671652587082be135de13ca1afa05b709
5
5
  SHA512:
6
- metadata.gz: 6e5b2b77aa673793101dfe20d17d7b6b58a8e936d10d5d9bd5d1285f392ada51b25808a89d1dd147dc6827868110d22ce868337b2b078e7ecd20b61ad5d9445f
7
- data.tar.gz: cb38ad07691ed932faa31de89fdc1278b6b8f581e251fd9fd37a84a1fdc9c61b2c5a80eb889c90b3ff85c6553b70941b07e4db680f7ff21df3ee2ab0e778eff7
6
+ metadata.gz: 8cee9e01316cd57089335922d058f7bb537f3845c5da764601be842331707ac1ef175ecd20e6bc8e7cb759b432ec752b0fe9bcda08877b10dea2a72f97a2fc76
7
+ data.tar.gz: 23964a8f464c39dd2d0c53f5f6418337c76235489d2924895af34d979c214e551999b430d0072d28d6243e7c06114f170eecb8a6e9124664715e82b342f4c1f2
data/.gitignore CHANGED
@@ -13,3 +13,4 @@ bin
13
13
  .ruby-version
14
14
  .ruby-gemset
15
15
  gemfiles/*.gemfile.lock
16
+ /fcrepo4-data
data/.rubocop.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  require: rubocop-rspec
2
2
 
3
3
  AllCops:
4
- RunRailsCops: true
4
+ TargetRubyVersion: 2.2
5
5
  DisplayCopNames: true
6
6
  Include:
7
7
  - '**/Rakefile'
@@ -9,10 +9,6 @@ AllCops:
9
9
  - 'script/**/*'
10
10
  - 'vendor/**/*'
11
11
 
12
- Lint/RescueException:
13
- Exclude:
14
- - 'lib/active_fedora/ldp_cache.rb'
15
-
16
12
  Lint/HandleExceptions:
17
13
  Exclude:
18
14
  - 'spec/unit/**/*'
@@ -184,9 +180,6 @@ Style/ClassAndModuleChildren:
184
180
  Style/Documentation:
185
181
  Enabled: false
186
182
 
187
- Style/HashSyntax:
188
- Exclude:
189
-
190
183
  Style/GlobalVars:
191
184
  Exclude:
192
185
  - 'spec/**/*'
@@ -210,6 +203,15 @@ Style/FileName:
210
203
  - 'lib/active-fedora.rb'
211
204
  - 'spec/samples/hydra-mods_article_datastream.rb'
212
205
 
206
+ Style/ZeroLengthPredicate:
207
+ Enabled: false # https://github.com/bbatsov/rubocop/issues/2782
208
+
209
+ Performance/RedundantMerge:
210
+ Enabled: false # https://github.com/bbatsov/rubocop/issues/2781
211
+
212
+ Rails:
213
+ Enabled: true
214
+
213
215
  Rails/Output:
214
216
  Exclude:
215
217
  - 'lib/generators/**/*'
@@ -242,4 +244,3 @@ RSpec/DescribeClass:
242
244
  RSpec/DescribedClass:
243
245
  Exclude:
244
246
  - 'spec/unit/finder_methods_spec.rb'
245
-
data/History.txt CHANGED
@@ -1,3 +1,21 @@
1
+ v9.8.0
2
+ 2016-02-04: Remove unused files [Justin Coyne]
3
+
4
+ 2016-02-03: Test on Solr 5 [Justin Coyne]
5
+
6
+ 2016-02-04: Fix rubocop [Justin Coyne]
7
+
8
+ 2016-01-29: Pass hash of options to index.as [Adam Wead]
9
+
10
+ v9.7.1
11
+ 2016-01-22 : The jcr/mix versionable predicate is no longer used [Adam Wead]
12
+
13
+ 2016-01-22 : Add detail to SolrQueryBuilder.construct_query_for_pids deprecation warning [David Chandek-Stark]
14
+
15
+ 2016-01-21 : Updating to the latest Rubocop [Michael J. Giarlo]
16
+
17
+ 2015-12-04 : Adds :PID property to ActiveFedora::RDF::Fcrepo::Model vocab [David Chandek-Stark]
18
+
1
19
  v9.7.0
2
20
  2015-11-25 : Allowing access to the gone? method from outside the object [Carolyn Cole]
3
21
 
data/README.md CHANGED
@@ -63,12 +63,8 @@ You can test ActiveFedora using the same process as our continuous
63
63
  integration server. To do that, unzip a copy of hydra-jetty first. This includes copies of Fedora and Solr which are
64
64
  used during the testing process.
65
65
 
66
- ```bash
67
- rake jetty:unzip
68
- ```
69
-
70
- Once hydra-jetty is unzipped, the ci rake task will spin up jetty,
71
- import the fixtures, and run the tests for you.
66
+ The `ci` rake task will download solr and fedora, start them,
67
+ and run the tests for you.
72
68
 
73
69
  ```bash
74
70
  rake active_fedora:ci
@@ -76,18 +72,21 @@ rake active_fedora:ci
76
72
 
77
73
  ### Testing Manually
78
74
 
79
- If you want to run the tests manually, follow these instructions.
75
+ If you want to run the tests manually, follow these instructions:
76
+
77
+ ```bash
78
+ solr_wrapper -d solr/config/ --collection_name hydra-test
79
+ ```
80
+
81
+ You can switch `hydra-test` to `hydra-dev` if you want to create a collection for development.
80
82
 
81
- You need to have a copy of hydra-jetty running. To do this, download a
82
- working copy of
83
- [hydra-jetty](https://github.com/projecthydra/hydra-jetty), cd into its
84
- root and run:
83
+ To start FCRepo, open another shell and run:
85
84
 
86
85
  ```bash
87
- java -jar start.jar
86
+ fedora_wrapper -p 8984
88
87
  ```
89
88
 
90
- Now you’re ready to run the tests. In the directory where active_fedora
89
+ Now you’re ready to run the tests. In the directory where active\_fedora
91
90
  is installed, run:
92
91
 
93
92
  ```bash
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ load "lib/tasks/active_fedora_dev.rake"
9
9
  CLEAN.include %w(**/.DS_Store tmp *.log *.orig *.tmp **/*~)
10
10
 
11
11
  desc 'setup jetty and run tests'
12
- task ci: ['jetty:clean', 'active_fedora:ci']
12
+ task ci: ['active_fedora:ci']
13
13
  desc 'run tests'
14
14
  task spec: ['active_fedora:rubocop', 'active_fedora:rspec']
15
15
  task rcov: ['active_fedora:rcov']
@@ -27,7 +27,8 @@ Gem::Specification.new do |s|
27
27
  s.add_development_dependency "rdoc"
28
28
  s.add_development_dependency "yard"
29
29
  s.add_development_dependency "rake"
30
- s.add_development_dependency "jettywrapper", ">= 2.0.0"
30
+ s.add_development_dependency "solr_wrapper", "~> 0.4"
31
+ s.add_development_dependency 'fcrepo_wrapper', '~> 0.1'
31
32
  s.add_development_dependency "rspec", "~> 3.0"
32
33
  s.add_development_dependency "rspec-its"
33
34
  s.add_development_dependency "equivalent-xml"
data/config/fedora.yml CHANGED
@@ -1,12 +1,12 @@
1
1
  development:
2
2
  user: fedoraAdmin
3
3
  password: fedoraAdmin
4
- url: http://127.0.0.1:8983/fedora/rest
4
+ url: http://127.0.0.1:8984/rest
5
5
  base_path: /dev
6
6
  test:
7
7
  user: fedoraAdmin
8
8
  password: fedoraAdmin
9
- url: http://localhost:8983/fedora/rest
9
+ url: http://localhost:8984/rest
10
10
  base_path: /test
11
11
  production:
12
12
  user: fedoraAdmin
data/config/solr.yml CHANGED
@@ -1,15 +1,15 @@
1
1
  development:
2
2
  default:
3
- url: http://localhost:8983/solr/development
3
+ url: http://localhost:8983/solr/hydra-dev
4
4
  full_text:
5
5
  url: http://localhost:8983/solr/development
6
- test:
6
+ test:
7
7
  default:
8
- url: http://localhost:8983/solr/test
8
+ url: http://localhost:8983/solr/hydra-test
9
9
  full_text:
10
10
  url: http://localhost:8983/solr/test
11
11
  production:
12
12
  default:
13
- url: http://localhost:8080/solr/production
13
+ url: http://localhost:8080/solr/production
14
14
  full_text:
15
- url: http://localhost:8080/solr/production
15
+ url: http://localhost:8080/solr/production
@@ -44,8 +44,8 @@ module ActiveFedora
44
44
  def key?(key)
45
45
  keys.include?(key) || keys.map(&:to_s).include?(key)
46
46
  end
47
- alias_method :include?, :key?
48
- alias_method :has_key?, :key?
47
+ alias include? key?
48
+ alias has_key? key?
49
49
 
50
50
  def values
51
51
  keys.map { |k| self[k] }
@@ -1,7 +1,7 @@
1
1
  require 'active_fedora/associations'
2
2
  module ActiveFedora::Associations::Builder
3
3
  class CollectionAssociation < Association #:nodoc:
4
- CALLBACKS = [:before_add, :after_add, :before_remove, :after_remove]
4
+ CALLBACKS = [:before_add, :after_add, :before_remove, :after_remove].freeze
5
5
 
6
6
  self.valid_options += [
7
7
  :before_add, :after_add, :before_remove, :after_remove
@@ -52,7 +52,7 @@ module ActiveFedora::Associations::Builder
52
52
  send(name).delete_all
53
53
  end
54
54
  end
55
- alias_method :define_nullify_dependency_method, :define_delete_all_dependency_method
55
+ alias define_nullify_dependency_method define_delete_all_dependency_method
56
56
 
57
57
  def define_restrict_dependency_method
58
58
  name = self.name
@@ -129,7 +129,7 @@ module ActiveFedora
129
129
  def to_ary
130
130
  load_target.dup
131
131
  end
132
- alias_method :to_a, :to_ary
132
+ alias to_a to_ary
133
133
 
134
134
  def build(attributes = {}, &block)
135
135
  if attributes.is_a?(Array)
@@ -835,7 +835,7 @@ module ActiveFedora
835
835
  @association.include?(record)
836
836
  end
837
837
 
838
- alias_method :new, :build
838
+ alias new build
839
839
 
840
840
  def proxy_association
841
841
  @association
@@ -845,17 +845,17 @@ module ActiveFedora
845
845
  def scope
846
846
  @association.scope
847
847
  end
848
- alias_method :spawn, :scope
848
+ alias spawn scope
849
849
 
850
850
  def to_ary
851
851
  load_target.dup
852
852
  end
853
- alias_method :to_a, :to_ary
853
+ alias to_a to_ary
854
854
 
855
855
  def <<(*records)
856
856
  proxy_association.concat(records) && self
857
857
  end
858
- alias_method :push, :<<
858
+ alias push <<
859
859
 
860
860
  def clear
861
861
  delete_all
@@ -98,13 +98,9 @@ module ActiveFedora
98
98
  # Returns the RDF node that contains metadata like RDF.type assertions for the record
99
99
  # Sometimes this is the record, other times it's record.metadata_node
100
100
  def metadata_node_for_record(record)
101
- if record.respond_to?(:type) && record.respond_to?(:set_value)
102
- return record
103
- elsif record.respond_to?(:metadata_node)
104
- return record.metadata_node
105
- else
106
- raise ArgumentError, "record must either have a metadata node or must respond to .type"
107
- end
101
+ return record if record.respond_to?(:type) && record.respond_to?(:set_value)
102
+ return record.metadata_node if record.respond_to?(:metadata_node)
103
+ raise ArgumentError, "record must either have a metadata node or must respond to .type"
108
104
  end
109
105
  end
110
106
  end
@@ -69,40 +69,33 @@ module ActiveFedora
69
69
 
70
70
  # Deletes the records according to the <tt>:dependent</tt> option.
71
71
  def delete_records(records, method)
72
- if method == :destroy
73
- records.each(&:destroy)
74
- else
75
- # Find all the records that point to this and nullify them
76
- # keys = records.map { |r| r[reflection.association_primary_key] }
77
- # scope = scoped.where(reflection.association_primary_key => keys)
72
+ return records.each(&:destroy) if method == :destroy
73
+ # Find all the records that point to this and nullify them
74
+ # keys = records.map { |r| r[reflection.association_primary_key] }
75
+ # scope = scoped.where(reflection.association_primary_key => keys)
78
76
 
79
- if method == :delete_all
80
- raise "Not Implemented"
81
- # update_counter(-scope.delete_all)
82
- else
77
+ raise "Not Implemented" if method == :delete_all # update_counter(-scope.delete_all)
83
78
 
84
- if reflection.inverse_of # Can't get an inverse when class_name: 'ActiveFedora::Base' is supplied
85
- inverse = reflection.inverse_of
86
- records.each do |record|
87
- next unless record.persisted?
88
- if inverse.collection?
89
- # Remove from a has_and_belongs_to_many
90
- record.association(inverse.name).delete(@owner)
91
- elsif inverse.klass == ActiveFedora::Base
92
- record[inverse.foreign_key] = nil
93
- else
94
- # Remove from a belongs_to
95
- record[reflection.foreign_key] = nil
96
- end
97
- # Check to see if the object still exists (may be already deleted).
98
- # In Rails, they do this with an update_all to avoid callbacks and validations, we may need the same.
99
- record.save! if record.class.exists?(record.id)
100
- end
79
+ if reflection.inverse_of # Can't get an inverse when class_name: 'ActiveFedora::Base' is supplied
80
+ inverse = reflection.inverse_of
81
+ records.each do |record|
82
+ next unless record.persisted?
83
+ if inverse.collection?
84
+ # Remove from a has_and_belongs_to_many
85
+ record.association(inverse.name).delete(@owner)
86
+ elsif inverse.klass == ActiveFedora::Base
87
+ record[inverse.foreign_key] = nil
88
+ else
89
+ # Remove from a belongs_to
90
+ record[reflection.foreign_key] = nil
101
91
  end
102
-
103
- # update_counter(-scope.update_all(reflection.foreign_key => nil))
92
+ # Check to see if the object still exists (may be already deleted).
93
+ # In Rails, they do this with an update_all to avoid callbacks and validations, we may need the same.
94
+ record.save! if record.class.exists?(record.id)
104
95
  end
105
96
  end
97
+
98
+ # update_counter(-scope.update_all(reflection.foreign_key => nil))
106
99
  end
107
100
  end
108
101
  end
@@ -30,7 +30,7 @@ module ActiveFedora
30
30
  target.map(&:id)
31
31
  else
32
32
  owner.resource.query(predicate: predicate)
33
- .map { |s| ActiveFedora::Base.uri_to_id(s.object) } | target.map(&:id)
33
+ .map { |s| ActiveFedora::Base.uri_to_id(s.object) } | target.map(&:id)
34
34
  end
35
35
  end
36
36
 
@@ -75,7 +75,7 @@ module ActiveFedora
75
75
  module AutosaveAssociation
76
76
  extend ActiveSupport::Concern
77
77
 
78
- ASSOCIATION_TYPES = %w( HasMany BelongsTo HasAndBelongsToMany DirectlyContains IndirectlyContains)
78
+ ASSOCIATION_TYPES = %w( HasMany BelongsTo HasAndBelongsToMany DirectlyContains IndirectlyContains).freeze
79
79
 
80
80
  module AssociationBuilderExtension #:nodoc:
81
81
  def self.included(base)
@@ -1,4 +1,4 @@
1
- SOLR_DOCUMENT_ID = "id" unless defined?(SOLR_DOCUMENT_ID) && !SOLR_DOCUMENT_ID.nil?
1
+ SOLR_DOCUMENT_ID = "id".freeze unless defined?(SOLR_DOCUMENT_ID) && !SOLR_DOCUMENT_ID.nil?
2
2
  ENABLE_SOLR_UPDATES = true unless defined?(ENABLE_SOLR_UPDATES)
3
3
  require 'active_support/descendants_tracker'
4
4
  require 'active_fedora/errors'
@@ -216,7 +216,7 @@ module ActiveFedora
216
216
  :before_save, :around_save, :after_save, :before_create, :around_create,
217
217
  :after_create, :before_update, :around_update, :after_update,
218
218
  :before_destroy, :around_destroy, :after_destroy
219
- ]
219
+ ].freeze
220
220
 
221
221
  included do
222
222
  extend ActiveModel::Callbacks
@@ -59,8 +59,7 @@ module ActiveFedora
59
59
  end
60
60
 
61
61
  def internal?
62
- value.object.to_s.start_with?("http://www.jcp.org") ||
63
- value.object.to_s.start_with?("http://fedora.info") ||
62
+ value.object.to_s.start_with?("http://www.jcp.org", "http://fedora.info") ||
64
63
  value.predicate.to_s.start_with?("http://fedora.info")
65
64
  end
66
65
  end
@@ -15,12 +15,12 @@ module ActiveFedora
15
15
 
16
16
  def ng_xml
17
17
  @ng_xml ||= begin
18
- if new_record?
19
- ## Load up the template
20
- xml = self.class.xml_template
21
- else
22
- xml = Nokogiri::XML::Document.parse(remote_content)
23
- end
18
+ xml = if new_record?
19
+ ## Load up the template
20
+ self.class.xml_template
21
+ else
22
+ Nokogiri::XML::Document.parse(remote_content)
23
+ end
24
24
  self.class.decorate_ng_xml xml
25
25
  end
26
26
  end
@@ -188,6 +188,11 @@ module ActiveFedora
188
188
  false
189
189
  end
190
190
 
191
+ def self.relation
192
+ FileRelation.new(self)
193
+ end
194
+ private_class_method :relation
195
+
191
196
  protected
192
197
 
193
198
  # The string to prefix all solr fields with. Override this method if you want
@@ -198,10 +203,6 @@ module ActiveFedora
198
203
 
199
204
  private
200
205
 
201
- def self.relation
202
- FileRelation.new(self)
203
- end
204
-
205
206
  # Rack::Test::UploadedFile is often set via content=, however it's not an IO, though it wraps an io object.
206
207
  def behaves_like_io?(obj)
207
208
  [IO, Tempfile, StringIO].any? { |klass| obj.is_a? klass } || (defined?(Rack) && obj.is_a?(Rack::Test::UploadedFile))
@@ -149,14 +149,12 @@ module ActiveFedora
149
149
  # Given the solr_config that's been loaded for this environment,
150
150
  # determine which solr url to use
151
151
  def solr_url(solr_config)
152
+ return solr_config[:url] if solr_config.key?(:url)
153
+ return solr_config['url'] if solr_config.key?('url')
152
154
  if @index_full_text == true && solr_config.key?(:fulltext) && solr_config[:fulltext].key?('url')
153
- return solr_config[:fulltext]['url']
155
+ solr_config[:fulltext]['url']
154
156
  elsif solr_config.key?(:default) && solr_config[:default].key?('url')
155
- return solr_config[:default]['url']
156
- elsif solr_config.key?('url')
157
- return solr_config['url']
158
- elsif solr_config.key?(:url)
159
- return solr_config[:url]
157
+ solr_config[:default]['url']
160
158
  else
161
159
  raise URI::InvalidURIError
162
160
  end
@@ -208,11 +206,8 @@ module ActiveFedora
208
206
  # Checks the existing fedora_config.path to see if there is a solr.yml there
209
207
  def check_fedora_path_for_solr
210
208
  path = ::File.dirname(self.path) + "/solr.yml"
211
- if ::File.file? path
212
- return path
213
- else
214
- return nil
215
- end
209
+ return unless ::File.file? path
210
+ path
216
211
  end
217
212
 
218
213
  def predicate_config
@@ -52,7 +52,7 @@ module ActiveFedora
52
52
  # See https://jira.duraspace.org/browse/FCREPO-1247
53
53
  # @param [String] uri
54
54
  def encoded_url(uri)
55
- if uri.match("fcr:versions")
55
+ if uri =~ /fcr:versions/
56
56
  uri.gsub(/fcr:versions/, "fcr%3aversions")
57
57
  else
58
58
  uri
@@ -16,7 +16,7 @@ module ActiveFedora::Indexing
16
16
 
17
17
  # this enables a cleaner API for solr integration
18
18
  class IndexObject
19
- attr_accessor :data_type, :behaviors
19
+ attr_accessor :data_type, :behaviors, :term
20
20
  attr_reader :key
21
21
 
22
22
  def initialize(name, &_block)
@@ -27,6 +27,7 @@ module ActiveFedora::Indexing
27
27
  end
28
28
 
29
29
  def as(*args)
30
+ @term = args.last.is_a?(Hash) ? args.pop : {}
30
31
  @behaviors = args
31
32
  end
32
33
 
@@ -39,9 +39,9 @@ module ActiveFedora
39
39
  Solrizer.set_field(solr_doc, 'system_create', c_time, :stored_sortable)
40
40
  Solrizer.set_field(solr_doc, 'system_modified', m_time, :stored_sortable)
41
41
  Solrizer.set_field(solr_doc, 'active_fedora_model', object.class.inspect, :stored_sortable)
42
- solr_doc.merge!(QueryResultBuilder::HAS_MODEL_SOLR_FIELD => object.has_model)
43
- solr_doc.merge!(SOLR_DOCUMENT_ID.to_sym => object.id)
44
- solr_doc.merge!(self.class.profile_solr_name => profile_service.new(object).export)
42
+ solr_doc[QueryResultBuilder::HAS_MODEL_SOLR_FIELD] = object.has_model
43
+ solr_doc[SOLR_DOCUMENT_ID.to_sym] = object.id
44
+ solr_doc[self.class.profile_solr_name] = profile_service.new(object).export
45
45
  object.declared_attached_files.each do |name, file|
46
46
  solr_doc.merge! file.to_solr(solr_doc, name: name.to_s)
47
47
  end
@@ -29,7 +29,7 @@ module ActiveFedora
29
29
  end
30
30
 
31
31
  response
32
- rescue Exception => e
32
+ rescue StandardError => e
33
33
  reset_cache_settings
34
34
  raise e
35
35
  end
@@ -1,4 +1,4 @@
1
- SOLR_DOCUMENT_ID = "id" unless defined?(SOLR_DOCUMENT_ID)
1
+ SOLR_DOCUMENT_ID = "id".freeze unless defined?(SOLR_DOCUMENT_ID)
2
2
 
3
3
  module ActiveFedora
4
4
  # = ActiveFedora
@@ -17,14 +17,13 @@ module ActiveFedora
17
17
  ActiveFedora.class_from_string(model_value)
18
18
  end
19
19
 
20
- private
21
-
22
- def self.class_exists?(class_name)
23
- return false if class_name.empty?
24
- klass = class_name.constantize
25
- return klass.is_a?(Class)
26
- rescue NameError
27
- return false
28
- end
20
+ def self.class_exists?(class_name)
21
+ return false if class_name.empty?
22
+ klass = class_name.constantize
23
+ return klass.is_a?(Class)
24
+ rescue NameError
25
+ return false
26
+ end
27
+ private_class_method :class_exists?
29
28
  end
30
29
  end
@@ -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( id _destroy )
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]
@@ -34,11 +34,11 @@ module ActiveFedora
34
34
  term.values.each do |v|
35
35
  Array(term.options[:index]).each do |index_as|
36
36
  solr_doc[index_as] ||= []
37
- if v.is_a? Nokogiri::XML::Node
38
- solr_doc[index_as] << v.text
39
- else
40
- solr_doc[index_as] << v
41
- end
37
+ solr_doc[index_as] << if v.is_a? Nokogiri::XML::Node
38
+ v.text
39
+ else
40
+ v
41
+ end
42
42
  end
43
43
  end
44
44
  end
@@ -13,8 +13,8 @@ module ActiveFedora
13
13
  include OM::XML::TerminologyBasedSolrizer # this adds support for calling .to_solr
14
14
  include Datastreams::NokogiriDatastreams
15
15
 
16
- alias_method(:om_term_values, :term_values) unless method_defined?(:om_term_values)
17
- alias_method(:om_update_values, :update_values) unless method_defined?(:om_update_values)
16
+ alias om_term_values term_values unless method_defined?(:om_term_values)
17
+ alias om_update_values update_values unless method_defined?(:om_update_values)
18
18
 
19
19
  def default_mime_type
20
20
  'text/xml'
@@ -37,7 +37,7 @@ module ActiveFedora
37
37
  save
38
38
  end
39
39
 
40
- alias_method :update_attributes, :update
40
+ alias update_attributes update
41
41
 
42
42
  # Deletes an object from Fedora and deletes the indexed record from Solr.
43
43
  # Delete does not run any callbacks, so consider using _destroy_ instead.
@@ -186,7 +186,7 @@ module ActiveFedora
186
186
  end
187
187
 
188
188
  def base_path_for_resource
189
- init_root_path if self.has_uri_prefix?
189
+ init_root_path if has_uri_prefix?
190
190
  root_resource_path
191
191
  end
192
192
 
@@ -76,7 +76,7 @@ module ActiveFedora
76
76
  :title,
77
77
  :type,
78
78
  :valid
79
- ] # removed :format
79
+ ].freeze # removed :format
80
80
  DCTERMS.freeze
81
81
 
82
82
  # Constructor. this class will call self.field for each DCTERM. In short, all DCTERMS fields will already exist
@@ -157,6 +157,12 @@ module ActiveFedora::RDF
157
157
  comment: %(indicates the owner of an object).freeze,
158
158
  label: "ownerId".freeze,
159
159
  type: "rdf:Property".freeze
160
+ property :PID,
161
+ comment: %(the Fedora 3 PID for an object).freeze,
162
+ label: "PID".freeze,
163
+ domain: "info:fedora/fedora-system:def/model#FedoraObject".freeze,
164
+ range: "xsd:string".freeze,
165
+ type: "rdf:Property".freeze
160
166
  property :state,
161
167
  comment: %(indicates the state of the object or datastream).freeze,
162
168
  label: "state".freeze,