diff options
author | drew cimino <dcimino@gitlab.com> | 2019-04-26 18:37:20 +0300 |
---|---|---|
committer | drew cimino <dcimino@gitlab.com> | 2019-06-05 03:03:24 +0300 |
commit | cfaac7532210ef1ce03f335a3198bb7d2ad3979a (patch) | |
tree | d544f21c63cc98acb03bd39ca2cd6bde44c135d5 /lib/gitlab/ci/pipeline/expression/lexeme/or.rb | |
parent | 54cc3b64929dfe2eea562089b5fd6656a50ed2ae (diff) |
&& and || operators for CI Pipeline expressions.
Refactored regex pattern matching to eagerly return tokens
Packaged behind a default-enabled feature flag and added operator documentation.
Diffstat (limited to 'lib/gitlab/ci/pipeline/expression/lexeme/or.rb')
-rw-r--r-- | lib/gitlab/ci/pipeline/expression/lexeme/or.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/gitlab/ci/pipeline/expression/lexeme/or.rb b/lib/gitlab/ci/pipeline/expression/lexeme/or.rb new file mode 100644 index 00000000000..807876f905a --- /dev/null +++ b/lib/gitlab/ci/pipeline/expression/lexeme/or.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Gitlab + module Ci + module Pipeline + module Expression + module Lexeme + class Or < Lexeme::Operator + PATTERN = /\|\|/.freeze + + def evaluate(variables = {}) + @left.evaluate(variables) || @right.evaluate(variables) + end + + def self.build(_value, behind, ahead) + new(behind, ahead) + end + + def self.precedence + 12 # See: https://ruby-doc.org/core-2.5.0/doc/syntax/precedence_rdoc.html + end + end + end + end + end + end +end |