run list regex in constant

This commit is contained in:
amartynov 2014-12-02 13:35:37 +03:00
parent 8dbc54b5da
commit ad92c1fd67

View File

@ -1,9 +1,10 @@
module Validators
class Helpers::RunList < Base
RUN_LIST_REGEX = /\Arole|recipe\[[\w-]+(::[\w-]+)?\]\Z/
def valid?
rl = /\Arole|recipe\[[\w-]+(::[\w-]+)?\]\Z/
@invalid_elements = @model.select {|l| (rl =~ l).nil?}
@invalid_elements = @model.select {|l| (RUN_LIST_REGEX =~ l).nil?}
@invalid_elements.empty?
end
@ -12,4 +13,4 @@ module Validators
"Invalid run list elements: '#{invalid_elements_as_string}'. Each element should be role or recipe."
end
end
end
end