Sha256: 600880aa9c3e5ddff0e51f6cd773c2e223c8c7f466f05948c5ddf1e02fd75b08

Contents?: true

Size: 1.17 KB

Versions: 19

Compression:

Stored size: 1.17 KB

Contents

#!/usr/bin/env ruby

using_gems = false
begin
  require 'fileutils'
  require 'optiflag'
  require File.join(File.dirname(__FILE__), '..', 'lib', 'sunspot', 'schema')
rescue LoadError => e
  if using_gems
    raise(e)
  else
    using_gems = true
    require 'rubygems'
    retry
  end
end

module ConfigureSolrFlags extend OptiFlagSet
  optional_flag 'tokenizer'
  optional_flag 'extra_filters'
  optional_flag 'dir'
  and_process!
end

solr_directory = ARGV.flags.dir || FileUtils.pwd
conf_directory = File.join(solr_directory, 'conf')
schema_file = File.join(conf_directory, 'schema.xml')
FileUtils.mkdir_p(conf_directory)

schema = Sunspot::Schema.new
schema.tokenizer = ARGV.flags.tokenizer if ARGV.flags.tokenizer
if ARGV.flags.extra_filters
  for filter in ARGV.flags.extra_filters.split(',')
    schema.add_filter(filter)
  end
end

if File.exist?(schema_file)
  backup_file = File.join(conf_directory, "schema-#{File.mtime(schema_file).strftime('%Y%m%d%H%M%S')}.xml")
  STDERR.puts("Backing up current schema file to #{File.expand_path(backup_file)}")
  FileUtils.mv(schema_file, backup_file)
end

File.open(File.join(conf_directory, 'schema.xml'), 'w') do |file|
  file << schema.to_xml
end

Version data entries

19 entries across 19 versions & 7 rubygems

Version Path
Chrononaut-sunspot-client-0.9.4 bin/sunspot-configure-solr
UnderpantsGnome-sunspot-0.9.1.1 bin/sunspot-configure-solr
UnderpantsGnome-sunspot-0.9.8.1 bin/sunspot-configure-solr
benjaminkrause-sunspot-0.9.7 bin/sunspot-configure-solr
benjaminkrause-sunspot-0.9.8 bin/sunspot-configure-solr
kristopher-sunspot-0.9.8 bin/sunspot-configure-solr
kuahyeow-sunspot-0.9.7 bin/sunspot-configure-solr
kuahyeow-sunspot-0.9.8 bin/sunspot-configure-solr
outoftime-sunspot-0.9.0 bin/sunspot-configure-solr
outoftime-sunspot-0.9.1 bin/sunspot-configure-solr
outoftime-sunspot-0.9.2 bin/sunspot-configure-solr
outoftime-sunspot-0.9.3 bin/sunspot-configure-solr
outoftime-sunspot-0.9.4 bin/sunspot-configure-solr
outoftime-sunspot-0.9.5 bin/sunspot-configure-solr
outoftime-sunspot-0.9.6 bin/sunspot-configure-solr
outoftime-sunspot-0.9.7 bin/sunspot-configure-solr
outoftime-sunspot-0.9.8 bin/sunspot-configure-solr
sunspot-0.9.8 bin/sunspot-configure-solr
sunspot-0.9.7 bin/sunspot-configure-solr