class Desi::Installer
Public Class Methods
new(archive, opts = {})
click to toggle source
# File lib/desi/installer.rb, line 9 def initialize(archive, opts = {}) @verbose = opts[:verbose] @archive = archive.to_s @local_install = Desi::LocalInstall.new(opts[:destination_dir], verbose: @verbose) end
Public Instance Methods
config_file()
click to toggle source
# File lib/desi/installer.rb, line 41 def config_file release_dir.join('config', 'elasticsearch.yml') end
extracted?()
click to toggle source
# File lib/desi/installer.rb, line 22 def extracted? !!@extracted end
install!()
click to toggle source
# File lib/desi/installer.rb, line 15 def install! extract! unless extracted? install_config_file update_symlinks! remove_archive! end
install_config_file()
click to toggle source
# File lib/desi/installer.rb, line 26 def install_config_file unless original_config_backup.exist? puts " * Installing custom config file" if @verbose FileUtils.mv config_file, original_config_backup FileUtils.cp our_config_file, config_file end end
original_config_backup()
click to toggle source
# File lib/desi/installer.rb, line 45 def original_config_backup release_dir.join('config', 'elasticsearch.yml.dist') end
our_config_file()
click to toggle source
# File lib/desi/installer.rb, line 49 def our_config_file File.expand_path('../../../config/elasticsearch.yml', __FILE__) end
update_symlinks!()
click to toggle source
# File lib/desi/installer.rb, line 35 def update_symlinks! @local_install. update_current_to(release_dir). add_data_symlink(release_dir) end
Private Instance Methods
extract!()
click to toggle source
# File lib/desi/installer.rb, line 55 def extract! line = Cocaine::CommandLine.new("tar", "--keep-newer-files -C :extract_dir -zxf :archive") begin line.run(extract_dir: @local_install.to_s, archive: @archive) rescue Cocaine::CommandNotFoundError => e warn "The tar command must be available for this to work! #{e}" exit 1 else @extracted = true end end
release_dir()
click to toggle source
# File lib/desi/installer.rb, line 71 def release_dir @release_dir ||= Pathname(@local_install).join(File.basename(@archive, '.tar.gz')) end
remove_archive!()
click to toggle source
# File lib/desi/installer.rb, line 67 def remove_archive! FileUtils.rm @archive end