Class: Sfn::Lint::Definition
- Inherits:
-
Object
- Object
- Sfn::Lint::Definition
- Defined in:
- lib/sfn/lint/definition.rb
Overview
Lint defition
Instance Attribute Summary collapse
-
#evaluator ⇒ Proc-ish
readonly
Must respond to #call.
-
#provider ⇒ Symbol
readonly
Target provider.
-
#search_expression ⇒ String
readonly
Search expression used for matching.
Instance Method Summary collapse
-
#apply(template) ⇒ TrueClass, Array<String>
Apply definition to template.
-
#initialize(expr, provider = :aws, evaluator = nil, &block) ⇒ self
constructor
Create a new definition.
Constructor Details
#initialize(expr, provider = :aws, evaluator = nil, &block) ⇒ self
Create a new definition
21 22 23 24 25 26 27 28 |
# File 'lib/sfn/lint/definition.rb', line 21 def initialize(expr, provider = :aws, evaluator = nil, &block) if evaluator && block raise ArgumentError.new "Only evaluator or block can be provided, not both." end @provider = Bogo::Utility.snake(provider).to_sym @search_expression = expr @evaluator = evaluator || block end |
Instance Attribute Details
#evaluator ⇒ Proc-ish (readonly)
Returns must respond to #call.
11 12 13 |
# File 'lib/sfn/lint/definition.rb', line 11 def evaluator @evaluator end |
#provider ⇒ Symbol (readonly)
Returns target provider.
13 14 15 |
# File 'lib/sfn/lint/definition.rb', line 13 def provider @provider end |
#search_expression ⇒ String (readonly)
Returns search expression used for matching.
9 10 11 |
# File 'lib/sfn/lint/definition.rb', line 9 def search_expression @search_expression end |
Instance Method Details
#apply(template) ⇒ TrueClass, Array<String>
Apply definition to template
34 35 36 37 |
# File 'lib/sfn/lint/definition.rb', line 34 def apply(template) result = JMESPath.search(search_expression, template) run(result, template) end |