difftastic 0.4.0-x86_64-linux → 0.5.1-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/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: b31263335eaaac1154d6f72a3a3ec931ea6cc15440f428bd600b0dfa69d03ad7
|
4
|
+
data.tar.gz: e9692792ec984e26288adf163bef628133b92a844d84c7ff9d1fe4dd39d909c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2be79d309e2b6dc6a0cf18c6ef282710f10bf7a9be45f1d58db6b4957dce361c9f517bbd9462315c9e3fa43c89fce5efa0fb7e79550d33e2024ea058024145a
|
7
|
+
data.tar.gz: ac693d2862b3cbc070d84dcbaf676644c8a1c29ca7100d32d591315845fecba3ad49d03ffbf920c7622f14f04bc40500f6275fa74f03ce63e696c3ad4386b444
|
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.prettify(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.1
|
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-05 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:
|