awesome_print 1.2.0 → 1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -2
- data/Appraisals +62 -0
- data/CHANGELOG.md +180 -0
- data/CONTRIBUTING.md +82 -0
- data/Gemfile +3 -2
- data/LICENSE +16 -19
- data/README.md +112 -87
- data/Rakefile +17 -4
- data/awesome_print.gemspec +33 -0
- data/init.rb +1 -0
- data/lib/ap.rb +2 -2
- data/lib/awesome_print.rb +22 -16
- 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 +47 -13
- 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 +9 -7
- 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 +27 -0
- data/lib/awesome_print/ext/ripple.rb +6 -7
- data/lib/awesome_print/ext/sequel.rb +7 -6
- data/lib/awesome_print/formatter.rb +54 -327
- data/lib/awesome_print/formatters.rb +15 -0
- 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/indentator.rb +18 -0
- data/lib/awesome_print/inspector.rb +92 -94
- data/lib/awesome_print/version.rb +2 -2
- data/spec/active_record_helper.rb +30 -0
- 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 +272 -205
- data/spec/methods_spec.rb +173 -177
- data/spec/misc_spec.rb +129 -105
- data/spec/objects_spec.rb +162 -27
- data/spec/spec_helper.rb +75 -37
- data/spec/support/active_record_data.rb +20 -0
- 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/ext_verifier.rb +42 -0
- data/spec/support/mongoid_versions.rb +26 -0
- data/spec/support/rails_versions.rb +55 -0
- metadata +163 -32
- data/CHANGELOG +0 -96
- data/lib/awesome_print/ext/no_brainer.rb +0 -58
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bc6d20d854c529b902cfe961bd8271b30f1aa9f82c4db11bfdcaa6ecb6b1f469
|
4
|
+
data.tar.gz: c4f69e0cf2663cb4889b27414bd9f242789fea28790c3252dc5b2788da70bca2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c34cd0b7347ecf6e98afc4ef0647f940a02a5d125c955748917c821e6bbf231830604fcbe0fb524c6bfdaa049d6f945bad658d30433bf878841b30a6d79ad765
|
7
|
+
data.tar.gz: 9cfae5c9646b5194a52c87b1ea38ba3d711cb616a713e66ce0ab83f255293a4b75f4016f349f047aa43d775d14b9f024fc0edccdf40b9f489e46626908162b00
|
data/.gitignore
CHANGED
@@ -13,12 +13,24 @@ tmtags
|
|
13
13
|
## VIM
|
14
14
|
*.swp
|
15
15
|
|
16
|
+
## RUBYMINE
|
17
|
+
.idea
|
18
|
+
|
16
19
|
## PROJECT::GENERAL
|
17
20
|
coverage
|
18
21
|
rdoc
|
19
22
|
pkg
|
23
|
+
.ruby-version
|
24
|
+
gemfiles/*.gemfile.lock
|
20
25
|
Gemfile.lock
|
26
|
+
/tmp
|
27
|
+
/.bundle
|
28
|
+
/gemfiles/.bundle
|
29
|
+
/gemfiles/vendor/bundle
|
21
30
|
|
22
|
-
## PROJECT::
|
31
|
+
## PROJECT::RVM
|
23
32
|
.rvmrc
|
24
|
-
|
33
|
+
|
34
|
+
# PROJECT::RBENV
|
35
|
+
.ruby-gemset
|
36
|
+
.awesome-print/
|
data/Appraisals
ADDED
@@ -0,0 +1,62 @@
|
|
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
|
+
|
9
|
+
appraise 'rails-5.0' do
|
10
|
+
gem 'rails', '>= 5.0.0', '< 5.1'
|
11
|
+
gem 'sqlite3', '~> 1.3.6'
|
12
|
+
end
|
13
|
+
|
14
|
+
appraise 'rails-5.1' do
|
15
|
+
gem 'rails', '>= 5.1.0', '< 5.2'
|
16
|
+
end
|
17
|
+
|
18
|
+
appraise 'rails-5.2' do
|
19
|
+
gem 'rails', '>= 5.2.0', '< 5.3'
|
20
|
+
end
|
21
|
+
|
22
|
+
appraise 'rails-6.0' do
|
23
|
+
gem 'rails', '>= 6.0.0', '< 6.1'
|
24
|
+
end
|
25
|
+
|
26
|
+
appraise 'rails-6.1' do
|
27
|
+
gem 'rails', '>= 6.1.0', '< 6.2'
|
28
|
+
end
|
29
|
+
|
30
|
+
appraise 'mongoid-5.0' do
|
31
|
+
gem 'mongoid', '~> 5.0.0'
|
32
|
+
gem 'bigdecimal', '~> 1.3.5'
|
33
|
+
end
|
34
|
+
|
35
|
+
appraise 'mongoid-6.0' do
|
36
|
+
gem 'mongoid', '~> 6.0.0'
|
37
|
+
end
|
38
|
+
|
39
|
+
appraise 'mongoid-7.0' do
|
40
|
+
gem 'mongoid', '~> 7.0.0'
|
41
|
+
end
|
42
|
+
|
43
|
+
appraise 'mongoid-7.1' do
|
44
|
+
gem 'mongoid', '~> 7.1.0'
|
45
|
+
end
|
46
|
+
|
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
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
## master (unreleased)
|
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]
|
21
|
+
|
22
|
+
## 1.8.0
|
23
|
+
- stat("$HOME/.aprc") once [@kstephens] - [#304]
|
24
|
+
- ActiveRecord: #joins now show the columns #select'ed [@adrianomitre] - [#211]
|
25
|
+
- Handles NoMethodError for IRB implicit `ai` [@jtnegrotto] - [#212]
|
26
|
+
- Replaced Fixnum reference with Integer
|
27
|
+
- Colorize ORM class names [@ixti]
|
28
|
+
|
29
|
+
## 1.7.0
|
30
|
+
- Refactoring by extracting formatters into their own classes [@waldyr] - [#237]
|
31
|
+
- Fixes Travis builds and improves tests [@nviennot], [@waldyr], [@gerrywastaken] - [#225], [#228], [#229], [#230], [#231]
|
32
|
+
- Creates `awesome_object_data` to encapsulate the logic of printing object internals,
|
33
|
+
so Structs and Objects can be printed as one [@waldyr] - [#226]
|
34
|
+
- Fixes development dependencies for environments without rake [@aleandros], [@cyberdelia] - [#222], [#216]
|
35
|
+
- Documents `ai` method usage [@MaxPleaner] - [#217]
|
36
|
+
- Fixes conflict with `mail` and other gems which fake ActiveSupport [@kemmason] - [#200]
|
37
|
+
- Improves spec performance and simplicity [@maurogeorge]
|
38
|
+
- Handle objects that have a custom #to_hash method [@clonezone]
|
39
|
+
|
40
|
+
## 1.6.1
|
41
|
+
- Fixes specs on all rails dependencies (Mauro George)
|
42
|
+
- Updates specs for mongoid, mongo_mapper and ripple (James Cox)
|
43
|
+
- Adds appraisals for simpler version/scenario management (Mauro George)
|
44
|
+
- Add Travis (Mauro George)
|
45
|
+
- Update documentation (Mauro George)
|
46
|
+
|
47
|
+
## 1.6.0
|
48
|
+
semi-major release since it's been a while, and there are several
|
49
|
+
improvements.
|
50
|
+
- Improves support for new mongoid/moped (Velkitor, Francois Bernier et al)
|
51
|
+
- Converts specs to rspec 3+ (Adam Jonas, James Cox)
|
52
|
+
- Fixes incompatibility with IPAddr (James Cox, Michael Dvorkin)
|
53
|
+
- Fixes incompatibility with the money gem (Michael Dvorkin)
|
54
|
+
- Fixes AR::Relation presentation (Sergey Ponomarov)
|
55
|
+
- Lazy-loads ActionView (Akira Matsuda)
|
56
|
+
- Fixes inspection of abstract classes (Jonathan Priddle)
|
57
|
+
- Gets most specs passing, and fixes suite (Eoin Kelly)
|
58
|
+
|
59
|
+
## 1.2.0
|
60
|
+
#### NOTE: This is the *last* release supporting Ruby < v1.9.3 and Rails < v3.
|
61
|
+
- Added Sequel ORM plugin (Jonathan Davies)
|
62
|
+
- Added Ripple plugin (Ruby modeling layer for Riak, Scott Hyndman)
|
63
|
+
- Added NoBrainer plugin (Ruby ORM for RethinkDB, Nicolas Viennot)
|
64
|
+
- Added formatting for Ruby set objects (Richard Hall)
|
65
|
+
- Fixed HTML formatting (Mike McQuaid)
|
66
|
+
- Other minor bugs and enhancements
|
67
|
+
|
68
|
+
## 1.1.0
|
69
|
+
- Objects are no longer recursively formatted by default. Reenable by using :raw => true option.
|
70
|
+
- ap(object) now returns nil when running under IRB or Pry
|
71
|
+
- Added support for Mongoid 3 and Moped (Nikolaj Nikolajsen)
|
72
|
+
- Improved formatting of MongoMapper objects (George .)
|
73
|
+
- ActiveRecord::Relation now renders as array (Dan Lynn)
|
74
|
+
- Formatting BigDecimal no longer looses precision (Evan Senter)
|
75
|
+
- Added AwesomePrint.irb! and AwesomePrint.pry! convenience methods
|
76
|
+
- Fixed conflict with the colorize gem
|
77
|
+
- Misc tweaks and bug fixes
|
78
|
+
|
79
|
+
## 1.0.2
|
80
|
+
- Added formatting of Mongoid documents (Adam Doppelt)
|
81
|
+
- ActiveRecord objects display attributes only. Use :raw => true to display the entire object
|
82
|
+
- ActiveSupport::Date objects get formatted as regular Date
|
83
|
+
- Rails.logger.ap colorizes output based on ActiveSupport::LogSubscriber.colorize_logging (default is true)
|
84
|
+
- Improved formatting of methods array
|
85
|
+
|
86
|
+
## 1.0.1
|
87
|
+
- Updated repo tags for Rubygems.org
|
88
|
+
|
89
|
+
## 1.0.0 Thanksgiving edition
|
90
|
+
- Added ability to format *arbitrary* Ruby object
|
91
|
+
- Added :limit option to limit large output for arrays and hashes (Andrew Horsman)
|
92
|
+
- Improved HTML formatting when :html => true (Daniel Johnson)
|
93
|
+
- Added Mongoid extension (Adam Doppelt)
|
94
|
+
- Added Nokogiri extension (Adam Doppelt)
|
95
|
+
- Removed Jeweler gem dependency
|
96
|
+
|
97
|
+
## 0.4.0
|
98
|
+
- 'ap object' now returns the object (Stephan Hagemann)
|
99
|
+
- Added :html => true option to enable HTML colors rather that ANSI (ex. Sinatra templates)
|
100
|
+
- Added AwesomePrint.force_colors! to allow color output on demand (Andrew O'Brien)
|
101
|
+
- Added MongoMapper formatter mixin (Elpizo Choi)
|
102
|
+
- Fixed formatting of methods array when object#method is overridden
|
103
|
+
- Fixed potential stack errors by checking whether AwesomePrint is already loaded
|
104
|
+
- Improved Ruby 1.8.6 and 1.8.7 compatibility
|
105
|
+
- Improved Windows compatibility (Viktar Basharymau)
|
106
|
+
|
107
|
+
## 0.3.2
|
108
|
+
- Make sure Rails mixins get loaded in Rails console when required from .irbrc
|
109
|
+
- Fixed an issue with classes that define their own #send method (ex: Socket)
|
110
|
+
- Fixed compatibility issue with Liquid gem that defines Module#liquid_methods
|
111
|
+
- Fixed hash spec for Ruby < 1.9 where order of hash keys is not guaranteed
|
112
|
+
- Added :sorted_hash_keys option to sort hash keys (Ed Ruder)
|
113
|
+
|
114
|
+
## 0.3.1 RubyConf X edition
|
115
|
+
- Fixed Ruby 1.8.6 compatibility issues (thanks, Tim!)
|
116
|
+
- Fixed stack overflow issue with Rails 2.3.x console
|
117
|
+
|
118
|
+
## 0.3.0
|
119
|
+
- Display object.methods and family in human readable format
|
120
|
+
- Objects inherited from Array, Hash, File, Dir, and Struct are shown as their base class
|
121
|
+
- Added option to suppress array index in output (Sean Gallagher)
|
122
|
+
- Updated README on how to set up ~/.irbrc for MacRuby (Eloy Duran)
|
123
|
+
- Specs pass 100% with Ruby 1.8.7/RSpec 1.3 and Ruby 1.9.2/RSpec 2.0
|
124
|
+
|
125
|
+
## 0.2.1
|
126
|
+
- ap can now be used within Rails templates (ex. <%= ap object %>)
|
127
|
+
- Added support for printing Struct
|
128
|
+
|
129
|
+
## 0.2.0
|
130
|
+
- Added support for logger.ap (including Rails logger)
|
131
|
+
- Added support for HashWithIndifferentAccess from ActiveSupport
|
132
|
+
- ap now works with scripts that use ActiveRecord/ActiveSupport outside Rails
|
133
|
+
- ap now correctly shows file and directory names with fancy characters (shell escape)
|
134
|
+
|
135
|
+
## 0.1.4
|
136
|
+
- Format BigDecimal and Rational objects as Float scalars
|
137
|
+
- Explicit options parameter can override custom defaults
|
138
|
+
- Custom defaults are not interfering when running specs
|
139
|
+
- Custom defaults now work correctly with Ruby 1.9.x
|
140
|
+
|
141
|
+
## 0.1.3
|
142
|
+
- Added support for setting custom defaults in ~/.aprc
|
143
|
+
|
144
|
+
## 0.1.2
|
145
|
+
- Correctly handle empty arrays and hashes
|
146
|
+
- Use alias_method instead of alias (fixes non-tty method aliasing)
|
147
|
+
- Added awesome_inspect method
|
148
|
+
|
149
|
+
## 0.1.1
|
150
|
+
- Added support for tableless ActiveRecord models
|
151
|
+
- Left align hash keys if @options[:indent] is negative
|
152
|
+
|
153
|
+
## 0.1.0
|
154
|
+
- Initial Release.
|
155
|
+
|
156
|
+
[#200]: https://github.com/awesome-print/awesome_print/pull/200
|
157
|
+
[#212]: https://github.com/awesome-print/awesome_print/pull/212
|
158
|
+
[#216]: https://github.com/awesome-print/awesome_print/pull/216
|
159
|
+
[#217]: https://github.com/awesome-print/awesome_print/pull/217
|
160
|
+
[#222]: https://github.com/awesome-print/awesome_print/pull/222
|
161
|
+
[#225]: https://github.com/awesome-print/awesome_print/pull/225
|
162
|
+
[#226]: https://github.com/awesome-print/awesome_print/pull/226
|
163
|
+
[#228]: https://github.com/awesome-print/awesome_print/pull/228
|
164
|
+
[#229]: https://github.com/awesome-print/awesome_print/pull/229
|
165
|
+
[#230]: https://github.com/awesome-print/awesome_print/pull/230
|
166
|
+
[#231]: https://github.com/awesome-print/awesome_print/pull/231
|
167
|
+
[#232]: https://github.com/awesome-print/awesome_print/pull/232
|
168
|
+
[#237]: https://github.com/awesome-print/awesome_print/pull/237
|
169
|
+
|
170
|
+
[@aleandros]: https://github.com/aleandros
|
171
|
+
[@clonezone]: https://github.com/clonezone
|
172
|
+
[@cyberdelia]: https://github.com/cyberdelia
|
173
|
+
[@gerrywastaken]: https://github.com/gerrywastaken
|
174
|
+
[@ixti]: https://github.com/ixti
|
175
|
+
[@jtnegrotto]: https://github.com/jtnegrotto
|
176
|
+
[@kemmason]: https://github.com/kemmason
|
177
|
+
[@maurogeorge]: https://github.com/maurogeorge
|
178
|
+
[@MaxPleaner]: https://github.com/MaxPleaner
|
179
|
+
[@nviennot]: https://github.com/nviennot
|
180
|
+
[@waldyr]: https://github.com/waldyr
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
We love pull requests. Here's a quick guide:
|
4
|
+
|
5
|
+
1. Fork the repo.
|
6
|
+
|
7
|
+
1. Create your feature branch (`git checkout -b my-new-feature`)
|
8
|
+
|
9
|
+
1. Update [CHANGELOG.md](https://github.com/awesome-print/awesome_print/blob/master/CHANGELOG.md) with a brief description of your changes under the `unreleased` heading.
|
10
|
+
|
11
|
+
1. Add/Update tests were appropriate
|
12
|
+
|
13
|
+
1. Commit your changes (`git commit -am 'Added some feature'`)
|
14
|
+
|
15
|
+
1. Push to the branch (`git push origin my-new-feature`)
|
16
|
+
|
17
|
+
1. Create new Pull Request
|
18
|
+
|
19
|
+
At this point you're waiting on us. We are not super fast at responding, but we will do our best to get to your PR as soon as time permits. We may suggest some changes, improvements or alternatives.
|
20
|
+
|
21
|
+
Some things that will increase the chance that your pull request is accepted is to follow the practices described on [Ruby style guide](https://github.com/bbatsov/ruby-style-guide), [Rails style guide](https://github.com/bbatsov/rails-style-guide) and [Better Specs](http://betterspecs.org/).
|
22
|
+
|
23
|
+
## Specs
|
24
|
+
|
25
|
+
To run all the specs in all gemfiles just run:
|
26
|
+
|
27
|
+
```
|
28
|
+
$ rake
|
29
|
+
```
|
30
|
+
|
31
|
+
To run specs of a single gemfile run:
|
32
|
+
|
33
|
+
```
|
34
|
+
$ appraisal rails-3.2 rake
|
35
|
+
```
|
36
|
+
|
37
|
+
If you want to run a specific spec in a gemfile run:
|
38
|
+
|
39
|
+
```
|
40
|
+
$ appraisal rails-3.2 rspec spec/colors_spec.rb
|
41
|
+
```
|
42
|
+
|
43
|
+
## Contributor Rolecall
|
44
|
+
|
45
|
+
Special thanks goes to awesome team of contributors, namely:
|
46
|
+
|
47
|
+
* 6fusion.com -- https://github.com/6fusion
|
48
|
+
* Adam Doppelt -- https://github.com/gurgeous
|
49
|
+
* Andrew O'Brien -- https://github.com/AndrewO
|
50
|
+
* Andrew Horsman -- https://github.com/basicxman
|
51
|
+
* Barry Allard -- https://github.com/steakknife
|
52
|
+
* Benoit Daloze -- http://github.com/eregon
|
53
|
+
* Brandon Zylstra -- https://github.com/brandondrew
|
54
|
+
* Bryan Hanks, PMP -- https://github.com/bryanh
|
55
|
+
* Dan Lynn -- https://github.com/danlynn
|
56
|
+
* Daniel Johnson -- https://github.com/adhd360
|
57
|
+
* Daniel Bretoi -- http://github.com/danielb2
|
58
|
+
* Eloy Duran -- http://github.com/alloy
|
59
|
+
* Elpizo Choi -- https://github.com/fuJiin
|
60
|
+
* Evan Senter -- https://github.com/evansenter
|
61
|
+
* George . -- https://github.com/gardelea
|
62
|
+
* Greg Weber -- https://github.com/gregwebs
|
63
|
+
* Jan Vansteenkiste -- https://github.com/vStone
|
64
|
+
* Jeff Felchner -- https://github.com/jfelchner
|
65
|
+
* Jonathan Davies -- send your Github URL ;-)
|
66
|
+
* Kevin Olbrich -- https://github.com/olbrich
|
67
|
+
* Matthew Schulkind -- https://github.com/mschulkind
|
68
|
+
* Mike McQuaid -- https://github.com/mikemcquaid
|
69
|
+
* Nami-Doc -- https://github.com/Nami-Doc
|
70
|
+
* Nicolas Viennot -- https://github.com/nviennot
|
71
|
+
* Nikolaj Nikolajsen -- https://github.com/nikolajsen
|
72
|
+
* Richard Hall -- https://github.com/richardardrichard
|
73
|
+
* Ryan Schlesinger -- https://github.com/ryansch
|
74
|
+
* Scott Hyndman -- https://github.com/shyndman
|
75
|
+
* Sean Gallagher -- http://github.com/torandu
|
76
|
+
* Stephan Hagemann -- https://github.com/shageman
|
77
|
+
* Tim Harper -- http://github.com/timcharper
|
78
|
+
* Tobias Crawley -- http://github.com/tobias
|
79
|
+
* Thibaut Barrère -- https://github.com/thbar
|
80
|
+
* Trevor Wennblom -- https://github.com/trevor
|
81
|
+
* vfrride -- https://github.com/vfrride
|
82
|
+
* Viktar Basharymau -- https://github.com/DNNX
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
@@ -1,22 +1,19 @@
|
|
1
|
-
Copyright (c) 2010-
|
2
|
-
http://www.dvorkin.net
|
3
|
-
%w(mike dvorkin.net) * "@" || %w(mike fatfreecrm.com) * "@"
|
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
@@ -1,18 +1,26 @@
|
|
1
1
|
## Awesome Print ##
|
2
|
+
|
3
|
+
[![RubyGems][gem_version_badge]][ruby_gems]
|
4
|
+
[![Travis CI][travis_ci_badge]][travis_ci]
|
5
|
+
[![Code Climate][code_climate_badge]][code_climate]
|
6
|
+
[![Code Climate Coverage][code_climate_coverage_badge]][code_climate]
|
7
|
+
[![RubyGems][gem_downloads_badge]][ruby_gems]
|
8
|
+
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/awesome-print/awesome_print?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
9
|
+
|
10
|
+
|
2
11
|
Awesome Print is a Ruby library that pretty prints Ruby objects in full color
|
3
12
|
exposing their internal structure with proper indentation. Rails ActiveRecord
|
4
13
|
objects and usage within Rails templates are supported via included mixins.
|
5
14
|
|
6
|
-
__NOTE__: awesome_print v1.
|
7
|
-
|
8
|
-
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.
|
9
17
|
|
10
18
|
### Installation ###
|
11
19
|
# Installing as Ruby gem
|
12
20
|
$ gem install awesome_print
|
13
21
|
|
14
22
|
# Cloning the repository
|
15
|
-
$ git clone git://github.com/
|
23
|
+
$ git clone git://github.com/awesome-print/awesome_print.git
|
16
24
|
|
17
25
|
### Usage ###
|
18
26
|
|
@@ -24,34 +32,38 @@ ap object, options = {}
|
|
24
32
|
Default options:
|
25
33
|
|
26
34
|
```ruby
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
35
|
+
indent: 4, # Number of spaces for indenting.
|
36
|
+
index: true, # Display array indices.
|
37
|
+
html: false, # Use ANSI color codes rather than HTML.
|
38
|
+
multiline: true, # Display in multiple lines.
|
39
|
+
plain: false, # Use colors.
|
40
|
+
raw: false, # Do not recursively format instance variables.
|
41
|
+
sort_keys: false, # Do not sort hash keys.
|
42
|
+
sort_vars: true, # Sort instance variables.
|
43
|
+
limit: false, # Limit arrays & hashes. Accepts bool or int.
|
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.
|
47
|
+
color: {
|
48
|
+
args: :pale,
|
49
|
+
array: :white,
|
50
|
+
bigdecimal: :blue,
|
51
|
+
class: :yellow,
|
52
|
+
date: :greenish,
|
53
|
+
falseclass: :red,
|
54
|
+
integer: :blue,
|
55
|
+
float: :blue,
|
56
|
+
hash: :pale,
|
57
|
+
keyword: :cyan,
|
58
|
+
method: :purpleish,
|
59
|
+
nilclass: :red,
|
60
|
+
rational: :blue,
|
61
|
+
string: :yellowish,
|
62
|
+
struct: :pale,
|
63
|
+
symbol: :cyanish,
|
64
|
+
time: :greenish,
|
65
|
+
trueclass: :green,
|
66
|
+
variable: :cyanish
|
55
67
|
}
|
56
68
|
```
|
57
69
|
|
@@ -62,8 +74,17 @@ Supported color names:
|
|
62
74
|
:black, :redish, :greenish, :yellowish, :blueish, :purpleish, :cyanish, :pale
|
63
75
|
```
|
64
76
|
|
77
|
+
Use `Object#ai` to return an ASCII encoded string:
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
irb> "awesome print".ai
|
81
|
+
=> "\e[0;33m\"awesome print\"\e[0m"
|
82
|
+
```
|
83
|
+
|
65
84
|
### Examples ###
|
66
85
|
|
86
|
+
#### Array
|
87
|
+
|
67
88
|
```ruby
|
68
89
|
$ cat > 1.rb
|
69
90
|
require "awesome_print"
|
@@ -84,7 +105,10 @@ $ ruby 1.rb
|
|
84
105
|
:distance => 4.2e+43
|
85
106
|
}
|
86
107
|
]
|
108
|
+
```
|
109
|
+
#### Hash
|
87
110
|
|
111
|
+
```ruby
|
88
112
|
$ cat > 2.rb
|
89
113
|
require "awesome_print"
|
90
114
|
data = { :now => Time.now, :class => Time.now.class, :distance => 42e42 }
|
@@ -96,7 +120,11 @@ $ ruby 2.rb
|
|
96
120
|
:now => Fri Apr 02 19:55:53 -0700 2010,
|
97
121
|
:distance => 4.2e+43
|
98
122
|
}
|
123
|
+
```
|
124
|
+
|
125
|
+
#### Nested array
|
99
126
|
|
127
|
+
```ruby
|
100
128
|
$ cat > 3.rb
|
101
129
|
require "awesome_print"
|
102
130
|
data = [ false, 42, %w(forty two) ]
|
@@ -106,6 +134,11 @@ ap data, :multiline => false
|
|
106
134
|
$ ruby 3.rb
|
107
135
|
[ false, 42, [ "forty", "two" ], [...] ]
|
108
136
|
|
137
|
+
```
|
138
|
+
|
139
|
+
#### Class methods
|
140
|
+
|
141
|
+
```ruby
|
109
142
|
$ cat > 4.rb
|
110
143
|
require "awesome_print"
|
111
144
|
class Hello
|
@@ -119,6 +152,11 @@ $ ruby 4.rb
|
|
119
152
|
[0] world(x, y, *z, &blk) Hello
|
120
153
|
]
|
121
154
|
|
155
|
+
```
|
156
|
+
|
157
|
+
#### Object methods
|
158
|
+
|
159
|
+
```ruby
|
122
160
|
$ cat > 5.rb
|
123
161
|
require "awesome_print"
|
124
162
|
ap (''.methods - Object.methods).grep(/!/)
|
@@ -147,6 +185,11 @@ $ ruby 5.rb
|
|
147
185
|
[19] upcase!() String
|
148
186
|
]
|
149
187
|
|
188
|
+
```
|
189
|
+
|
190
|
+
#### Compare output to value
|
191
|
+
|
192
|
+
```ruby
|
150
193
|
$ cat > 6.rb
|
151
194
|
require "awesome_print"
|
152
195
|
ap 42 == ap(42)
|
@@ -154,7 +197,13 @@ ap 42 == ap(42)
|
|
154
197
|
$ ruby 6.rb
|
155
198
|
42
|
156
199
|
true
|
157
|
-
|
200
|
+
|
201
|
+
```
|
202
|
+
|
203
|
+
#### Array with default output limit
|
204
|
+
|
205
|
+
```ruby
|
206
|
+
$ cat > 7.rb
|
158
207
|
require "awesome_print"
|
159
208
|
some_array = (1..1000).to_a
|
160
209
|
ap some_array, :limit => true
|
@@ -169,8 +218,12 @@ $ ruby 7.rb
|
|
169
218
|
[998] 999,
|
170
219
|
[999] 1000
|
171
220
|
]
|
221
|
+
```
|
222
|
+
|
223
|
+
#### Array with specific output limit
|
172
224
|
|
173
|
-
|
225
|
+
```ruby
|
226
|
+
$ cat > 8.rb
|
174
227
|
require "awesome_print"
|
175
228
|
some_array = (1..1000).to_a
|
176
229
|
ap some_array, :limit => 5
|
@@ -185,7 +238,7 @@ $ ruby 8.rb
|
|
185
238
|
]
|
186
239
|
```
|
187
240
|
|
188
|
-
|
241
|
+
#### Rails console
|
189
242
|
```ruby
|
190
243
|
$ rails console
|
191
244
|
rails> require "awesome_print"
|
@@ -288,6 +341,14 @@ formatting:
|
|
288
341
|
|
289
342
|
<%= ap @accounts.first, :html => true %>
|
290
343
|
|
344
|
+
### String Convenience Methods ###
|
345
|
+
Use methods such as `.red` to set string color:
|
346
|
+
|
347
|
+
```ruby
|
348
|
+
irb> puts "red text".red
|
349
|
+
red text # (it's red)
|
350
|
+
```
|
351
|
+
|
291
352
|
### Setting Custom Defaults ###
|
292
353
|
You can set your own default options by creating ``.aprc`` file in your home
|
293
354
|
directory. Within that file assign your defaults to ``AwesomePrint.defaults``.
|
@@ -304,63 +365,27 @@ AwesomePrint.defaults = {
|
|
304
365
|
}
|
305
366
|
```
|
306
367
|
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
### Note on Patches/Pull Requests ###
|
314
|
-
* Fork the project on Github.
|
315
|
-
* Make your feature addition or bug fix.
|
316
|
-
* Add specs for it, making sure $ rake spec is all green.
|
317
|
-
* Commit, do not mess with rakefile, version, or history.
|
318
|
-
* Send commit URL (*do not* send pull requests).
|
319
|
-
|
320
|
-
### Contributors ###
|
321
|
-
Special thanks goes to awesome team of contributors, namely:
|
322
|
-
|
323
|
-
* 6fusion.com -- https://github.com/6fusion
|
324
|
-
* Adam Doppelt -- https://github.com/gurgeous
|
325
|
-
* Andrew O'Brien -- https://github.com/AndrewO
|
326
|
-
* Andrew Horsman -- https://github.com/basicxman
|
327
|
-
* Barry Allard -- https://github.com/steakknife
|
328
|
-
* Benoit Daloze -- http://github.com/eregon
|
329
|
-
* Brandon Zylstra -- https://github.com/brandondrew
|
330
|
-
* Dan Lynn -- https://github.com/danlynn
|
331
|
-
* Daniel Johnson -- https://github.com/adhd360
|
332
|
-
* Daniel Bretoi -- http://github.com/danielb2
|
333
|
-
* Eloy Duran -- http://github.com/alloy
|
334
|
-
* Elpizo Choi -- https://github.com/fuJiin
|
335
|
-
* Evan Senter -- https://github.com/evansenter
|
336
|
-
* George . -- https://github.com/gardelea
|
337
|
-
* Greg Weber -- https://github.com/gregwebs
|
338
|
-
* Jan Vansteenkiste -- https://github.com/vStone
|
339
|
-
* Jeff Felchner -- https://github.com/jfelchner
|
340
|
-
* Jonathan Davies -- send your Github URL ;-)
|
341
|
-
* Kevin Olbrich -- https://github.com/olbrich
|
342
|
-
* Matthew Schulkind -- https://github.com/mschulkind
|
343
|
-
* Mike McQuaid -- https://github.com/mikemcquaid
|
344
|
-
* Nami-Doc -- https://github.com/Nami-Doc
|
345
|
-
* Nicolas Viennot -- https://github.com/nviennot
|
346
|
-
* Nikolaj Nikolajsen -- https://github.com/nikolajsen
|
347
|
-
* Richard Hall -- https://github.com/richardardrichard
|
348
|
-
* Ryan Schlesinger -- https://github.com/ryansch
|
349
|
-
* Scott Hyndman -- https://github.com/shyndman
|
350
|
-
* Sean Gallagher -- http://github.com/torandu
|
351
|
-
* Stephan Hagemann -- https://github.com/shageman
|
352
|
-
* Tim Harper -- http://github.com/timcharper
|
353
|
-
* Tobias Crawley -- http://github.com/tobias
|
354
|
-
* Thibaut Barrère -- https://github.com/thbar
|
355
|
-
* Trevor Wennblom -- https://github.com/trevor
|
356
|
-
* vfrride -- https://github.com/vfrride
|
357
|
-
* Viktar Basharymau -- https://github.com/DNNX
|
368
|
+
## Versioning
|
369
|
+
|
370
|
+
AwesomePrint follows the [Semantic Versioning](http://semver.org/) standard.
|
371
|
+
|
372
|
+
### Contributing ###
|
373
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for information.
|
358
374
|
|
359
375
|
### License ###
|
360
|
-
Copyright (c) 2010-
|
376
|
+
Copyright (c) 2010-2016 Michael Dvorkin and contributors
|
361
377
|
|
362
378
|
http://www.dvorkin.net
|
363
379
|
|
364
380
|
%w(mike dvorkin.net) * "@" || "twitter.com/mid"
|
365
381
|
|
366
382
|
Released under the MIT license. See LICENSE file for details.
|
383
|
+
|
384
|
+
[gem_version_badge]: https://img.shields.io/gem/v/awesome_print.svg?style=flat
|
385
|
+
[gem_downloads_badge]: http://img.shields.io/gem/dt/awesome_print.svg?style=flat
|
386
|
+
[ruby_gems]: http://rubygems.org/gems/awesome_print
|
387
|
+
[travis_ci]: http://travis-ci.org/awesome-print/awesome_print
|
388
|
+
[travis_ci_badge]: https://img.shields.io/travis/awesome-print/awesome_print/master.svg?style=flat
|
389
|
+
[code_climate]: https://codeclimate.com/github/awesome-print/awesome_print
|
390
|
+
[code_climate_badge]: http://img.shields.io/codeclimate/github/awesome-print/awesome_print.svg?style=flat
|
391
|
+
[code_climate_coverage_badge]: https://codeclimate.com/github/awesome-print/awesome_print/badges/coverage.svg
|