7e6f6e1603
Enables frozens string for the following: * lib/gitlab/conflict/**/*.rb * lib/gitlab/cross_project_access/**/*.rb * lib/gitlab/cycle_analytics/**/*.rb * lib/gitlab/data_builder/**/*.rb * lib/gitlab/database/**/*.rb * lib/gitlab/dependency_linker/**/*.rb * lib/gitlab/diff/**/*.rb * lib/gitlab/downtime_check/**/*.rb * lib/gitlab/email/**/*.rb * lib/gitlab/etag_caching/**/*.rb Partially addresses gitlab-org/gitlab-ce#47424.
51 lines
976 B
Ruby
51 lines
976 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Gitlab
|
|
module Diff
|
|
module Formatters
|
|
class TextFormatter < BaseFormatter
|
|
attr_reader :old_line
|
|
attr_reader :new_line
|
|
|
|
def initialize(attrs)
|
|
@old_line = attrs[:old_line]
|
|
@new_line = attrs[:new_line]
|
|
|
|
super(attrs)
|
|
end
|
|
|
|
def key
|
|
@key ||= super.push(old_line, new_line)
|
|
end
|
|
|
|
def complete?
|
|
old_line || new_line
|
|
end
|
|
|
|
def to_h
|
|
super.merge(old_line: old_line, new_line: new_line)
|
|
end
|
|
|
|
def line_age
|
|
if old_line && new_line
|
|
nil
|
|
elsif new_line
|
|
'new'
|
|
else
|
|
'old'
|
|
end
|
|
end
|
|
|
|
def position_type
|
|
"text"
|
|
end
|
|
|
|
def ==(other)
|
|
other.is_a?(self.class) &&
|
|
new_line == other.new_line &&
|
|
old_line == other.old_line
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|