Class: HelmWrapper::Shared::Binary

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/helm-wrapper/shared/binary.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

configure_logger_for, logger_for

Constructor Details

#initialize(options:) ⇒ Binary

Returns a new instance of Binary.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/helm-wrapper/shared/binary.rb', line 30

def initialize(options:)
  logger.fatal("Binary base path must be a string!") unless options["base"].kind_of?(String)
  logger.fatal("Binary base path must not be blank!") if options["base"].strip.empty?

  @base = options["base"]

  logger.fatal("Binary version must be a string!") unless options["version"].kind_of?(String)
  logger.fatal("Binary version must not be blank!") if options["version"].strip.empty?

  @version = options["version"]

  @platform = platform_detect

  @directory = File.join(@base, @version, @platform)
  @name = "helm"
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



23
24
25
# File 'lib/helm-wrapper/shared/binary.rb', line 23

def base
  @base
end

#directoryObject (readonly)

Returns the value of attribute directory.



24
25
26
# File 'lib/helm-wrapper/shared/binary.rb', line 24

def directory
  @directory
end

#nameObject

Returns the value of attribute name.



19
20
21
# File 'lib/helm-wrapper/shared/binary.rb', line 19

def name
  @name
end

#platformObject (readonly)

Returns the value of attribute platform.



25
26
27
# File 'lib/helm-wrapper/shared/binary.rb', line 25

def platform
  @platform
end

#versionObject (readonly)

Returns the value of attribute version.



26
27
28
# File 'lib/helm-wrapper/shared/binary.rb', line 26

def version
  @version
end

Instance Method Details

#checkObject



49
50
51
52
53
54
55
56
57
# File 'lib/helm-wrapper/shared/binary.rb', line 49

def check()
  result = false

  if exists and executable then
    result = system("\"#{path}\" version --short") || false
  end

  return result
end

#executableObject



67
68
69
# File 'lib/helm-wrapper/shared/binary.rb', line 67

def executable()
  return File.executable?(path)
end

#existsObject



61
62
63
# File 'lib/helm-wrapper/shared/binary.rb', line 61

def exists()
  return File.exist?(path)
end

#pathObject



73
74
75
# File 'lib/helm-wrapper/shared/binary.rb', line 73

def path()
  return File.join(@directory, @name)
end