awesome_print 1.8.0 → 1.9.2
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 +5 -5
- data/.gitignore +1 -0
- data/Appraisals +43 -44
- data/CHANGELOG.md +20 -2
- data/CONTRIBUTING.md +1 -0
- data/LICENSE +16 -19
- data/README.md +43 -8
- data/awesome_print.gemspec +33 -0
- data/init.rb +1 -0
- data/lib/awesome_print/custom_defaults.rb +1 -1
- data/lib/awesome_print/ext/active_record.rb +26 -1
- data/lib/awesome_print/formatter.rb +20 -12
- data/lib/awesome_print/formatters/array_formatter.rb +2 -2
- data/lib/awesome_print/formatters/base_formatter.rb +3 -3
- data/lib/awesome_print/formatters/hash_formatter.rb +2 -2
- data/lib/awesome_print/formatters/object_formatter.rb +5 -2
- data/lib/awesome_print/inspector.rb +6 -3
- data/lib/awesome_print/version.rb +1 -1
- data/spec/ext/action_view_spec.rb +5 -2
- data/spec/ext/active_record_spec.rb +57 -49
- data/spec/ext/active_support_spec.rb +5 -1
- data/spec/ext/mongoid_spec.rb +2 -39
- data/spec/formats_spec.rb +4 -4
- data/spec/methods_spec.rb +10 -2
- data/spec/misc_spec.rb +25 -18
- data/spec/objects_spec.rb +49 -0
- data/spec/spec_helper.rb +4 -2
- data/spec/support/active_record_data/5_1_diana.txt +104 -0
- data/spec/support/active_record_data/5_1_multi.txt +210 -0
- data/spec/support/active_record_data/5_2_diana.txt +104 -0
- data/spec/support/active_record_data/5_2_multi.txt +210 -0
- data/spec/support/active_record_data/6_0_diana.txt +104 -0
- data/spec/support/active_record_data/6_0_multi.txt +210 -0
- data/spec/support/active_record_data/6_1_diana.txt +109 -0
- data/spec/support/active_record_data/6_1_multi.txt +220 -0
- data/spec/support/mongoid_versions.rb +10 -6
- data/spec/support/rails_versions.rb +20 -0
- metadata +45 -56
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bc6d20d854c529b902cfe961bd8271b30f1aa9f82c4db11bfdcaa6ecb6b1f469
|
4
|
+
data.tar.gz: c4f69e0cf2663cb4889b27414bd9f242789fea28790c3252dc5b2788da70bca2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c34cd0b7347ecf6e98afc4ef0647f940a02a5d125c955748917c821e6bbf231830604fcbe0fb524c6bfdaa049d6f945bad658d30433bf878841b30a6d79ad765
|
7
|
+
data.tar.gz: 9cfae5c9646b5194a52c87b1ea38ba3d711cb616a713e66ce0ab83f255293a4b75f4016f349f047aa43d775d14b9f024fc0edccdf40b9f489e46626908162b00
|
data/.gitignore
CHANGED
data/Appraisals
CHANGED
@@ -1,63 +1,62 @@
|
|
1
|
-
appraise 'rails-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
# appraise 'rails-4.2' do
|
2
|
+
# gem 'rails', '~> 4.2.0'
|
3
|
+
#
|
4
|
+
# # The last version that doesn't need Ruby 2.0 and works with version 4.2 of
|
5
|
+
# # Rails. This addresses a build problem with Travis for version 1.9.3 of Ruby
|
6
|
+
# gem 'mime-types', '2.6.2', :platforms => :ruby_19
|
7
|
+
# end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
gem '
|
9
|
+
appraise 'rails-5.0' do
|
10
|
+
gem 'rails', '>= 5.0.0', '< 5.1'
|
11
|
+
gem 'sqlite3', '~> 1.3.6'
|
12
12
|
end
|
13
13
|
|
14
|
-
appraise 'rails-
|
15
|
-
gem 'rails', '
|
16
|
-
|
17
|
-
# The last version that doesn't need Ruby 2.0 and works with version 4.1 of
|
18
|
-
# Rails. This addresses a build problem with Travis for version 1.9.3 of Ruby
|
19
|
-
gem 'mime-types', '2.6.2', :platforms => :ruby_19
|
14
|
+
appraise 'rails-5.1' do
|
15
|
+
gem 'rails', '>= 5.1.0', '< 5.2'
|
20
16
|
end
|
21
17
|
|
22
|
-
appraise 'rails-
|
23
|
-
gem 'rails', '
|
24
|
-
|
25
|
-
# The last version that doesn't need Ruby 2.0 and works with version 4.2 of
|
26
|
-
# Rails. This addresses a build problem with Travis for version 1.9.3 of Ruby
|
27
|
-
gem 'mime-types', '2.6.2', :platforms => :ruby_19
|
18
|
+
appraise 'rails-5.2' do
|
19
|
+
gem 'rails', '>= 5.2.0', '< 5.3'
|
28
20
|
end
|
29
21
|
|
30
|
-
appraise 'rails-
|
31
|
-
|
32
|
-
gem 'rails', '>= 5.0.0.racecar1', '< 5.1'
|
22
|
+
appraise 'rails-6.0' do
|
23
|
+
gem 'rails', '>= 6.0.0', '< 6.1'
|
33
24
|
end
|
34
25
|
|
35
|
-
appraise '
|
36
|
-
gem '
|
26
|
+
appraise 'rails-6.1' do
|
27
|
+
gem 'rails', '>= 6.1.0', '< 6.2'
|
37
28
|
end
|
38
29
|
|
39
|
-
appraise 'mongoid-
|
40
|
-
gem 'mongoid', '~>
|
41
|
-
gem '
|
30
|
+
appraise 'mongoid-5.0' do
|
31
|
+
gem 'mongoid', '~> 5.0.0'
|
32
|
+
gem 'bigdecimal', '~> 1.3.5'
|
42
33
|
end
|
43
34
|
|
44
|
-
appraise 'mongoid-
|
45
|
-
gem 'mongoid', '~>
|
35
|
+
appraise 'mongoid-6.0' do
|
36
|
+
gem 'mongoid', '~> 6.0.0'
|
46
37
|
end
|
47
38
|
|
48
|
-
appraise '
|
49
|
-
gem '
|
39
|
+
appraise 'mongoid-7.0' do
|
40
|
+
gem 'mongoid', '~> 7.0.0'
|
50
41
|
end
|
51
42
|
|
52
|
-
appraise '
|
53
|
-
gem '
|
54
|
-
gem 'ripple'
|
43
|
+
appraise 'mongoid-7.1' do
|
44
|
+
gem 'mongoid', '~> 7.1.0'
|
55
45
|
end
|
56
46
|
|
57
|
-
appraise '
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
47
|
+
# appraise 'mongo_mapper' do
|
48
|
+
# gem 'mongo_mapper'
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
# appraise 'ripple' do
|
52
|
+
# gem 'tzinfo'
|
53
|
+
# gem 'ripple'
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# appraise 'nobrainer' do
|
57
|
+
# gem 'nobrainer'
|
58
|
+
#
|
59
|
+
# # When activesupport 5 was released, it required ruby 2.2.2 as a minimum.
|
60
|
+
# # Locking this down to 4.2.6 allows our Ruby 1.9 tests to keep working.
|
61
|
+
# gem 'activesupport', '4.2.6', :platforms => :ruby_19
|
62
|
+
# end
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,29 @@
|
|
1
1
|
## master (unreleased)
|
2
|
-
|
2
|
+
|
3
|
+
|
4
|
+
## 1.9.2
|
5
|
+
- Tests work with Ruby 2.6.6, 2.7.2 and 3.0.0
|
6
|
+
- Update awsome_print.gemspec nokogiri dependency to resolve CVEs [@gvwirth]
|
7
|
+
|
8
|
+
## 1.9.1
|
9
|
+
- Updated code so it can be released to rubygems.
|
10
|
+
- Updated nokogiri to resolve vulnerability scan
|
11
|
+
|
12
|
+
## 1.9.0
|
13
|
+
- Update method signature after change in IRB [@febeling]
|
14
|
+
- Fixes block and proc definition to work with Ruby 3.0.0 [@csalvato] - [#392]
|
15
|
+
- Removed check for Ruby 2.4 and earlier [@bryanh]
|
16
|
+
- Rails 5.0 builds are failing, because the sqlite3 version being installed is wrong version [#366]
|
17
|
+
- Fixes spec suite to properly work via travis, gets a clean build [@imajes, others]
|
18
|
+
- Adds support for ActiveModel::Errors [@dshinzie] - [#301]
|
19
|
+
- removes use of `strip_heredoc` from specs as it's a rails dep [@kstephens] - [#303]
|
20
|
+
- ArrayFormatter now returns arrays for has_many :through associations [@chadh13] - [#332]
|
3
21
|
|
4
22
|
## 1.8.0
|
5
23
|
- stat("$HOME/.aprc") once [@kstephens] - [#304]
|
6
24
|
- ActiveRecord: #joins now show the columns #select'ed [@adrianomitre] - [#211]
|
7
25
|
- Handles NoMethodError for IRB implicit `ai` [@jtnegrotto] - [#212]
|
8
|
-
- Replaced Fixnum reference with Integer
|
26
|
+
- Replaced Fixnum reference with Integer
|
9
27
|
- Colorize ORM class names [@ixti]
|
10
28
|
|
11
29
|
## 1.7.0
|
data/CONTRIBUTING.md
CHANGED
@@ -51,6 +51,7 @@ Special thanks goes to awesome team of contributors, namely:
|
|
51
51
|
* Barry Allard -- https://github.com/steakknife
|
52
52
|
* Benoit Daloze -- http://github.com/eregon
|
53
53
|
* Brandon Zylstra -- https://github.com/brandondrew
|
54
|
+
* Bryan Hanks, PMP -- https://github.com/bryanh
|
54
55
|
* Dan Lynn -- https://github.com/danlynn
|
55
56
|
* Daniel Johnson -- https://github.com/adhd360
|
56
57
|
* Daniel Bretoi -- http://github.com/danielb2
|
data/LICENSE
CHANGED
@@ -1,22 +1,19 @@
|
|
1
|
-
Copyright (c) 2010-
|
2
|
-
http://www.dvorkin.net
|
3
|
-
%w(mike dvorkin.net) * "@" || "twitter.com/mid"
|
1
|
+
Copyright (c) 2010-2019 Michael Dvorkin
|
4
2
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
the following conditions:
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
12
9
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
15
12
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
OF
|
22
|
-
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -12,9 +12,8 @@ Awesome Print is a Ruby library that pretty prints Ruby objects in full color
|
|
12
12
|
exposing their internal structure with proper indentation. Rails ActiveRecord
|
13
13
|
objects and usage within Rails templates are supported via included mixins.
|
14
14
|
|
15
|
-
__NOTE__: awesome_print v1.
|
16
|
-
|
17
|
-
v2.0 will *require* Ruby v1.9.3 or later and Rails v3.0 or later.
|
15
|
+
__NOTE__: awesome_print v1.9.0 may not work on Ruby versions 2.4 or older or Rails versions 4.2 or older.
|
16
|
+
The upcoming awesome_print v2.0 will *require* Ruby v1.9.3 or later and Rails v3.0 or later.
|
18
17
|
|
19
18
|
### Installation ###
|
20
19
|
# Installing as Ruby gem
|
@@ -43,6 +42,8 @@ sort_keys: false, # Do not sort hash keys.
|
|
43
42
|
sort_vars: true, # Sort instance variables.
|
44
43
|
limit: false, # Limit arrays & hashes. Accepts bool or int.
|
45
44
|
ruby19_syntax: false, # Use Ruby 1.9 hash syntax in output.
|
45
|
+
class_name: :class, # Method called to report the instance class name. (e.g. :to_s)
|
46
|
+
object_id: true, # Show object id.
|
46
47
|
color: {
|
47
48
|
args: :pale,
|
48
49
|
array: :white,
|
@@ -50,7 +51,7 @@ color: {
|
|
50
51
|
class: :yellow,
|
51
52
|
date: :greenish,
|
52
53
|
falseclass: :red,
|
53
|
-
|
54
|
+
integer: :blue,
|
54
55
|
float: :blue,
|
55
56
|
hash: :pale,
|
56
57
|
keyword: :cyan,
|
@@ -82,6 +83,8 @@ irb> "awesome print".ai
|
|
82
83
|
|
83
84
|
### Examples ###
|
84
85
|
|
86
|
+
#### Array
|
87
|
+
|
85
88
|
```ruby
|
86
89
|
$ cat > 1.rb
|
87
90
|
require "awesome_print"
|
@@ -102,7 +105,10 @@ $ ruby 1.rb
|
|
102
105
|
:distance => 4.2e+43
|
103
106
|
}
|
104
107
|
]
|
108
|
+
```
|
109
|
+
#### Hash
|
105
110
|
|
111
|
+
```ruby
|
106
112
|
$ cat > 2.rb
|
107
113
|
require "awesome_print"
|
108
114
|
data = { :now => Time.now, :class => Time.now.class, :distance => 42e42 }
|
@@ -114,7 +120,11 @@ $ ruby 2.rb
|
|
114
120
|
:now => Fri Apr 02 19:55:53 -0700 2010,
|
115
121
|
:distance => 4.2e+43
|
116
122
|
}
|
123
|
+
```
|
117
124
|
|
125
|
+
#### Nested array
|
126
|
+
|
127
|
+
```ruby
|
118
128
|
$ cat > 3.rb
|
119
129
|
require "awesome_print"
|
120
130
|
data = [ false, 42, %w(forty two) ]
|
@@ -124,6 +134,11 @@ ap data, :multiline => false
|
|
124
134
|
$ ruby 3.rb
|
125
135
|
[ false, 42, [ "forty", "two" ], [...] ]
|
126
136
|
|
137
|
+
```
|
138
|
+
|
139
|
+
#### Class methods
|
140
|
+
|
141
|
+
```ruby
|
127
142
|
$ cat > 4.rb
|
128
143
|
require "awesome_print"
|
129
144
|
class Hello
|
@@ -137,6 +152,11 @@ $ ruby 4.rb
|
|
137
152
|
[0] world(x, y, *z, &blk) Hello
|
138
153
|
]
|
139
154
|
|
155
|
+
```
|
156
|
+
|
157
|
+
#### Object methods
|
158
|
+
|
159
|
+
```ruby
|
140
160
|
$ cat > 5.rb
|
141
161
|
require "awesome_print"
|
142
162
|
ap (''.methods - Object.methods).grep(/!/)
|
@@ -165,6 +185,11 @@ $ ruby 5.rb
|
|
165
185
|
[19] upcase!() String
|
166
186
|
]
|
167
187
|
|
188
|
+
```
|
189
|
+
|
190
|
+
#### Compare output to value
|
191
|
+
|
192
|
+
```ruby
|
168
193
|
$ cat > 6.rb
|
169
194
|
require "awesome_print"
|
170
195
|
ap 42 == ap(42)
|
@@ -172,7 +197,13 @@ ap 42 == ap(42)
|
|
172
197
|
$ ruby 6.rb
|
173
198
|
42
|
174
199
|
true
|
175
|
-
|
200
|
+
|
201
|
+
```
|
202
|
+
|
203
|
+
#### Array with default output limit
|
204
|
+
|
205
|
+
```ruby
|
206
|
+
$ cat > 7.rb
|
176
207
|
require "awesome_print"
|
177
208
|
some_array = (1..1000).to_a
|
178
209
|
ap some_array, :limit => true
|
@@ -187,8 +218,12 @@ $ ruby 7.rb
|
|
187
218
|
[998] 999,
|
188
219
|
[999] 1000
|
189
220
|
]
|
221
|
+
```
|
190
222
|
|
191
|
-
|
223
|
+
#### Array with specific output limit
|
224
|
+
|
225
|
+
```ruby
|
226
|
+
$ cat > 8.rb
|
192
227
|
require "awesome_print"
|
193
228
|
some_array = (1..1000).to_a
|
194
229
|
ap some_array, :limit => 5
|
@@ -203,7 +238,7 @@ $ ruby 8.rb
|
|
203
238
|
]
|
204
239
|
```
|
205
240
|
|
206
|
-
|
241
|
+
#### Rails console
|
207
242
|
```ruby
|
208
243
|
$ rails console
|
209
244
|
rails> require "awesome_print"
|
@@ -305,7 +340,7 @@ With other web frameworks (ex: in Sinatra templates) you can explicitly request
|
|
305
340
|
formatting:
|
306
341
|
|
307
342
|
<%= ap @accounts.first, :html => true %>
|
308
|
-
|
343
|
+
|
309
344
|
### String Convenience Methods ###
|
310
345
|
Use methods such as `.red` to set string color:
|
311
346
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Copyright (c) 2010-2016 Michael Dvorkin and contributors
|
2
|
+
#
|
3
|
+
# Awesome Print is freely distributable under the terms of MIT license.
|
4
|
+
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
5
|
+
#------------------------------------------------------------------------------
|
6
|
+
|
7
|
+
$:.push File.expand_path('../lib', __FILE__)
|
8
|
+
require 'awesome_print/version'
|
9
|
+
|
10
|
+
Gem::Specification.new do |s|
|
11
|
+
s.name = 'awesome_print'
|
12
|
+
s.version = AwesomePrint.version
|
13
|
+
s.authors = 'Michael Dvorkin'
|
14
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
15
|
+
s.email = 'mike@dvorkin.net'
|
16
|
+
s.homepage = 'https://github.com/awesome-print/awesome_print'
|
17
|
+
s.summary = 'Pretty print Ruby objects with proper indentation and colors'
|
18
|
+
s.description = 'Great Ruby debugging companion: pretty print Ruby objects to visualize their structure. Supports custom object formatting via plugins'
|
19
|
+
s.license = 'MIT'
|
20
|
+
|
21
|
+
s.files = Dir['[A-Z]*[^~]'] + Dir['lib/**/*.rb'] + Dir['spec/**/*'] + ['.gitignore']
|
22
|
+
s.test_files = Dir['spec/**/*']
|
23
|
+
s.executables = []
|
24
|
+
s.require_paths = ['lib']
|
25
|
+
|
26
|
+
s.add_development_dependency 'rspec', '>= 3.0.0'
|
27
|
+
s.add_development_dependency 'appraisal'
|
28
|
+
s.add_development_dependency 'fakefs', '>= 0.2.1'
|
29
|
+
s.add_development_dependency 'sqlite3'
|
30
|
+
s.add_development_dependency 'nokogiri', '>= 1.11.0'
|
31
|
+
# s.add_development_dependency 'simplecov'
|
32
|
+
# s.add_development_dependency 'codeclimate-test-reporter'
|
33
|
+
end
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'lib', 'awesome_print')
|
@@ -19,6 +19,8 @@ module AwesomePrint
|
|
19
19
|
|
20
20
|
if object.is_a?(::ActiveRecord::Base)
|
21
21
|
cast = :active_record_instance
|
22
|
+
elsif object.is_a?(::ActiveModel::Errors)
|
23
|
+
cast = :active_model_error
|
22
24
|
elsif object.is_a?(Class) && object.ancestors.include?(::ActiveRecord::Base)
|
23
25
|
cast = :active_record_class
|
24
26
|
elsif type == :activerecord_relation || object.class.ancestors.include?(::ActiveRecord::Relation)
|
@@ -53,7 +55,7 @@ module AwesomePrint
|
|
53
55
|
hash
|
54
56
|
end
|
55
57
|
end
|
56
|
-
"#{object}
|
58
|
+
"#{object} #{awesome_hash(data)}"
|
57
59
|
end
|
58
60
|
|
59
61
|
# Format ActiveRecord class object.
|
@@ -72,6 +74,29 @@ module AwesomePrint
|
|
72
74
|
|
73
75
|
[name, base, awesome_hash(data)].join(' ')
|
74
76
|
end
|
77
|
+
|
78
|
+
# Format ActiveModel error object.
|
79
|
+
#------------------------------------------------------------------------------
|
80
|
+
def awesome_active_model_error(object)
|
81
|
+
return object.inspect if !defined?(::ActiveSupport::OrderedHash)
|
82
|
+
return awesome_object(object) if @options[:raw]
|
83
|
+
|
84
|
+
object_dump = object.marshal_dump.first
|
85
|
+
data = if object_dump.class.column_names != object_dump.attributes.keys
|
86
|
+
object_dump.attributes
|
87
|
+
else
|
88
|
+
object_dump.class.column_names.inject(::ActiveSupport::OrderedHash.new) do |hash, name|
|
89
|
+
if object_dump.has_attribute?(name) || object_dump.new_record?
|
90
|
+
value = object_dump.respond_to?(name) ? object_dump.send(name) : object_dump.read_attribute(name)
|
91
|
+
hash[name.to_sym] = value
|
92
|
+
end
|
93
|
+
hash
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
data.merge!({details: object.details, messages: object.messages})
|
98
|
+
"#{object} #{awesome_hash(data)}"
|
99
|
+
end
|
75
100
|
end
|
76
101
|
end
|
77
102
|
|