active-fedora 11.0.1 → 11.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -9
  3. data/Gemfile +1 -0
  4. data/History.txt +34 -0
  5. data/active-fedora.gemspec +3 -4
  6. data/lib/active_fedora.rb +1 -0
  7. data/lib/active_fedora/associations/collection_association.rb +2 -2
  8. data/lib/active_fedora/associations/collection_proxy.rb +10 -10
  9. data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +1 -1
  10. data/lib/active_fedora/attribute_methods.rb +1 -1
  11. data/lib/active_fedora/attributes.rb +1 -1
  12. data/lib/active_fedora/cleaner.rb +1 -1
  13. data/lib/active_fedora/core.rb +11 -5
  14. data/lib/active_fedora/fedora.rb +7 -3
  15. data/lib/active_fedora/file.rb +1 -0
  16. data/lib/active_fedora/file_configurator.rb +3 -3
  17. data/lib/active_fedora/indexing.rb +1 -1
  18. data/lib/active_fedora/initializing_connection.rb +1 -1
  19. data/lib/active_fedora/loadable_from_json.rb +1 -1
  20. data/lib/active_fedora/model_classifier.rb +1 -1
  21. data/lib/active_fedora/null_logger.rb +10 -0
  22. data/lib/active_fedora/orders/ordered_list.rb +1 -1
  23. data/lib/active_fedora/relation/finder_methods.rb +3 -1
  24. data/lib/active_fedora/solr_hit.rb +1 -1
  25. data/lib/active_fedora/version.rb +1 -1
  26. data/lib/active_fedora/with_metadata/metadata_node.rb +2 -1
  27. data/spec/integration/attached_files_spec.rb +1 -1
  28. data/spec/integration/base_spec.rb +5 -5
  29. data/spec/integration/file_spec.rb +7 -7
  30. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +2 -2
  31. data/spec/integration/scoping_spec.rb +3 -3
  32. data/spec/unit/base_spec.rb +5 -5
  33. data/spec/unit/builder/has_and_belongs_to_many_spec.rb +1 -1
  34. data/spec/unit/core/fedora_id_translator_spec.rb +2 -2
  35. data/spec/unit/core/fedora_uri_translator_spec.rb +2 -2
  36. data/spec/unit/core/logger_spec.rb +18 -0
  37. data/spec/unit/core_spec.rb +6 -6
  38. data/spec/unit/file_path_builder_spec.rb +2 -2
  39. data/spec/unit/file_spec.rb +34 -2
  40. data/spec/unit/indexing_spec.rb +2 -2
  41. data/spec/unit/query_spec.rb +2 -2
  42. data/spec/unit/validations_spec.rb +3 -3
  43. metadata +17 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16ead45129d9f2be4aa17bde6a13d62a1079cf31
4
- data.tar.gz: ae8fb524751ba62d38fe12f0f4b3953efaf2a4e1
3
+ metadata.gz: d30a0af700ab6f5855f2ac0dae9bd20aace608b3
4
+ data.tar.gz: f2e755860c2c67c4559c339c1468fa0a23b6038f
5
5
  SHA512:
6
- metadata.gz: f043c0eabd5bc35f273e2d479d01edf61afc4d5987ac3c48eef8fd58eae863f5901d87192fea088c2e4d0c6d0abe6bf93931c8fab2fb80b5d443f870575bc625
7
- data.tar.gz: f2eff2fb6b5d014e6c6ec7a1f97cb4dd152ee92218526040bc78a6fbe53463018b15009d620677fefe29e6aef9183d882f6f4a818a89e725578523a0e38760ac
6
+ metadata.gz: 61d91bdf7413839f75fa6be613786888dd74fd0a19253cc911886fbf6877d6b2d1903cb924c6312d0e92c5cc7d719f7394e5d5ab1c6d9d960a40b15c7d885125
7
+ data.tar.gz: f11e71036ebc0316ebc79bef415d98e0f0fa09036f3ce7438cf6839baf3cca87a168f1ec53e83366913e24d33d246d3d394647ac21a9c5480a1f92610a67a030
@@ -1,15 +1,12 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  sudo: false
4
- rvm:
5
- - 2.3.0
6
-
7
- notifications:
8
- irc: "irc.freenode.org#projecthydra"
9
-
10
- env:
11
- - "RAILS_VERSION=4.2.6"
12
-
4
+ rvm: 2.4.0
5
+ matrix:
6
+ include:
7
+ - rvm: 2.3.3
8
+ env: "RAILS_VERSION=4.2.7.1"
9
+ - env: "RSOLR_VERSION=2.0.0.pre1"
13
10
  global_env:
14
11
  - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
15
12
  before_script:
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ gem 'byebug' unless ENV['TRAVIS']
8
8
  gem 'pry-byebug' unless ENV['CI']
9
9
 
10
10
  gem 'activemodel', ENV['RAILS_VERSION'] if ENV['RAILS_VERSION']
11
+ gem 'rsolr', ENV['RSOLR_VERSION'] if ENV['RSOLR_VERSION']
11
12
 
12
13
  group :test do
13
14
  gem 'simplecov', require: false
@@ -1,3 +1,37 @@
1
+ v11.1.0
2
+ 2017-01-12: Casting an RDF::URI to a RDF::URI is unnecessary [Justin Coyne]
3
+
4
+ 2017-01-06: Replace deprecated Fixnum with Integer [Justin Coyne]
5
+
6
+ 2017-01-06: Pin rubocop-rspec to 1.8.0 [Justin Coyne]
7
+
8
+ 2017-01-06: Add Ruby 2.4.0 to the test matrix [Justin Coyne]
9
+
10
+ 2016-12-19: Removing invalid namespaces from tests [Esmé Cowles]
11
+
12
+ 2016-12-16: Correct the documentation [Justin Coyne]
13
+
14
+ 2016-11-14: Use base_uri instead of relying on id_to_uri [Chris Colvard]
15
+
16
+ 2016-11-14: Add base_uri convenience method [Chris Colvard]
17
+
18
+ 2016-11-09: There is no need to pin rake anylonger [Justin Coyne]
19
+
20
+ 2016-10-28: Allow logger to be set by default. Fixes #1170 [Justin Coyne]
21
+
22
+ 2016-10-28: Add return value YARD doc [Justin Coyne]
23
+
24
+ 2016-10-28: Update to latest Rubocop [Adam Wead]
25
+
26
+ 2016-10-27: Stop spamming IRC with Travis builds [Michael J. Giarlo]
27
+
28
+ 2016-10-19: Changing file to accept any object that responds to URI including
29
+ another File object or a Version [Carolyn Cole]
30
+
31
+ 2016-09-30: Test with rsolr 2.x [Chris Beer]
32
+
33
+ 2016-09-22: Use ActiveFedora::NullLogger [Adam Wead]
34
+
1
35
  v9.10.1
