awesome_print 1.6.1 → 1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +4 -0
- data/Appraisals +45 -22
- data/{CHANGELOG → CHANGELOG.md} +83 -18
- data/CONTRIBUTING.md +45 -4
- data/Gemfile.lock +28 -22
- data/LICENSE +16 -19
- data/README.md +97 -92
- data/Rakefile +5 -5
- data/awesome_print.gemspec +33 -0
- data/init.rb +1 -0
- data/lib/ap.rb +2 -2
- data/lib/awesome_print/colorize.rb +24 -0
- data/lib/awesome_print/core_ext/{array.rb → awesome_method_array.rb} +16 -18
- data/lib/awesome_print/core_ext/class.rb +3 -2
- data/lib/awesome_print/core_ext/kernel.rb +1 -1
- data/lib/awesome_print/core_ext/logger.rb +1 -1
- data/lib/awesome_print/core_ext/method.rb +2 -2
- data/lib/awesome_print/core_ext/object.rb +3 -2
- data/lib/awesome_print/core_ext/string.rb +3 -3
- data/lib/awesome_print/custom_defaults.rb +57 -0
- data/lib/awesome_print/ext/action_view.rb +8 -4
- data/lib/awesome_print/ext/active_record.rb +45 -12
- data/lib/awesome_print/ext/active_support.rb +1 -1
- data/lib/awesome_print/ext/mongo_mapper.rb +16 -13
- data/lib/awesome_print/ext/mongoid.rb +8 -6
- data/lib/awesome_print/ext/nobrainer.rb +52 -0
- data/lib/awesome_print/ext/nokogiri.rb +4 -4
- data/lib/awesome_print/ext/ostruct.rb +1 -1
- data/lib/awesome_print/ext/ripple.rb +5 -6
- data/lib/awesome_print/ext/sequel.rb +7 -6
- data/lib/awesome_print/formatter.rb +54 -327
- data/lib/awesome_print/formatters/array_formatter.rb +139 -0
- data/lib/awesome_print/formatters/base_formatter.rb +140 -0
- data/lib/awesome_print/formatters/class_formatter.rb +25 -0
- data/lib/awesome_print/formatters/dir_formatter.rb +22 -0
- data/lib/awesome_print/formatters/file_formatter.rb +22 -0
- data/lib/awesome_print/formatters/hash_formatter.rb +106 -0
- data/lib/awesome_print/formatters/method_formatter.rb +22 -0
- data/lib/awesome_print/formatters/object_formatter.rb +78 -0
- data/lib/awesome_print/formatters/simple_formatter.rb +21 -0
- data/lib/awesome_print/formatters/struct_formatter.rb +71 -0
- data/lib/awesome_print/formatters.rb +15 -0
- data/lib/awesome_print/indentator.rb +18 -0
- data/lib/awesome_print/inspector.rb +92 -94
- data/lib/awesome_print/version.rb +2 -2
- data/lib/awesome_print.rb +19 -18
- data/spec/active_record_helper.rb +24 -28
- data/spec/colors_spec.rb +31 -31
- data/spec/core_ext/logger_spec.rb +43 -0
- data/spec/core_ext/string_spec.rb +20 -0
- data/spec/ext/action_view_spec.rb +21 -0
- data/spec/ext/active_record_spec.rb +260 -0
- data/spec/ext/active_support_spec.rb +30 -0
- data/spec/ext/mongo_mapper_spec.rb +261 -0
- data/spec/ext/mongoid_spec.rb +67 -0
- data/spec/ext/nobrainer_spec.rb +59 -0
- data/spec/ext/nokogiri_spec.rb +46 -0
- data/spec/ext/ostruct_spec.rb +22 -0
- data/spec/ext/ripple_spec.rb +48 -0
- data/spec/formats_spec.rb +251 -184
- data/spec/methods_spec.rb +126 -130
- data/spec/misc_spec.rb +98 -93
- data/spec/objects_spec.rb +162 -27
- data/spec/spec_helper.rb +72 -38
- data/spec/support/active_record_data/3_2_diana.txt +24 -0
- data/spec/support/active_record_data/3_2_diana_legacy.txt +24 -0
- data/spec/support/active_record_data/3_2_multi.txt +50 -0
- data/spec/support/active_record_data/3_2_multi_legacy.txt +50 -0
- data/spec/support/active_record_data/4_0_diana.txt +98 -0
- data/spec/support/active_record_data/4_0_multi.txt +198 -0
- data/spec/support/active_record_data/4_1_diana.txt +97 -0
- data/spec/support/active_record_data/4_1_multi.txt +196 -0
- data/spec/support/active_record_data/4_2_diana.txt +109 -0
- data/spec/support/active_record_data/4_2_diana_legacy.txt +109 -0
- data/spec/support/active_record_data/4_2_multi.txt +220 -0
- data/spec/support/active_record_data/4_2_multi_legacy.txt +220 -0
- data/spec/support/active_record_data/5_0_diana.txt +105 -0
- data/spec/support/active_record_data/5_0_multi.txt +212 -0
- 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/active_record_data.rb +20 -0
- data/spec/support/ext_verifier.rb +42 -0
- data/spec/support/mongoid_versions.rb +26 -0
- data/spec/support/rails_versions.rb +55 -0
- metadata +104 -15
- data/lib/awesome_print/ext/no_brainer.rb +0 -58
@@ -0,0 +1,55 @@
|
|
1
|
+
module RailsVersions
|
2
|
+
def rails_version
|
3
|
+
Gem::Version.new(Rails::VERSION::STRING)
|
4
|
+
end
|
5
|
+
|
6
|
+
def rails_6_1?
|
7
|
+
Gem::Requirement.new('~> 6.1.0').satisfied_by?(rails_version)
|
8
|
+
end
|
9
|
+
alias_method :activerecord_6_1?, :rails_6_1?
|
10
|
+
|
11
|
+
def rails_6_0?
|
12
|
+
Gem::Requirement.new('~> 6.0.0').satisfied_by?(rails_version)
|
13
|
+
end
|
14
|
+
alias_method :activerecord_6_0?, :rails_6_0?
|
15
|
+
|
16
|
+
def rails_5_2?
|
17
|
+
Gem::Requirement.new('~> 5.2.0').satisfied_by?(rails_version)
|
18
|
+
end
|
19
|
+
alias_method :activerecord_5_2?, :rails_5_2?
|
20
|
+
|
21
|
+
def rails_5_1?
|
22
|
+
Gem::Requirement.new('~> 5.1.0').satisfied_by?(rails_version)
|
23
|
+
end
|
24
|
+
alias_method :activerecord_5_1?, :rails_5_1?
|
25
|
+
|
26
|
+
def rails_5_0?
|
27
|
+
Gem::Requirement.new('~> 5.0.0.racecar1').satisfied_by?(rails_version)
|
28
|
+
end
|
29
|
+
alias_method :activerecord_5_0?, :rails_5_0?
|
30
|
+
|
31
|
+
def rails_4_2?
|
32
|
+
Gem::Requirement.new('~> 4.2.0').satisfied_by?(rails_version)
|
33
|
+
end
|
34
|
+
alias_method :activerecord_4_2?, :rails_4_2?
|
35
|
+
|
36
|
+
def rails_4_1?
|
37
|
+
Gem::Requirement.new('~> 4.1.0').satisfied_by?(rails_version)
|
38
|
+
end
|
39
|
+
alias_method :activerecord_4_1?, :rails_4_1?
|
40
|
+
|
41
|
+
def rails_4_0?
|
42
|
+
Gem::Requirement.new('~> 4.0.0').satisfied_by?(rails_version)
|
43
|
+
end
|
44
|
+
alias_method :activerecord_4_0?, :rails_4_0?
|
45
|
+
|
46
|
+
def rails_3_2?
|
47
|
+
Gem::Requirement.new('~> 3.2.0').satisfied_by?(rails_version)
|
48
|
+
end
|
49
|
+
alias_method :activerecord_3_2?, :rails_3_2?
|
50
|
+
end
|
51
|
+
|
52
|
+
RSpec.configure do |config|
|
53
|
+
config.include(RailsVersions)
|
54
|
+
config.extend(RailsVersions)
|
55
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awesome_print
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Dvorkin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -72,15 +72,15 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.
|
75
|
+
version: 1.11.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.
|
83
|
-
description: 'Great Ruby
|
82
|
+
version: 1.11.0
|
83
|
+
description: 'Great Ruby debugging companion: pretty print Ruby objects to visualize
|
84
84
|
their structure. Supports custom object formatting via plugins'
|
85
85
|
email: mike@dvorkin.net
|
86
86
|
executables: []
|
@@ -89,43 +89,96 @@ extra_rdoc_files: []
|
|
89
89
|
files:
|
90
90
|
- ".gitignore"
|
91
91
|
- Appraisals
|
92
|
-
- CHANGELOG
|
92
|
+
- CHANGELOG.md
|
93
93
|
- CONTRIBUTING.md
|
94
94
|
- Gemfile
|
95
95
|
- Gemfile.lock
|
96
96
|
- LICENSE
|
97
97
|
- README.md
|
98
98
|
- Rakefile
|
99
|
+
- awesome_print.gemspec
|
100
|
+
- init.rb
|
99
101
|
- lib/ap.rb
|
100
102
|
- lib/awesome_print.rb
|
101
|
-
- lib/awesome_print/
|
103
|
+
- lib/awesome_print/colorize.rb
|
104
|
+
- lib/awesome_print/core_ext/awesome_method_array.rb
|
102
105
|
- lib/awesome_print/core_ext/class.rb
|
103
106
|
- lib/awesome_print/core_ext/kernel.rb
|
104
107
|
- lib/awesome_print/core_ext/logger.rb
|
105
108
|
- lib/awesome_print/core_ext/method.rb
|
106
109
|
- lib/awesome_print/core_ext/object.rb
|
107
110
|
- lib/awesome_print/core_ext/string.rb
|
111
|
+
- lib/awesome_print/custom_defaults.rb
|
108
112
|
- lib/awesome_print/ext/action_view.rb
|
109
113
|
- lib/awesome_print/ext/active_record.rb
|
110
114
|
- lib/awesome_print/ext/active_support.rb
|
111
115
|
- lib/awesome_print/ext/mongo_mapper.rb
|
112
116
|
- lib/awesome_print/ext/mongoid.rb
|
113
|
-
- lib/awesome_print/ext/
|
117
|
+
- lib/awesome_print/ext/nobrainer.rb
|
114
118
|
- lib/awesome_print/ext/nokogiri.rb
|
115
119
|
- lib/awesome_print/ext/ostruct.rb
|
116
120
|
- lib/awesome_print/ext/ripple.rb
|
117
121
|
- lib/awesome_print/ext/sequel.rb
|
118
122
|
- lib/awesome_print/formatter.rb
|
123
|
+
- lib/awesome_print/formatters.rb
|
124
|
+
- lib/awesome_print/formatters/array_formatter.rb
|
125
|
+
- lib/awesome_print/formatters/base_formatter.rb
|
126
|
+
- lib/awesome_print/formatters/class_formatter.rb
|
127
|
+
- lib/awesome_print/formatters/dir_formatter.rb
|
128
|
+
- lib/awesome_print/formatters/file_formatter.rb
|
129
|
+
- lib/awesome_print/formatters/hash_formatter.rb
|
130
|
+
- lib/awesome_print/formatters/method_formatter.rb
|
131
|
+
- lib/awesome_print/formatters/object_formatter.rb
|
132
|
+
- lib/awesome_print/formatters/simple_formatter.rb
|
133
|
+
- lib/awesome_print/formatters/struct_formatter.rb
|
134
|
+
- lib/awesome_print/indentator.rb
|
119
135
|
- lib/awesome_print/inspector.rb
|
120
136
|
- lib/awesome_print/version.rb
|
121
137
|
- spec/active_record_helper.rb
|
122
138
|
- spec/colors_spec.rb
|
139
|
+
- spec/core_ext/logger_spec.rb
|
140
|
+
- spec/core_ext/string_spec.rb
|
141
|
+
- spec/ext/action_view_spec.rb
|
142
|
+
- spec/ext/active_record_spec.rb
|
143
|
+
- spec/ext/active_support_spec.rb
|
144
|
+
- spec/ext/mongo_mapper_spec.rb
|
145
|
+
- spec/ext/mongoid_spec.rb
|
146
|
+
- spec/ext/nobrainer_spec.rb
|
147
|
+
- spec/ext/nokogiri_spec.rb
|
148
|
+
- spec/ext/ostruct_spec.rb
|
149
|
+
- spec/ext/ripple_spec.rb
|
123
150
|
- spec/formats_spec.rb
|
124
151
|
- spec/methods_spec.rb
|
125
152
|
- spec/misc_spec.rb
|
126
153
|
- spec/objects_spec.rb
|
127
154
|
- spec/spec_helper.rb
|
128
|
-
|
155
|
+
- spec/support/active_record_data.rb
|
156
|
+
- spec/support/active_record_data/3_2_diana.txt
|
157
|
+
- spec/support/active_record_data/3_2_diana_legacy.txt
|
158
|
+
- spec/support/active_record_data/3_2_multi.txt
|
159
|
+
- spec/support/active_record_data/3_2_multi_legacy.txt
|
160
|
+
- spec/support/active_record_data/4_0_diana.txt
|
161
|
+
- spec/support/active_record_data/4_0_multi.txt
|
162
|
+
- spec/support/active_record_data/4_1_diana.txt
|
163
|
+
- spec/support/active_record_data/4_1_multi.txt
|
164
|
+
- spec/support/active_record_data/4_2_diana.txt
|
165
|
+
- spec/support/active_record_data/4_2_diana_legacy.txt
|
166
|
+
- spec/support/active_record_data/4_2_multi.txt
|
167
|
+
- spec/support/active_record_data/4_2_multi_legacy.txt
|
168
|
+
- spec/support/active_record_data/5_0_diana.txt
|
169
|
+
- spec/support/active_record_data/5_0_multi.txt
|
170
|
+
- spec/support/active_record_data/5_1_diana.txt
|
171
|
+
- spec/support/active_record_data/5_1_multi.txt
|
172
|
+
- spec/support/active_record_data/5_2_diana.txt
|
173
|
+
- spec/support/active_record_data/5_2_multi.txt
|
174
|
+
- spec/support/active_record_data/6_0_diana.txt
|
175
|
+
- spec/support/active_record_data/6_0_multi.txt
|
176
|
+
- spec/support/active_record_data/6_1_diana.txt
|
177
|
+
- spec/support/active_record_data/6_1_multi.txt
|
178
|
+
- spec/support/ext_verifier.rb
|
179
|
+
- spec/support/mongoid_versions.rb
|
180
|
+
- spec/support/rails_versions.rb
|
181
|
+
homepage: https://github.com/awesome-print/awesome_print
|
129
182
|
licenses:
|
130
183
|
- MIT
|
131
184
|
metadata: {}
|
@@ -144,16 +197,52 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
197
|
- !ruby/object:Gem::Version
|
145
198
|
version: '0'
|
146
199
|
requirements: []
|
147
|
-
|
148
|
-
rubygems_version: 2.2.2
|
200
|
+
rubygems_version: 3.1.4
|
149
201
|
signing_key:
|
150
202
|
specification_version: 4
|
151
203
|
summary: Pretty print Ruby objects with proper indentation and colors
|
152
204
|
test_files:
|
153
|
-
- spec/
|
205
|
+
- spec/spec_helper.rb
|
206
|
+
- spec/core_ext/logger_spec.rb
|
207
|
+
- spec/core_ext/string_spec.rb
|
154
208
|
- spec/colors_spec.rb
|
155
|
-
- spec/
|
209
|
+
- spec/ext/active_support_spec.rb
|
210
|
+
- spec/ext/mongoid_spec.rb
|
211
|
+
- spec/ext/active_record_spec.rb
|
212
|
+
- spec/ext/ripple_spec.rb
|
213
|
+
- spec/ext/nokogiri_spec.rb
|
214
|
+
- spec/ext/nobrainer_spec.rb
|
215
|
+
- spec/ext/mongo_mapper_spec.rb
|
216
|
+
- spec/ext/ostruct_spec.rb
|
217
|
+
- spec/ext/action_view_spec.rb
|
156
218
|
- spec/methods_spec.rb
|
157
|
-
- spec/
|
219
|
+
- spec/active_record_helper.rb
|
158
220
|
- spec/objects_spec.rb
|
159
|
-
- spec/
|
221
|
+
- spec/support/mongoid_versions.rb
|
222
|
+
- spec/support/active_record_data/4_2_multi.txt
|
223
|
+
- spec/support/active_record_data/6_1_multi.txt
|
224
|
+
- spec/support/active_record_data/3_2_diana.txt
|
225
|
+
- spec/support/active_record_data/4_1_diana.txt
|
226
|
+
- spec/support/active_record_data/5_0_multi.txt
|
227
|
+
- spec/support/active_record_data/5_2_diana.txt
|
228
|
+
- spec/support/active_record_data/4_2_diana_legacy.txt
|
229
|
+
- spec/support/active_record_data/4_2_multi_legacy.txt
|
230
|
+
- spec/support/active_record_data/6_0_multi.txt
|
231
|
+
- spec/support/active_record_data/4_0_diana.txt
|
232
|
+
- spec/support/active_record_data/5_1_multi.txt
|
233
|
+
- spec/support/active_record_data/4_0_multi.txt
|
234
|
+
- spec/support/active_record_data/5_1_diana.txt
|
235
|
+
- spec/support/active_record_data/6_0_diana.txt
|
236
|
+
- spec/support/active_record_data/5_2_multi.txt
|
237
|
+
- spec/support/active_record_data/4_1_multi.txt
|
238
|
+
- spec/support/active_record_data/5_0_diana.txt
|
239
|
+
- spec/support/active_record_data/3_2_diana_legacy.txt
|
240
|
+
- spec/support/active_record_data/3_2_multi_legacy.txt
|
241
|
+
- spec/support/active_record_data/3_2_multi.txt
|
242
|
+
- spec/support/active_record_data/6_1_diana.txt
|
243
|
+
- spec/support/active_record_data/4_2_diana.txt
|
244
|
+
- spec/support/ext_verifier.rb
|
245
|
+
- spec/support/rails_versions.rb
|
246
|
+
- spec/support/active_record_data.rb
|
247
|
+
- spec/formats_spec.rb
|
248
|
+
- spec/misc_spec.rb
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# Copyright (c) 2010-2013 Michael Dvorkin
|
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
|
-
module AwesomePrint
|
7
|
-
module NoBrainer
|
8
|
-
|
9
|
-
def self.included(base)
|
10
|
-
base.send :alias_method, :cast_without_no_brainer, :cast
|
11
|
-
base.send :alias_method, :cast, :cast_with_no_brainer
|
12
|
-
end
|
13
|
-
|
14
|
-
# Add NoBrainer class names to the dispatcher pipeline.
|
15
|
-
#------------------------------------------------------------------------------
|
16
|
-
def cast_with_no_brainer(object, type)
|
17
|
-
cast = cast_without_no_brainer(object, type)
|
18
|
-
if defined?(::NoBrainer::Document)
|
19
|
-
if object.is_a?(Class) && object.ancestors.include?(::NoBrainer::Document)
|
20
|
-
cast = :no_brainer_class
|
21
|
-
elsif object.class.ancestors.include?(::NoBrainer::Document)
|
22
|
-
cast = :no_brainer_document
|
23
|
-
end
|
24
|
-
end
|
25
|
-
cast
|
26
|
-
end
|
27
|
-
|
28
|
-
# Format NoBrainer class object.
|
29
|
-
#------------------------------------------------------------------------------
|
30
|
-
def awesome_no_brainer_class(object)
|
31
|
-
return object.inspect if !defined?(::ActiveSupport::OrderedHash) || !object.respond_to?(:fields)
|
32
|
-
|
33
|
-
# We want id first
|
34
|
-
data = object.fields.sort_by { |key| key[0] == :id ? '_id' : key[0].to_s }.inject(::ActiveSupport::OrderedHash.new) do |hash, c|
|
35
|
-
hash[c[0]] = :object
|
36
|
-
hash
|
37
|
-
end
|
38
|
-
"class #{object} < #{object.superclass} " << awesome_hash(data)
|
39
|
-
end
|
40
|
-
|
41
|
-
# Format NoBrainer Document object.
|
42
|
-
#------------------------------------------------------------------------------
|
43
|
-
def awesome_no_brainer_document(object)
|
44
|
-
return object.inspect if !defined?(::ActiveSupport::OrderedHash)
|
45
|
-
|
46
|
-
data = object.attributes.sort_by { |key| key }.inject(::ActiveSupport::OrderedHash.new) do |hash, c|
|
47
|
-
hash[c[0].to_sym] = c[1]
|
48
|
-
hash
|
49
|
-
end
|
50
|
-
if !object.errors.empty?
|
51
|
-
data = {:errors => object.errors, :attributes => data}
|
52
|
-
end
|
53
|
-
"#{object} #{awesome_hash(data)}"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
AwesomePrint::Formatter.send(:include, AwesomePrint::NoBrainer)
|