amazing_print 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -2
- data/README.md +7 -1
- data/lib/amazing_print/core_ext/logger.rb +9 -2
- data/lib/amazing_print/custom_defaults.rb +1 -1
- data/lib/amazing_print/ext/nobrainer.rb +4 -0
- data/lib/amazing_print/formatters/hash_formatter.rb +2 -2
- data/lib/amazing_print/version.rb +1 -1
- data/spec/colors_spec.rb +32 -44
- data/spec/core_ext/logger_spec.rb +38 -14
- data/spec/support/ext_verifier.rb +2 -4
- metadata +56 -56
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d16f5d91a4e2a69b255fed58405879e2adfbc390f1c55617e717a06249ec035
|
4
|
+
data.tar.gz: 1ddabc2b038aea1b78c956c0d3eb08c4e56294b968da9214235f2db944e579a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d6edeeb83162ab87b4c3a40cffd126fda850abfbd22531bb2149ae51a89aaac3314cb8a5d7a9a06ce0bf48e4fc9fdc2df29359d6828b11a67b4562a71d12558
|
7
|
+
data.tar.gz: d264dd5aba47cf7f9c3681f20979441d7337f8115443bf3052bbf3623914036a6ed96b9e75efae6979f2a74f02bde5d41b7d44b90b06c4ad47e01069bd096f6d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
|
-
##
|
2
|
-
-
|
1
|
+
## v1.2.2
|
2
|
+
- Support Ruby 3.0 / IRB 1.2.6 - #57
|
3
|
+
- Fix FrozenError - #51
|
4
|
+
- Drop support for Ruby 2.3 and 2.4 as well as JRuby 9.1 - #46
|
5
|
+
- Add passing of `options` to `Logger#ap` - #55
|
6
|
+
|
7
|
+
## v1.2.1
|
8
|
+
- Correctly print active_model_errors for models that don't have tables - #42 by sahglie
|
9
|
+
- Update AmazingPrint::MongoMapper for frozen strings - #44
|
3
10
|
|
4
11
|
## v1.2.0
|
5
12
|
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
|
|
10
10
|
[![Gitter](https://badges.gitter.im/amazing-print/community.svg)](https://gitter.im/amazing-print/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
11
11
|
|
12
|
-
AmazingPrint is a fork of [AwesomePrint](https://github.com/awesome-print/awesome_print) which became stale and should be used in
|
12
|
+
AmazingPrint is a fork of [AwesomePrint](https://github.com/awesome-print/awesome_print) which became stale and should be used in its place to avoid conflicts. It is a Ruby library that pretty prints Ruby objects in full color exposing their internal structure with proper indentation. Rails ActiveRecord objects and usage within Rails templates are supported via included mixins.
|
13
13
|
|
14
14
|
![GitHub API demo](github-api-demo.gif)
|
15
15
|
|
@@ -297,6 +297,12 @@ By default, this logs at the :debug level. You can override that globally with:
|
|
297
297
|
in the custom defaults (see below). You can also override on a per call basis with:
|
298
298
|
|
299
299
|
logger.ap object, :warn
|
300
|
+
# or
|
301
|
+
logger.ap object, level: :warn
|
302
|
+
|
303
|
+
You can also pass additional options (providing `nil` or leaving off `level` will log at the default level):
|
304
|
+
|
305
|
+
logger.ap object, { level: :info, sort_keys: true }
|
300
306
|
|
301
307
|
### ActionView Convenience Method ###
|
302
308
|
amazing_print adds the 'ap' method to the ActionView::Base class making it available
|
@@ -9,10 +9,17 @@ module AmazingPrint
|
|
9
9
|
module Logger
|
10
10
|
# Add ap method to logger
|
11
11
|
#------------------------------------------------------------------------------
|
12
|
-
def ap(object,
|
12
|
+
def ap(object, options = {})
|
13
|
+
if options.is_a?(Hash)
|
14
|
+
level = options.delete(:level)
|
15
|
+
else
|
16
|
+
level = options
|
17
|
+
options = {}
|
18
|
+
end
|
19
|
+
|
13
20
|
level ||= AmazingPrint.defaults[:log_level] if AmazingPrint.defaults
|
14
21
|
level ||= :debug
|
15
|
-
send level, object.ai
|
22
|
+
send level, object.ai(options)
|
16
23
|
end
|
17
24
|
end
|
18
25
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# rubocop:disable Style/HashTransformValues
|
4
|
+
|
3
5
|
# Copyright (c) 2010-2016 Michael Dvorkin and contributors
|
4
6
|
#
|
5
7
|
# AmazingPrint is freely distributable under the terms of MIT license.
|
@@ -53,3 +55,5 @@ module AmazingPrint
|
|
53
55
|
end
|
54
56
|
|
55
57
|
AmazingPrint::Formatter.include AmazingPrint::NoBrainer
|
58
|
+
|
59
|
+
# rubocop:enable Style/HashTransformValues
|
@@ -86,11 +86,11 @@ module AmazingPrint
|
|
86
86
|
|
87
87
|
def ruby19_syntax(key, value, width)
|
88
88
|
key[0] = ''
|
89
|
-
align(key, width - 1)
|
89
|
+
"#{align(key, width - 1)}#{colorize(': ', :hash)}#{inspector.awesome(value)}"
|
90
90
|
end
|
91
91
|
|
92
92
|
def pre_ruby19_syntax(key, value, width)
|
93
|
-
align(key, width)
|
93
|
+
"#{align(key, width)}#{colorize(' => ', :hash)}#{inspector.awesome(value)}"
|
94
94
|
end
|
95
95
|
|
96
96
|
def plain_single_line
|
data/spec/colors_spec.rb
CHANGED
@@ -40,34 +40,28 @@ RSpec.describe 'AmazingPrint' do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it "colorizes processes with ENV['ANSICON'] by default" do
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
ENV['ANSICON'] = term
|
50
|
-
end
|
43
|
+
stub_tty!
|
44
|
+
term = ENV['ANSICON']
|
45
|
+
ENV['ANSICON'] = '1'
|
46
|
+
expect(@arr.ai(multiline: false)).to eq(COLORIZED)
|
47
|
+
ensure
|
48
|
+
ENV['ANSICON'] = term
|
51
49
|
end
|
52
50
|
|
53
51
|
it 'does not colorize tty processes running in dumb terminals by default' do
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
ENV['TERM'] = term
|
61
|
-
end
|
52
|
+
stub_tty!
|
53
|
+
term = ENV['TERM']
|
54
|
+
ENV['TERM'] = 'dumb'
|
55
|
+
expect(@arr.ai(multiline: false)).to eq(PLAIN)
|
56
|
+
ensure
|
57
|
+
ENV['TERM'] = term
|
62
58
|
end
|
63
59
|
|
64
60
|
it 'does not colorize subprocesses by default' do
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
stub_tty!
|
70
|
-
end
|
61
|
+
stub_tty! false
|
62
|
+
expect(@arr.ai(multiline: false)).to eq(PLAIN)
|
63
|
+
ensure
|
64
|
+
stub_tty!
|
71
65
|
end
|
72
66
|
end
|
73
67
|
|
@@ -82,34 +76,28 @@ RSpec.describe 'AmazingPrint' do
|
|
82
76
|
end
|
83
77
|
|
84
78
|
it "colorizes processes with ENV['ANSICON'] set to 0" do
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
ENV['ANSICON'] = term
|
92
|
-
end
|
79
|
+
stub_tty!
|
80
|
+
term = ENV['ANSICON']
|
81
|
+
ENV['ANSICON'] = '1'
|
82
|
+
expect(@arr.ai(multiline: false)).to eq(COLORIZED)
|
83
|
+
ensure
|
84
|
+
ENV['ANSICON'] = term
|
93
85
|
end
|
94
86
|
|
95
87
|
it 'colorizes dumb terminals' do
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
ENV['TERM'] = term
|
103
|
-
end
|
88
|
+
stub_tty!
|
89
|
+
term = ENV['TERM']
|
90
|
+
ENV['TERM'] = 'dumb'
|
91
|
+
expect(@arr.ai(multiline: false)).to eq(COLORIZED)
|
92
|
+
ensure
|
93
|
+
ENV['TERM'] = term
|
104
94
|
end
|
105
95
|
|
106
96
|
it 'colorizes subprocess' do
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
stub_tty!
|
112
|
-
end
|
97
|
+
stub_tty! false
|
98
|
+
expect(@arr.ai(multiline: false)).to eq(COLORIZED)
|
99
|
+
ensure
|
100
|
+
stub_tty!
|
113
101
|
end
|
114
102
|
end
|
115
103
|
|
@@ -6,19 +6,24 @@ require 'logger'
|
|
6
6
|
require 'amazing_print/core_ext/logger'
|
7
7
|
|
8
8
|
RSpec.describe 'AmazingPrint logging extensions' do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
let(:object) { double }
|
10
|
+
let(:options) { { sort_keys: true } }
|
11
|
+
|
12
|
+
subject(:logger) do
|
13
|
+
Logger.new('/dev/null')
|
14
|
+
rescue Errno::ENOENT
|
15
|
+
Logger.new('nul')
|
15
16
|
end
|
16
17
|
|
17
18
|
describe 'ap method' do
|
18
19
|
it 'should awesome_inspect the given object' do
|
19
|
-
object = double
|
20
20
|
expect(object).to receive(:ai)
|
21
|
-
|
21
|
+
logger.ap object
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'passes options to `ai`' do
|
25
|
+
expect(object).to receive(:ai).with(options)
|
26
|
+
logger.ap object, options
|
22
27
|
end
|
23
28
|
|
24
29
|
describe 'the log level' do
|
@@ -27,19 +32,38 @@ RSpec.describe 'AmazingPrint logging extensions' do
|
|
27
32
|
end
|
28
33
|
|
29
34
|
it 'should fallback to the default :debug log level' do
|
30
|
-
expect(
|
31
|
-
|
35
|
+
expect(logger).to receive(:debug)
|
36
|
+
logger.ap nil
|
32
37
|
end
|
33
38
|
|
34
39
|
it 'should use the global user default if no level passed' do
|
35
40
|
AmazingPrint.defaults = { log_level: :info }
|
36
|
-
expect(
|
37
|
-
|
41
|
+
expect(logger).to receive(:info)
|
42
|
+
logger.ap nil
|
38
43
|
end
|
39
44
|
|
40
45
|
it 'should use the passed in level' do
|
41
|
-
expect(
|
42
|
-
|
46
|
+
expect(logger).to receive(:warn)
|
47
|
+
logger.ap nil, :warn
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'makes no difference if passed as a hash or a part of options' do
|
51
|
+
expect(logger).to receive(:warn)
|
52
|
+
logger.ap nil, { level: :warn }
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when given options' do
|
56
|
+
it 'uses the default log level with the options' do
|
57
|
+
expect(logger).to receive(:debug)
|
58
|
+
expect(object).to receive(:ai).with(options)
|
59
|
+
logger.ap object, options
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'still uses the passed in level with options' do
|
63
|
+
expect(logger).to receive(:warn)
|
64
|
+
expect(object).to receive(:ai).with(options)
|
65
|
+
logger.ap object, options.merge({ level: :warn })
|
66
|
+
end
|
43
67
|
end
|
44
68
|
end
|
45
69
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amazing_print
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Dvorkin
|
@@ -9,50 +9,50 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-10-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: appraisal
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '2.3'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
27
|
+
version: '2.3'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: fakefs
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: '1.2'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "
|
39
|
+
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: '1.2'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: nokogiri
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 1.
|
48
|
+
version: '1.10'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 1.
|
55
|
+
version: '1.10'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: pry
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -71,16 +71,16 @@ dependencies:
|
|
71
71
|
name: rspec
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - "
|
74
|
+
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: 3.
|
76
|
+
version: '3.9'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- - "
|
81
|
+
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: 3.
|
83
|
+
version: '3.9'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: rubocop
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -204,7 +204,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
204
204
|
requirements:
|
205
205
|
- - ">="
|
206
206
|
- !ruby/object:Gem::Version
|
207
|
-
version: 2.
|
207
|
+
version: 2.5.0
|
208
208
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
209
|
requirements:
|
210
210
|
- - ">="
|
@@ -216,49 +216,49 @@ signing_key:
|
|
216
216
|
specification_version: 4
|
217
217
|
summary: Pretty print Ruby objects with proper indentation and colors
|
218
218
|
test_files:
|
219
|
-
- spec/
|
220
|
-
- spec/
|
219
|
+
- spec/support/active_record_data.rb
|
220
|
+
- spec/support/rails_versions.rb
|
221
|
+
- spec/support/mongoid_versions.rb
|
222
|
+
- spec/support/active_record_data/4_0_multi.txt
|
223
|
+
- spec/support/active_record_data/3_2_multi_legacy.txt
|
224
|
+
- spec/support/active_record_data/4_1_diana.txt
|
225
|
+
- spec/support/active_record_data/4_2_multi.txt
|
226
|
+
- spec/support/active_record_data/5_2_multi.txt
|
227
|
+
- spec/support/active_record_data/3_2_multi.txt
|
228
|
+
- spec/support/active_record_data/4_1_multi.txt
|
229
|
+
- spec/support/active_record_data/3_2_diana.txt
|
230
|
+
- spec/support/active_record_data/5_0_diana.txt
|
231
|
+
- spec/support/active_record_data/6_0_multi.txt
|
232
|
+
- spec/support/active_record_data/6_0_diana.txt
|
233
|
+
- spec/support/active_record_data/5_1_multi.txt
|
234
|
+
- spec/support/active_record_data/5_0_multi.txt
|
235
|
+
- spec/support/active_record_data/4_2_diana.txt
|
236
|
+
- spec/support/active_record_data/5_1_diana.txt
|
237
|
+
- spec/support/active_record_data/4_2_diana_legacy.txt
|
238
|
+
- spec/support/active_record_data/5_2_diana.txt
|
239
|
+
- spec/support/active_record_data/4_0_diana.txt
|
240
|
+
- spec/support/active_record_data/3_2_diana_legacy.txt
|
241
|
+
- spec/support/active_record_data/4_2_multi_legacy.txt
|
242
|
+
- spec/support/ext_verifier.rb
|
221
243
|
- spec/colors_spec.rb
|
222
|
-
- spec/
|
223
|
-
- spec/
|
224
|
-
- spec/
|
244
|
+
- spec/core_ext/string_spec.rb
|
245
|
+
- spec/core_ext/logger_spec.rb
|
246
|
+
- spec/ext/active_support_spec.rb
|
225
247
|
- spec/ext/active_record_spec.rb
|
248
|
+
- spec/ext/active_model_spec.rb
|
226
249
|
- spec/ext/action_view_spec.rb
|
227
|
-
- spec/ext/
|
250
|
+
- spec/ext/nobrainer_spec.rb
|
251
|
+
- spec/ext/action_controller_spec.rb
|
252
|
+
- spec/ext/sequel_spec.rb
|
228
253
|
- spec/ext/mongoid_spec.rb
|
229
254
|
- spec/ext/ripple_spec.rb
|
230
|
-
- spec/ext/
|
231
|
-
- spec/ext/active_support_spec.rb
|
232
|
-
- spec/ext/active_model_spec.rb
|
255
|
+
- spec/ext/ostruct_spec.rb
|
233
256
|
- spec/ext/nokogiri_spec.rb
|
234
257
|
- spec/ext/mongo_mapper_spec.rb
|
235
|
-
- spec/ext/nobrainer_spec.rb
|
236
|
-
- spec/ext/action_controller_spec.rb
|
237
|
-
- spec/core_ext/string_spec.rb
|
238
|
-
- spec/core_ext/logger_spec.rb
|
239
|
-
- spec/support/mongoid_versions.rb
|
240
|
-
- spec/support/active_record_data/6_0_diana.txt
|
241
|
-
- spec/support/active_record_data/4_2_diana.txt
|
242
|
-
- spec/support/active_record_data/4_2_multi_legacy.txt
|
243
|
-
- spec/support/active_record_data/3_2_diana.txt
|
244
|
-
- spec/support/active_record_data/4_0_diana.txt
|
245
|
-
- spec/support/active_record_data/4_2_diana_legacy.txt
|
246
|
-
- spec/support/active_record_data/5_1_diana.txt
|
247
|
-
- spec/support/active_record_data/6_0_multi.txt
|
248
|
-
- spec/support/active_record_data/3_2_multi_legacy.txt
|
249
|
-
- spec/support/active_record_data/5_0_multi.txt
|
250
|
-
- spec/support/active_record_data/5_2_multi.txt
|
251
|
-
- spec/support/active_record_data/4_2_multi.txt
|
252
|
-
- spec/support/active_record_data/5_1_multi.txt
|
253
|
-
- spec/support/active_record_data/4_0_multi.txt
|
254
|
-
- spec/support/active_record_data/3_2_diana_legacy.txt
|
255
|
-
- spec/support/active_record_data/4_1_multi.txt
|
256
|
-
- spec/support/active_record_data/5_2_diana.txt
|
257
|
-
- spec/support/active_record_data/4_1_diana.txt
|
258
|
-
- spec/support/active_record_data/3_2_multi.txt
|
259
|
-
- spec/support/active_record_data/5_0_diana.txt
|
260
|
-
- spec/support/rails_versions.rb
|
261
|
-
- spec/support/active_record_data.rb
|
262
|
-
- spec/support/ext_verifier.rb
|
263
258
|
- spec/sequel_helper.rb
|
259
|
+
- spec/formats_spec.rb
|
260
|
+
- spec/spec_helper.rb
|
261
|
+
- spec/active_record_helper.rb
|
262
|
+
- spec/methods_spec.rb
|
264
263
|
- spec/misc_spec.rb
|
264
|
+
- spec/objects_spec.rb
|