Class: Pangea::Magma::Matchers::CompatibleWithBackend

Inherits:
Object
  • Object
show all
Defined in:
lib/pangea/magma/matchers.rb

Instance Method Summary collapse

Constructor Details

#initialize(backend) ⇒ CompatibleWithBackend

Returns a new instance of CompatibleWithBackend.



124
125
126
127
# File 'lib/pangea/magma/matchers.rb', line 124

def initialize(backend)
  @backend = backend
  @requires = {}
end

Instance Method Details

#descriptionObject



156
157
158
# File 'lib/pangea/magma/matchers.rb', line 156

def description
  "be compatible with backend #{@backend.inspect}"
end

#failure_messageObject



152
153
154
# File 'lib/pangea/magma/matchers.rb', line 152

def failure_message
  @failure_message || "expected backend #{@backend} to be compatible with requires=#{@requires.inspect}"
end

#matches?(_workspace_path_or_nil = nil) ⇒ Boolean

Returns:

  • (Boolean)


141
142
143
144
145
146
147
148
149
150
# File 'lib/pangea/magma/matchers.rb', line 141

def matches?(_workspace_path_or_nil = nil)
  Pangea::Backend.verify_compatible!(@backend, @requires)
  true
rescue Pangea::Backend::BackendIncompatible => e
  @failure_message = e.message
  false
rescue Pangea::Backend::BackendUnavailable => e
  @failure_message = "backend #{@backend} unavailable: #{e.message}"
  false
end

#requiring_feature(feature) ⇒ Object

Examples:

.requiring_feature(:in_memory_pipeline)



130
131
132
133
# File 'lib/pangea/magma/matchers.rb', line 130

def requiring_feature(feature)
  @requires[:feature] = feature
  self
end

#requiring_input_format(format) ⇒ Object

Examples:

.requiring_input_format(‘terraform-json’)



136
137
138
139
# File 'lib/pangea/magma/matchers.rb', line 136

def requiring_input_format(format)
  @requires[:input_format] = format
  self
end