awesome_print 1.6.1 → 1.7.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/Appraisals +16 -3
- data/{CHANGELOG → CHANGELOG.md} +55 -18
- data/CONTRIBUTING.md +43 -3
- data/README.md +13 -52
- data/lib/awesome_print.rb +2 -2
- data/lib/awesome_print/colorize.rb +24 -0
- data/lib/awesome_print/ext/nobrainer.rb +49 -0
- data/lib/awesome_print/formatter.rb +53 -326
- data/lib/awesome_print/formatters/array_formatter.rb +73 -0
- data/lib/awesome_print/formatters/base_formatter.rb +138 -0
- data/lib/awesome_print/formatters/class_formatter.rb +24 -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 +54 -0
- data/lib/awesome_print/formatters/method_formatter.rb +22 -0
- data/lib/awesome_print/formatters/object_formatter.rb +80 -0
- data/lib/awesome_print/formatters/simple_formatter.rb +21 -0
- data/lib/awesome_print/indentator.rb +18 -0
- data/lib/awesome_print/inspector.rb +12 -1
- data/lib/awesome_print/version.rb +1 -1
- data/spec/active_record_helper.rb +19 -29
- data/spec/colors_spec.rb +2 -2
- data/spec/formats_spec.rb +73 -34
- data/spec/methods_spec.rb +6 -6
- data/spec/misc_spec.rb +4 -2
- data/spec/objects_spec.rb +52 -8
- data/spec/spec_helper.rb +49 -34
- metadata +31 -6
- data/lib/awesome_print/ext/no_brainer.rb +0 -58
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.7.0
|
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: 2016-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 1.6.5
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: codeclimate-test-reporter
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: 'Great Ruby dubugging companion: pretty print Ruby objects to visualize
|
84
98
|
their structure. Supports custom object formatting via plugins'
|
85
99
|
email: mike@dvorkin.net
|
@@ -89,7 +103,7 @@ extra_rdoc_files: []
|
|
89
103
|
files:
|
90
104
|
- ".gitignore"
|
91
105
|
- Appraisals
|
92
|
-
- CHANGELOG
|
106
|
+
- CHANGELOG.md
|
93
107
|
- CONTRIBUTING.md
|
94
108
|
- Gemfile
|
95
109
|
- Gemfile.lock
|
@@ -98,6 +112,7 @@ files:
|
|
98
112
|
- Rakefile
|
99
113
|
- lib/ap.rb
|
100
114
|
- lib/awesome_print.rb
|
115
|
+
- lib/awesome_print/colorize.rb
|
101
116
|
- lib/awesome_print/core_ext/array.rb
|
102
117
|
- lib/awesome_print/core_ext/class.rb
|
103
118
|
- lib/awesome_print/core_ext/kernel.rb
|
@@ -110,12 +125,22 @@ files:
|
|
110
125
|
- lib/awesome_print/ext/active_support.rb
|
111
126
|
- lib/awesome_print/ext/mongo_mapper.rb
|
112
127
|
- lib/awesome_print/ext/mongoid.rb
|
113
|
-
- lib/awesome_print/ext/
|
128
|
+
- lib/awesome_print/ext/nobrainer.rb
|
114
129
|
- lib/awesome_print/ext/nokogiri.rb
|
115
130
|
- lib/awesome_print/ext/ostruct.rb
|
116
131
|
- lib/awesome_print/ext/ripple.rb
|
117
132
|
- lib/awesome_print/ext/sequel.rb
|
118
133
|
- lib/awesome_print/formatter.rb
|
134
|
+
- lib/awesome_print/formatters/array_formatter.rb
|
135
|
+
- lib/awesome_print/formatters/base_formatter.rb
|
136
|
+
- lib/awesome_print/formatters/class_formatter.rb
|
137
|
+
- lib/awesome_print/formatters/dir_formatter.rb
|
138
|
+
- lib/awesome_print/formatters/file_formatter.rb
|
139
|
+
- lib/awesome_print/formatters/hash_formatter.rb
|
140
|
+
- lib/awesome_print/formatters/method_formatter.rb
|
141
|
+
- lib/awesome_print/formatters/object_formatter.rb
|
142
|
+
- lib/awesome_print/formatters/simple_formatter.rb
|
143
|
+
- lib/awesome_print/indentator.rb
|
119
144
|
- lib/awesome_print/inspector.rb
|
120
145
|
- lib/awesome_print/version.rb
|
121
146
|
- spec/active_record_helper.rb
|
@@ -125,7 +150,7 @@ files:
|
|
125
150
|
- spec/misc_spec.rb
|
126
151
|
- spec/objects_spec.rb
|
127
152
|
- spec/spec_helper.rb
|
128
|
-
homepage:
|
153
|
+
homepage: https://github.com/awesome-print/awesome_print
|
129
154
|
licenses:
|
130
155
|
- MIT
|
131
156
|
metadata: {}
|
@@ -145,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
170
|
version: '0'
|
146
171
|
requirements: []
|
147
172
|
rubyforge_project: awesome_print
|
148
|
-
rubygems_version: 2.
|
173
|
+
rubygems_version: 2.5.1
|
149
174
|
signing_key:
|
150
175
|
specification_version: 4
|
151
176
|
summary: Pretty print Ruby objects with proper indentation and colors
|
@@ -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)
|