2
36
  2016-03-26: Fix #reflect_on_association. [Trey Pendragon]
3
37
 
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.license = "APACHE2"
15
15
  s.required_ruby_version = '~> 2.0'
16
16
 
17
- s.add_dependency 'rsolr', '~> 1.1', '>= 1.1.2'
17
+ s.add_dependency 'rsolr', '>= 1.1.2', '< 3'
18
18
  s.add_dependency 'solrizer', '~> 3.4'
19
19
  s.add_dependency "activesupport", '>= 4.2.4', '< 6'
20
20
  s.add_dependency "activemodel", '>= 4.2', '< 6'
@@ -25,8 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.add_development_dependency "rails"
26
26
  s.add_development_dependency "rdoc"
27
27
  s.add_development_dependency "yard"
28
- # Pin rake to 10.0 due to https://github.com/lsegal/yard/issues/947
29
- s.add_development_dependency "rake", '~> 10.0'
28
+ s.add_development_dependency "rake"
30
29
  s.add_development_dependency "solr_wrapper", "~> 0.15"
31
30
  s.add_development_dependency 'fcrepo_wrapper', '~> 0.2'
32
31
  s.add_development_dependency "rspec", "~> 3.0"
@@ -34,7 +33,7 @@ Gem::Specification.new do |s|
34
33
  s.add_development_dependency "equivalent-xml"
35
34
  s.add_development_dependency "simplecov", '~> 0.8'
36
35
  s.add_development_dependency "rubocop", '~> 0.42.0'
37
- s.add_development_dependency "rubocop-rspec", '~> 1.6'
36
+ s.add_development_dependency "rubocop-rspec", '~> 1.8.0'
38
37
 
39
38
  s.files = `git ls-files`.split("\n")
40
39
  s.test_files = `git ls-files -- {spec}/*`.split("\n")
@@ -89,6 +89,7 @@ module ActiveFedora #:nodoc:
89
89
  autoload :ModelClassifier
90
90
  autoload :NestedAttributes
91
91
  autoload :NullRelation
92
+ autoload :NullLogger
92
93
  autoload :Orders
93
94
  autoload :Pathing
94
95
  autoload :Persistence
@@ -204,7 +204,7 @@ module ActiveFedora
204
204
  # Note that this method will _always_ remove records from the database
205
205
  # ignoring the +:dependent+ option.
206
206
  def destroy(*records)
207
- records = find(records) if records.any? { |record| record.is_a?(Fixnum) || record.is_a?(String) }
207
+ records = find(records) if records.any? { |record| record.is_a?(Integer) || record.is_a?(String) }
208
208
  delete_or_destroy(records, :destroy)
209
209
  end
210
210
 
@@ -305,7 +305,7 @@ module ActiveFedora
305
305
  records.each { |record| set_inverse_instance(record) }
306
306
  records
307
307
  rescue ObjectNotFoundError, Ldp::Gone => e
308
- ActiveFedora::Base.logger.error "Solr and Fedora may be out of sync:\n" + e.message if ActiveFedora::Base.logger
308
+ ActiveFedora::Base.logger.error "Solr and Fedora may be out of sync:\n" + e.message
309
309
  reset
310
310
  []
311
311
  end
@@ -115,7 +115,7 @@ module ActiveFedora
115
115
  end
116
116
 
117
117
  # Finds an object in the collection responding to the +id+. Uses the same
118
- # rules as <tt>ActiveFedora::Base.find</tt>. Returns <tt>ActiveFedora::RecordNotFound</tt>
118
+ # rules as <tt>ActiveFedora::Base.find</tt>. Returns <tt>ActiveFedora::ObjectNotFoundError</tt>
119
119
  # error if the object can not be found.
120
120
  #
121
121
  # class Person < ActiveFedora::Base
@@ -130,7 +130,7 @@ module ActiveFedora
130
130
  # # ]
131
131
  #
132
132
  # person.pets.find(1) # => #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>
133
- # person.pets.find(4) # => ActiveFedora::RecordNotFound: Couldn't find Pet with id=4
133
+ # person.pets.find(4) # => ActiveFedora::ObjectNotFoundError: Couldn't find Pet with id=4
134
134
  #
135
135
  # person.pets.find(2) { |pet| pet.name.downcase! }
136
136
  # # => #<Pet id: 2, name: "fancy-fancy", person_id: 1>
@@ -394,7 +394,7 @@ module ActiveFedora
394
394
  # # ]
395
395
  #
396
396
  # Pet.find(1, 2, 3)
397
- # # => ActiveFedora::RecordNotFound
397
+ # # => ActiveFedora::ObjectNotFoundError
398
398
  #
399
399
  # If it is set to <tt>:delete_all</tt>, all the objects are deleted
400
400
  # *without* calling their +destroy+ method.
@@ -419,7 +419,7 @@ module ActiveFedora
419
419
  # # ]
420
420
  #
421
421
  # Pet.find(1, 2, 3)
422
- # # => ActiveFedora::RecordNotFound
422
+ # # => ActiveFedora::ObjectNotFoundError
423
423
  def delete_all
424
424
  @association.delete_all
425
425
  end
@@ -511,7 +511,7 @@ module ActiveFedora
511
511
  # # => [#<Pet id: 2, name: "Spook", person_id: 1>]
512
512
  #
