| 
									
										
										
										
											2014-11-26 16:59:46 +03:00
										 |  |  | module Validators | 
					
						
							|  |  |  |   class Helpers::RunList < Base | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-02 13:35:37 +03:00
										 |  |  |     RUN_LIST_REGEX = /\Arole|recipe\[[\w-]+(::[\w-]+)?\]\Z/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-26 16:59:46 +03:00
										 |  |  |     def valid? | 
					
						
							| 
									
										
										
										
											2014-12-02 13:35:37 +03:00
										 |  |  |       @invalid_elements = @model.select {|l| (RUN_LIST_REGEX =~ l).nil?} | 
					
						
							| 
									
										
										
										
											2014-11-26 16:59:46 +03:00
										 |  |  |       @invalid_elements.empty? | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def message | 
					
						
							|  |  |  |       invalid_elements_as_string = @invalid_elements.join("', '") | 
					
						
							| 
									
										
										
										
											2015-09-29 17:15:05 +03:00
										 |  |  |       "Invalid run list elements: '#{invalid_elements_as_string}'. Each element should be a role or a recipe." | 
					
						
							| 
									
										
										
										
											2014-11-26 16:59:46 +03:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2014-12-02 13:35:37 +03:00
										 |  |  | end |