awesome_print 1.7.0 → 1.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +4 -0
  3. data/Appraisals +44 -34
  4. data/CHANGELOG.md +28 -0
  5. data/CONTRIBUTING.md +2 -1
  6. data/Gemfile.lock +25 -33
  7. data/LICENSE +16 -19
  8. data/README.md +88 -44
  9. data/Rakefile +5 -5
  10. data/awesome_print.gemspec +33 -0
  11. data/init.rb +1 -0
  12. data/lib/ap.rb +2 -2
  13. data/lib/awesome_print/colorize.rb +1 -1
  14. data/lib/awesome_print/core_ext/{array.rb → awesome_method_array.rb} +16 -18
  15. data/lib/awesome_print/core_ext/class.rb +3 -2
  16. data/lib/awesome_print/core_ext/kernel.rb +1 -1
  17. data/lib/awesome_print/core_ext/logger.rb +1 -1
  18. data/lib/awesome_print/core_ext/method.rb +2 -2
  19. data/lib/awesome_print/core_ext/object.rb +3 -2
  20. data/lib/awesome_print/core_ext/string.rb +3 -3
  21. data/lib/awesome_print/custom_defaults.rb +57 -0
  22. data/lib/awesome_print/ext/action_view.rb +8 -4
  23. data/lib/awesome_print/ext/active_record.rb +45 -12
  24. data/lib/awesome_print/ext/active_support.rb +1 -1
  25. data/lib/awesome_print/ext/mongo_mapper.rb +16 -13
  26. data/lib/awesome_print/ext/mongoid.rb +8 -6
  27. data/lib/awesome_print/ext/nobrainer.rb +8 -5
  28. data/lib/awesome_print/ext/nokogiri.rb +4 -4
  29. data/lib/awesome_print/ext/ostruct.rb +1 -1
  30. data/lib/awesome_print/ext/ripple.rb +5 -6
  31. data/lib/awesome_print/ext/sequel.rb +7 -6
  32. data/lib/awesome_print/formatter.rb +28 -28
  33. data/lib/awesome_print/formatters/array_formatter.rb +108 -42
  34. data/lib/awesome_print/formatters/base_formatter.rb +16 -14
  35. data/lib/awesome_print/formatters/class_formatter.rb +2 -1
  36. data/lib/awesome_print/formatters/dir_formatter.rb +1 -1
  37. data/lib/awesome_print/formatters/file_formatter.rb +1 -1
  38. data/lib/awesome_print/formatters/hash_formatter.rb +74 -22
  39. data/lib/awesome_print/formatters/object_formatter.rb +13 -15
  40. data/lib/awesome_print/formatters/struct_formatter.rb +71 -0
  41. data/lib/awesome_print/formatters.rb +15 -0
  42. data/lib/awesome_print/inspector.rb +83 -96
  43. data/lib/awesome_print/version.rb +2 -2
  44. data/lib/awesome_print.rb +18 -17
  45. data/spec/active_record_helper.rb +8 -2
  46. data/spec/colors_spec.rb +30 -30
  47. data/spec/core_ext/logger_spec.rb +43 -0
  48. data/spec/core_ext/string_spec.rb +20 -0
  49. data/spec/ext/action_view_spec.rb +21 -0
  50. data/spec/ext/active_record_spec.rb +260 -0
  51. data/spec/ext/active_support_spec.rb +30 -0
  52. data/spec/ext/mongo_mapper_spec.rb +261 -0
  53. data/spec/ext/mongoid_spec.rb +67 -0
  54. data/spec/ext/nobrainer_spec.rb +59 -0
  55. data/spec/ext/nokogiri_spec.rb +46 -0
  56. data/spec/ext/ostruct_spec.rb +22 -0
  57. data/spec/ext/ripple_spec.rb +48 -0
  58. data/spec/formats_spec.rb +193 -165
  59. data/spec/methods_spec.rb +125 -129
  60. data/spec/misc_spec.rb +95 -92
  61. data/spec/objects_spec.rb +119 -28
  62. data/spec/spec_helper.rb +29 -10
  63. data/spec/support/active_record_data/3_2_diana.txt +24 -0
  64. data/spec/support/active_record_data/3_2_diana_legacy.txt +24 -0
  65. data/spec/support/active_record_data/3_2_multi.txt +50 -0
  66. data/spec/support/active_record_data/3_2_multi_legacy.txt +50 -0
  67. data/spec/support/active_record_data/4_0_diana.txt +98 -0
  68. data/spec/support/active_record_data/4_0_multi.txt +198 -0
  69. data/spec/support/active_record_data/4_1_diana.txt +97 -0
  70. data/spec/support/active_record_data/4_1_multi.txt +196 -0
  71. data/spec/support/active_record_data/4_2_diana.txt +109 -0
  72. data/spec/support/active_record_data/4_2_diana_legacy.txt +109 -0
  73. data/spec/support/active_record_data/4_2_multi.txt +220 -0
  74. data/spec/support/active_record_data/4_2_multi_legacy.txt +220 -0
  75. data/spec/support/active_record_data/5_0_diana.txt +105 -0
  76. data/spec/support/active_record_data/5_0_multi.txt +212 -0
  77. data/spec/support/active_record_data/5_1_diana.txt +104 -0
  78. data/spec/support/active_record_data/5_1_multi.txt +210 -0
  79. data/spec/support/active_record_data/5_2_diana.txt +104 -0
  80. data/spec/support/active_record_data/5_2_multi.txt +210 -0
  81. data/spec/support/active_record_data/6_0_diana.txt +104 -0
  82. data/spec/support/active_record_data/6_0_multi.txt +210 -0
  83. data/spec/support/active_record_data/6_1_diana.txt +109 -0
  84. data/spec/support/active_record_data/6_1_multi.txt +220 -0
  85. data/spec/support/active_record_data.rb +20 -0
  86. data/spec/support/ext_verifier.rb +42 -0
  87. data/spec/support/mongoid_versions.rb +26 -0
  88. data/spec/support/rails_versions.rb +55 -0
  89. metadata +90 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 99b8a5036bd1ecee2419c7b8dd40c4d532be0d3b
