Class: Sunspot::Solr::Installer::ConfigInstaller

Inherits:
Object
  • Object
show all
Includes:
FileUtils, TaskHelper
Defined in:
lib/sunspot/solr/installer/config_installer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TaskHelper

#say

Constructor Details

#initialize(config_path, options) ⇒ ConfigInstaller

Returns a new instance of ConfigInstaller.



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

def initialize(config_path, options)
  self.config_path = File.expand_path config_path
  self.force   = !!options[:force]
  @verbose = !!options[:verbose]
end

Instance Attribute Details

#config_pathObject

Returns the value of attribute config_path.



11
12
13
# File 'lib/sunspot/solr/installer/config_installer.rb', line 11

def config_path
  @config_path
end

#forceObject Also known as: force?

Returns the value of attribute force.



11
12
13
# File 'lib/sunspot/solr/installer/config_installer.rb', line 11

def force
  @force
end

Class Method Details

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



15
16
17
# File 'lib/sunspot/solr/installer/config_installer.rb', line 15

def execute(config_path, options = {})
  new(config_path, options).execute
end

Instance Method Details

#executeObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/sunspot/solr/installer/config_installer.rb', line 26

def execute
  return if sunspot_config_path == config_path

  sunspot_config_files do |file, dest|
    if File.exist?(dest)
      next unless force?
      say("Removing existing file #{dest}")
    end

    dir = dest.pathmap('%d')
    unless File.exist?(dir)
      say("Creating directory #{dir}")
      mkdir_p dir
    end

    next if File.directory? file

    say("Copying #{file} => #{dest}")
    cp(file, dest)
  end
end