Class: Desi::LocalInstall

Inherits:
Object
  • Object
show all
Defined in:
lib/desi/local_install.rb

Defined Under Namespace

Classes: Release

Constant Summary collapse

DEFAULT_DIR =
'~/elasticsearch'

Instance Method Summary collapse

Constructor Details

#initialize(workdir = nil, opts = {}) ⇒ LocalInstall

Returns a new instance of LocalInstall.



54
55
56
57
58
# File 'lib/desi/local_install.rb', line 54

def initialize(workdir = nil, opts = {})
  @verbose = opts[:verbose]
  @workdir = Pathname(File.expand_path(workdir || DEFAULT_DIR))
  create!
end

Instance Method Details

#create!Object



76
77
78
# File 'lib/desi/local_install.rb', line 76

def create!
  FileUtils.mkdir_p @workdir
end

#current_dirObject



64
65
66
# File 'lib/desi/local_install.rb', line 64

def current_dir
  @workdir.join('current')
end

#exists?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/desi/local_install.rb', line 60

def exists?
  @workdir.exist?
end

#launcherObject



96
97
98
# File 'lib/desi/local_install.rb', line 96

def launcher
  current_dir.join('bin', 'elasticsearch')
end

#pidfileObject



92
93
94
# File 'lib/desi/local_install.rb', line 92

def pidfile
  @workdir.join('elasticsearch.pid')
end

#releasesObject



80
81
82
# File 'lib/desi/local_install.rb', line 80

def releases
  Release.all_in(@workdir)
end

#to_pathObject



84
85
86
# File 'lib/desi/local_install.rb', line 84

def to_path
  @workdir.to_s
end

#to_sObject



88
89
90
# File 'lib/desi/local_install.rb', line 88

def to_s
  to_path
end

#update_current_to(release_dir) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/desi/local_install.rb', line 68

def update_current_to(release_dir)
  current_dir_must_be_nil_or_symlink!

  puts " * Updating #{@local_install.current_dir} symlink" if @verbose
  FileUtils.remove(current_dir) if current_dir.exist?
  FileUtils.ln_sf(release_dir, current_dir)
end