Module: Ansr::Blacklight
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/ansr_blacklight/relation/solr_projection_methods.rb,
lib/ansr_blacklight/request_builders.rb,
lib/ansr_blacklight/relation.rb,
lib/ansr_blacklight/base.rb,
lib/ansr_blacklight/arel.rb,
lib/ansr_blacklight.rb
Defined Under Namespace
Modules: RequestBuilders, SolrProjectionMethods
Classes: Base, Relation
Class Method Summary
collapse
Class Method Details
.solr ⇒ Object
18
19
20
|
# File 'lib/ansr_blacklight.rb', line 18
def self.solr
@solr ||= RSolr.connect(Ansr::Blacklight.solr_config)
end
|
.solr_config ⇒ Object
22
23
24
25
26
27
|
# File 'lib/ansr_blacklight.rb', line 22
def self.solr_config
@solr_config ||= begin
raise "The #{::Rails.env} environment settings were not found in the solr.yml config" unless solr_yml[::Rails.env]
solr_yml[::Rails.env].symbolize_keys
end
end
|
.solr_file ⇒ Object
14
15
16
|
# File 'lib/ansr_blacklight.rb', line 14
def self.solr_file
"#{::Rails.root.to_s}/config/solr.yml"
end
|
.solr_yml ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/ansr_blacklight.rb', line 29
def self.solr_yml
require 'erb'
require 'yaml'
return @solr_yml if @solr_yml
unless File.exists?(solr_file)
raise "You are missing a solr configuration file: #{solr_file}. Have you run \"rails generate blacklight:install\"?"
end
begin
@solr_erb = ERB.new(IO.read(solr_file)).result(binding)
rescue Exception => e
raise("solr.yml was found, but could not be parsed with ERB. \n#{$!.inspect}")
end
begin
@solr_yml = YAML::load(@solr_erb)
rescue StandardError => e
raise("solr.yml was found, but could not be parsed.\n")
end
if @solr_yml.nil? || !@solr_yml.is_a?(Hash)
raise("solr.yml was found, but was blank or malformed.\n")
end
return @solr_yml
end
|