Module: Kitchen::Terraform::Version

Defined in:
lib/kitchen/terraform/version.rb

Overview

Kitchen::Terraform::Version represents the version of the Kitchen-Terraform gem. The module can send the version to different containers as well as conditionally yield to blocks based on version requirements.

Class Method Summary collapse

Class Method Details

.assign_plugin_version(configurable_class:) ⇒ self

assign_plugin_version assigns the version to a class which includes Kitchen::Configurable.

Parameters:

  • configurable_class (Kitchen::Configurable)

    the configurable class to which the version will be assigned.

Returns:

  • (self)


29
30
31
32
# File 'lib/kitchen/terraform/version.rb', line 29

def assign_plugin_version(configurable_class:)
  configurable_class.plugin_version value.to_s
  self
end

.assign_specification_version(specification:) ⇒ self

assign_specification_version assigns the version to a Gem::Specification.

Parameters:

  • specification (Gem::Specification)

    the specification to which the version will be assigned.

Returns:

  • (self)


38
39
40
41
# File 'lib/kitchen/terraform/version.rb', line 38

def assign_specification_version(specification:)
  specification.version = value
  self
end

.if_satisfies(requirement:) { ... } ⇒ self

if_satisfies yields control if the provided requirement is satisfied by the version.

Parameters:

  • requirement (Gem::Requirement, ::String)

    the requirement to be satisfied by the version.

Yields:

  • if the requirement is satisfied by the version.

Returns:

  • (self)

Raises:

  • (Gem::Requirement::BadRequirementError)

    if the requirement is illformed.



49
50
51
52
53
# File 'lib/kitchen/terraform/version.rb', line 49

def if_satisfies(requirement:)
  yield if ::Gem::Requirement.new(requirement).satisfied_by? value

  self
end

.temporarily_override(version:) { ... } ⇒ self

Note:

temporarily_override must only be used in tests to validate version flow control logic.

temporarily_override overrides the current version with the version provided, yields control, and then resets the version.

Yields:

  • the value of the version will be overridden while control is yielded.

Returns:

  • (self)

Raises:

  • (ArgumentError)

    if the version is malformed.



62
63
64
65
66
67
68
# File 'lib/kitchen/terraform/version.rb', line 62

def temporarily_override(version:)
  current_value = value
  self.value = version
  yield
  self.value = current_value
  self
end