Class: Gitlab::Ci::Reports::ReportsComparer

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

Constant Summary collapse

STATUS_SUCCESS =
'success'
STATUS_FAILED =
'failed'
STATUS_NOT_FOUND =
'not_found'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(base_report, head_report) ⇒ ReportsComparer

Returns a new instance of ReportsComparer.


15
16
17
18
# File 'lib/gitlab/ci/reports/reports_comparer.rb', line 15

def initialize(base_report, head_report)
  @base_report = base_report
  @head_report = head_report
end

Instance Attribute Details

#base_reportObject (readonly)

Returns the value of attribute base_report.


13
14
15
# File 'lib/gitlab/ci/reports/reports_comparer.rb', line 13

def base_report
  @base_report
end

#head_reportObject (readonly)

Returns the value of attribute head_report.


13
14
15
# File 'lib/gitlab/ci/reports/reports_comparer.rb', line 13

def head_report
  @head_report
end

Instance Method Details

#errors_countObject

Raises:

  • (NotImplementedError)

46
47
48
# File 'lib/gitlab/ci/reports/reports_comparer.rb', line 46

def errors_count
  raise NotImplementedError
end

#existing_errorsObject

Raises:

  • (NotImplementedError)

34
35
36
# File 'lib/gitlab/ci/reports/reports_comparer.rb', line 34

def existing_errors
  raise NotImplementedError
end

#new_errorsObject

Raises:

  • (NotImplementedError)

38
39
40
# File 'lib/gitlab/ci/reports/reports_comparer.rb', line 38

def new_errors
  raise NotImplementedError
end

#not_found?Boolean

Returns:

  • (Boolean)

58
59
60
# File 'lib/gitlab/ci/reports/reports_comparer.rb', line 58

def not_found?
  status == STATUS_NOT_FOUND
end

#resolved_countObject


50
51
52
# File 'lib/gitlab/ci/reports/reports_comparer.rb', line 50

def resolved_count
  resolved_errors.size
end

#resolved_errorsObject

Raises:

  • (NotImplementedError)

42
43
44
# File 'lib/gitlab/ci/reports/reports_comparer.rb', line 42

def resolved_errors
  raise NotImplementedError
end

#statusObject


20
21
22
23
24
25
26
27
28
# File 'lib/gitlab/ci/reports/reports_comparer.rb', line 20

def status
  if base_report.nil? || head_report.nil?
    STATUS_NOT_FOUND
  elsif success?
    STATUS_SUCCESS
  else
    STATUS_FAILED
  end
end

#success?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)

30
31
32
# File 'lib/gitlab/ci/reports/reports_comparer.rb', line 30

def success?
  raise NotImplementedError
end

#total_countObject


54
55
56
# File 'lib/gitlab/ci/reports/reports_comparer.rb', line 54

def total_count
  existing_errors.size + new_errors.size
end