Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRubén Dávila <rdavila84@gmail.com>2015-12-31 05:23:50 +0300
committerRubén Dávila <rdavila84@gmail.com>2015-12-31 05:23:50 +0300
commit8b079315d98a8ccf852592148632c6f052d9cb55 (patch)
treebc2dc4ae4fb47fd943b1ad06ac19728220551daa /lib/gitlab/diff
parentd83275620a0eeaf17a2958e59e2b4d6f217c6464 (diff)
A bit of refactoring. #3945
Diffstat (limited to 'lib/gitlab/diff')
-rw-r--r--lib/gitlab/diff/file.rb2
-rw-r--r--lib/gitlab/diff/highlight.rb16
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/gitlab/diff/file.rb b/lib/gitlab/diff/file.rb
index ff8765b8e26..69b38a32eeb 100644
--- a/lib/gitlab/diff/file.rb
+++ b/lib/gitlab/diff/file.rb
@@ -16,7 +16,7 @@ module Gitlab
end
def highlighted_diff_lines
- Gitlab::Diff::Highlight.process_diff_lines(self)
+ Gitlab::Diff::Highlight.process_diff_lines(new_path, diff_lines)
end
def mode_changed?
diff --git a/lib/gitlab/diff/highlight.rb b/lib/gitlab/diff/highlight.rb
index d0c2e3670c6..40a54ede2bb 100644
--- a/lib/gitlab/diff/highlight.rb
+++ b/lib/gitlab/diff/highlight.rb
@@ -1,15 +1,15 @@
module Gitlab
module Diff
class Highlight
- def self.process_diff_lines(diff_file)
- processor = new(diff_file)
+ def self.process_diff_lines(file_name, diff_lines)
+ processor = new(file_name, diff_lines)
processor.highlight
end
- def initialize(diff_file)
- text_lines = diff_file.diff_lines.map(&:text)
- @diff_file = diff_file
- @diff_lines = diff_file.diff_lines
+ def initialize(file_name, diff_lines)
+ text_lines = diff_lines.map(&:text)
+ @file_name = file_name
+ @diff_lines = diff_lines
@diff_line_prefixes = text_lines.map { |line| line.sub!(/\A((\+|\-)\s*)/, '');$1 }
@raw_lines = text_lines.join("\n")
end
@@ -32,7 +32,7 @@ module Gitlab
end
def lexer
- parent = Rouge::Lexer.guess(filename: @diff_file.new_path, source: @code).new rescue Rouge::Lexers::PlainText.new
+ parent = Rouge::Lexer.guess(filename: @file_name, source: @code).new rescue Rouge::Lexers::PlainText.new
Rouge::Lexers::GitlabDiff.new(parent_lexer: parent)
end
@@ -43,7 +43,7 @@ module Gitlab
end
def formatter
- @formatter ||= Rouge::Formatters::HTMLGitlab.new(
+ Rouge::Formatters::HTMLGitlab.new(
nowrap: true,
cssclass: 'code highlight',
lineanchors: true,