Module: BlacklightCql

Defined in:
lib/blacklight_cql.rb,
lib/blacklight_cql/engine.rb,
lib/blacklight_cql/version.rb,
lib/blacklight_cql/explain_behavior.rb

Defined Under Namespace

Modules: ControllerExtension, ExplainBehavior, ExplainHelper, SearchBuilderExtension Classes: Engine

Constant Summary collapse

VERSION =
self.version

Class Method Summary collapse

Class Method Details

.configure_controller(bl_controller_class) ⇒ Object

Called by app using this gem in it’s (eg) CatalogController class definition

BlacklightCql.configure_controller(self)

to configure for BlacklightCql



50
51
52
53
54
55
56
57
# File 'lib/blacklight_cql.rb', line 50

def self.configure_controller(bl_controller_class)
  bl_controller_class.blacklight_config.configure do |config|
    hash = BlacklightCql::SolrHelperExtension.pseudo_search_field
    config.add_search_field hash[:key], hash
  end

  bl_controller_class.send(:helper, BlacklightCql::TemplateHelperExtension)
end

.configure_search_builder(search_builder_class) ⇒ Object

Called by app using this gem in it’s SearchBuilder class definition

BlacklightCql.configure_search_builder(self)

to configure for BlacklightCql



40
41
42
# File 'lib/blacklight_cql.rb', line 40

def self.configure_search_builder(search_builder_class)
  search_builder_class.send(:include, BlacklightCql::SolrHelperExtension)
end

.escape_quotes(input) ⇒ Object

Escape single or double quote marks with backslash



20
21
22
# File 'lib/blacklight_cql.rb', line 20

def self.escape_quotes(input)
  input.gsub("'", "\\\'").gsub('"', "\\\"")
end

.solr_param_quote(val) ⇒ Object

Escapes value for Solr LocalParam. Will wrap in quotes only if needed (if not needed, and the value turns out to have been a $param, then quotes will mess things up!), and escapes value inside quotes.



28
29
30
31
32
33
# File 'lib/blacklight_cql.rb', line 28

def self.solr_param_quote(val)
  unless val =~ /^[a-zA-Z$_\-\^]+$/
    val = "'" + escape_quotes(val) + "'"
  end
  return val
end

.versionObject



3
4
5
# File 'lib/blacklight_cql/version.rb', line 3

def self.version
  @version ||= File.read(File.join(File.dirname(__FILE__), '..', '..', 'VERSION')).chomp
end