pp 0.5.0 → 0.6.1
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/{LICENSE.txt → BSDL} +3 -3
- data/COPYING +56 -0
- data/lib/pp.rb +59 -15
- data/pp.gemspec +2 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2751ebd39fe3d2944f2602f9ce69f648486eda46449d220a8bf2b03fe5747472
|
4
|
+
data.tar.gz: 4871bac0b9091f6b31b591d5a072c0ea397b482896a68e173024c2fbafa722b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2db91222da3bc546be4e7f997a4d1827c911a47a81f0b5825c51074a9d0b1818127e02eaf43a586341bcc21bb66e8a2f5c68225ab1b9a6f84171e8c4513fc3d2
|
7
|
+
data.tar.gz: 51de0e0644941377203b3674805e31cd33530ff3980256ffd587a6672a3a455f69cdd7267a29ee5576c56cbff1e6f8546ec1f73d2fdc79fdaa201e9751e6f31f
|
data/{LICENSE.txt → BSDL}
RENAMED
@@ -4,10 +4,10 @@ Redistribution and use in source and binary forms, with or without
|
|
4
4
|
modification, are permitted provided that the following conditions
|
5
5
|
are met:
|
6
6
|
1. Redistributions of source code must retain the above copyright
|
7
|
-
notice, this list of conditions and the following disclaimer.
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
8
|
2. Redistributions in binary form must reproduce the above copyright
|
9
|
-
notice, this list of conditions and the following disclaimer in the
|
10
|
-
documentation and/or other materials provided with the distribution.
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
11
|
|
12
12
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
13
13
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
data/COPYING
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
|
2
|
+
You can redistribute it and/or modify it under either the terms of the
|
3
|
+
2-clause BSDL (see the file BSDL), or the conditions below:
|
4
|
+
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
6
|
+
software without restriction, provided that you duplicate all of the
|
7
|
+
original copyright notices and associated disclaimers.
|
8
|
+
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
10
|
+
you do at least ONE of the following:
|
11
|
+
|
12
|
+
a. place your modifications in the Public Domain or otherwise
|
13
|
+
make them Freely Available, such as by posting said
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
+
the author to include your modifications in the software.
|
16
|
+
|
17
|
+
b. use the modified software only within your corporation or
|
18
|
+
organization.
|
19
|
+
|
20
|
+
c. give non-standard binaries non-standard names, with
|
21
|
+
instructions on where to get the original software distribution.
|
22
|
+
|
23
|
+
d. make other distribution arrangements with the author.
|
24
|
+
|
25
|
+
3. You may distribute the software in object code or binary form,
|
26
|
+
provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a. distribute the binaries and library files of the software,
|
29
|
+
together with instructions (in the manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b. accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c. give non-standard binaries non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d. make other distribution arrangements with the author.
|
39
|
+
|
40
|
+
4. You may modify and include the part of the software into any other
|
41
|
+
software (possibly commercial). But some files in the distribution
|
42
|
+
are not written by the author, so that they are not under these terms.
|
43
|
+
|
44
|
+
For the list of those files and their copying conditions, see the
|
45
|
+
file LEGAL.
|
46
|
+
|
47
|
+
5. The scripts and library files supplied as input to or produced as
|
48
|
+
output from the software do not automatically fall under the
|
49
|
+
copyright of the software, but belong to whomever generated them,
|
50
|
+
and may be sold commercially, and may be aggregated with this
|
51
|
+
software.
|
52
|
+
|
53
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
54
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
55
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
56
|
+
PURPOSE.
|
data/lib/pp.rb
CHANGED
@@ -63,7 +63,7 @@ require 'prettyprint'
|
|
63
63
|
|
64
64
|
class PP < PrettyPrint
|
65
65
|
|
66
|
-
VERSION = "0.
|
66
|
+
VERSION = "0.6.1"
|
67
67
|
|
68
68
|
# Returns the usable width for +out+.
|
69
69
|
# As the width of +out+:
|
@@ -93,7 +93,7 @@ class PP < PrettyPrint
|
|
93
93
|
#
|
94
94
|
# PP.pp returns +out+.
|
95
95
|
def PP.pp(obj, out=$>, width=width_for(out))
|
96
|
-
q =
|
96
|
+
q = new(out, width)
|
97
97
|
q.guard_inspect_key {q.pp obj}
|
98
98
|
q.flush
|
99
99
|
#$pp = q
|
@@ -189,7 +189,7 @@ class PP < PrettyPrint
|
|
189
189
|
def pp(obj)
|
190
190
|
# If obj is a Delegator then use the object being delegated to for cycle
|
191
191
|
# detection
|
192
|
-
obj = obj.__getobj__ if defined?(::Delegator) and
|
192
|
+
obj = obj.__getobj__ if defined?(::Delegator) and ::Delegator === obj
|
193
193
|
|
194
194
|
if check_inspect_key(obj)
|
195
195
|
group {obj.pretty_print_cycle self}
|
@@ -198,7 +198,11 @@ class PP < PrettyPrint
|
|
198
198
|
|
199
199
|
begin
|
200
200
|
push_inspect_key(obj)
|
201
|
-
group
|
201
|
+
group do
|
202
|
+
obj.pretty_print self
|
203
|
+
rescue NoMethodError
|
204
|
+
text Kernel.instance_method(:inspect).bind_call(obj)
|
205
|
+
end
|
202
206
|
ensure
|
203
207
|
pop_inspect_key(obj) unless PP.sharing_detection
|
204
208
|
end
|
@@ -286,16 +290,42 @@ class PP < PrettyPrint
|
|
286
290
|
group(1, '{', '}') {
|
287
291
|
seplist(obj, nil, :each_pair) {|k, v|
|
288
292
|
group {
|
289
|
-
|
290
|
-
text '=>'
|
291
|
-
group(1) {
|
292
|
-
breakable ''
|
293
|
-
pp v
|
294
|
-
}
|
293
|
+
pp_hash_pair k, v
|
295
294
|
}
|
296
295
|
}
|
297
296
|
}
|
298
297
|
end
|
298
|
+
|
299
|
+
if RUBY_VERSION >= '3.4.'
|
300
|
+
# A pretty print for a pair of Hash
|
301
|
+
def pp_hash_pair(k, v)
|
302
|
+
if Symbol === k
|
303
|
+
sym_s = k.inspect
|
304
|
+
if sym_s[1].match?(/["$@!]/) || sym_s[-1].match?(/[%&*+\-\/<=>@\]^`|~]/)
|
305
|
+
text "#{k.to_s.inspect}:"
|
306
|
+
else
|
307
|
+
text "#{k}:"
|
308
|
+
end
|
309
|
+
else
|
310
|
+
pp k
|
311
|
+
text ' '
|
312
|
+
text '=>'
|
313
|
+
end
|
314
|
+
group(1) {
|
315
|
+
breakable
|
316
|
+
pp v
|
317
|
+
}
|
318
|
+
end
|
319
|
+
else
|
320
|
+
def pp_hash_pair(k, v)
|
321
|
+
pp k
|
322
|
+
text '=>'
|
323
|
+
group(1) {
|
324
|
+
breakable ''
|
325
|
+
pp v
|
326
|
+
}
|
327
|
+
end
|
328
|
+
end
|
299
329
|
end
|
300
330
|
|
301
331
|
include PPMethods
|
@@ -422,14 +452,28 @@ end
|
|
422
452
|
|
423
453
|
class Data # :nodoc:
|
424
454
|
def pretty_print(q) # :nodoc:
|
425
|
-
|
426
|
-
|
455
|
+
class_name = PP.mcall(self, Kernel, :class).name
|
456
|
+
class_name = " #{class_name}" if class_name
|
457
|
+
q.group(1, "#<data#{class_name}", '>') {
|
458
|
+
|
459
|
+
members = PP.mcall(self, Kernel, :class).members
|
460
|
+
values = []
|
461
|
+
members.select! do |member|
|
462
|
+
begin
|
463
|
+
values << __send__(member)
|
464
|
+
true
|
465
|
+
rescue NoMethodError
|
466
|
+
false
|
467
|
+
end
|
468
|
+
end
|
469
|
+
|
470
|
+
q.seplist(members.zip(values), lambda { q.text "," }) {|(member, value)|
|
427
471
|
q.breakable
|
428
472
|
q.text member.to_s
|
429
473
|
q.text '='
|
430
474
|
q.group(1) {
|
431
475
|
q.breakable ''
|
432
|
-
q.pp
|
476
|
+
q.pp value
|
433
477
|
}
|
434
478
|
}
|
435
479
|
}
|
@@ -438,11 +482,11 @@ class Data # :nodoc:
|
|
438
482
|
def pretty_print_cycle(q) # :nodoc:
|
439
483
|
q.text sprintf("#<data %s:...>", PP.mcall(self, Kernel, :class).name)
|
440
484
|
end
|
441
|
-
end if
|
485
|
+
end if defined?(Data.define)
|
442
486
|
|
443
487
|
class Range # :nodoc:
|
444
488
|
def pretty_print(q) # :nodoc:
|
445
|
-
q.pp self.begin
|
489
|
+
q.pp self.begin if self.begin
|
446
490
|
q.breakable ''
|
447
491
|
q.text(self.exclude_end? ? '...' : '..')
|
448
492
|
q.breakable ''
|
data/pp.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tanaka Akira
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: prettyprint
|
@@ -31,7 +31,8 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
-
-
|
34
|
+
- BSDL
|
35
|
+
- COPYING
|
35
36
|
- lib/pp.rb
|
36
37
|
- pp.gemspec
|
37
38
|
homepage: https://github.com/ruby/pp
|
@@ -41,7 +42,7 @@ licenses:
|
|
41
42
|
metadata:
|
42
43
|
homepage_uri: https://github.com/ruby/pp
|
43
44
|
source_code_uri: https://github.com/ruby/pp
|
44
|
-
post_install_message:
|
45
|
+
post_install_message:
|
45
46
|
rdoc_options: []
|
46
47
|
require_paths:
|
47
48
|
- lib
|
@@ -56,8 +57,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
57
|
- !ruby/object:Gem::Version
|
57
58
|
version: '0'
|
58
59
|
requirements: []
|
59
|
-
rubygems_version: 3.5.
|
60
|
-
signing_key:
|
60
|
+
rubygems_version: 3.5.11
|
61
|
+
signing_key:
|
61
62
|
specification_version: 4
|
62
63
|
summary: Provides a PrettyPrinter for Ruby objects
|
63
64
|
test_files: []
|