Class: TerraformWrapper::Shared::Code

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

configure_logger_for, logger_for

Constructor Details

#initialize(options:) ⇒ Code

Returns a new instance of Code.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/terraform-wrapper/shared/code.rb', line 25

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

  @base = options["base"]

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

  @name = options["name"]

  @path = File.join(@base, @name)
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



19
20
21
# File 'lib/terraform-wrapper/shared/code.rb', line 19

def base
  @base
end

#nameObject (readonly)

Returns the value of attribute name.



20
21
22
# File 'lib/terraform-wrapper/shared/code.rb', line 20

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



21
22
23
# File 'lib/terraform-wrapper/shared/code.rb', line 21

def path
  @path
end

Instance Method Details

#checkObject



41
42
43
# File 'lib/terraform-wrapper/shared/code.rb', line 41

def check()
  return exists
end

#existsObject



47
48
49
# File 'lib/terraform-wrapper/shared/code.rb', line 47

def exists()
  return File.directory?(@path)
end