Class: Desi::LocalInstall::Release

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dirname, workdir) ⇒ Release

Returns a new instance of Release.



16
17
18
19
# File 'lib/desi/local_install/release.rb', line 16

def initialize(dirname, workdir)
  @dirname = Pathname.new(dirname)
  @workdir = workdir
end

Class Method Details

.all_in(workdir) ⇒ Object



10
11
12
13
14
# File 'lib/desi/local_install/release.rb', line 10

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

Instance Method Details

#<=>(other) ⇒ Object



47
48
49
# File 'lib/desi/local_install/release.rb', line 47

def <=>(other)
  name <=> other.name
end

#==(other) ⇒ Object



43
44
45
# File 'lib/desi/local_install/release.rb', line 43

def ==(other)
  other.version.to_s == version.to_s
end

#current?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/desi/local_install/release.rb', line 25

def current?
  current_symlink? && current_symlink.realpath == @dirname
end

#nameObject



21
22
23
# File 'lib/desi/local_install/release.rb', line 21

def name
  @name ||= File.basename(@dirname)
end

#pre_one_zero?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/desi/local_install/release.rb', line 51

def pre_one_zero?
  @pre_one_zero ||= (version < Semantic::Version.new("1.0.0-alpha"))
end

#to_pathObject



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

def to_path
  @dirname.to_path
end

#to_sObject



37
38
39
40
41
# File 'lib/desi/local_install/release.rb', line 37

def to_s
  current_mark = current? ? '*' : '-'

  " #{current_mark} #{name} (#{@dirname})"
end

#versionObject



29
30
31
# File 'lib/desi/local_install/release.rb', line 29

def version
  @version ||= Semantic::Version.new(version_number)
end

#with_version?(other_version) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/desi/local_install/release.rb', line 33

def with_version?(other_version)
  version == Semantic::Version.new(other_version)
end