Class: Gitlab::Ci::Reports::AccessibilityReports

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/reports/accessibility_reports.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAccessibilityReports

Returns a new instance of AccessibilityReports.


9
10
11
12
# File 'lib/gitlab/ci/reports/accessibility_reports.rb', line 9

def initialize
  @urls = {}
  @error_message = nil
end

Instance Attribute Details

#error_messageObject (readonly)

Returns the value of attribute error_message


7
8
9
# File 'lib/gitlab/ci/reports/accessibility_reports.rb', line 7

def error_message
  @error_message
end

#urlsObject (readonly)

Returns the value of attribute urls


7
8
9
# File 'lib/gitlab/ci/reports/accessibility_reports.rb', line 7

def urls
  @urls
end

Instance Method Details

#add_url(url, data) ⇒ Object


14
15
16
17
18
19
20
# File 'lib/gitlab/ci/reports/accessibility_reports.rb', line 14

def add_url(url, data)
  if url.empty?
    set_error_message("Empty URL detected in gl-accessibility.json")
  else
    urls[url] = data
  end
end

#all_errorsObject


40
41
42
# File 'lib/gitlab/ci/reports/accessibility_reports.rb', line 40

def all_errors
  @urls.values.flatten
end

#errors_countObject

rubocop: disable CodeReuse/ActiveRecord


31
32
33
# File 'lib/gitlab/ci/reports/accessibility_reports.rb', line 31

def errors_count
  @urls.sum { |url, errors| errors.size }
end

#passes_countObject


26
27
28
# File 'lib/gitlab/ci/reports/accessibility_reports.rb', line 26

def passes_count
  @urls.count { |url, errors| errors.empty? }
end

#scans_countObject


22
23
24
# File 'lib/gitlab/ci/reports/accessibility_reports.rb', line 22

def scans_count
  @urls.size
end

#set_error_message(error) ⇒ Object

rubocop: enable CodeReuse/ActiveRecord


36
37
38
# File 'lib/gitlab/ci/reports/accessibility_reports.rb', line 36

def set_error_message(error)
  @error_message = error
end