blob: 2ecd50d32e46ba536dcd69d0ff0b13e329f39b4f (
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
|
# frozen_string_literal: true
module Gitlab
module Ci
module Pipeline
module Expression
module Lexeme
class Variable < Lexeme::Value
PATTERN = /\$(?<name>\w+)/
def evaluate(variables = {})
unless variables.is_a?(ActiveSupport::HashWithIndifferentAccess)
variables = variables.with_indifferent_access
end
variables.fetch(@value, nil)
end
def inspect
"$#{@value}"
end
def self.build(string)
new(string.match(PATTERN)[:name])
end
end
end
end
end
end
end
|