513
513
  # Pet.find(1, 3)
514
- # # => ActiveFedora::RecordNotFound: Couldn't find all Pets with IDs (1, 3)
514
+ # # => ActiveFedora::ObjectNotFoundError: Couldn't find all Pets with IDs (1, 3)
515
515
  #
516
516
  # If it is set to <tt>:delete_all</tt>, all the +records+ are deleted
517
517
  # *without* calling their +destroy+ method.
@@ -539,9 +539,9 @@ module ActiveFedora
539
539
  # # ]
540
540
  #
541
541
  # Pet.find(1)
542
- # # => ActiveFedora::RecordNotFound: Couldn't find Pet with id=1
542
+ # # => ActiveFedora::ObjectNotFoundError: Couldn't find Pet with id=1
543
543
  #
544
- # You can pass +Fixnum+ or +String+ values, it finds the records
544
+ # You can pass +Integer+ or +String+ values, it finds the records
545
545
  # responding to the +id+ and executes delete on them.
546
546
  #
547
547
  # class Person < ActiveFedora::Base
@@ -603,9 +603,9 @@ module ActiveFedora
603
603
  # person.pets.size # => 0
604
604
  # person.pets # => []
605
605
  #
606
- # Pet.find(1, 2, 3) # => ActiveFedora::RecordNotFound: Couldn't find all Pets with IDs (1, 2, 3)
606
+ # Pet.find(1, 2, 3) # => ActiveFedora::ObjectNotFoundError: Couldn't find all Pets with IDs (1, 2, 3)
607
607
  #
608
- # You can pass +Fixnum+ or +String+ values, it finds the records
608
+ # You can pass +Integer+ or +String+ values, it finds the records
609
609
  # responding to the +id+ and then deletes them from the database.
610
610
  #
611
611
  # person.pets.size # => 3
@@ -635,7 +635,7 @@ module ActiveFedora
635
635
  # person.pets.size # => 0
636
636
  # person.pets # => []
637
637
  #
638
- # Pet.find(4, 5, 6) # => ActiveFedora::RecordNotFound: Couldn't find all Pets with IDs (4, 5, 6)
638
+ # Pet.find(4, 5, 6) # => ActiveFedora::ObjectNotFoundError: Couldn't find all Pets with IDs (4, 5, 6)
639
639
  def destroy(*records)
640
640
  @association.destroy(*records)
641
641
  end
@@ -21,7 +21,7 @@ module ActiveFedora
21
21
  if reflection.options[:inverse_of]
22
22
  inverse = reflection.inverse_of
23
23
  if owner.new_record?
24
- ActiveFedora::Base.logger.warn("has_and_belongs_to_many #{reflection.inspect} is cowardly refusing to insert the inverse relationship into #{record}, because #{owner} is not persisted yet.") if ActiveFedora::Base.logger
24
+ ActiveFedora::Base.logger.warn("has_and_belongs_to_many #{reflection.inspect} is cowardly refusing to insert the inverse relationship into #{record}, because #{owner} is not persisted yet.")
25
25
  elsif inverse.has_and_belongs_to_many?
26
26
  record[inverse.foreign_key] ||= []
27
27
  record[inverse.foreign_key] += [owner.id]
@@ -235,7 +235,7 @@ module ActiveFedora
235
235
  # person = Person.new
236
236
  # person[:age] = '22'
237
237
  # person[:age] # => 22
238
- # person[:age] # => Fixnum
238
+ # person[:age] # => Integer
239
239
  def []=(attr_name, value)
240
240
  write_attribute(attr_name, value)
241
241
  end
@@ -138,7 +138,7 @@ module ActiveFedora
138
138
  def warn_duplicate_predicates(new_name, new_properties)
139
139
  new_predicate = new_properties[:predicate]
140
140
  properties.select { |_k, existing| existing.predicate == new_predicate }.each do |key, _value|
141
- ActiveFedora::Base.logger.warn "Same predicate (#{new_predicate}) used for properties #{key} and #{new_name}" if ActiveFedora::Base.logger
141
+ ActiveFedora::Base.logger.warn "Same predicate (#{new_predicate}) used for properties #{key} and #{new_name}"
142
142
  end
143
143
  end
144
144
 
@@ -48,7 +48,7 @@ module ActiveFedora
48
48
  end
49
49
 
50
50
  def self.log(message)
51
- ActiveFedora::Base.logger.debug message if ActiveFedora::Base.logger
51
+ ActiveFedora::Base.logger.debug message
52
52
  end
53
53
  end
54
54
  end
@@ -8,13 +8,19 @@ module ActiveFedora
8
8
  autoload :FedoraUriTranslator
9
9
 
10
10
  included do
11
- ##
12
- # :singleton-method:
13
- #
11
+ mattr_accessor :belongs_to_required_by_default, instance_accessor: false
12
+
14
13
  # Accepts a logger conforming to the interface of Log4r which can be
15
14
  # retrieved on both a class and instance level by calling +logger+.
16
- mattr_accessor :logger, instance_writer: false
17
- mattr_accessor :belongs_to_required_by_default, instance_accessor: false
15
+ class_attribute :logger
16
+
17
+ # Use NullLogger as the default and all messages sent to it are retuned as nil
18
+ self.logger = ActiveFedora::NullLogger.new
19
+
20
+ # All instances default to the class-level logger
21
+ def logger
22
+ self.class.logger
23
+ end
18
24
  end
19
25
 
20
26
  # Constructor. You may supply a custom +:id+, or we call the Fedora Rest API for the
@@ -23,11 +23,15 @@ module ActiveFedora
23
23
  end
24
24
 
25
25
  def host
26
- @config[:url]
26
+ @config[:url].sub(/\/$/, BLANK)
27
27
  end
28
28
 
29
29
  def base_path
30
- @config[:base_path] || '/'
30
+ @config[:base_path] || SLASH
31
+ end
32
+
33
+ def base_uri
34
+ host + base_path.sub(/\/$/, BLANK)
31
35
  end
32
36
 
33
37
  def user
@@ -86,7 +90,7 @@ module ActiveFedora
86
90
 
