From 01f3bf0032036cbfb1f39636eda4b94001f5c476 Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Sun, 29 Jun 2014 22:56:08 +0000 Subject: [PATCH] Push static literals into constants --- lib/mutant/diff.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/mutant/diff.rb b/lib/mutant/diff.rb index e7c8a885..c449f0bc 100644 --- a/lib/mutant/diff.rb +++ b/lib/mutant/diff.rb @@ -3,6 +3,10 @@ module Mutant class Diff include Adamantium::Flat, Concord.new(:old, :new) + ADDITION = '+'.freeze + DELETION = '-'.freeze + NEWLINE = "\n".freeze + # Return source diff # # @return [String] @@ -16,7 +20,7 @@ module Mutant def diff return unless diffs.length.equal?(1) ::Diff::LCS::Hunk.new(old, new, diffs.first, max_length, 0) - .diff(:unified) << "\n" + .diff(:unified) << NEWLINE end memoize :diff @@ -97,9 +101,9 @@ module Mutant # def self.colorize_line(line) case line[0] - when '+' + when ADDITION Color::GREEN - when '-' + when DELETION Color::RED else Color::NONE