pp 0.4.0 → 0.6.0
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 +62 -18
- data/pp.gemspec +11 -3
- 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: f7baebc9ed9b6d7e6a59bab9519127ddae100eb3d8f69f34e2f425a8676f4de2
|
4
|
+
data.tar.gz: fd88755cc44af04429d8295ddbbf0e5f607e140fcedcca3f5f93130cd619a845
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5839273be7f644375b772d91608303d003a15925006c5b65b4f25fca5d5cba3e0e22ea53749126d401e11484607efe95de2c969ea9f7b58a1a9a5eec9948282b
|
7
|
+
data.tar.gz: e5c76b514108b430d939767308cc078915ab2fb4f796cbabf65d58ab2355c018b5882378db7edd96155cf60b20971be40cfaef32a68ff1315abc450bac89218f
|
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
@@ -46,6 +46,7 @@ require 'prettyprint'
|
|
46
46
|
#
|
47
47
|
# To define a customized pretty printing function for your classes,
|
48
48
|
# redefine method <code>#pretty_print(pp)</code> in the class.
|
49
|
+
# Note that <code>require 'pp'</code> is needed before redefining <code>#pretty_print(pp)</code>.
|
49
50
|
#
|
50
51
|
# <code>#pretty_print</code> takes the +pp+ argument, which is an instance of the PP class.
|
51
52
|
# The method uses #text, #breakable, #nest, #group and #pp to print the
|
@@ -61,6 +62,9 @@ require 'prettyprint'
|
|
61
62
|
# Tanaka Akira <akr@fsij.org>
|
62
63
|
|
63
64
|
class PP < PrettyPrint
|
65
|
+
|
66
|
+
VERSION = "0.6.0"
|
67
|
+
|
64
68
|
# Returns the usable width for +out+.
|
65
69
|
# As the width of +out+:
|
66
70
|
# 1. If +out+ is assigned to a tty device, its width is used.
|
@@ -89,7 +93,7 @@ class PP < PrettyPrint
|
|
89
93
|
#
|
90
94
|
# PP.pp returns +out+.
|
91
95
|
def PP.pp(obj, out=$>, width=width_for(out))
|
92
|
-
q =
|
96
|
+
q = new(out, width)
|
93
97
|
q.guard_inspect_key {q.pp obj}
|
94
98
|
q.flush
|
95
99
|
#$pp = q
|
@@ -185,7 +189,7 @@ class PP < PrettyPrint
|
|
185
189
|
def pp(obj)
|
186
190
|
# If obj is a Delegator then use the object being delegated to for cycle
|
187
191
|
# detection
|
188
|
-
obj = obj.__getobj__ if defined?(::Delegator) and
|
192
|
+
obj = obj.__getobj__ if defined?(::Delegator) and ::Delegator === obj
|
189
193
|
|
190
194
|
if check_inspect_key(obj)
|
191
195
|
group {obj.pretty_print_cycle self}
|
@@ -194,7 +198,11 @@ class PP < PrettyPrint
|
|
194
198
|
|
195
199
|
begin
|
196
200
|
push_inspect_key(obj)
|
197
|
-
group
|
201
|
+
group do
|
202
|
+
obj.pretty_print self
|
203
|
+
rescue NoMethodError
|
204
|
+
text Kernel.instance_method(:inspect).bind_call(obj)
|
205
|
+
end
|
198
206
|
ensure
|
199
207
|
pop_inspect_key(obj) unless PP.sharing_detection
|
200
208
|
end
|
@@ -282,16 +290,42 @@ class PP < PrettyPrint
|
|
282
290
|
group(1, '{', '}') {
|
283
291
|
seplist(obj, nil, :each_pair) {|k, v|
|
284
292
|
group {
|
285
|
-
|
286
|
-
text '=>'
|
287
|
-
group(1) {
|
288
|
-
breakable ''
|
289
|
-
pp v
|
290
|
-
}
|
293
|
+
pp_hash_pair k, v
|
291
294
|
}
|
292
295
|
}
|
293
296
|
}
|
294
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
|
295
329
|
end
|
296
330
|
|
297
331
|
include PPMethods
|
@@ -418,14 +452,28 @@ end
|
|
418
452
|
|
419
453
|
class Data # :nodoc:
|
420
454
|
def pretty_print(q) # :nodoc:
|
421
|
-
|
422
|
-
|
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
|
+
value = 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)|
|
423
471
|
q.breakable
|
424
472
|
q.text member.to_s
|
425
473
|
q.text '='
|
426
474
|
q.group(1) {
|
427
475
|
q.breakable ''
|
428
|
-
q.pp
|
476
|
+
q.pp value
|
429
477
|
}
|
430
478
|
}
|
431
479
|
}
|
@@ -434,11 +482,11 @@ class Data # :nodoc:
|
|
434
482
|
def pretty_print_cycle(q) # :nodoc:
|
435
483
|
q.text sprintf("#<data %s:...>", PP.mcall(self, Kernel, :class).name)
|
436
484
|
end
|
437
|
-
end if
|
485
|
+
end if defined?(Data.define)
|
438
486
|
|
439
487
|
class Range # :nodoc:
|
440
488
|
def pretty_print(q) # :nodoc:
|
441
|
-
q.pp self.begin
|
489
|
+
q.pp self.begin if self.begin
|
442
490
|
q.breakable ''
|
443
491
|
q.text(self.exclude_end? ? '...' : '..')
|
444
492
|
q.breakable ''
|
@@ -629,10 +677,6 @@ end
|
|
629
677
|
module Kernel
|
630
678
|
# Returns a pretty printed object as a string.
|
631
679
|
#
|
632
|
-
# In order to use this method you must first require the PP module:
|
633
|
-
#
|
634
|
-
# require 'pp'
|
635
|
-
#
|
636
680
|
# See the PP module for more information.
|
637
681
|
def pretty_inspect
|
638
682
|
PP.pp(self, ''.dup)
|
data/pp.gemspec
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
+
name = File.basename(__FILE__, ".gemspec")
|
2
|
+
version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir|
|
3
|
+
break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
|
4
|
+
/^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
|
5
|
+
end rescue nil
|
6
|
+
end
|
7
|
+
|
1
8
|
Gem::Specification.new do |spec|
|
2
|
-
spec.name =
|
3
|
-
spec.version =
|
9
|
+
spec.name = name
|
10
|
+
spec.version = version
|
4
11
|
spec.authors = ["Tanaka Akira"]
|
5
12
|
spec.email = ["akr@fsij.org"]
|
6
13
|
|
@@ -15,7 +22,8 @@ Gem::Specification.new do |spec|
|
|
15
22
|
spec.metadata["source_code_uri"] = spec.homepage
|
16
23
|
|
17
24
|
spec.files = %w[
|
18
|
-
|
25
|
+
BSDL
|
26
|
+
COPYING
|
19
27
|
lib/pp.rb
|
20
28
|
pp.gemspec
|
21
29
|
]
|
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.0
|
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-12 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.
|
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: []
|