awesome_print 1.6.1 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb92d5e2cf0fdfb4adea4dce07a036029b215e53
4
- data.tar.gz: 5ff2f87c655f96bdbf5393d18432dd967f3c48ef
3
+ metadata.gz: 99b8a5036bd1ecee2419c7b8dd40c4d532be0d3b
4
+ data.tar.gz: 76664afa8dcdc3113e0563dbab551c15eb88fc7d
5
5
  SHA512:
6
- metadata.gz: e41bf9d0871110552cd501c718276cf610c14dad19732a75670d81b9028c84fe21af86405bca36a3b5d3f35ef1180bb6d3ae0871b26d8bd313091b8298a4a147
7
- data.tar.gz: 7980fa638d522e0be24381a8edca2c480f1a3579b4c310bbee2c2228c41c4b9c1a738e23251381e52b8e2744d860e7ab35dcef654af37a003e2366a8a67c3b75
6
+ metadata.gz: 1c1351608b30f507cd3147eb6ef4a54d328919f46b30c75b5c60561f506db2b6ef5c7faacf62020a21e6a0e8fb7feebeb3c57b246acb25e72452338ecd347d12
7
+ data.tar.gz: 61497937047523ccd15d81ac8c0059e0a2ddcac9d505832513ed1ac8300fff46fa496da3a4e33f5c2e92b70dd2ba0b8c6c8ed3f45bac393902ce524464235df0
data/Appraisals CHANGED
@@ -4,28 +4,37 @@ end
4
4
 
5
5
  appraise 'rails-4.0' do
6
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
7
11
  end
8
12
 
9
13
  appraise 'rails-4.1' do
10
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
11
19
  end
12
20
 
13
21
  appraise 'rails-4.2' do
14
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
15
27
  end
16
28
 
17
29
  appraise 'mongoid-3.0' do
18
- gem 'rails', '~> 3.2.0'
19
30
  gem 'mongoid', '~> 3.0.0'
20
31
  end
21
32
 
22
33
  appraise 'mongoid-3.1' do
23
- gem 'rails', '~> 3.2.0'
24
34
  gem 'mongoid', '~> 3.1.0'
25
35
  end
26
36
 
27
37
  appraise 'mongoid-4.0' do
28
- gem 'rails', '~> 4.2.0'
29
38
  gem 'mongoid', '~> 4.0.0'
30
39
  end
31
40
 
@@ -37,3 +46,7 @@ appraise 'ripple' do
37
46
  gem 'tzinfo'
38
47
  gem 'ripple'
39
48
  end
49
+
50
+ appraise 'nobrainer' do
51
+ gem 'nobrainer'
52
+ end
@@ -1,11 +1,25 @@
1
- 1.6.1
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
2
16
  - Fixes specs on all rails dependencies (Mauro George)
3
17
  - Updates specs for mongoid, mongo_mapper and ripple (James Cox)
4
18
  - Adds appraisals for simpler version/scenario management (Mauro George)
5
19
  - Add Travis (Mauro George)
6
20
  - Update documentation (Mauro George)
7
21
 
8
- 1.6.0
22
+ ## 1.6.0
9
23
  semi-major release since it's been a while, and there are several
10
24
  improvements.
11
25
  - Improves support for new mongoid/moped (Velkitor, Francois Bernier et al)
@@ -17,7 +31,8 @@
17
31
  - Fixes inspection of abstract classes (Jonathan Priddle)
18
32
  - Gets most specs passing, and fixes suite (Eoin Kelly)
19
33
 
20
- 1.2.0 <-- NOTE: This is the *last* release supporting Ruby < v1.9.3 and Rails < v3.
34
+ ## 1.2.0
35
+ #### NOTE: This is the *last* release supporting Ruby < v1.9.3 and Rails < v3.
21
36
  - Added Sequel ORM plugin (Jonathan Davies)
22
37
  - Added Ripple plugin (Ruby modeling layer for Riak, Scott Hyndman)
23
38
  - Added NoBrainer plugin (Ruby ORM for RethinkDB, Nicolas Viennot)
@@ -25,7 +40,7 @@
25
40
  - Fixed HTML formatting (Mike McQuaid)
26
41
  - Other minor bugs and enhancements
27
42
 
28
- 1.1.0
43
+ ## 1.1.0
29
44
  - Objects are no longer recursively formatted by default. Reenable by using :raw => true option.
30
45
  - ap(object) now returns nil when running under IRB or Pry
31
46
  - Added support for Mongoid 3 and Moped (Nikolaj Nikolajsen)
@@ -36,17 +51,17 @@
36
51
  - Fixed conflict with the colorize gem
37
52
  - Misc tweaks and bug fixes
38
53
 
39
- 1.0.2
54
+ ## 1.0.2
40
55
  - Added formatting of Mongoid documents (Adam Doppelt)
