Class: Enforce::Handler
- Inherits:
-
DSL
- Object
- DSL
- Enforce::Handler
show all
- Includes:
- Colors
- Defined in:
- lib/enforce/handler.rb
Instance Attribute Summary
Attributes inherited from DSL
#last_file
Instance Method Summary
collapse
Methods included from Colors
#colors, #say
Methods inherited from DSL
#failed_results, #file, #folder, #line, #no_file, #no_folder, #no_line, #no_regex, #no_text, #passed_results, #regex, #results, #text
Instance Method Details
#execute(file) ⇒ Object
7
8
9
10
11
|
# File 'lib/enforce/handler.rb', line 7
def execute(file)
eval File.read file
color = failed? ? "%{red}" : "%{green}"
say "#{color}#{results.count} rules, #{failed} failures"
end
|
#failed ⇒ Object
13
14
15
|
# File 'lib/enforce/handler.rb', line 13
def failed
failed_results.count
end
|
#failed? ⇒ Boolean
17
18
19
|
# File 'lib/enforce/handler.rb', line 17
def failed?
failed_results.count > 0
end
|
#handle(message:, pass:) ⇒ Object
21
22
23
24
|
# File 'lib/enforce/handler.rb', line 21
def handle(message:, pass:)
status = pass ? "%{green}PASS%{reset}" : "%{red}FAIL%{reset}"
say "#{status} #{message}"
end
|