betterp 0.1.8 → 0.1.10
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/Gemfile.lock +1 -1
- data/Makefile +8 -0
- data/lib/betterp/output.rb +24 -13
- data/lib/betterp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38943c3f0f9baf276c68d39efa2229a6a93546ed347c658c71175b70a314153f
|
4
|
+
data.tar.gz: f9ecb8dd7a3cd930d08ddd4125e33816b07b263cb89438002d9b29a5a0880ff6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6001d2655ad45bbe85d8263e541a2865fa8ab0e83ea932927f3818deab82d57c49f813dcd1c9c3b98b2b0b0d45f41961a8c3d2f02ef79933b0671e7eb3d22039
|
7
|
+
data.tar.gz: dce5f9cce1aa13ac4791fe7300c5c61b85e532f3d0061c1b29cdecea8037ed6dc56f19b8e0095ece45aecfe92580deda30c8e8d01b57fad474e69d57bf2542bf
|
data/Gemfile.lock
CHANGED
data/Makefile
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
+
project=betterp
|
2
|
+
|
1
3
|
.PHONY: test
|
2
4
|
test:
|
3
5
|
bin/rspec
|
4
6
|
bin/rubocop
|
5
7
|
bin/strong_versions
|
6
8
|
bundle exec rspec-documentation
|
9
|
+
|
10
|
+
.PHONY: publish
|
11
|
+
publish:
|
12
|
+
@RSPEC_DOCUMENTATION_URL_ROOT='/$(project)' rspec-documentation
|
13
|
+
@rsync --delete -r rspec-documentation/bundle/ docs.bob.frl:/var/www/html/$(project)/
|
14
|
+
@echo 'Published.'
|
data/lib/betterp/output.rb
CHANGED
@@ -14,10 +14,15 @@ module Betterp
|
|
14
14
|
@pretty = options.fetch(:pretty, false)
|
15
15
|
end
|
16
16
|
|
17
|
-
def formatted(args)
|
18
|
-
|
17
|
+
def formatted(args) # rubocop:disable Metrics/MethodLength
|
18
|
+
args.map do |arg|
|
19
19
|
output = [
|
20
|
-
header,
|
20
|
+
header,
|
21
|
+
colorized_prefix,
|
22
|
+
colorized_duration,
|
23
|
+
highlighted(caller_code),
|
24
|
+
Paintbrush.paintbrush { cyan_b '=>' },
|
25
|
+
return_value(arg)
|
21
26
|
].compact.join(' ').chomp
|
22
27
|
"#{output}\n"
|
23
28
|
end
|
@@ -25,10 +30,24 @@ module Betterp
|
|
25
30
|
|
26
31
|
private
|
27
32
|
|
33
|
+
def return_value(val)
|
34
|
+
return normalized_highlighted(val) unless @pretty
|
35
|
+
|
36
|
+
highlighted(pretty(val))
|
37
|
+
end
|
38
|
+
|
28
39
|
def highlighted(output)
|
29
40
|
formatter = Rouge::Formatters::Terminal256.new
|
30
41
|
lexer = Rouge::Lexers::Ruby.new
|
31
|
-
formatter.format(lexer.lex(output))
|
42
|
+
formatter.format(lexer.lex(output.nil? ? '' : output))
|
43
|
+
end
|
44
|
+
|
45
|
+
def normalized_highlighted(val)
|
46
|
+
pretty_squashed = pretty(val).split("\n")
|
47
|
+
.map { |string| string.gsub(/^\s+/, '') }
|
48
|
+
.join("\n")
|
49
|
+
|
50
|
+
highlighted(pretty_squashed).split("\n").join(' ')
|
32
51
|
end
|
33
52
|
|
34
53
|
def colorized_duration
|
@@ -39,13 +58,7 @@ module Betterp
|
|
39
58
|
Paintbrush.paintbrush { "[#{send color, "#{Float(format('%.2g', duration))}ms"}]" }
|
40
59
|
end
|
41
60
|
|
42
|
-
def colorized_pretty(arg)
|
43
|
-
Paintbrush.paintbrush { cyan pretty(arg) }
|
44
|
-
end
|
45
|
-
|
46
61
|
def pretty(arg)
|
47
|
-
return arg unless @pretty
|
48
|
-
|
49
62
|
io = StringIO.new
|
50
63
|
PP.pp(arg, io)
|
51
64
|
return io.string unless io.string.include?("\n")
|
@@ -59,9 +72,7 @@ module Betterp
|
|
59
72
|
path, line, *_rest = @raw.split(':')
|
60
73
|
return nil unless Pathname.new(path).readable? && line.to_i.positive?
|
61
74
|
|
62
|
-
|
63
|
-
white "{ #{blue find_caller(line.to_i, path).to_s.strip} }"
|
64
|
-
end
|
75
|
+
find_caller(line.to_i, path).to_s.strip
|
65
76
|
end
|
66
77
|
|
67
78
|
def find_caller(line_number, path)
|
data/lib/betterp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: betterp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Farrell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: paintbrush
|