41
56
  - ActiveRecord objects display attributes only. Use :raw => true to display the entire object
42
57
  - ActiveSupport::Date objects get formatted as regular Date
43
58
  - Rails.logger.ap colorizes output based on ActiveSupport::LogSubscriber.colorize_logging (default is true)
44
59
  - Improved formatting of methods array
45
60
 
46
- 1.0.1
61
+ ## 1.0.1
47
62
  - Updated repo tags for Rubygems.org
48
63
 
49
- 1.0.0 Thanksgiving edition
64
+ ## 1.0.0 Thanksgiving edition
50
65
  - Added ability to format *arbitrary* Ruby object
51
66
  - Added :limit option to limit large output for arrays and hashes (Andrew Horsman)
52
67
  - Improved HTML formatting when :html => true (Daniel Johnson)
@@ -54,7 +69,7 @@
54
69
  - Added Nokogiri extension (Adam Doppelt)
55
70
  - Removed Jeweler gem dependency
56
71
 
57
- 0.4.0
72
+ ## 0.4.0
58
73
  - 'ap object' now returns the object (Stephan Hagemann)
59
74
  - Added :html => true option to enable HTML colors rather that ANSI (ex. Sinatra templates)
60
75
  - Added AwesomePrint.force_colors! to allow color output on demand (Andrew O'Brien)
@@ -64,52 +79,74 @@
64
79
  - Improved Ruby 1.8.6 and 1.8.7 compatibility
65
80
  - Improved Windows compatibility (Viktar Basharymau)
66
81
 
67
- 0.3.2
82
+ ## 0.3.2
68
83
  - Make sure Rails mixins get loaded in Rails console when required from .irbrc
69
84
  - Fixed an issue with classes that define their own #send method (ex: Socket)
70
85
  - Fixed compatibility issue with Liquid gem that defines Module#liquid_methods
71
86
  - Fixed hash spec for Ruby < 1.9 where order of hash keys is not guaranteed
72
87
  - Added :sorted_hash_keys option to sort hash keys (Ed Ruder)
73
88
 
74
- 0.3.1 RubyConf X edition
89
+ ## 0.3.1 RubyConf X edition
75
90
  - Fixed Ruby 1.8.6 compatibility issues (thanks, Tim!)
76
91
  - Fixed stack overflow issue with Rails 2.3.x console
77
92
 
78
- 0.3.0
93
+ ## 0.3.0
79
94
  - Display object.methods and family in human readable format
80
95
  - Objects inherited from Array, Hash, File, Dir, and Struct are shown as their base class
81
96
  - Added option to suppress array index in output (Sean Gallagher)
82
97
  - Updated README on how to set up ~/.irbrc for MacRuby (Eloy Duran)
83
98
  - Specs pass 100% with Ruby 1.8.7/RSpec 1.3 and Ruby 1.9.2/RSpec 2.0
84
99
 
85
- 0.2.1
100
+ ## 0.2.1
86
101
  - ap can now be used within Rails templates (ex. <%= ap object %>)
87
102
  - Added support for printing Struct
88
103
 
89
- 0.2.0
104
+ ## 0.2.0
90
105
  - Added support for logger.ap (including Rails logger)
91
106
  - Added support for HashWithIndifferentAccess from ActiveSupport
92
107
  - ap now works with scripts that use ActiveRecord/ActiveSupport outside Rails
93
108
  - ap now correctly shows file and directory names with fancy characters (shell escape)
94
109
 
95
- 0.1.4
110
+ ## 0.1.4
96
111
  - Format BigDecimal and Rational objects as Float scalars
97
112
  - Explicit options parameter can override custom defaults
98
113
  - Custom defaults are not interfering when running specs
99
114
  - Custom defaults now work correctly with Ruby 1.9.x
100
115
 
101
- 0.1.3
116
+ ## 0.1.3
102
117
  - Added support for setting custom defaults in ~/.aprc
103
118
 
104
- 0.1.2
119
+ ## 0.1.2
105
120
  - Correctly handle empty arrays and hashes
106
121
  - Use alias_method instead of alias (fixes non-tty method aliasing)
107
122
  - Added awesome_inspect method
108
123
 
109
- 0.1.1
124
+ ## 0.1.1
110
125
  - Added support for tableless ActiveRecord models
111
126
  - Left align hash keys if @options[:indent] is negative
112
127
 
113
- 0.1.0
128
+ ## 0.1.0
114
129
  - Initial Release.
115
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
@@ -8,15 +8,15 @@ We love pull requests. Here's a quick guide:
8
8
 
9
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
10
 
11
+ 1. Add/Update tests were appropriate
12
+
11
13
  1. Commit your changes (`git commit -am 'Added some feature'`)
12
14
 
13
15
  1. Push to the branch (`git push origin my-new-feature`)
14
16
 
15
17
  1. Create new Pull Request
16
18
 
17
- At this point you're waiting on us. We like to at least comment on, if not
18
- accept, pull requests within three business days (and, typically, one business
19
- day). We may suggest some changes or improvements or alternatives.
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
20
 
21
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
22
 
@@ -39,3 +39,43 @@ If you want to run a specific spec in a gemfile run:
39
39
  ```
40
40
  $ appraisal rails-3.2 rspec spec/colors_spec.rb
41
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/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  [![RubyGems][gem_version_badge]][ruby_gems]
4
4
  [![Travis CI][travis_ci_badge]][travis_ci]
5
5
  [![Code Climate][code_climate_badge]][code_climate]
6
+ [![Code Climate Coverage][code_climate_coverage_badge]][code_climate]
6
7
  [![RubyGems][gem_downloads_badge]][ruby_gems]
7
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
9
 
@@ -70,6 +71,13 @@ Supported color names:
70
71
  :black, :redish, :greenish, :yellowish, :blueish, :purpleish, :cyanish, :pale
71
72
  ```
72
73
 
74
+ Use `Object#ai` to return an ASCII encoded string:
75
+
76
+ ```ruby
77
+ irb> "awesome print".ai
78
+ => "\e[0;33m\"awesome print\"\e[0m"
79
+ ```
80
+
73
81
  ### Examples ###
74
82
 
75
83
  ```ruby
@@ -316,57 +324,9 @@ AwesomePrint.defaults = {
316
324
 
317
325
  AwesomePrint follows the [Semantic Versioning](http://semver.org/) standard.
318
326
 
319
- ### Running Specs ###
320
-
321
- $ gem install rspec # RSpec 2.x is the requirement.
322
- $ rake spec # Run the entire spec suite.
323
- $ rspec spec/logger_spec.rb # Run individual spec file.
324
-
325
- ### Note on Patches/Pull Requests ###
326
- * Fork the project on Github.
327
- * Make your feature addition or bug fix.
328
- * Add specs for it, making sure $ rake spec is all green.
329
- * Commit, do not mess with rakefile, version, or history.
330
- * Send commit URL (*do not* send pull requests).
331
-
332
- ### Contributors ###
333
- Special thanks goes to awesome team of contributors, namely:
334
-
335
- * 6fusion.com -- https://github.com/6fusion
336
- * Adam Doppelt -- https://github.com/gurgeous
337
- * Andrew O'Brien -- https://github.com/AndrewO
338
- * Andrew Horsman -- https://github.com/basicxman
339
- * Barry Allard -- https://github.com/steakknife
340
- * Benoit Daloze -- http://github.com/eregon
341
- * Brandon Zylstra -- https://github.com/brandondrew
342
- * Dan Lynn -- https://github.com/danlynn
343
- * Daniel Johnson -- https://github.com/adhd360
344
- * Daniel Bretoi -- http://github.com/danielb2
345
- * Eloy Duran -- http://github.com/alloy
346
- * Elpizo Choi -- https://github.com/fuJiin
347
- * Evan Senter -- https://github.com/evansenter
348
- * George . -- https://github.com/gardelea
349
- * Greg Weber -- https://github.com/gregwebs
350
- * Jan Vansteenkiste -- https://github.com/vStone
351
- * Jeff Felchner -- https://github.com/jfelchner
352
- * Jonathan Davies -- send your Github URL ;-)
353
- * Kevin Olbrich -- https://github.com/olbrich
354
- * Matthew Schulkind -- https://github.com/mschulkind
355
- * Mike McQuaid -- https://github.com/mikemcquaid
356
- * Nami-Doc -- https://github.com/Nami-Doc
357
- * Nicolas Viennot -- https://github.com/nviennot
358
- * Nikolaj Nikolajsen -- https://github.com/nikolajsen
359
- * Richard Hall -- https://github.com/richardardrichard
360
- * Ryan Schlesinger -- https://github.com/ryansch
361
- * Scott Hyndman -- https://github.com/shyndman
362
- * Sean Gallagher -- http://github.com/torandu
363
- * Stephan Hagemann -- https://github.com/shageman
364
- * Tim Harper -- http://github.com/timcharper
365
- * Tobias Crawley -- http://github.com/tobias
366
- * Thibaut Barrère -- https://github.com/thbar
367
- * Trevor Wennblom -- https://github.com/trevor
368
- * vfrride -- https://github.com/vfrride
369
- * Viktar Basharymau -- https://github.com/DNNX
327
+ ### Contributing ###
328
+ See [Contributing.md](https://github.com/michaeldv/awesome_print/blob/master/CONTRIBUTING.md)
329
+ for information.
370
330
 
371
331
  ### License ###
372
332
  Copyright (c) 2010-2013 Michael Dvorkin
@@ -381,6 +341,7 @@ Released under the MIT license. See LICENSE file for details.
381
341
  [gem_downloads_badge]: http://img.shields.io/gem/dt/awesome_print.svg?style=flat
382
342
  [ruby_gems]: http://rubygems.org/gems/awesome_print
383
343
  [travis_ci]: http://travis-ci.org/michaeldv/awesome_print
384
- [travis_ci_badge]: https://img.shields.io/travis/michaeldv/awesome_print.svg?style=flat
344
+ [travis_ci_badge]: https://img.shields.io/travis/michaeldv/awesome_print/master.svg?style=flat
385
345
  [code_climate]: https://codeclimate.com/github/michaeldv/awesome_print
386
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
@@ -25,7 +25,7 @@ unless defined?(AwesomePrint::Inspector)
25
25
  #
26
26
  # Load remaining extensions.
27
27
  #
28
- if defined?(ActiveSupport)
28
+ if defined?(ActiveSupport.on_load)
29
29
  ActiveSupport.on_load(:action_view) do
30
30
  require File.dirname(__FILE__) + "/awesome_print/ext/action_view"
31
31
  end
@@ -33,7 +33,7 @@ unless defined?(AwesomePrint::Inspector)
33
33
  require File.dirname(__FILE__) + "/awesome_print/ext/mongo_mapper" if defined?(MongoMapper)
34
34
  require File.dirname(__FILE__) + "/awesome_print/ext/mongoid" if defined?(Mongoid)
35
35
  require File.dirname(__FILE__) + "/awesome_print/ext/nokogiri" if defined?(Nokogiri)
36
- require File.dirname(__FILE__) + "/awesome_print/ext/no_brainer" if defined?(NoBrainer)
36
+ require File.dirname(__FILE__) + "/awesome_print/ext/nobrainer" if defined?(NoBrainer)
37
37
  require File.dirname(__FILE__) + "/awesome_print/ext/ripple" if defined?(Ripple)
38
38
  require File.dirname(__FILE__) + "/awesome_print/ext/sequel" if defined?(Sequel)
39
39
  require File.dirname(__FILE__) + "/awesome_print/ext/ostruct" if defined?(OpenStruct)
@@ -0,0 +1,24 @@
1
+ autoload :CGI, "cgi"
2
+
3
+ module AwesomePrint
4
+ module Colorize
5
+
6
+ # Pick the color and apply it to the given string as necessary.
7
+ #------------------------------------------------------------------------------
8
+ def colorize(str, type)
9
+ str = CGI.escapeHTML(str) if options[:html]
10
+ if options[:plain] || !options[:color][type] || !inspector.colorize?
11
+ str
12
+ #
13
+ # Check if the string color method is defined by awesome_print and accepts
14
+ # html parameter or it has been overriden by some gem such as colorize.
15
+ #
16
+ elsif str.method(options[:color][type]).arity == -1 # Accepts html parameter.
17
+ str.send(options[:color][type], options[:html])
18
+ else
19
+ str = %Q|<kbd style="color:#{options[:color][type]}">#{str}</kbd>| if options[:html]
20
+ str.send(options[:color][type])
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,49 @@
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_nobrainer, :cast
11
+ base.send :alias_method, :cast, :cast_with_nobrainer
12
+ end
13
+
14
+ # Add NoBrainer class names to the dispatcher pipeline.
15
+ #------------------------------------------------------------------------------
16
+ def cast_with_nobrainer(object, type)
17
+ cast = cast_without_nobrainer(object, type)
18
+ if defined?(::NoBrainer::Document)
19
+ if object.is_a?(Class) && object < ::NoBrainer::Document
20
+ cast = :nobrainer_class
21
+ elsif object.is_a?(::NoBrainer::Document)
22
+ cast = :nobrainer_document
23
+ end
24
+ end
25
+ cast
26
+ end
27
+
28
+ # Format NoBrainer class object.
29
+ #------------------------------------------------------------------------------
30
+ def awesome_nobrainer_class(object)
31
+ data = Hash[object.fields.map do |field, options|
32
+ [field, (options[:type] || Object).to_s.underscore.to_sym]
33
+ end]
34
+ "class #{object} < #{object.superclass} " << awesome_hash(data)
35
+ end
36
+
37
+ # Format NoBrainer Document object.
38
+ #------------------------------------------------------------------------------
39
+ def awesome_nobrainer_document(object)
40
+ data = object.inspectable_attributes.symbolize_keys
41
+ if object.errors.present?
42
+ data = {:errors => object.errors, :attributes => data}
43
+ end
44
+ "#{object} #{awesome_hash(data)}"
45
+ end
46
+ end
47
+ end
48
+
49
+ AwesomePrint::Formatter.send(:include, AwesomePrint::NoBrainer)