Class: Gitlab::Ci::Reports::AccessibilityReportsComparer

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/ci/reports/accessibility_reports_comparer.rb

Constant Summary collapse

STATUS_SUCCESS =
'success'
STATUS_FAILED =
'failed'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(base_reports, head_reports) ⇒ AccessibilityReportsComparer

Returns a new instance of AccessibilityReportsComparer.


14
15
16
17
# File 'lib/gitlab/ci/reports/accessibility_reports_comparer.rb', line 14

def initialize(base_reports, head_reports)
  @base_reports = base_reports || AccessibilityReports.new
  @head_reports = head_reports
end

Instance Attribute Details

#base_reportsObject (readonly)

Returns the value of attribute base_reports


12
13
14
# File 'lib/gitlab/ci/reports/accessibility_reports_comparer.rb', line 12

def base_reports
  @base_reports
end

#head_reportsObject (readonly)

Returns the value of attribute head_reports


12
13
14
# File 'lib/gitlab/ci/reports/accessibility_reports_comparer.rb', line 12

def head_reports
  @head_reports
end

Instance Method Details

#errors_countObject


41
42
43
# File 'lib/gitlab/ci/reports/accessibility_reports_comparer.rb', line 41

def errors_count
  head_reports.errors_count
end

#existing_errorsObject


23
24
25
26
27
# File 'lib/gitlab/ci/reports/accessibility_reports_comparer.rb', line 23

def existing_errors
  strong_memoize(:existing_errors) do
    base_reports.all_errors
  end
end

#new_errorsObject


29
30
31
32
33
# File 'lib/gitlab/ci/reports/accessibility_reports_comparer.rb', line 29

def new_errors
  strong_memoize(:new_errors) do
    head_reports.all_errors - base_reports.all_errors
  end
end

#resolved_countObject


45
46
47
# File 'lib/gitlab/ci/reports/accessibility_reports_comparer.rb', line 45

def resolved_count
  resolved_errors.size
end

#resolved_errorsObject


35
36
37
38
39
# File 'lib/gitlab/ci/reports/accessibility_reports_comparer.rb', line 35

def resolved_errors
  strong_memoize(:resolved_errors) do
    base_reports.all_errors - head_reports.all_errors
  end
end

#statusObject


19
20
21
# File 'lib/gitlab/ci/reports/accessibility_reports_comparer.rb', line 19

def status
  head_reports.errors_count > 0 ? STATUS_FAILED : STATUS_SUCCESS
end

#total_countObject


49
50
51
# File 'lib/gitlab/ci/reports/accessibility_reports_comparer.rb', line 49

def total_count
  existing_errors.size + new_errors.size
end