2019-12-04 20:38:33 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
module Build
|
|
|
|
class Rules::Rule
|
|
|
|
attr_accessor :attributes
|
|
|
|
|
|
|
|
def self.fabricate_list(list)
|
|
|
|
list.map(&method(:new)) if list
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(spec)
|
|
|
|
@clauses = []
|
|
|
|
@attributes = {}
|
|
|
|
|
|
|
|
spec.each do |type, value|
|
|
|
|
if clause = Clause.fabricate(type, value)
|
|
|
|
@clauses << clause
|
|
|
|
else
|
|
|
|
@attributes.merge!(type => value)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
def matches?(pipeline, context)
|
|
|
|
@clauses.all? { |clause| clause.satisfied_by?(pipeline, context) }
|
2019-12-04 20:38:33 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|