Skip to content

Commit fed6227

Browse files
committed
Use magenta/yellow in favor of red/green
Using red for expected and green for actual value implies that the actual is "correct" and the expected value is "incorrect". However, it could very well be that it is it the reverse. Using different colors looks "strange", but it is technically more accurate.
1 parent b755a2b commit fed6227

31 files changed

+826
-808
lines changed

lib/super_diff.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
require "patience_diff"
44

55
module SuperDiff
6-
autoload :ColorizedDocumentExtensions, "super_diff/colorized_document_extensions"
6+
autoload(
7+
:ColorizedDocumentExtensions,
8+
"super_diff/colorized_document_extensions",
9+
)
710
autoload :Csi, "super_diff/csi"
811
autoload :DiffFormatter, "super_diff/diff_formatter"
912
autoload :DiffFormatters, "super_diff/diff_formatters"
@@ -23,4 +26,11 @@ module SuperDiff
2326
autoload :OperationSequences, "super_diff/operation_sequences"
2427
autoload :Operations, "super_diff/operations"
2528
autoload :RecursionGuard, "super_diff/recursion_guard"
29+
30+
COLORS = {
31+
alpha: :magenta,
32+
beta: :yellow,
33+
border: :blue,
34+
header: :white,
35+
}.freeze
2636
end

lib/super_diff/colorized_document_extensions.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ def self.extended(extendee)
66
end
77
end
88

9-
def deleted(*args, **opts, &block)
10-
colorize(*args, **opts, fg: :red, &block)
9+
def alpha(*args, **opts, &block)
10+
colorize(*args, **opts, fg: SuperDiff::COLORS.fetch(:alpha), &block)
1111
end
1212

13-
def inserted(*args, **opts, &block)
14-
colorize(*args, **opts, fg: :green, &block)
13+
def beta(*args, **opts, &block)
14+
colorize(*args, **opts, fg: SuperDiff::COLORS.fetch(:beta), &block)
1515
end
1616
end
1717
end

lib/super_diff/diff_formatters/collection.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Collection
44
extend AttrExtras.mixin
55

66
ICONS = { delete: "-", insert: "+" }.freeze
7-
STYLES = { insert: :inserted, delete: :deleted, noop: :normal }.freeze
7+
STYLES = { insert: :beta, delete: :alpha, noop: :plain }.freeze
88

99
method_object(
1010
[

lib/super_diff/diff_formatters/multiline_string.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ def lines
1515
operations.reduce([]) do |array, operation|
1616
case operation.name
1717
when :change
18-
array << Helpers.style(:deleted, "- #{operation.left_value}")
19-
array << Helpers.style(:inserted, "+ #{operation.right_value}")
18+
array << Helpers.style(:alpha, "- #{operation.left_value}")
19+
array << Helpers.style(:beta, "+ #{operation.right_value}")
2020
when :delete
21-
array << Helpers.style(:deleted, "- #{operation.value}")
21+
array << Helpers.style(:alpha, "- #{operation.value}")
2222
when :insert
23-
array << Helpers.style(:inserted, "+ #{operation.value}")
23+
array << Helpers.style(:beta, "+ #{operation.value}")
2424
else
25-
array << Helpers.style(:normal, " #{operation.value}")
25+
array << Helpers.style(:plain, " #{operation.value}")
2626
end
2727
end
2828
end

lib/super_diff/equality_matchers/array.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ def fail
1111
1212
#{
1313
Helpers.style(
14-
:deleted,
14+
:alpha,
1515
"Expected: " +
1616
ObjectInspection.inspect(expected, as_single_line: true),
1717
)
1818
}
1919
#{
2020
Helpers.style(
21-
:inserted,
21+
:beta,
2222
" Actual: " +
2323
ObjectInspection.inspect(actual, as_single_line: true),
2424
)

lib/super_diff/equality_matchers/default.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ def fail
1919

2020
def expected_line
2121
Helpers.style(
22-
:deleted,
22+
:alpha,
2323
"Expected: " +
2424
ObjectInspection.inspect(expected, as_single_line: true),
2525
)
2626
end
2727

2828
def actual_line
2929
Helpers.style(
30-
:inserted,
30+
:beta,
3131
" Actual: " +
3232
ObjectInspection.inspect(actual, as_single_line: true),
3333
)

lib/super_diff/equality_matchers/hash.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ def fail
1111
1212
#{
1313
Helpers.style(
14-
:deleted,
14+
:alpha,
1515
"Expected: " +
1616
ObjectInspection.inspect(expected, as_single_line: true),
1717
)
1818
}
1919
#{
2020
Helpers.style(
21-
:inserted,
21+
:beta,
2222
" Actual: " +
2323
ObjectInspection.inspect(actual, as_single_line: true),
2424
)

lib/super_diff/equality_matchers/multiline_string.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ def fail
1212
#{
1313
# TODO: This whole thing should not be red or green, just the values
1414
Helpers.style(
15-
:deleted,
15+
:alpha,
1616
"Expected: " +
1717
ObjectInspection.inspect(expected, as_single_line: true),
1818
)
1919
}
2020
#{
2121
Helpers.style(
22-
:inserted,
22+
:beta,
2323
" Actual: " +
2424
ObjectInspection.inspect(actual, as_single_line: true),
2525
)

lib/super_diff/equality_matchers/primitive.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ def fail
1515
1616
#{
1717
Helpers.style(
18-
:deleted,
18+
:alpha,
1919
"Expected: " +
2020
ObjectInspection.inspect(expected, as_single_line: true),
2121
)
2222
}
2323
#{
2424
Helpers.style(
25-
:inserted,
25+
:beta,
2626
" Actual: " +
2727
ObjectInspection.inspect(actual, as_single_line: true),
2828
)

lib/super_diff/equality_matchers/singleline_string.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ def fail
1111
1212
#{
1313
Helpers.style(
14-
:deleted,
14+
:alpha,
1515
"Expected: " +
1616
ObjectInspection.inspect(expected, as_single_line: true),
1717
)
1818
}
1919
#{
2020
Helpers.style(
21-
:inserted,
21+
:beta,
2222
" Actual: " +
2323
ObjectInspection.inspect(actual, as_single_line: true),
2424
)

0 commit comments

Comments
 (0)