4
- data.tar.gz: 76664afa8dcdc3113e0563dbab551c15eb88fc7d
2
+ SHA256:
3
+ metadata.gz: bc6d20d854c529b902cfe961bd8271b30f1aa9f82c4db11bfdcaa6ecb6b1f469
4
+ data.tar.gz: c4f69e0cf2663cb4889b27414bd9f242789fea28790c3252dc5b2788da70bca2
5
5
  SHA512:
6
- metadata.gz: 1c1351608b30f507cd3147eb6ef4a54d328919f46b30c75b5c60561f506db2b6ef5c7faacf62020a21e6a0e8fb7feebeb3c57b246acb25e72452338ecd347d12
7
- data.tar.gz: 61497937047523ccd15d81ac8c0059e0a2ddcac9d505832513ed1ac8300fff46fa496da3a4e33f5c2e92b70dd2ba0b8c6c8ed3f45bac393902ce524464235df0
6
+ metadata.gz: c34cd0b7347ecf6e98afc4ef0647f940a02a5d125c955748917c821e6bbf231830604fcbe0fb524c6bfdaa049d6f945bad658d30433bf878841b30a6d79ad765
7
+ data.tar.gz: 9cfae5c9646b5194a52c87b1ea38ba3d711cb616a713e66ce0ab83f255293a4b75f4016f349f047aa43d775d14b9f024fc0edccdf40b9f489e46626908162b00
data/.gitignore CHANGED
@@ -23,6 +23,10 @@ pkg
23
23
  .ruby-version
