blob: b9ce8cdc5bc7e2e0e43f66033a1022773ed39158 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# frozen_string_literal: true
module Gitlab
module Ci
class Config
module Interpolation
module Functions
class Base
attr_reader :errors
def self.function_expression_pattern
raise NotImplementedError
end
def self.name
raise NotImplementedError
end
def self.matches?(function_expression)
function_expression_pattern.match?(function_expression)
end
def initialize(function_expression)
@errors = []
@function_args = parse_args(function_expression)
end
def valid?
errors.empty?
end
def execute(_input_value)
raise NotImplementedError
end
private
attr_reader :function_args
def error(message)
errors << "error in `#{self.class.name}` function: #{message}"
end
def parse_args(function_expression)
self.class.function_expression_pattern.match(function_expression)
end
end
end
end
end
end
end
|