Class: TerraformWrapper::Shared::Binary
- Inherits:
-
Object
- Object
- TerraformWrapper::Shared::Binary
- Includes:
- Logging
- Defined in:
- lib/terraform-wrapper/shared/binary.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#name ⇒ Object
Returns the value of attribute name.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #check ⇒ Object
- #executable ⇒ Object
- #exists ⇒ Object
-
#initialize(options:, provider:) ⇒ Binary
constructor
A new instance of Binary.
- #path ⇒ Object
Methods included from Logging
configure_logger_for, logger_for
Constructor Details
#initialize(options:, provider:) ⇒ Binary
Returns a new instance of Binary.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/terraform-wrapper/shared/binary.rb', line 31 def initialize(options:, provider:) logger.fatal("Binary base path must be a string!") unless ["base"].kind_of?(String) logger.fatal("Binary base path must not be blank!") if ["base"].strip.empty? @base = ["base"] logger.fatal("Binary version must be a string!") unless ["version"].kind_of?(String) logger.fatal("Binary version must not be blank!") if ["version"].strip.empty? @version = ["version"] @platform = platform_detect @directory = File.join(@base, @version, @platform) @provider = provider @name = "terraform" end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
23 24 25 |
# File 'lib/terraform-wrapper/shared/binary.rb', line 23 def base @base end |
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
24 25 26 |
# File 'lib/terraform-wrapper/shared/binary.rb', line 24 def directory @directory end |
#name ⇒ Object
Returns the value of attribute name.
19 20 21 |
# File 'lib/terraform-wrapper/shared/binary.rb', line 19 def name @name end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
26 27 28 |
# File 'lib/terraform-wrapper/shared/binary.rb', line 26 def platform @platform end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
25 26 27 |
# File 'lib/terraform-wrapper/shared/binary.rb', line 25 def provider @provider end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
27 28 29 |
# File 'lib/terraform-wrapper/shared/binary.rb', line 27 def version @version end |
Instance Method Details
#check ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/terraform-wrapper/shared/binary.rb', line 50 def check() result = false if exists and executable then result = system("\"#{path}\" version") || false end return result end |
#executable ⇒ Object
68 69 70 |
# File 'lib/terraform-wrapper/shared/binary.rb', line 68 def executable() return File.executable?(path) end |
#exists ⇒ Object
62 63 64 |
# File 'lib/terraform-wrapper/shared/binary.rb', line 62 def exists() return File.exist?(path) end |
#path ⇒ Object
74 75 76 |
# File 'lib/terraform-wrapper/shared/binary.rb', line 74 def path() return File.join(@directory, @name) end |