From ad92c1fd670b2b8718e94d640b27e0f99ba0327e Mon Sep 17 00:00:00 2001 From: amartynov Date: Tue, 2 Dec 2014 13:35:37 +0300 Subject: [PATCH] run list regex in constant --- devops-service/db/validators/helpers/run_list.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/devops-service/db/validators/helpers/run_list.rb b/devops-service/db/validators/helpers/run_list.rb index e9f73ac..3fa9418 100644 --- a/devops-service/db/validators/helpers/run_list.rb +++ b/devops-service/db/validators/helpers/run_list.rb @@ -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 \ No newline at end of file +end