Sha256: ee51bd363695e474f97d8a4c8f2ebd27e3c323c00ed41318b45f0e483d361d22
Contents?: true
Size: 1.65 KB
Versions: 3
Compression:
Stored size: 1.65 KB
Contents
# encoding: utf-8 require "pathname" module Desi class LocalInstall DEFAULT_DIR = '~/elasticsearch' class Release def self.all_in(workdir) Dir[workdir.join('*')]. select {|subdir| File.directory?(subdir) && File.basename(subdir) =~ /^elasticsearch\-\d+\.\d+\.\d+/ }. map {|dirname| new(dirname, workdir) } end def initialize(dirname, workdir) @dirname = Pathname.new(dirname) @workdir = workdir end def name @name ||= File.basename(@dirname) end def current? current_symlink? && current_symlink.realpath == @dirname end def version @version ||= /^elasticsearch\-(?<version>.*)$/.match(name.to_s)[:version] end def to_s current_mark = current? ? '*' : '-' " #{current_mark} #{name} (#{@dirname})" end def <=>(other) name <=> other.name end private def current_symlink @current_symlink ||= Pathname(@workdir).join('current') end def current_symlink? current_symlink.exist? end end def initialize(workdir = nil) @workdir = Pathname(File.expand_path(workdir || DEFAULT_DIR)) end def exists? @workdir.exist? end def current_dir @workdir.join('current') end def create! FileUtils.mkdir_p @workdir end def releases Release.all_in(@workdir) end def to_path @workdir.to_s end def to_s to_path end def pidfile @workdir.join('elasticsearch.pid') end def launcher current_dir.join('bin', 'elasticsearch') end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
desi-0.2.1 | lib/desi/local_install.rb |
desi-0.2.0 | lib/desi/local_install.rb |
desi-0.1.0 | lib/desi/local_install.rb |