class Hasta::InterpolateString
Interpolates scheduled start time expressions in S3 path strings
Constants
- INTERPOLATE_PATTERN
- PATTERN_CONVERSIONS
Attributes
pattern[R]
Public Class Methods
evaluate(pattern, context)
click to toggle source
# File lib/hasta/interpolate_string.rb, line 17 def self.evaluate(pattern, context) new(pattern).evaluate(context) end
new(pattern)
click to toggle source
# File lib/hasta/interpolate_string.rb, line 21 def initialize(pattern) @pattern = pattern end
Public Instance Methods
evaluate(context)
click to toggle source
# File lib/hasta/interpolate_string.rb, line 25 def evaluate(context) pattern.gsub(INTERPOLATE_PATTERN) do |match| format(context, Regexp.last_match[1]) end end
Private Instance Methods
convert_pattern(pattern)
click to toggle source
# File lib/hasta/interpolate_string.rb, line 39 def convert_pattern(pattern) PATTERN_CONVERSIONS.inject(pattern) { |converted_pattern, (pipeline_pattern, ruby_pattern)| converted_pattern.gsub(pipeline_pattern, ruby_pattern) } end
format(context, pattern)
click to toggle source
# File lib/hasta/interpolate_string.rb, line 35 def format(context, pattern) context['scheduledStartTime'].strftime(convert_pattern(pattern)) end