87
91
  def validate_options
88
92
  unless host.downcase.end_with?("/rest")
89
- ActiveFedora::Base.logger.warn "Fedora URL (#{host}) does not end with /rest. This could be a problem. Check your fedora.yml config" if ActiveFedora::Base.logger
93
+ ActiveFedora::Base.logger.warn "Fedora URL (#{host}) does not end with /rest. This could be a problem. Check your fedora.yml config"
90
94
  end
91
95
  end
92
96
  end
@@ -31,6 +31,7 @@ module ActiveFedora
31
31
  # @yieldparam [File] self the newly created file
32
32
  def initialize(identifier = nil, &_block)
33
33
  identifier = identifier.delete(:id) if identifier.is_a? Hash
34
+ identifier = identifier.uri if identifier.respond_to? :uri
34
35
  run_callbacks(:initialize) do
35
36
  case identifier
36
37
  when nil, ::RDF::URI
@@ -99,7 +99,7 @@ module ActiveFedora
99
99
  def load_fedora_config
100
100
  return @fedora_config unless @fedora_config.empty?
101
101
  @fedora_config_path = config_path(:fedora)
102
- ActiveFedora::Base.logger.info("ActiveFedora: loading fedora config from #{::File.expand_path(@fedora_config_path)}") if ActiveFedora::Base.logger
102
+ ActiveFedora::Base.logger.info("ActiveFedora: loading fedora config from #{::File.expand_path(@fedora_config_path)}")
103
103
 
104
104
  begin
105
105
  config_erb = ERB.new(IO.read(@fedora_config_path)).result(binding)
@@ -124,7 +124,7 @@ module ActiveFedora
124
124
  return @solr_config unless @solr_config.empty?
125
125
  @solr_config_path = config_path(:solr)
126
126
 
127
- ActiveFedora::Base.logger.info "ActiveFedora: loading solr config from #{::File.expand_path(@solr_config_path)}" if ActiveFedora::Base.logger
127
+ ActiveFedora::Base.logger.info "ActiveFedora: loading solr config from #{::File.expand_path(@solr_config_path)}"
128
128
  begin
129
129
  config_erb = ERB.new(IO.read(@solr_config_path)).result(binding)
130
130
  rescue StandardError
@@ -188,7 +188,7 @@ module ActiveFedora
188
188
  # Last choice, check for the default config file
189
189
  config_path = ::File.join(ActiveFedora.root, "config", "#{config_type}.yml")
190
190
  if ::File.file? config_path
191
- ActiveFedora::Base.logger.warn "Using the default #{config_type}.yml that comes with active-fedora. If you want to override this, pass the path to #{config_type}.yml to ActiveFedora - ie. ActiveFedora.init(:#{config_type}_config_path => '/path/to/#{config_type}.yml') - or set Rails.root and put #{config_type}.yml into \#{Rails.root}/config." if ActiveFedora::Base.logger
191
+ ActiveFedora::Base.logger.warn "Using the default #{config_type}.yml that comes with active-fedora. If you want to override this, pass the path to #{config_type}.yml to ActiveFedora - ie. ActiveFedora.init(:#{config_type}_config_path => '/path/to/#{config_type}.yml') - or set Rails.root and put #{config_type}.yml into \#{Rails.root}/config."
192
192
  return config_path
193
193
  else
194
194
  raise ConfigurationError, "Couldn't load #{config_type} config file!"
@@ -83,7 +83,7 @@ module ActiveFedora
83
83
  end
84
84
 
85
85
  def reindex_everything
86
- descendants = descendant_uris(ActiveFedora::Base.id_to_uri(''))
86
+ descendants = descendant_uris(ActiveFedora.fedora.base_uri)
87
87
  descendants.shift # Discard the root uri
88
88
  descendants.each do |uri|
89
89
  logger.debug "Re-index everything ... #{uri}"
@@ -54,7 +54,7 @@ module ActiveFedora
54
54
  return if @initialized
55
55
 
56
56
  connection.head(root_resource_path)
57
- ActiveFedora::Base.logger.info "Attempted to init base path `#{root_resource_path}`, but it already exists" if ActiveFedora::Base.logger
57
+ ActiveFedora::Base.logger.info "Attempted to init base path `#{root_resource_path}`, but it already exists"
58
58
  @initialized = true
59
59
  false
60
60
  rescue Ldp::NotFound
@@ -176,7 +176,7 @@ module ActiveFedora
176
176
  def property_reflection(attribute_name)
177
177
  self.class.reflect_on_property(attribute_name)
178
178
  rescue ActiveTriples::UndefinedPropertyError
179
- ActiveFedora::Base.logger.info "Undefined property #{attribute_name} reflected." if ActiveFedora::Base.logger
179
+ ActiveFedora::Base.logger.info "Undefined property #{attribute_name} reflected."
180
180
  nil
181
181
  end
182
182
 
@@ -60,7 +60,7 @@ module ActiveFedora
60
60
 
61
61
  def classify(model_value)
62
62
  unless class_exists?(model_value)
63
- ActiveFedora::Base.logger.warn "'#{model_value}' is not a real class" if ActiveFedora::Base.logger
63
+ ActiveFedora::Base.logger.warn "'#{model_value}' is not a real class"
64
64
  return nil
65
65
  end
66
66
  ActiveFedora::ModelClassifier.class_from_string(model_value)
@@ -0,0 +1,10 @@
1
+ module ActiveFedora
2
+ class NullLogger < Logger
3
+ def initialize(*)
4
+ end
5
+
6
+ # allows all the usual logger method calls (warn, info, error, etc.)
7
+ def add(*)
8
+ end
9
+ end
10
+ end
@@ -174,7 +174,7 @@ module ActiveFedora
174
174
  def proxy_in
175
175
  proxies = to_a.map(&:proxy_in_id).compact.uniq
176
176
  if proxies.length > 1
177
- ActiveFedora::Base.logger.warn "WARNING: List contains nodes aggregated under different URIs. Returning only the first." if ActiveFedora::Base.logger
177
+ ActiveFedora::Base.logger.warn "WARNING: List contains nodes aggregated under different URIs. Returning only the first."
178
178
  end
