Class: Sunspot::Solr::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/sunspot/solr/installer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path, options) ⇒ Installer


21
22
23
24
# File 'lib/sunspot/solr/installer.rb', line 21

def initialize(config_path, options)
  @config_path = config_path
  @options     = options
end

Instance Attribute Details

#config_pathObject (readonly)

Returns the value of attribute config_path


13
14
15
# File 'lib/sunspot/solr/installer.rb', line 13

def config_path
  @config_path
end

#optionsObject (readonly)

Returns the value of attribute options


13
14
15
# File 'lib/sunspot/solr/installer.rb', line 13

def options
  @options
end

Class Method Details

.execute(config_path, options = {}) ⇒ Object


8
9
10
# File 'lib/sunspot/solr/installer.rb', line 8

def execute(solr_home, options = {})
  new(Pathname(solr_home).expand_path, options).execute
end

Instance Method Details

#config_source_filesObject


60
61
62
# File 'lib/sunspot/solr/installer.rb', line 60

def config_source_files
  @config_source_files ||= glob_source_files
end

#executeObject


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/sunspot/solr/installer.rb', line 34

def execute
  return if sunspot_config_path == config_path

  config_source_files.each do |source_path|
    destination_path = get_destination_path(source_path)

    if destination_path.exist?
      next unless force?
      output "Removing existing file #{ destination_path }"
    end

    destination_dir = destination_path.dirname
    unless destination_dir.exist?
      output "Creating directory #{ destination_dir }"
      destination_dir.mkpath
    end

    output "Copying #{ source_path } => #{ destination_path }"
    FileUtils.copy(source_path, destination_path)
  end
end

#force?Boolean


26
27
28
# File 'lib/sunspot/solr/installer.rb', line 26

def force?
  !!@options[:force]
end

#sunspot_config_pathObject


56
57
58
# File 'lib/sunspot/solr/installer.rb', line 56

def sunspot_config_path
  @sunspot_config_path ||= Pathname(__FILE__).join("../../../../solr/solr")
end

#verbose?Boolean


30
31
32
# File 'lib/sunspot/solr/installer.rb', line 30

def verbose?
  !!@options[:verbose]
end