awesome_print 1.0.2 → 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.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -1
  3. data/Appraisals +52 -0
  4. data/CHANGELOG.md +152 -0
  5. data/CONTRIBUTING.md +81 -0
  6. data/Gemfile +3 -2
  7. data/Gemfile.lock +44 -13
  8. data/LICENSE +3 -3
  9. data/README.md +272 -264
  10. data/Rakefile +23 -1
  11. data/lib/ap.rb +1 -1
  12. data/lib/awesome_print/colorize.rb +24 -0
  13. data/lib/awesome_print/core_ext/array.rb +12 -2
  14. data/lib/awesome_print/core_ext/class.rb +1 -1
  15. data/lib/awesome_print/core_ext/kernel.rb +8 -3
  16. data/lib/awesome_print/core_ext/logger.rb +1 -1
  17. data/lib/awesome_print/core_ext/method.rb +1 -1
  18. data/lib/awesome_print/core_ext/object.rb +1 -1
  19. data/lib/awesome_print/core_ext/string.rb +1 -1
  20. data/lib/awesome_print/ext/action_view.rb +1 -1
  21. data/lib/awesome_print/ext/active_record.rb +8 -2
  22. data/lib/awesome_print/ext/active_support.rb +2 -2
  23. data/lib/awesome_print/ext/mongo_mapper.rb +86 -3
  24. data/lib/awesome_print/ext/mongoid.rb +3 -3
  25. data/lib/awesome_print/ext/nobrainer.rb +49 -0
  26. data/lib/awesome_print/ext/nokogiri.rb +1 -1
  27. data/lib/awesome_print/ext/ostruct.rb +27 -0
  28. data/lib/awesome_print/ext/ripple.rb +72 -0
  29. data/lib/awesome_print/ext/sequel.rb +57 -0
  30. data/lib/awesome_print/formatter.rb +59 -309
  31. data/lib/awesome_print/formatters/array_formatter.rb +73 -0
  32. data/lib/awesome_print/formatters/base_formatter.rb +138 -0
  33. data/lib/awesome_print/formatters/class_formatter.rb +24 -0
  34. data/lib/awesome_print/formatters/dir_formatter.rb +22 -0
  35. data/lib/awesome_print/formatters/file_formatter.rb +22 -0
  36. data/lib/awesome_print/formatters/hash_formatter.rb +54 -0
  37. data/lib/awesome_print/formatters/method_formatter.rb +22 -0
  38. data/lib/awesome_print/formatters/object_formatter.rb +80 -0
  39. data/lib/awesome_print/formatters/simple_formatter.rb +21 -0
  40. data/lib/awesome_print/indentator.rb +18 -0
  41. data/lib/awesome_print/inspector.rb +48 -6
  42. data/lib/awesome_print/version.rb +2 -2
  43. data/lib/awesome_print.rb +20 -10
  44. data/spec/active_record_helper.rb +24 -0
  45. data/spec/colors_spec.rb +10 -10
  46. data/spec/formats_spec.rb +191 -170
  47. data/spec/methods_spec.rb +69 -68
  48. data/spec/misc_spec.rb +250 -0
  49. data/spec/objects_spec.rb +62 -12
  50. data/spec/spec_helper.rb +66 -34
  51. metadata +125 -49
  52. data/CHANGELOG +0 -77
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 99b8a5036bd1ecee2419c7b8dd40c4d532be0d3b
4
+ data.tar.gz: 76664afa8dcdc3113e0563dbab551c15eb88fc7d
5
+ SHA512:
6
+ metadata.gz: 1c1351608b30f507cd3147eb6ef4a54d328919f46b30c75b5c60561f506db2b6ef5c7faacf62020a21e6a0e8fb7feebeb3c57b246acb25e72452338ecd347d12
7
+ data.tar.gz: 61497937047523ccd15d81ac8c0059e0a2ddcac9d505832513ed1ac8300fff46fa496da3a4e33f5c2e92b70dd2ba0b8c6c8ed3f45bac393902ce524464235df0
data/.gitignore CHANGED
@@ -13,10 +13,20 @@ 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
25
+ Gemfile.lock
20
26
 
21
- ## PROJECT::SPECIFIC
27
+ ## PROJECT::RVM
22
28
  .rvmrc