24
24
  gemfiles/*.gemfile.lock
25
25
  Gemfile.lock
26
+ /tmp
27
+ /.bundle
28
+ /gemfiles/.bundle
29
+ /gemfiles/vendor/bundle
26
30
 
27
31
  ## PROJECT::RVM
28
32
  .rvmrc
data/Appraisals CHANGED
@@ -1,52 +1,62 @@
1
- appraise 'rails-3.2' do
2
- gem 'rails', '~> 3.2.0'
3
- end
4
-
5
- appraise 'rails-4.0' do
6
- gem 'rails', '~> 4.0.0'
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
7
8
 
8
- # The last version that doesn't need Ruby 2.0 and works with version 4.0 of
9
- # Rails. This addresses a build problem with Travis for version 1.9.3 of Ruby
10
- gem 'mime-types', '2.6.2', :platforms => :ruby_19
9
+ appraise 'rails-5.0' do
10
+ gem 'rails', '>= 5.0.0', '< 5.1'
11
+ gem 'sqlite3', '~> 1.3.6'
11
12
  end
12
13
 
13
- appraise 'rails-4.1' do
14
- gem 'rails', '~> 4.1.0'
15
-
16
- # The last version that doesn't need Ruby 2.0 and works with version 4.1 of
17
- # Rails. This addresses a build problem with Travis for version 1.9.3 of Ruby
18
- gem 'mime-types', '2.6.2', :platforms => :ruby_19
14
+ appraise 'rails-5.1' do
15
+ gem 'rails', '>= 5.1.0', '< 5.2'
19
16
  end
20
17
 
21
- appraise 'rails-4.2' do
22
- gem 'rails', '~> 4.2.0'
23
-
24
- # The last version that doesn't need Ruby 2.0 and works with version 4.2 of
25
- # Rails. This addresses a build problem with Travis for version 1.9.3 of Ruby
26
- gem 'mime-types', '2.6.2', :platforms => :ruby_19
18
+ appraise 'rails-5.2' do
19
+ gem 'rails', '>= 5.2.0', '< 5.3'
27
20
  end
28
21
 
29
- appraise 'mongoid-3.0' do
30
- gem 'mongoid', '~> 3.0.0'
22
+ appraise 'rails-6.0' do
23
+ gem 'rails', '>= 6.0.0', '< 6.1'
31
24
  end
32
25
 
33
- appraise 'mongoid-3.1' do
34
- gem 'mongoid', '~> 3.1.0'
26
+ appraise 'rails-6.1' do
27
+ gem 'rails', '>= 6.1.0', '< 6.2'
35
28
  end
36
29
 
37
- appraise 'mongoid-4.0' do
38
- gem 'mongoid', '~> 4.0.0'
30
+ appraise 'mongoid-5.0' do
31
+ gem 'mongoid', '~> 5.0.0'
32
+ gem 'bigdecimal', '~> 1.3.5'
39
33
  end
40
34
 
41
- appraise 'mongo_mapper' do
42
- gem 'mongo_mapper'
35
+ appraise 'mongoid-6.0' do
36
+ gem 'mongoid', '~> 6.0.0'
43
37
  end
44
38
 
45
- appraise 'ripple' do
46
- gem 'tzinfo'
47
- gem 'ripple'
39
+ appraise 'mongoid-7.0' do
40
+ gem 'mongoid', '~> 7.0.0'
48
41
  end
49
42
 
50
- appraise 'nobrainer' do
51
- gem 'nobrainer'
43
+ appraise 'mongoid-7.1' do
44
+ gem 'mongoid', '~> 7.1.0'
52
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 CHANGED
@@ -1,6 +1,31 @@
1
1
  ## master (unreleased)
2
2
 
3
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
+
4
29
  ## 1.7.0
5
30
  - Refactoring by extracting formatters into their own classes [@waldyr] - [#237]
6
31
  - Fixes Travis builds and improves tests [@nviennot], [@waldyr], [@gerrywastaken] - [#225], [#228], [#229], [#230], [#231]
@@ -129,6 +154,7 @@
129
154
  - Initial Release.
130
155
 
131
156
  [#200]: https://github.com/awesome-print/awesome_print/pull/200
157
+ [#212]: https://github.com/awesome-print/awesome_print/pull/212
132
158
  [#216]: https://github.com/awesome-print/awesome_print/pull/216
133
159
  [#217]: https://github.com/awesome-print/awesome_print/pull/217
134
160
  [#222]: https://github.com/awesome-print/awesome_print/pull/222
@@ -145,6 +171,8 @@
145
171
  [@clonezone]: https://github.com/clonezone
146
172
  [@cyberdelia]: https://github.com/cyberdelia
147
173
  [@gerrywastaken]: https://github.com/gerrywastaken
174
+ [@ixti]: https://github.com/ixti
175
+ [@jtnegrotto]: https://github.com/jtnegrotto
148
176
  [@kemmason]: https://github.com/kemmason
149
177
  [@maurogeorge]: https://github.com/maurogeorge
150
178
  [@MaxPleaner]: https://github.com/MaxPleaner
data/CONTRIBUTING.md CHANGED
@@ -6,7 +6,7 @@ We love pull requests. Here's a quick guide:
6
6
 
7
7
  1. Create your feature branch (`git checkout -b my-new-feature`)
8
8
 
9
- 1. Update [CHANGELOG.md](https://github.com/michaeldv/awesome_print/blob/master/CHANGELOG.md) with a brief description of your changes under the `unreleased` heading.
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
10
 
11
11
  1. Add/Update tests were appropriate
12
12
 
@@ -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/Gemfile.lock CHANGED
@@ -1,45 +1,38 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- awesome_print (1.7.0)
4
+ awesome_print (1.9.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- appraisal (2.1.0)
9
+ appraisal (2.3.0)
10
10
  bundler
11
11
  rake
12
12
  thor (>= 0.14.0)
13
- codeclimate-test-reporter (0.5.0)
14
- simplecov (>= 0.7.1, < 1.0.0)
15
- diff-lcs (1.2.5)
16
- docile (1.1.5)
17
- fakefs (0.8.1)
18
- json (1.8.3)
19
- mini_portile2 (2.0.0)
20
- nokogiri (1.6.7.2)
21
- mini_portile2 (~> 2.0.0.rc2)
22
- rake (11.1.2)
23
- rspec (3.4.0)
24
- rspec-core (~> 3.4.0)
25
- rspec-expectations (~> 3.4.0)
26
- rspec-mocks (~> 3.4.0)
27
- rspec-core (3.4.4)
28
- rspec-support (~> 3.4.0)
29
- rspec-expectations (3.4.0)
13
+ diff-lcs (1.4.4)
14
+ fakefs (1.3.2)
15
+ mini_portile2 (2.5.0)
16
+ nokogiri (1.11.1)
17
+ mini_portile2 (~> 2.5.0)
18
+ racc (~> 1.4)
19
+ racc (1.5.2)
20
+ rake (13.0.3)
21
+ rspec (3.10.0)
22
+ rspec-core (~> 3.10.0)
23
+ rspec-expectations (~> 3.10.0)
24
+ rspec-mocks (~> 3.10.0)
25
+ rspec-core (3.10.1)
26
+ rspec-support (~> 3.10.0)
27
+ rspec-expectations (3.10.1)
30
28
  diff-lcs (>= 1.2.0, < 2.0)
31
- rspec-support (~> 3.4.0)
32
- rspec-mocks (3.4.1)
29
+ rspec-support (~> 3.10.0)
30
+ rspec-mocks (3.10.1)
33
31
  diff-lcs (>= 1.2.0, < 2.0)
34
- rspec-support (~> 3.4.0)
35
- rspec-support (3.4.1)
36
- simplecov (0.11.2)
37
- docile (~> 1.1.0)
38
- json (~> 1.8)
39
- simplecov-html (~> 0.10.0)
40
- simplecov-html (0.10.0)
41
- sqlite3 (1.3.11)
42
- thor (0.19.1)
32
+ rspec-support (~> 3.10.0)
33
+ rspec-support (3.10.1)
34
+ sqlite3 (1.4.2)
35
+ thor (1.1.0)
43
36
 
44
37
  PLATFORMS
45
38
  ruby
@@ -47,11 +40,10 @@ PLATFORMS
47
40
  DEPENDENCIES
48
41
  appraisal
49
42
  awesome_print!
50
- codeclimate-test-reporter
51
43
  fakefs (>= 0.2.1)
52
- nokogiri (>= 1.6.5)
44
+ nokogiri (>= 1.11.0)
53
45
  rspec (>= 3.0.0)
54
46
  sqlite3
55
47
 
56
48
  BUNDLED WITH
57
- 1.12.5
49
+ 2.2.8
data/LICENSE CHANGED
@@ -1,22 +1,19 @@
1
- Copyright (c) 2010-2013 Michael Dvorkin
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
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
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
- included in all copies or substantial portions of the Software.
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
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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
@@ -5,23 +5,22 @@
5
5
  [![Code Climate][code_climate_badge]][code_climate]
6
6
  [![Code Climate Coverage][code_climate_coverage_badge]][code_climate]
7
7
  [![RubyGems][gem_downloads_badge]][ruby_gems]
8
- [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/michaeldv/awesome_print?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
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
9
 
10
10
 
11
11
  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.2.0 is the last release supporting Ruby versions
16
- prior to v1.9.3 and Rails versions prior to v3.0. The upcoming awesome_print
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
21
20
  $ gem install awesome_print
22
21
 
23
22
  # Cloning the repository
24
- $ git clone git://github.com/michaeldv/awesome_print.git
23
+ $ git clone git://github.com/awesome-print/awesome_print.git
25
24
 
26
25
  ### Usage ###
27
26
 
@@ -33,34 +32,38 @@ ap object, options = {}
33
32
  Default options:
34
33
 
35
34
  ```ruby
36
- :indent => 4, # Indent using 4 spaces.
37
- :index => true, # Display array indices.
38
- :html => false, # Use ANSI color codes rather than HTML.
39
- :multiline => true, # Display in multiple lines.
40
- :plain => false, # Use colors.
41
- :raw => false, # Do not recursively format object instance variables.
42
- :sort_keys => false, # Do not sort hash keys.
43
- :limit => false, # Limit large output for arrays and hashes. Set to a boolean or integer.
44
- :color => {
45
- :args => :pale,
46
- :array => :white,
47
- :bigdecimal => :blue,
48
- :class => :yellow,
49
- :date => :greenish,
50
- :falseclass => :red,
51
- :fixnum => :blue,
52
- :float => :blue,
53
- :hash => :pale,
54
- :keyword => :cyan,
55
- :method => :purpleish,
56
- :nilclass => :red,
57
- :rational => :blue,
58
- :string => :yellowish,
59
- :struct => :pale,
60
- :symbol => :cyanish,
61
- :time => :greenish,
62
- :trueclass => :green,
63
- :variable => :cyanish
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
64
67
  }
65
68
  ```
66
69
 
@@ -80,6 +83,8 @@ irb> "awesome print".ai
80
83
 
81
84
  ### Examples ###
82
85
 
86
+ #### Array
87
+
83
88
  ```ruby
84
89
  $ cat > 1.rb
85
90
  require "awesome_print"
@@ -100,7 +105,10 @@ $ ruby 1.rb
100
105
  :distance => 4.2e+43
101
106
  }
102
107
  ]
108
+ ```
109
+ #### Hash
103
110
 
111
+ ```ruby
104
112
  $ cat > 2.rb
105
113
  require "awesome_print"
106
114
  data = { :now => Time.now, :class => Time.now.class, :distance => 42e42 }
@@ -112,7 +120,11 @@ $ ruby 2.rb
112
120
  :now => Fri Apr 02 19:55:53 -0700 2010,
113
121
  :distance => 4.2e+43
114
122
  }
123
+ ```
115
124
 
125
+ #### Nested array
126
+
127
+ ```ruby
116
128
  $ cat > 3.rb
117
129
  require "awesome_print"
118
130
  data = [ false, 42, %w(forty two) ]
@@ -122,6 +134,11 @@ ap data, :multiline => false
122
134
  $ ruby 3.rb
123
135
  [ false, 42, [ "forty", "two" ], [...] ]
124
136
 
137
+ ```
138
+
139
+ #### Class methods
140
+
141
+ ```ruby
125
142
  $ cat > 4.rb
126
143
  require "awesome_print"
127
144
  class Hello
@@ -135,6 +152,11 @@ $ ruby 4.rb
135
152
  [0] world(x, y, *z, &blk) Hello
136
153
  ]
137
154
 
155
+ ```
156
+
157
+ #### Object methods
158
+
159
+ ```ruby
138
160
  $ cat > 5.rb
139
161
  require "awesome_print"
140
162
  ap (''.methods - Object.methods).grep(/!/)
@@ -163,6 +185,11 @@ $ ruby 5.rb
163
185
  [19] upcase!() String
164
186
  ]
165
187
 
188
+ ```
189
+
190
+ #### Compare output to value
191
+
192
+ ```ruby
166
193
  $ cat > 6.rb
167
194
  require "awesome_print"
168
195
  ap 42 == ap(42)
@@ -170,7 +197,13 @@ ap 42 == ap(42)
170
197
  $ ruby 6.rb
171
198
  42
172
199
  true
173
- $ cat 7.rb
200
+
201
+ ```
202
+
203
+ #### Array with default output limit
204
+
205
+ ```ruby
206
+ $ cat > 7.rb
174
207
  require "awesome_print"
175
208
  some_array = (1..1000).to_a
176
209
  ap some_array, :limit => true
@@ -185,8 +218,12 @@ $ ruby 7.rb
185
218
  [998] 999,
186
219
  [999] 1000
187
220
  ]
221
+ ```
222
+
223
+ #### Array with specific output limit
188
224
 
189
- $ cat 8.rb
225
+ ```ruby
226
+ $ cat > 8.rb
190
227
  require "awesome_print"
191
228
  some_array = (1..1000).to_a
192
229
  ap some_array, :limit => 5
@@ -201,7 +238,7 @@ $ ruby 8.rb
201
238
  ]
202
239
  ```
203
240
 
204
- ### Example (Rails console) ###
241
+ #### Rails console
205
242
  ```ruby
206
243
  $ rails console
207
244
  rails> require "awesome_print"
@@ -304,6 +341,14 @@ formatting:
304
341
 
305
342
  <%= ap @accounts.first, :html => true %>
306
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
+
307
352
  ### Setting Custom Defaults ###
308
353
  You can set your own default options by creating ``.aprc`` file in your home
309
354
  directory. Within that file assign your defaults to ``AwesomePrint.defaults``.
@@ -325,11 +370,10 @@ AwesomePrint.defaults = {
325
370
  AwesomePrint follows the [Semantic Versioning](http://semver.org/) standard.
326
371
 
327
372
  ### Contributing ###
328
- See [Contributing.md](https://github.com/michaeldv/awesome_print/blob/master/CONTRIBUTING.md)
329
- for information.
373
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for information.
330
374
 
331
375
  ### License ###
332
- Copyright (c) 2010-2013 Michael Dvorkin
376
+ Copyright (c) 2010-2016 Michael Dvorkin and contributors
333
377
 
334
378
  http://www.dvorkin.net
335
379
 
@@ -340,8 +384,8 @@ Released under the MIT license. See LICENSE file for details.
340
384
  [gem_version_badge]: https://img.shields.io/gem/v/awesome_print.svg?style=flat
341
385
  [gem_downloads_badge]: http://img.shields.io/gem/dt/awesome_print.svg?style=flat
342
386
  [ruby_gems]: http://rubygems.org/gems/awesome_print
343
- [travis_ci]: http://travis-ci.org/michaeldv/awesome_print
344
- [travis_ci_badge]: https://img.shields.io/travis/michaeldv/awesome_print/master.svg?style=flat
345
- [code_climate]: https://codeclimate.com/github/michaeldv/awesome_print
346
- [code_climate_badge]: http://img.shields.io/codeclimate/github/michaeldv/awesome_print.svg?style=flat
347
- [code_climate_coverage_badge]: https://codeclimate.com/github/michaeldv/awesome_print/badges/coverage.svg
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
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
- require "rubygems"
2
- require "bundler/setup"
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
3
 
4
- require "bundler"
4
+ require 'bundler'
5
5
  Bundler::GemHelper.install_tasks
6
6
 
7
7
  task :default do
@@ -16,9 +16,9 @@ task :appraise do
16
16
  exec 'appraisal install && appraisal rake'
17
17
  end
18
18
 
19
- desc "Run all awesome_print gem specs"
19
+ desc 'Run all awesome_print gem specs'
20
20
  task :spec do
21
21
  # Run plain rspec command without RSpec::Core::RakeTask overrides.
22
- exec "rspec -c spec"
22
+ exec 'rspec -c spec'
23
23
  end
24
24
 
@@ -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')
data/lib/ap.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2010-2013 Michael Dvorkin
1
+ # Copyright (c) 2010-2016 Michael Dvorkin and contributors
2
2
  #
3
3
  # Awesome Print is freely distributable under the terms of MIT license.
4
4
  # See LICENSE file or http://www.opensource.org/licenses/mit-license.php
@@ -7,4 +7,4 @@
7
7
  # Keeping this for backwards compatibility to allow
8
8
  # require "ap"
9
9
  #
10
- require File.dirname(__FILE__) + "/awesome_print"
10
+ require File.dirname(__FILE__) + '/awesome_print'
@@ -1,4 +1,4 @@
1
- autoload :CGI, "cgi"
1
+ autoload :CGI, 'cgi'
2
2
 
3
3
  module AwesomePrint
4
4
  module Colorize