Class: Kamal::Lint::Result

Inherits:
Struct
  • Object
show all
Defined in:
lib/kamal/lint/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contextObject

Returns the value of attribute context

Returns:

  • (Object)

    the current value of context



5
6
7
# File 'lib/kamal/lint/runner.rb', line 5

def context
  @context
end

#destinationsObject

Returns the value of attribute destinations

Returns:

  • (Object)

    the current value of destinations



5
6
7
# File 'lib/kamal/lint/runner.rb', line 5

def destinations
  @destinations
end

#findingsObject

Returns the value of attribute findings

Returns:

  • (Object)

    the current value of findings



5
6
7
# File 'lib/kamal/lint/runner.rb', line 5

def findings
  @findings
end

Instance Method Details

#by_destinationObject

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

Returns:

  • (Boolean)


18
19
20
# File 'lib/kamal/lint/runner.rb', line 18

def empty?
  findings.empty?
end

#errorsObject



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

#infosObject



14
15
16
# File 'lib/kamal/lint/runner.rb', line 14

def infos
  findings.select { |f| f.severity == :info }
end

#warningsObject



10
11
12
# File 'lib/kamal/lint/runner.rb', line 10

def warnings
  findings.select { |f| f.severity == :warning }
end