module Kitchen::Terraform::Version
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.
Public Class Methods
assign_plugin_version
assigns the version to a class which includes Kitchen::Configurable.
@param configurable_class [Kitchen::Configurable] the configurable class to which the version will be assigned. @return [self]
# 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
assigns the version to a Gem::Specification.
@param specification [Gem::Specification] the specification to which the version will be assigned. @return [self]
# File lib/kitchen/terraform/version.rb, line 38 def assign_specification_version(specification:) specification.version = value self end
if_satisfies
yields control if the provided requirement is satisfied by the version.
@param requirement [Gem::Requirement, ::String] the requirement to be satisfied by the version. @raise [Gem::Requirement::BadRequirementError] if the requirement is illformed. @return [self] @yield [] if the requirement is satisfied by the version.
# 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
overrides the current version with the version provided, yields control, and then resets the version.
@note temporarily_override
must only be used in tests to validate version flow control logic. @raise [ArgumentError] if the version is malformed. @return [self] @yield [] the value of the version will be overridden while control is yielded.
# 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
Private Class Methods
@api private
# File lib/kitchen/terraform/version.rb, line 73 def value self.value = ::Gem::Version.new "6.0.0" if not @value @value end
@api private
# File lib/kitchen/terraform/version.rb, line 79 def value=(version) @value = ::Gem::Version.new version self end