179
179
  proxies.first
180
180
  end
@@ -130,7 +130,7 @@ module ActiveFedora
130
130
  begin
131
131
  yield(load_from_fedora(hit[ActiveFedora.id_field], cast))
132
132
  rescue Ldp::Gone
133
- ActiveFedora::Base.logger.error "Although #{hit[ActiveFedora.id_field]} was found in Solr, it doesn't seem to exist in Fedora. The index is out of synch." if ActiveFedora::Base.logger
133
+ ActiveFedora::Base.logger.error "Although #{hit[ActiveFedora.id_field]} was found in Solr, it doesn't seem to exist in Fedora. The index is out of synch."
134
134
  end
135
135
  end
136
136
  end
@@ -240,11 +240,13 @@ module ActiveFedora
240
240
 
241
241
  # Returns a solr query for the supplied conditions
242
242
  # @param[Hash,String,Array] conditions solr conditions to match
243
+ # @return [String]
243
244
  def create_query(conditions)
244
245
  build_query(build_where(conditions))
245
246
  end
246
247
 
247
248
  # @param [Array<String>] conditions
249
+ # @return [String]
248
250
  def build_query(conditions)
249
251
  clauses = search_model_clause ? [search_model_clause] : []
250
252
  clauses += conditions.reject(&:blank?)
@@ -36,7 +36,7 @@ module ActiveFedora
36
36
 
37
37
  def model(opts = {})
38
38
  best_model_match = classifier.best_model(opts)
39
- ActiveFedora::Base.logger.warn "Could not find a model for #{id}, defaulting to ActiveFedora::Base" if ActiveFedora::Base.logger && best_model_match == ActiveFedora::Base
39
+ ActiveFedora::Base.logger.warn "Could not find a model for #{id}, defaulting to ActiveFedora::Base" if best_model_match == ActiveFedora::Base
40
40
  best_model_match
41
41
  end
42
42
 
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "11.0.1".freeze
2
+ VERSION = "11.1.0".freeze
3
3
  end
@@ -10,6 +10,7 @@ module ActiveFedora
10
10
  # this class rather than being in the DefaultSchema.
11
11
  property :mime_type, predicate: ::RDF::Vocab::EBUCore.hasMimeType
12
12
 
13
+ # @param file [ActiveFedora::File]
13
14
  def initialize(file)
14
15
  @file = file
15
16
  super(file.uri, ldp_source.graph)
@@ -44,7 +45,7 @@ module ActiveFedora
44
45
 
45
46
  def save
46
47
  raise "Save the file first" if file.new_record?
47
- SparqlInsert.new(changes_for_update, ::RDF::URI.new(file.uri)).execute(metadata_uri)
48
+ SparqlInsert.new(changes_for_update, file.uri).execute(metadata_uri)
48
49
  @ldp_source = nil
49
50
  true
50
51
  end
@@ -46,7 +46,7 @@ describe ActiveFedora::AttachedFiles do
46
46
  Object.send(:remove_const, :DSTest)
47
47
  end
48
48
 
49
- it { should == 'XXX' }
49
+ it { is_expected.to eq('XXX') }
50
50
 
51
51
  context "After updating" do
52
52
  before do
@@ -48,12 +48,12 @@ describe ActiveFedora::Base do
48
48
 
49
49
  describe "#errors" do
50
50
  subject { obj.errors }
51
- it { should be_empty }
51
+ it { is_expected.to be_empty }
52
52
  end
53
53
 
54
54
  describe "#id" do
55
55
  subject { obj.id }
56
- it { should_not be_nil }
56
+ it { is_expected.to_not be_nil }
57
57
  end
58
58
 
59
59
  context "when updated with changes after one second" do
@@ -71,12 +71,12 @@ describe ActiveFedora::Base do
71
71
 
72
72
  describe "#create_date" do
73
73
  subject { obj.create_date }
74
- it { should_not be_nil }
74
+ it { is_expected.to_not be_nil }
75
75
  end
76
76
 
77
77
  describe "#modified_date" do
78
78
  subject { obj.modified_date }
79
- it { should_not be_nil }
79
+ it { is_expected.to_not be_nil }
80
80
  end
81
81
 
82
82
  describe "delete" do
@@ -130,7 +130,7 @@ describe ActiveFedora::Base do
130
130
  expect(described_class.exists?(obj.id)).to be true
131
131
  end
132
132
  it "returns false for ids that don't exist" do
133
- expect(described_class.exists?('test:missing_object')).to be false
133
+ expect(described_class.exists?('test_missing_object')).to be false
134
134
  end
135
135
  it "returns false for nil" do
136
136
  expect(described_class.exists?(nil)).to be false
@@ -84,7 +84,7 @@ describe ActiveFedora::File do
84
84
  allow_any_instance_of(SampleResource).to receive(:content_changed?).and_return(true)
85
85
  end
86
86
  subject { descMetadata.described_by }
87
- it { should eq descMetadata.uri + '/fcr:metadata' }
87
+ it { is_expected.to eq descMetadata.uri + '/fcr:metadata' }
88
88
  end
89
89
  end
90
90
 
@@ -108,7 +108,7 @@ describe ActiveFedora::File do
108
108
 
109
109
  describe "the metadata file" do
110
110
  subject { descMetadata }
111
- it { should be_a_kind_of(described_class) }
111
+ it { is_expected.to be_a_kind_of(described_class) }
112
112
  end
113
113
 
114
114
  context "a binary file" do
@@ -145,19 +145,19 @@ describe ActiveFedora::File do
145
145
  subject { str = ''; test_object.webm.stream(range).each { |chunk| str << chunk }; str }
146
146
  context "whole thing" do
147
147
  let(:range) { 'bytes=0-15' }
148
- it { should eq 'one1two2threfour' }
148
+ it { is_expected.to eq 'one1two2threfour' }
149
149
  end
150
150
  context "open ended" do
151
151
  let(:range) { 'bytes=0-' }