29
+
30
+ # PROJECT::RBENV
31
+ .ruby-gemset
32
+ .awesome-print/
data/Appraisals ADDED
@@ -0,0 +1,52 @@
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'
7
+
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
11
+ end
12
+
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
19
+ end
20
+
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
27
+ end
28
+
29
+ appraise 'mongoid-3.0' do
30
+ gem 'mongoid', '~> 3.0.0'
31
+ end
32
+
33
+ appraise 'mongoid-3.1' do
34
+ gem 'mongoid', '~> 3.1.0'
35
+ end
36
+
37
+ appraise 'mongoid-4.0' do
38
+ gem 'mongoid', '~> 4.0.0'
39
+ end
40
+
41
+ appraise 'mongo_mapper' do
42
+ gem 'mongo_mapper'
43
+ end
44
+
45
+ appraise 'ripple' do
46
+ gem 'tzinfo'
47
+ gem 'ripple'
48
+ end
49
+
50
+ appraise 'nobrainer' do
51
+ gem 'nobrainer'
52
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,152 @@
1
+ ## master (unreleased)
2
+
3
+
4
+ ## 1.7.0
5
+ - Refactoring by extracting formatters into their own classes [@waldyr] - [#237]
6
+ - Fixes Travis builds and improves tests [@nviennot], [@waldyr], [@gerrywastaken] - [#225], [#228], [#229], [#230], [#231]
7
+ - Creates `awesome_object_data` to encapsulate the logic of printing object internals,
8
+ so Structs and Objects can be printed as one [@waldyr] - [#226]
9
+ - Fixes development dependencies for environments without rake [@aleandros], [@cyberdelia] - [#222], [#216]
10
+ - Documents `ai` method usage [@MaxPleaner] - [#217]
11
+ - Fixes conflict with `mail` and other gems which fake ActiveSupport [@kemmason] - [#200]
12
+ - Improves spec performance and simplicity [@maurogeorge]
13
+ - Handle objects that have a custom #to_hash method [@clonezone]
14
+
15
+ ## 1.6.1
16
+ - Fixes specs on all rails dependencies (Mauro George)
17
+ - Updates specs for mongoid, mongo_mapper and ripple (James Cox)
18
+ - Adds appraisals for simpler version/scenario management (Mauro George)
19
+ - Add Travis (Mauro George)
20
+ - Update documentation (Mauro George)
21
+
22
+ ## 1.6.0
23
+ semi-major release since it's been a while, and there are several
24
+ improvements.
25
+ - Improves support for new mongoid/moped (Velkitor, Francois Bernier et al)
26
+ - Converts specs to rspec 3+ (Adam Jonas, James Cox)
27
+ - Fixes incompatibility with IPAddr (James Cox, Michael Dvorkin)
28
+ - Fixes incompatibility with the money gem (Michael Dvorkin)
29
+ - Fixes AR::Relation presentation (Sergey Ponomarov)
30
+ - Lazy-loads ActionView (Akira Matsuda)
31
+ - Fixes inspection of abstract classes (Jonathan Priddle)
32
+ - Gets most specs passing, and fixes suite (Eoin Kelly)
33
+
34
+ ## 1.2.0
35
+ #### NOTE: This is the *last* release supporting Ruby < v1.9.3 and Rails < v3.
36
+ - Added Sequel ORM plugin (Jonathan Davies)
37
+ - Added Ripple plugin (Ruby modeling layer for Riak, Scott Hyndman)
38
+ - Added NoBrainer plugin (Ruby ORM for RethinkDB, Nicolas Viennot)
39
+ - Added formatting for Ruby set objects (Richard Hall)
40
+ - Fixed HTML formatting (Mike McQuaid)
41
+ - Other minor bugs and enhancements
42
+
43
+ ## 1.1.0
44
+ - Objects are no longer recursively formatted by default. Reenable by using :raw => true option.
45
+ - ap(object) now returns nil when running under IRB or Pry
46
+ - Added support for Mongoid 3 and Moped (Nikolaj Nikolajsen)
47
+ - Improved formatting of MongoMapper objects (George .)
48
+ - ActiveRecord::Relation now renders as array (Dan Lynn)
49
+ - Formatting BigDecimal no longer looses precision (Evan Senter)
50
+ - Added AwesomePrint.irb! and AwesomePrint.pry! convenience methods
51
+ - Fixed conflict with the colorize gem
52
+ - Misc tweaks and bug fixes
53
+
54
+ ## 1.0.2
55
+ - Added formatting of Mongoid documents (Adam Doppelt)
56
+ - ActiveRecord objects display attributes only. Use :raw => true to display the entire object
57
+ - ActiveSupport::Date objects get formatted as regular Date
58
+ - Rails.logger.ap colorizes output based on ActiveSupport::LogSubscriber.colorize_logging (default is true)
59
+ - Improved formatting of methods array
60
+
61
+ ## 1.0.1
62
+ - Updated repo tags for Rubygems.org
63
+
64
+ ## 1.0.0 Thanksgiving edition
65
+ - Added ability to format *arbitrary* Ruby object
66
+ - Added :limit option to limit large output for arrays and hashes (Andrew Horsman)
67
+ - Improved HTML formatting when :html => true (Daniel Johnson)
68
+ - Added Mongoid extension (Adam Doppelt)
69
+ - Added Nokogiri extension (Adam Doppelt)
70
+ - Removed Jeweler gem dependency
71
+
72
+ ## 0.4.0
73
+ - 'ap object' now returns the object (Stephan Hagemann)
74
+ - Added :html => true option to enable HTML colors rather that ANSI (ex. Sinatra templates)
75
+ - Added AwesomePrint.force_colors! to allow color output on demand (Andrew O'Brien)
76
+ - Added MongoMapper formatter mixin (Elpizo Choi)
77
+ - Fixed formatting of methods array when object#method is overridden
78
+ - Fixed potential stack errors by checking whether AwesomePrint is already loaded
79
+ - Improved Ruby 1.8.6 and 1.8.7 compatibility
80
+ - Improved Windows compatibility (Viktar Basharymau)
81
+
82
+ ## 0.3.2
83
+ - Make sure Rails mixins get loaded in Rails console when required from .irbrc
84
+ - Fixed an issue with classes that define their own #send method (ex: Socket)
85
+ - Fixed compatibility issue with Liquid gem that defines Module#liquid_methods
86
+ - Fixed hash spec for Ruby < 1.9 where order of hash keys is not guaranteed
87
+ - Added :sorted_hash_keys option to sort hash keys (Ed Ruder)
88
+
89
+ ## 0.3.1 RubyConf X edition
90
+ - Fixed Ruby 1.8.6 compatibility issues (thanks, Tim!)
91
+ - Fixed stack overflow issue with Rails 2.3.x console
92
+
93
+ ## 0.3.0
94
+ - Display object.methods and family in human readable format
95
+ - Objects inherited from Array, Hash, File, Dir, and Struct are shown as their base class
96
+ - Added option to suppress array index in output (Sean Gallagher)
97
+ - Updated README on how to set up ~/.irbrc for MacRuby (Eloy Duran)
98
+ - Specs pass 100% with Ruby 1.8.7/RSpec 1.3 and Ruby 1.9.2/RSpec 2.0
99
+
100
+ ## 0.2.1
101
+ - ap can now be used within Rails templates (ex. <%= ap object %>)
102
+ - Added support for printing Struct
103
+
104
+ ## 0.2.0
105
+ - Added support for logger.ap (including Rails logger)
106
+ - Added support for HashWithIndifferentAccess from ActiveSupport
107
+ - ap now works with scripts that use ActiveRecord/ActiveSupport outside Rails
108
+ - ap now correctly shows file and directory names with fancy characters (shell escape)
109
+
110
+ ## 0.1.4
111
+ - Format BigDecimal and Rational objects as Float scalars
112
+ - Explicit options parameter can override custom defaults
113
+ - Custom defaults are not interfering when running specs
114
+ - Custom defaults now work correctly with Ruby 1.9.x
115
+
116
+ ## 0.1.3
117
+ - Added support for setting custom defaults in ~/.aprc
118
+
119
+ ## 0.1.2
120
+ - Correctly handle empty arrays and hashes
121
+ - Use alias_method instead of alias (fixes non-tty method aliasing)
122
+ - Added awesome_inspect method
123
+
124
+ ## 0.1.1
125
+ - Added support for tableless ActiveRecord models
126
+ - Left align hash keys if @options[:indent] is negative
127
+
128
+ ## 0.1.0
129
+ - Initial Release.
130
+
131
+ [#200]: https://github.com/awesome-print/awesome_print/pull/200
132
+ [#216]: https://github.com/awesome-print/awesome_print/pull/216
133
+ [#217]: https://github.com/awesome-print/awesome_print/pull/217
134
+ [#222]: https://github.com/awesome-print/awesome_print/pull/222
135
+ [#225]: https://github.com/awesome-print/awesome_print/pull/225
136
+ [#226]: https://github.com/awesome-print/awesome_print/pull/226
137
+ [#228]: https://github.com/awesome-print/awesome_print/pull/228
138
+ [#229]: https://github.com/awesome-print/awesome_print/pull/229
139
+ [#230]: https://github.com/awesome-print/awesome_print/pull/230
140
+ [#231]: https://github.com/awesome-print/awesome_print/pull/231
141
+ [#232]: https://github.com/awesome-print/awesome_print/pull/232
142
+ [#237]: https://github.com/awesome-print/awesome_print/pull/237
143
+
144
+ [@aleandros]: https://github.com/aleandros
145
+ [@clonezone]: https://github.com/clonezone
146
+ [@cyberdelia]: https://github.com/cyberdelia
147
+ [@gerrywastaken]: https://github.com/gerrywastaken
148
+ [@kemmason]: https://github.com/kemmason
149
+ [@maurogeorge]: https://github.com/maurogeorge
150
+ [@MaxPleaner]: https://github.com/MaxPleaner
151
+ [@nviennot]: https://github.com/nviennot
152
+ [@waldyr]: https://github.com/waldyr
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,81 @@
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/michaeldv/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
+ * Dan Lynn -- https://github.com/danlynn
55
+ * Daniel Johnson -- https://github.com/adhd360
56
+ * Daniel Bretoi -- http://github.com/danielb2
57
+ * Eloy Duran -- http://github.com/alloy
58
+ * Elpizo Choi -- https://github.com/fuJiin
59
+ * Evan Senter -- https://github.com/evansenter
60
+ * George . -- https://github.com/gardelea
61
+ * Greg Weber -- https://github.com/gregwebs
62
+ * Jan Vansteenkiste -- https://github.com/vStone
63
+ * Jeff Felchner -- https://github.com/jfelchner
64
+ * Jonathan Davies -- send your Github URL ;-)
65
+ * Kevin Olbrich -- https://github.com/olbrich
66
+ * Matthew Schulkind -- https://github.com/mschulkind
67
+ * Mike McQuaid -- https://github.com/mikemcquaid
68
+ * Nami-Doc -- https://github.com/Nami-Doc
69
+ * Nicolas Viennot -- https://github.com/nviennot
70
+ * Nikolaj Nikolajsen -- https://github.com/nikolajsen
71
+ * Richard Hall -- https://github.com/richardardrichard
72
+ * Ryan Schlesinger -- https://github.com/ryansch
73
+ * Scott Hyndman -- https://github.com/shyndman
74
+ * Sean Gallagher -- http://github.com/torandu
75
+ * Stephan Hagemann -- https://github.com/shageman
76
+ * Tim Harper -- http://github.com/timcharper
77
+ * Tobias Crawley -- http://github.com/tobias
78
+ * Thibaut Barrère -- https://github.com/thbar
79
+ * Trevor Wennblom -- https://github.com/trevor
80
+ * vfrride -- https://github.com/vfrride
81
+ * Viktar Basharymau -- https://github.com/DNNX
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
- source "http://rubygems.org"
2
- gemspec
1
+ source 'https://rubygems.org'
3
2
 
3
+ # Specify your gem's dependencies in awesome_print.gemspec
4
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,26 +1,57 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- awesome_print (1.0.0)
4
+ awesome_print (1.7.0)
5
5
 
6
6
  GEM
7
- remote: http://rubygems.org/
7
+ remote: https://rubygems.org/
8
8
  specs:
9
- diff-lcs (1.1.2)
10
- fakefs (0.3.2)
11
- rspec (2.6.0)
12
- rspec-core (~> 2.6.0)
13
- rspec-expectations (~> 2.6.0)
14
- rspec-mocks (~> 2.6.0)
15
- rspec-core (2.6.4)
16
- rspec-expectations (2.6.0)
17
- diff-lcs (~> 1.1.2)
18
- rspec-mocks (2.6.0)
9
+ appraisal (2.1.0)
10
+ bundler
11
+ rake
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)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.4.0)
32
+ rspec-mocks (3.4.1)
33
+ 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)
19
43
 
20
44
  PLATFORMS
21
45
  ruby
22
46
 
23
47
  DEPENDENCIES
48
+ appraisal
24
49
  awesome_print!
50
+ codeclimate-test-reporter
25
51
  fakefs (>= 0.2.1)
26
- rspec (>= 2.6.0)
52
+ nokogiri (>= 1.6.5)
53
+ rspec (>= 3.0.0)
54
+ sqlite3
55
+
56
+ BUNDLED WITH
57
+ 1.12.5
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- Copyright (c) 2010-2011 Michael Dvorkin
2
- twitter.com/mid
3
- %w(mike dvorkin.net) * "@" || %w(mike fatfreecrm.com) * "@"
1
+ Copyright (c) 2010-2013 Michael Dvorkin
2
+ http://www.dvorkin.net
3
+ %w(mike dvorkin.net) * "@" || "twitter.com/mid"
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the