Class: Sunspot::Solr::Installer
- Inherits:
-
Object
- Object
- Sunspot::Solr::Installer
- Defined in:
- lib/sunspot/solr/installer.rb
Instance Attribute Summary collapse
-
#config_path ⇒ Object
readonly
Returns the value of attribute config_path.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #config_source_files ⇒ Object
- #execute ⇒ Object
- #force? ⇒ Boolean
-
#initialize(config_path, options) ⇒ Installer
constructor
A new instance of Installer.
- #sunspot_config_path ⇒ Object
- #verbose? ⇒ Boolean
Constructor Details
#initialize(config_path, options) ⇒ Installer
Returns a new instance of Installer.
21 22 23 24 |
# File 'lib/sunspot/solr/installer.rb', line 21 def initialize(config_path, ) @config_path = config_path @options = end |
Instance Attribute Details
#config_path ⇒ Object (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 |
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/sunspot/solr/installer.rb', line 13 def @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, = {}) new(Pathname(solr_home)., ).execute end |
Instance Method Details
#config_source_files ⇒ Object
60 61 62 |
# File 'lib/sunspot/solr/installer.rb', line 60 def config_source_files @config_source_files ||= glob_source_files end |
#execute ⇒ Object
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_path ⇒ Object
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 |