152
- it { should eq 'one1two2threfour' }
152
+ it { is_expected.to eq 'one1two2threfour' }
153
153
  end
154
154
  context "not starting at the beginning" do
155
155
  let(:range) { 'bytes=3-15' }
156
- it { should eq '1two2threfour' }
156
+ it { is_expected.to eq '1two2threfour' }
157
157
  end
158
158
  context "not ending at the end" do
159
159
  let(:range) { 'bytes=4-11' }
160
- it { should eq 'two2thre' }
160
+ it { is_expected.to eq 'two2thre' }
161
161
  end
162
162
  end
163
163
 
@@ -168,7 +168,7 @@ describe ActiveFedora::File do
168
168
  test_object.save!
169
169
  end
170
170
  subject { str = ''; test_object.redirector.stream.each { |chunk| str << chunk }; str }
171
- it { should eq 'one1two2threfour' }
171
+ it { is_expected.to eq 'one1two2threfour' }
172
172
  end
173
173
 
174
174
  context "when there are more than 3 requests because of redirects" do
@@ -171,14 +171,14 @@ describe ActiveFedora::Base do
171
171
 
172
172
  describe "#empty?" do
173
173
  subject { book.collections }
174
- it { should_not be_empty }
174
+ it { is_expected.to_not be_empty }
175
175
  end
176
176
  end
177
177
 
178
178
  context "when a book isn't in a collection" do
179
179
  describe "#empty?" do
180
180
  subject { book.collections }
181
- it { should be_empty }
181
+ it { is_expected.to be_empty }
182
182
  end
183
183
  end
184
184
  end
@@ -27,16 +27,16 @@ describe ActiveFedora::Scoping::Named do
27
27
  describe '#find' do
28
28
  describe "#find with a valid id without cast" do
29
29
  subject { ActiveFedora::Base.find(test_instance.id) }
30
- it { should be_instance_of TestClass }
30
+ it { is_expected.to be_instance_of TestClass }
31
31
  end
32
32
  describe "#find with a valid id with cast of false" do
33
33
  subject { ActiveFedora::Base.find(test_instance.id, cast: false) }
34
- it { should be_instance_of ActiveFedora::Base }
34
+ it { is_expected.to be_instance_of ActiveFedora::Base }
35
35
  end
36
36
 
37
37
  describe "#find with a valid id without cast on a model extending Base" do
38
38
  subject { TestClass.find(test_instance.id) }
39
- it { should be_instance_of TestClass }
39
+ it { is_expected.to be_instance_of TestClass }
40
40
  end
41
41
  end
42
42
  end
@@ -165,11 +165,11 @@ describe ActiveFedora::Base do
165
165
  context "before saving" do
166
166
  context "#to_param" do
167
167
  subject { @test_object.to_param }
168
- it { should be_nil }
168
+ it { is_expected.to be_nil }
169
169
  end
170
170
  context "#to_key" do
171
171
  subject { @test_object.to_key }
172
- it { should be_nil }
172
+ it { is_expected.to be_nil }
173
173
  end
174
174
  end
175
175
 
@@ -181,12 +181,12 @@ describe ActiveFedora::Base do
181
181
 
182
182
  context "#to_param" do
183
183
  subject { @test_object.to_param }
184
- it { should eq 'one/two/three' }
184
+ it { is_expected.to eq 'one/two/three' }
185
185
  end
186
186
 
187
187
  context "#to_key" do
188
188
  subject { @test_object.to_key }
189
- it { should eq ['one/two/three'] }
189
+ it { is_expected.to eq ['one/two/three'] }
190
190
  end
191
191
  end
192
192
  ### end ActiveModel::Conversions
@@ -253,7 +253,7 @@ describe ActiveFedora::Base do
253
253
  end
254
254
 
255
255
  it "updates the resource" do
256
- expect(test_object.resource.rdf_subject).to eq ::RDF::URI.new("#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/#{@this_id}")
256
+ expect(test_object.resource.rdf_subject).to eq ::RDF::URI.new("#{ActiveFedora.fedora.base_uri}/#{@this_id}")
257
257
  expect(test_object.title).to eq ['foo']
258
258
  end
259
259
  end
@@ -3,6 +3,6 @@ require 'spec_helper'
3
3
  describe ActiveFedora::Associations::Builder::HasAndBelongsToMany do
4
4
  describe "valid_options" do
5
5
  subject { described_class.valid_options({}) }
6
- it { should match_array [:class_name, :predicate, :type_validator, :before_add, :after_add, :before_remove, :after_remove, :inverse_of, :solr_page_size, :autosave] }
6
+ it { is_expected.to match_array [:class_name, :predicate, :type_validator, :before_add, :after_add, :before_remove, :after_remove, :inverse_of, :solr_page_size, :autosave] }
7
7
  end
8
8
  end
@@ -4,7 +4,7 @@ RSpec.describe ActiveFedora::Core::FedoraIdTranslator do
4
4
  describe ".call" do
5
5
  let(:result) { described_class.call(id) }
6
6
  context "when given an id" do
7
- let(:good_uri) { ActiveFedora.fedora.host + ActiveFedora.fedora.base_path + "/banana" }
7
+ let(:good_uri) { ActiveFedora.fedora.base_uri + "/banana" }
8
8
  let(:id) { "banana" }
9
9
  it "returns a fedora URI" do
10
10
  expect(result).to eq good_uri
@@ -18,7 +18,7 @@ RSpec.describe ActiveFedora::Core::FedoraIdTranslator do
18
18
  end
19
19
 
20
20
  context "with characters that need escaping" do
21
- let(:good_uri) { ActiveFedora.fedora.host + ActiveFedora.fedora.base_path + "/%5Bfrob%5D" }
21
+ let(:good_uri) { ActiveFedora.fedora.base_uri + "/%5Bfrob%5D" }
22
22
  let(:id) { "[frob]" }
23
23
  it "returns a good fedora URI" do
24
24
  expect(result).to eq good_uri
@@ -4,13 +4,13 @@ RSpec.describe ActiveFedora::Core::FedoraUriTranslator do
4
4
  describe ".call" do
