| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | module Hbc::Checkable | 
					
						
							|  |  |  |   def errors | 
					
						
							|  |  |  |     Array(@errors) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def warnings | 
					
						
							|  |  |  |     Array(@warnings) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def add_error(message) | 
					
						
							|  |  |  |     @errors ||= [] | 
					
						
							|  |  |  |     @errors << message | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def add_warning(message) | 
					
						
							|  |  |  |     @warnings ||= [] | 
					
						
							|  |  |  |     @warnings << message | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def errors? | 
					
						
							|  |  |  |     Array(@errors).any? | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def warnings? | 
					
						
							|  |  |  |     Array(@warnings).any? | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def result | 
					
						
							|  |  |  |     if errors? | 
					
						
							| 
									
										
										
										
											2016-08-23 09:11:09 +03:00
										 |  |  |       "#{Tty.red}failed#{Tty.reset}" | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |     elsif warnings? | 
					
						
							| 
									
										
										
										
											2016-08-23 09:11:09 +03:00
										 |  |  |       "#{Tty.yellow}warning#{Tty.reset}" | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2016-08-23 09:11:09 +03:00
										 |  |  |       "#{Tty.green}passed#{Tty.reset}" | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def summary | 
					
						
							|  |  |  |     summary = ["#{summary_header}: #{result}"] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     errors.each do |error| | 
					
						
							| 
									
										
										
										
											2016-08-23 09:11:09 +03:00
										 |  |  |       summary << " #{Tty.red}-#{Tty.reset} #{error}" | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     warnings.each do |warning| | 
					
						
							| 
									
										
										
										
											2016-08-23 09:11:09 +03:00
										 |  |  |       summary << " #{Tty.yellow}-#{Tty.reset} #{warning}" | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     summary.join("\n") | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |