From 890df1b1f09e6ce080fdf9d792882ed133e28882 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 21 Feb 2018 14:09:43 +0100 Subject: Add code that evaluates pipelines expressions --- lib/gitlab/ci/pipeline/expression/statement.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/gitlab/ci/pipeline/expression/statement.rb b/lib/gitlab/ci/pipeline/expression/statement.rb index 417b3f806b1..5d37d3ff0b0 100644 --- a/lib/gitlab/ci/pipeline/expression/statement.rb +++ b/lib/gitlab/ci/pipeline/expression/statement.rb @@ -31,8 +31,8 @@ module Gitlab end ## - # Our syntax is very simple, so we don't need yet to implement a - # recurisive parser, we can use the most simple approach to create + # Our syntax is very simple, so we don't yet need to implement a + # recursive parser, we can use the most simple approach to create # a reverse descent parse tree "by hand". # def parse_tree @@ -42,7 +42,7 @@ module Gitlab raise ParserError, 'Unknown pipeline expression!' end - if lexemes.many? + if tokens.many? Expression::Equals.new(tokens.first.build, tokens.last.build) else tokens.first.build @@ -50,6 +50,11 @@ module Gitlab end def evaluate + if tokens.many? + parse_tree.evaluate + else + parse_tree.evaluate.present? + end end end end -- cgit v1.2.1