Class: Kamal::Lint::Result
- Inherits:
-
Struct
- Object
- Struct
- Kamal::Lint::Result
- Defined in:
- lib/kamal/lint/runner.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#destinations ⇒ Object
Returns the value of attribute destinations.
-
#findings ⇒ Object
Returns the value of attribute findings.
Instance Method Summary collapse
-
#by_destination ⇒ Object
Findings grouped by destination (nil for base), preserving the discovery order: base first, then each destination alphabetically.
- #empty? ⇒ Boolean
- #errors ⇒ Object
- #exit_code(fail_on: :error) ⇒ Object
- #infos ⇒ Object
- #warnings ⇒ Object
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context
5 6 7 |
# File 'lib/kamal/lint/runner.rb', line 5 def context @context end |
#destinations ⇒ Object
Returns the value of attribute destinations
5 6 7 |
# File 'lib/kamal/lint/runner.rb', line 5 def destinations @destinations end |
#findings ⇒ Object
Returns the value of attribute findings
5 6 7 |
# File 'lib/kamal/lint/runner.rb', line 5 def findings @findings end |
Instance Method Details
#by_destination ⇒ Object
Findings grouped by destination (nil for base), preserving the discovery order: base first, then each destination alphabetically.
24 25 26 27 28 29 30 31 |
# File 'lib/kamal/lint/runner.rb', line 24 def by_destination groups = { nil => [] } destinations.each { |d| groups[d] = [] } findings.each do |f| (groups[f.destination] ||= []) << f end groups end |
#empty? ⇒ Boolean
18 19 20 |
# File 'lib/kamal/lint/runner.rb', line 18 def empty? findings.empty? end |
#errors ⇒ Object
6 7 8 |
# File 'lib/kamal/lint/runner.rb', line 6 def errors findings.select { |f| f.severity == :error } end |
#exit_code(fail_on: :error) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/kamal/lint/runner.rb', line 33 def exit_code(fail_on: :error) threshold = SEVERITIES.index(fail_on.to_sym) worst = findings.map { |f| SEVERITIES.index(f.severity) }.compact.min return 0 if worst.nil? worst <= threshold ? 1 : 0 end |
#infos ⇒ Object
14 15 16 |
# File 'lib/kamal/lint/runner.rb', line 14 def infos findings.select { |f| f.severity == :info } end |
#warnings ⇒ Object
10 11 12 |
# File 'lib/kamal/lint/runner.rb', line 10 def warnings findings.select { |f| f.severity == :warning } end |