Module: Roast::Workflow::ExpressionUtils
- Included in:
- BaseIterationStep, ExpressionEvaluator
- Defined in:
- lib/roast/workflow/expression_utils.rb
Overview
Shared utilities for detecting and extracting expressions
Instance Method Summary collapse
-
#bash_command?(input) ⇒ Boolean
Check if the input is a Bash command in $(…).
-
#extract_command(input) ⇒ Object
Extract the command from $(…).
-
#extract_expression(input) ⇒ Object
Extract the expression from {…}.
-
#ruby_expression?(input) ⇒ Boolean
Check if the input is a Ruby expression in {…}.
Instance Method Details
#bash_command?(input) ⇒ Boolean
Check if the input is a Bash command in $(…)
15 16 17 18 19 |
# File 'lib/roast/workflow/expression_utils.rb', line 15 def bash_command?(input) return false unless input.is_a?(String) input.strip.start_with?("$(") && input.strip.end_with?(")") end |
#extract_command(input) ⇒ Object
Extract the command from $(…)
29 30 31 32 33 |
# File 'lib/roast/workflow/expression_utils.rb', line 29 def extract_command(input) return input unless bash_command?(input) input.strip[2...-1].strip end |
#extract_expression(input) ⇒ Object
Extract the expression from {…}
22 23 24 25 26 |
# File 'lib/roast/workflow/expression_utils.rb', line 22 def extract_expression(input) return input unless ruby_expression?(input) input.strip[2...-2].strip end |
#ruby_expression?(input) ⇒ Boolean
Check if the input is a Ruby expression in {…}
8 9 10 11 12 |
# File 'lib/roast/workflow/expression_utils.rb', line 8 def ruby_expression?(input) return false unless input.is_a?(String) input.strip.start_with?("{{") && input.strip.end_with?("}}") end |