5
5
  let(:result) { described_class.call(uri) }
6
6
  context "when given a Fedora URI" do
7
- let(:uri) { ActiveFedora.fedora.host + ActiveFedora.fedora.base_path + "/6" }
7
+ let(:uri) { ActiveFedora.fedora.base_uri + "/6" }
8
8
  it "returns the id" do
9
9
  expect(result).to eq '6'
10
10
  end
11
11
  end
12
12
  context "when given a URI missing a slash" do
13
- let(:uri) { ActiveFedora.fedora.host + ActiveFedora.fedora.base_path + "602-a" }
13
+ let(:uri) { ActiveFedora.fedora.base_uri + "602-a" }
14
14
  it "returns the id" do
15
15
  expect(result).to eq "602-a"
16
16
  end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActiveFedora::NullLogger do
4
+ before { ActiveFedora::Base.logger = described_class.new }
5
+ describe "::logger" do
6
+ let(:logger) { ActiveFedora::Base.logger }
7
+ it "when calling the logger" do
8
+ expect(logger.warn("warning!")).to be_nil
9
+ end
10
+ end
11
+
12
+ describe "#logger" do
13
+ let(:logger) { ActiveFedora::Base.new.logger }
14
+ it "when calling the logger" do
15
+ expect(logger.warn("warning!")).to be_nil
16
+ end
17
+ end
18
+ end
@@ -109,7 +109,7 @@ describe ActiveFedora::Base do
109
109
  subject(:uri) { described_class.id_to_uri(id) }
110
110
 
111
111
  context "with no custom proc is set" do
112
- it { should eq "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/123456w" }
112
+ it { is_expected.to eq "#{ActiveFedora.fedora.base_uri}/123456w" }
113
113
  it "justs call #translate_id_to_uri" do
114
114
  allow(described_class).to receive(:translate_id_to_uri).and_call_original
115
115
  allow(ActiveFedora::Core::FedoraIdTranslator).to receive(:call).and_call_original
@@ -122,11 +122,11 @@ describe ActiveFedora::Base do
122
122
 
123
123
  context "when custom proc is set" do
124
124
  before do
125
- described_class.translate_id_to_uri = lambda { |id| "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/foo/#{id}" }
125
+ described_class.translate_id_to_uri = lambda { |id| "#{ActiveFedora.fedora.base_uri}/foo/#{id}" }
126
126
  end
127
127
  after { described_class.translate_id_to_uri = nil }
128
128
 
129
- it { should eq "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/foo/123456w" }
129
+ it { is_expected.to eq "#{ActiveFedora.fedora.base_uri}/foo/123456w" }
130
130
  end
131
131
 
132
132
  context "with an empty base path" do
@@ -145,11 +145,11 @@ describe ActiveFedora::Base do
145
145
  end
146
146
 
147
147
  describe "uri_to_id" do
148
- let(:uri) { "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/foo/123456w" }
148
+ let(:uri) { "#{ActiveFedora.fedora.base_uri}/foo/123456w" }
149
149
  subject(:uri_id) { described_class.uri_to_id(uri) }
150
150
 
151
151
  context "with no custom proc is set" do
152
- it { should eq 'foo/123456w' }
152
+ it { is_expected.to eq 'foo/123456w' }
153
153
  it "justs call #translate_uri_to_id" do
154
154
  allow(described_class).to receive(:translate_uri_to_id).and_call_original
155
155
  allow(ActiveFedora::Core::FedoraUriTranslator).to receive(:call).and_call_original
@@ -166,7 +166,7 @@ describe ActiveFedora::Base do
166
166
  end
167
167
  after { described_class.translate_uri_to_id = nil }
168
168
 
169
- it { should eq '123456w' }
169
+ it { is_expected.to eq '123456w' }
170
170
  end
171
171
  end
172
172
 
@@ -5,14 +5,14 @@ describe ActiveFedora::FilePathBuilder do
5
5
  let(:parent) { ActiveFedora::Base.new(id: '1234') }
6
6
  subject { described_class.build(parent, nil, 'FOO') }
7
7
 
8
- it { should eq 'FOO1' }
8
+ it { is_expected.to eq 'FOO1' }
9
9
 
10
10
  context "when some datastreams exist" do
11
11
  before do
12
12
  allow(parent).to receive(:attached_files).and_return('FOO56' => instance_double(ActiveFedora::File))
13
13
  end
14
14
 
15
- it { should eq 'FOO57' }
15
+ it { is_expected.to eq 'FOO57' }
16
16
  end
17
17
  end
18
18
  end
@@ -51,14 +51,14 @@ describe ActiveFedora::File do
51
51
  context "and it's initialized with the URI" do
52
52
  let(:file) { described_class.new(parent.uri + "/FOO1") }
53
53
  it "works" do
54
- expect(uri.to_s).to eq "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/1234/FOO1"
54
+ expect(uri.to_s).to eq "#{ActiveFedora.fedora.base_uri}/1234/FOO1"
55
55
  end
56
56
  end
57
57
 
58
58
  context "and it's initialized with an ID" do
59
59
  let(:file) { described_class.new(parent.id + "/FOO1") }
60
60
  it "works" do
61
- expect(uri.to_s).to eq "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/1234/FOO1"
61
+ expect(uri.to_s).to eq "#{ActiveFedora.fedora.base_uri}/1234/FOO1"
62
62
  end
63
63
  end
64
64
  end
@@ -425,4 +425,36 @@ describe ActiveFedora::File do
425
425
  }
426
426
  end
427
427
  end
428
+
429
+ describe "#new" do
430
+ let(:file2) do
431
+ described_class.new do |file|
432
+ file.content = "My Content"
433
+ file.save!
434
+ end
435
+ end
436
+
437
+ context "when uri is passed to new" do
438
+ subject { described_class.new(file2.uri).content }
439
+
440
+ it { is_expected.to eq "My Content" }
441
+ end
442
+
443
+ context "when id is passed to new" do
444
+ subject { described_class.new(file2.id).content }
445
+
446
+ it { is_expected.to eq "My Content" }
447
+ end
448
+
449
+ context "when object responding to .uri is passed to new" do
450
+ subject { described_class.new(file2).content }
451
+ it { is_expected.to eq "My Content" }
452
+ end
453
+
454
+ context "when Array passed to new" do
455
+ it "raises an expection" do
456
+ expect { described_class.new([]) }.to raise_error
457
+ end
458
+ end
459
+ end
428
460
  end
