require 'rubygems' require 'fileutils' require 'nokogiri' module Sunspot class Installer class SolrconfigUpdater include TaskHelper CONFIG_FILES = %w(solrconfig.xml elevate.xml spellings.txt stopwords.txt synonyms.txt) class < 2 ) end say("Wrote solrconfig to #{@solrconfig_path}") end end private def maybe_create_spatial_component if @root.xpath('searchComponent[@name="spatial"]').any? say('Spatial search component already defined') else say('Defining spatial search component') search_component_node = Nokogiri::XML::Node.new('searchComponent', @document) search_component_node['name'] = 'spatial' search_component_node['class'] = 'me.outofti.solrspatiallight.SpatialQueryComponent' @root << search_component_node end end def maybe_add_spatial_component_to_standard_handler standard_handler_node = @root.xpath('requestHandler[@name="standard"]').first last_components_node = standard_handler_node.xpath('arr[@name="last-components"]').first || add_element(standard_handler_node, 'arr', 'name' => 'last-components') if last_components_node.xpath('str[normalize-space()="spatial"]').any? say('Spatial search component already in standard search handler') else say('Adding spatial search component into standard search handler') add_element(last_components_node, 'str').content = 'spatial' end end end end end