minitest-holdify 1.3.2 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/holdify/feedback.rb +17 -9
- data/lib/holdify.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 91ac2c93846bb953d73a2cee3f89f8985b5ed1596b13995423212e91020cf52f
|
|
4
|
+
data.tar.gz: c3d196b9a65791d40aa3255a2c11345bebecf989a7c154d0e7d93cb4b9302294
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 20007012180156142177f200c8874325e446638ab65fd87ecd6aa7f3377473fce0ff8dee1c88da698dc5aff77318cd66d6ad2bf3c419fabbc9c77170ff9b909d
|
|
7
|
+
data.tar.gz: aad5cb0fd0683f63fe3754c39745e87674e0df1c98b2babc4facc926d79bf1d0c9d3f643dd72d156acf29b18a159c0ea79e21b4e0e68ff384bc7c1402a2ae60e
|
data/lib/holdify/feedback.rb
CHANGED
|
@@ -22,12 +22,16 @@ module Holdify
|
|
|
22
22
|
|
|
23
23
|
@expected, @actual, @message = *args
|
|
24
24
|
|
|
25
|
-
# Extend
|
|
26
|
-
extend
|
|
25
|
+
# Extend features
|
|
26
|
+
extend Color if Holdify.color
|
|
27
27
|
return unless Holdify.git_diff
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
extend
|
|
29
|
+
@diff_yaml_headers = 2 # ----expected and +---actual (no sgr code) on 2 lines
|
|
30
|
+
extend GitDiff # rubocop:disable Layout/EmptyLinesAfterModuleInclusion
|
|
31
|
+
return unless Holdify.color
|
|
32
|
+
|
|
33
|
+
@diff_yaml_headers = 1 # ---expected---actual (with sgr codes) on single line
|
|
34
|
+
extend Color::GitDiff
|
|
31
35
|
end
|
|
32
36
|
|
|
33
37
|
def message = [@message, *file_refs, *diff, ''].join("\n")
|
|
@@ -87,14 +91,15 @@ module Holdify
|
|
|
87
91
|
end
|
|
88
92
|
|
|
89
93
|
def process_lines(lines)
|
|
90
|
-
width
|
|
91
|
-
lineno
|
|
94
|
+
width = 0
|
|
95
|
+
lineno = [@yaml_lno - 1]
|
|
92
96
|
lines.map.with_index do |line, i|
|
|
93
97
|
if i.zero? # @@ ... @@
|
|
94
98
|
width, line = render_hunk(line)
|
|
95
99
|
next line
|
|
100
|
+
elsif i <= @diff_yaml_headers # ---
|
|
101
|
+
next
|
|
96
102
|
end
|
|
97
|
-
next if i == 1 || (i == 2 && !Holdify.color) # ---
|
|
98
103
|
|
|
99
104
|
render_line(line, lineno, width)
|
|
100
105
|
end.compact
|
|
@@ -144,7 +149,10 @@ module Holdify
|
|
|
144
149
|
|
|
145
150
|
# Methods enabling the git-diff ANSI feedback
|
|
146
151
|
module GitDiff
|
|
147
|
-
def git_command
|
|
152
|
+
def git_command
|
|
153
|
+
re = '[[:alnum:]:._-]+|[^[:alnum:]:._-]|[[:space:]]+' # YAML and HTML friendly: avoid long continuous tokens
|
|
154
|
+
"git diff --no-index --color-words='#{re}' --unified=1000 #{@exp_path} #{@act_path}"
|
|
155
|
+
end
|
|
148
156
|
|
|
149
157
|
def render_line(line, lineno, width)
|
|
150
158
|
clean = line.gsub(/\e\[(1|22|0)m/, '').lstrip
|
|
@@ -156,7 +164,7 @@ module Holdify
|
|
|
156
164
|
|
|
157
165
|
sgr = SGR[color].to_s if color
|
|
158
166
|
gutter = if added
|
|
159
|
-
"#{sgr}#{type}
|
|
167
|
+
"#{sgr}#{type}#{' ' * width}#{SGR[:clear]}"
|
|
160
168
|
else
|
|
161
169
|
lineno[0] += 1
|
|
162
170
|
"#{sgr}#{type || ' '}#{lineno[0].to_s.rjust(width)}#{SGR[:clear]}"
|
data/lib/holdify.rb
CHANGED