@@ -29,12 +29,12 @@ describe ActiveFedora::Indexing do
29
29
 
30
30
  describe "#create_needs_index?" do
31
31
  subject { SpecNode.new.send(:create_needs_index?) }
32
- it { should be true }
32
+ it { is_expected.to be true }
33
33
  end
34
34
 
35
35
  describe "#update_needs_index?" do
36
36
  subject { SpecNode.new.send(:update_needs_index?) }
37
- it { should be true }
37
+ it { is_expected.to be true }
38
38
  end
39
39
  end
40
40
 
@@ -298,10 +298,10 @@ describe ActiveFedora::Base do
298
298
 
299
299
  describe "#load_from_fedora" do
300
300
  let(:relation) { ActiveFedora::Relation.new(described_class) }
301
- before { @obj = SpecModel::Basic.create(id: "test:123") }
301
+ before { @obj = SpecModel::Basic.create(id: "test_123") }
302
302
  after { @obj.destroy }
303
303
  it "casts when klass == ActiveFedora::Base and cast argument is nil" do
304
- expect(relation.send(:load_from_fedora, "test:123", nil)).to be_a SpecModel::Basic
304
+ expect(relation.send(:load_from_fedora, "test_123", nil)).to be_a SpecModel::Basic
305
305
  end
306
306
  end
307
307
  end
@@ -22,7 +22,7 @@ describe ActiveFedora::Base do
22
22
  validation_stub.attributes = { fubar: ['here'], swank: 'long enough' }
23
23
  end
24
24
 
25
- it { should be_valid }
25
+ it { is_expected.to be_valid }
26
26
  end
27
27
  describe "an invalid object" do
28
28
  before do
@@ -36,8 +36,8 @@ describe ActiveFedora::Base do
36
36
  end
37
37
 
38
38
  describe "required terms" do
39
- it { should be_required(:fubar) }
40
- it { should_not be_required(:swank) }
39
+ it { is_expected.to be_required(:fubar) }
40
+ it { is_expected.to_not be_required(:swank) }
41
41
  end
42
42
 
43
43
  describe "#save!" 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: 11.0.1
4
+ version: 11.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Zumwalt
@@ -10,28 +10,28 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-09-22 00:00:00.000000000 Z
13
+ date: 2017-01-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rsolr
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - "~>"
20
- - !ruby/object:Gem::Version
21
- version: '1.1'
22
19
  - - ">="
23
20
  - !ruby/object:Gem::Version
24
21
  version: 1.1.2
22
+ - - "<"
23
+ - !ruby/object:Gem::Version
24
+ version: '3'
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
28
28
  requirements:
29
- - - "~>"
30
- - !ruby/object:Gem::Version
31
- version: '1.1'
32
29
  - - ">="
33
30
  - !ruby/object:Gem::Version
34
31
  version: 1.1.2
32
+ - - "<"
33
+ - !ruby/object:Gem::Version
34
+ version: '3'
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: solrizer
37
37
  requirement: !ruby/object:Gem::Requirement
@@ -174,16 +174,16 @@ dependencies:
174
174
  name: rake
175
175
  requirement: !ruby/object:Gem::Requirement
176
176
  requirements:
177
- - - "~>"
177
+ - - ">="
178
178
  - !ruby/object:Gem::Version
179
- version: '10.0'
179
+ version: '0'
180
180
  type: :development
181
181
  prerelease: false
182
182
  version_requirements: !ruby/object:Gem::Requirement
183
183
  requirements:
184
- - - "~>"
184
+ - - ">="
185
185
  - !ruby/object:Gem::Version
186
- version: '10.0'
186
+ version: '0'
187
187
  - !ruby/object:Gem::Dependency
188
188
  name: solr_wrapper
189
189
  requirement: !ruby/object:Gem::Requirement
@@ -288,14 +288,14 @@ dependencies:
288
288
  requirements:
289
289
  - - "~>"
290
290
  - !ruby/object:Gem::Version
291
- version: '1.6'
291
+ version: 1.8.0
292
292
  type: :development
293
293
  prerelease: false
294
294
  version_requirements: !ruby/object:Gem::Requirement
295
295
  requirements:
296
296
  - - "~>"
297
297
  - !ruby/object:Gem::Version
298
- version: '1.6'
298
+ version: 1.8.0
299
299
  description: ActiveFedora provides for creating and managing objects in the Fedora
300
300
  Repository Architecture.
301
301
  email:
@@ -436,6 +436,7 @@ files:
436
436
  - lib/active_fedora/log_subscriber.rb
437
437
  - lib/active_fedora/model_classifier.rb
438
438
  - lib/active_fedora/nested_attributes.rb
439
+ - lib/active_fedora/null_logger.rb
439
440
  - lib/active_fedora/null_relation.rb
440
441
  - lib/active_fedora/orders.rb
441
442
  - lib/active_fedora/orders/collection_proxy.rb
@@ -604,6 +605,7 @@ files:
604
605
  - spec/unit/config_spec.rb
605
606
  - spec/unit/core/fedora_id_translator_spec.rb
606
607
  - spec/unit/core/fedora_uri_translator_spec.rb
608
+ - spec/unit/core/logger_spec.rb
607
609
  - spec/unit/core_spec.rb
608
610
  - spec/unit/default_model_mapper_spec.rb
609
611
  - spec/unit/fedora_spec.rb
@@ -675,7 +677,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
675
677
  version: '0'
676
678
  requirements: []
677
679
  rubyforge_project:
678
- rubygems_version: 2.5.1
680
+ rubygems_version: 2.6.8
679
681
  signing_key:
680
682
  specification_version: 4
681
683
  summary: A convenience libary for manipulating documents in the Fedora Repository.