Class: BrewCaskTools::Casks::Version

Inherits:
Object
  • Object
show all
Defined in:
lib/bct/cask/version.rb

Overview

Parent class for different types of Versions

Constant Summary collapse

DIR_BLACKLIST =
['.', '..', '.metadata'].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ Version

Returns a new instance of Version.



9
10
11
# File 'lib/bct/cask/version.rb', line 9

def initialize(dir)
  @dir = dir
end

Class Method Details

.parse_version(version) ⇒ Object



30
31
32
33
34
# File 'lib/bct/cask/version.rb', line 30

def self.parse_version(version)
  Versionomy.parse(version)
rescue Versionomy::Errors::ParseError
  version
end

Instance Method Details

#latest?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/bct/cask/version.rb', line 17

def latest?
  all_versions.select { |version| version.to_s == 'latest' }.length.positive?
end

#oldObject



25
26
27
28
# File 'lib/bct/cask/version.rb', line 25

def old
  _, *previous = versions.reverse
  previous
end

#rm_oldObject



21
22
23
# File 'lib/bct/cask/version.rb', line 21

def rm_old
  old.each { |version| rm(version) }
end

#versionsObject



13
14
15
# File 'lib/bct/cask/version.rb', line 13

def versions
  @versions ||= latest? ? ['latest'] : all_versions.sort
end