difftastic 0.3.0-x86_64-linux → 0.5.0-x86_64-linux
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/difftastic/differ.rb +2 -2
- data/lib/difftastic/version.rb +1 -1
- data/lib/difftastic.rb +4 -100
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d2185e3d3c624b7d71ff8f65a3a8abc6913348aca06888386035fb4626284d6
|
4
|
+
data.tar.gz: 2b59d3af4d799d89ed70e7d5291972e33709ac2323eb4008b20a096b9ae72406
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36eb2a4d0777807b3db2b6781e90f535cbffe6ddfb6622dff222aa56be943cb660fca18f785532c63187bbb58f4a8bea41bdf6cec90461d134b149ac76d8ed6d
|
7
|
+
data.tar.gz: 159112a9265098c851ab609cef830c6526f2a39bbf368d10b1ab457384d260eb1bd8be824f7bb846fa154e799853346c53078c50cad8096cb1a7d697cd68265c
|
data/lib/difftastic/differ.rb
CHANGED
@@ -300,7 +300,7 @@ class Difftastic::Differ
|
|
300
300
|
("--width=#{@width}" if @width),
|
301
301
|
].compact!
|
302
302
|
|
303
|
-
result = Difftastic.execute(options.join(" "))
|
303
|
+
result = Difftastic.execute(options.join(" ")).lstrip.sub(/\n{2}\z/, "")
|
304
304
|
|
305
305
|
unless @show_paths
|
306
306
|
new_line_index = result.index("\n") + 1
|
@@ -328,7 +328,7 @@ class Difftastic::Differ
|
|
328
328
|
end
|
329
329
|
|
330
330
|
# Insert formatted labels at the top
|
331
|
-
result = "
|
331
|
+
result = "#{left_part}#{right_part}#{Difftastic::ANSI.reset}\n#{result}"
|
332
332
|
end
|
333
333
|
|
334
334
|
# Removed due to inconsistencies in the original output. Need to improve the pattern matching.
|
data/lib/difftastic/version.rb
CHANGED
data/lib/difftastic.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "difftastic/version"
|
4
4
|
require "tempfile"
|
5
|
+
require "pretty_please"
|
5
6
|
|
6
7
|
module Difftastic
|
7
8
|
autoload :ANSI, "difftastic/ansi"
|
@@ -65,111 +66,14 @@ module Difftastic
|
|
65
66
|
See `bundle lock --help` output for details.
|
66
67
|
|
67
68
|
If you're still seeing this message after taking those steps, try running
|
68
|
-
`bundle config` and ensure `force_ruby_platform` isn't set to `true`.
|
69
|
-
https://github.com/fractaledmind/difftastic-ruby#check-bundle_force_ruby_platform
|
70
|
-
for more details.
|
69
|
+
`bundle config` and ensure `force_ruby_platform` isn't set to `true`.
|
71
70
|
MESSAGE
|
72
71
|
end
|
73
72
|
|
74
73
|
exe_file
|
75
74
|
end
|
76
75
|
|
77
|
-
def self.pretty(object, indent: 0, tab_width: 2, max_width: 60, max_depth: 5,
|
78
|
-
|
79
|
-
|
80
|
-
original_object ||= object
|
81
|
-
|
82
|
-
case object
|
83
|
-
when Hash
|
84
|
-
return "{}" if object.empty?
|
85
|
-
|
86
|
-
buffer = +"{\n"
|
87
|
-
indent += 1
|
88
|
-
object.each do |key, value|
|
89
|
-
buffer << ("\t" * indent)
|
90
|
-
case key
|
91
|
-
when Symbol
|
92
|
-
buffer << "#{key.name}: "
|
93
|
-
else
|
94
|
-
buffer << pretty(key, indent:, original_object:)
|
95
|
-
buffer << " => "
|
96
|
-
end
|
97
|
-
buffer << pretty(value, indent:, original_object:)
|
98
|
-
buffer << ",\n"
|
99
|
-
end
|
100
|
-
indent -= 1
|
101
|
-
buffer << ("\t" * indent)
|
102
|
-
buffer << "}"
|
103
|
-
when Array
|
104
|
-
new_lines = false
|
105
|
-
length = 0
|
106
|
-
items = object.map do |item|
|
107
|
-
pretty_item = pretty(item, indent: indent + 1, original_object:)
|
108
|
-
new_lines = true if pretty_item.include?("\n")
|
109
|
-
length += pretty_item.bytesize
|
110
|
-
pretty_item
|
111
|
-
end
|
112
|
-
|
113
|
-
if new_lines || length > max_width - (indent * tab_width)
|
114
|
-
"[\n#{"\t" * (indent + 1)}#{items.join(",\n#{"\t" * (indent + 1)}")},\n#{"\t" * indent}]"
|
115
|
-
else
|
116
|
-
"[#{items.join(', ')}]"
|
117
|
-
end
|
118
|
-
when Set
|
119
|
-
new_lines = false
|
120
|
-
length = 0
|
121
|
-
items = object.to_a.sort!.map do |item|
|
122
|
-
pretty_item = pretty(item, indent: indent + 1, original_object:)
|
123
|
-
new_lines = true if pretty_item.include?("\n")
|
124
|
-
length += pretty_item.bytesize
|
125
|
-
pretty_item
|
126
|
-
end
|
127
|
-
|
128
|
-
if new_lines || length > max_width - (indent * tab_width)
|
129
|
-
"Set[\n#{"\t" * (indent + 1)}#{items.join(",\n#{"\t" * (indent + 1)}")},\n#{"\t" * indent}]"
|
130
|
-
else
|
131
|
-
"Set[#{items.join(', ')}]"
|
132
|
-
end
|
133
|
-
when Module
|
134
|
-
object.name
|
135
|
-
when Pathname
|
136
|
-
%(Pathname("#{object.to_path}"))
|
137
|
-
when Symbol, String, Integer, Float, Regexp, Range, Rational, Complex, true, false, nil
|
138
|
-
object.inspect
|
139
|
-
else
|
140
|
-
buffer = +""
|
141
|
-
instance_variables = object.instance_variables
|
142
|
-
if instance_variables.length > 0 && indent < max_depth
|
143
|
-
buffer << "#{object.class.name}(\n"
|
144
|
-
indent += 1
|
145
|
-
|
146
|
-
if indent < max_depth
|
147
|
-
object.instance_variables.take(max_instance_variables).each do |name|
|
148
|
-
buffer << ("\t" * indent)
|
149
|
-
buffer << name.name
|
150
|
-
buffer << " = "
|
151
|
-
|
152
|
-
buffer << pretty(object.instance_variable_get(name), indent:, original_object:)
|
153
|
-
buffer << ",\n"
|
154
|
-
end
|
155
|
-
|
156
|
-
if object.instance_variables.count > max_instance_variables
|
157
|
-
buffer << ("\t" * indent)
|
158
|
-
buffer << "...\n"
|
159
|
-
end
|
160
|
-
else
|
161
|
-
buffer << ("\t" * indent)
|
162
|
-
buffer << "...\n"
|
163
|
-
end
|
164
|
-
|
165
|
-
indent -= 1
|
166
|
-
buffer << ("\t" * indent)
|
167
|
-
buffer << ")"
|
168
|
-
elsif indent >= max_depth
|
169
|
-
buffer << "#{object.class.name}(...)"
|
170
|
-
else
|
171
|
-
buffer << "#{object.class.name}()"
|
172
|
-
end
|
173
|
-
end
|
76
|
+
def self.pretty(object, indent: 0, tab_width: 2, max_width: 60, max_depth: 5, max_items: 10)
|
77
|
+
PrettyPlease.inspect(object, indent:, tab_width:, max_width:, max_depth:, max_items:)
|
174
78
|
end
|
175
79
|
end
|
metadata
CHANGED
@@ -1,14 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: difftastic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: x86_64-linux
|
6
6
|
authors:
|
7
7
|
- Joel Drapper
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
11
|
-
dependencies:
|
10
|
+
date: 2025-02-04 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: pretty_please
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
12
26
|
email:
|
13
27
|
- joel@drapper.me
|
14
28
|
executables:
|