Class: Kitchen::Terraform::VersionVerifierStrategyFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/terraform/version_verifier_strategy_factory.rb

Overview

VersionVerifierStrategyFactory is the class of objects which build strategies for instances of VersionVerifier.

Instance Method Summary collapse

Constructor Details

#initialize(version_requirement:) ⇒ Kitchen::Terraform::VersionVerifierStrategyFactory

#initialize prepares a new instance of the class.

Parameters:

  • version_requirement (Gem::Requirement)

    the requirement for version support.



41
42
43
# File 'lib/kitchen/terraform/version_verifier_strategy_factory.rb', line 41

def initialize(version_requirement:)
  self.version_requirement = version_requirement
end

Instance Method Details

#build(version:) ⇒ Kitchen::Terraform::VersionVerifierStrategy::Supported, Kitchen::Terraform::VersionVerifierStrategy::Unsupported

#build creates a strategy.

Parameters:

  • version (Gem::Version)

    the Terraform client version.

Returns:



29
30
31
32
33
34
35
# File 'lib/kitchen/terraform/version_verifier_strategy_factory.rb', line 29

def build(version:)
  if version_requirement.satisfied_by? version
    return ::Kitchen::Terraform::VersionVerifierStrategy::Supported.new
  else
    return ::Kitchen::Terraform::VersionVerifierStrategy::Unsupported.new
  end
end