awesome_print 1.9.2 → 2.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -1
  3. data/Appraisals +2 -33
  4. data/CHANGELOG.md +6 -15
  5. data/CONTRIBUTING.md +0 -1
  6. data/README.md +7 -49
  7. data/lib/ap.rb +1 -5
  8. data/lib/awesome_print.rb +7 -29
  9. data/lib/awesome_print/colorize.rb +2 -0
  10. data/lib/awesome_print/core_ext/active_support.rb +7 -0
  11. data/lib/awesome_print/core_ext/awesome_method_array.rb +0 -6
  12. data/lib/awesome_print/core_ext/class.rb +0 -5
  13. data/lib/awesome_print/core_ext/kernel.rb +0 -5
  14. data/lib/awesome_print/core_ext/logger.rb +0 -5
  15. data/lib/awesome_print/core_ext/object.rb +0 -5
  16. data/lib/awesome_print/core_ext/string.rb +0 -5
  17. data/lib/awesome_print/custom_defaults.rb +1 -1
  18. data/lib/awesome_print/formatter.rb +38 -106
  19. data/lib/awesome_print/formatters/array_formatter.rb +11 -8
  20. data/lib/awesome_print/formatters/base_formatter.rb +20 -53
  21. data/lib/awesome_print/formatters/bigdecimal_formatter.rb +20 -0
  22. data/lib/awesome_print/formatters/class_formatter.rb +5 -6
  23. data/lib/awesome_print/formatters/dir_formatter.rb +4 -6
  24. data/lib/awesome_print/formatters/ext/active_model_error_formatter.rb +44 -0
  25. data/lib/awesome_print/formatters/ext/active_record_attributeset_formatter.rb +27 -0
  26. data/lib/awesome_print/formatters/ext/active_record_class_formatter.rb +43 -0
  27. data/lib/awesome_print/formatters/ext/active_record_instance_formatter.rb +48 -0
  28. data/lib/awesome_print/formatters/ext/active_record_relation_formatter.rb +19 -0
  29. data/lib/awesome_print/formatters/ext/bson_objectid_formatter.rb +20 -0
  30. data/lib/awesome_print/formatters/ext/hash_with_indifferent_access_formatter.rb +20 -0
  31. data/lib/awesome_print/formatters/ext/mongoid_document_formatter.rb +59 -0
  32. data/lib/awesome_print/formatters/ext/nokogiri_document_formatter.rb +30 -0
  33. data/lib/awesome_print/formatters/ext/nokogiri_node_formatter.rb +29 -0
  34. data/lib/awesome_print/formatters/ext/nokogiri_nodeset_formatter.rb +32 -0
  35. data/lib/awesome_print/formatters/ext/sequel_dataset_formatter.rb +20 -0
  36. data/lib/awesome_print/formatters/ext/sequel_model_class_formatter.rb +25 -0
  37. data/lib/awesome_print/formatters/ext/sequel_model_formatter.rb +26 -0
  38. data/lib/awesome_print/formatters/ext/time_with_zone_formatter.rb +24 -0
  39. data/lib/awesome_print/formatters/fallback_formatter.rb +55 -0
  40. data/lib/awesome_print/formatters/false_class_formatter.rb +15 -0
  41. data/lib/awesome_print/formatters/file_formatter.rb +4 -6
  42. data/lib/awesome_print/formatters/hash_formatter.rb +12 -7
  43. data/lib/awesome_print/formatters/integer_formatter.rb +11 -0
  44. data/lib/awesome_print/formatters/method_formatter.rb +8 -6
  45. data/lib/awesome_print/formatters/module_formatter.rb +18 -0
  46. data/lib/awesome_print/formatters/nil_class_formatter.rb +19 -0
  47. data/lib/awesome_print/formatters/object_formatter.rb +19 -9
  48. data/lib/awesome_print/formatters/open_struct.rb +19 -0
  49. data/lib/awesome_print/formatters/range_formatter.rb +11 -0
  50. data/lib/awesome_print/formatters/rational_formatter.rb +15 -0
  51. data/lib/awesome_print/formatters/set_formatter.rb +19 -0
  52. data/lib/awesome_print/formatters/simple_formatter.rb +10 -8
  53. data/lib/awesome_print/formatters/string_formatter.rb +14 -0
  54. data/lib/awesome_print/formatters/struct_formatter.rb +8 -6
  55. data/lib/awesome_print/formatters/symbol_formatter.rb +18 -0
  56. data/lib/awesome_print/formatters/true_class_formatter.rb +15 -0
  57. data/lib/awesome_print/formatters/unbound_method_formatter.rb +15 -0
  58. data/lib/awesome_print/inspector.rb +18 -17
  59. data/lib/awesome_print/limiter.rb +63 -0
  60. data/lib/awesome_print/registrar.rb +20 -0
  61. data/lib/awesome_print/version.rb +6 -6
  62. data/spec/formatters/array_spec.rb +251 -0
  63. data/spec/formatters/big_decimal_spec.rb +28 -0
  64. data/spec/formatters/class_spec.rb +91 -0
  65. data/spec/formatters/dir_file_spec.rb +43 -0
  66. data/spec/{ext → formatters/ext}/active_record_spec.rb +14 -58
  67. data/spec/{ext → formatters/ext}/active_support_spec.rb +7 -11
  68. data/spec/{ext → formatters/ext}/mongoid_spec.rb +2 -2
  69. data/spec/{ext → formatters/ext}/nokogiri_spec.rb +0 -0
  70. data/spec/formatters/hash_spec.rb +284 -0
  71. data/spec/{methods_spec.rb → formatters/methods_spec.rb} +3 -5
  72. data/spec/{objects_spec.rb → formatters/objects_spec.rb} +0 -0
  73. data/spec/{ext → formatters}/ostruct_spec.rb +1 -0
  74. data/spec/formatters/set_spec.rb +49 -0
  75. data/spec/formatters/struct_spec.rb +61 -0
  76. data/spec/merge_options_spec.rb +13 -0
  77. data/spec/misc_spec.rb +3 -10
  78. data/spec/spec_helper.rb +2 -9
  79. data/spec/support/ext_verifier.rb +0 -15
  80. data/spec/support/mongoid_versions.rb +4 -8
  81. data/spec/support/rails_versions.rb +2 -32
  82. metadata +100 -78
  83. data/awesome_print.gemspec +0 -33
  84. data/init.rb +0 -1
  85. data/lib/awesome_print/core_ext/method.rb +0 -21
  86. data/lib/awesome_print/ext/action_view.rb +0 -22
  87. data/lib/awesome_print/ext/active_record.rb +0 -103
  88. data/lib/awesome_print/ext/active_support.rb +0 -47
  89. data/lib/awesome_print/ext/mongo_mapper.rb +0 -124
  90. data/lib/awesome_print/ext/mongoid.rb +0 -67
  91. data/lib/awesome_print/ext/nobrainer.rb +0 -52
  92. data/lib/awesome_print/ext/nokogiri.rb +0 -45
  93. data/lib/awesome_print/ext/ostruct.rb +0 -27
  94. data/lib/awesome_print/ext/ripple.rb +0 -71
  95. data/lib/awesome_print/ext/sequel.rb +0 -58
  96. data/spec/ext/action_view_spec.rb +0 -21
  97. data/spec/ext/mongo_mapper_spec.rb +0 -261
  98. data/spec/ext/nobrainer_spec.rb +0 -59
  99. data/spec/ext/ripple_spec.rb +0 -48
  100. data/spec/formats_spec.rb +0 -779
  101. data/spec/support/active_record_data/3_2_diana.txt +0 -24
  102. data/spec/support/active_record_data/3_2_diana_legacy.txt +0 -24
  103. data/spec/support/active_record_data/3_2_multi.txt +0 -50
  104. data/spec/support/active_record_data/3_2_multi_legacy.txt +0 -50
  105. data/spec/support/active_record_data/4_0_diana.txt +0 -98
  106. data/spec/support/active_record_data/4_0_multi.txt +0 -198
  107. data/spec/support/active_record_data/4_1_diana.txt +0 -97
  108. data/spec/support/active_record_data/4_1_multi.txt +0 -196
  109. data/spec/support/active_record_data/4_2_diana.txt +0 -109
  110. data/spec/support/active_record_data/4_2_diana_legacy.txt +0 -109
  111. data/spec/support/active_record_data/4_2_multi.txt +0 -220
  112. data/spec/support/active_record_data/4_2_multi_legacy.txt +0 -220
  113. data/spec/support/active_record_data/6_0_diana.txt +0 -104
  114. data/spec/support/active_record_data/6_0_multi.txt +0 -210
  115. data/spec/support/active_record_data/6_1_diana.txt +0 -109
  116. data/spec/support/active_record_data/6_1_multi.txt +0 -220
@@ -3,16 +3,19 @@ require_relative 'base_formatter'
3
3
  module AwesomePrint
4
4
  module Formatters
5
5
  class ArrayFormatter < BaseFormatter
6
- attr_reader :array, :inspector, :options
7
6
 
8
- def initialize(array, inspector)
9
- @array = array
10
- @inspector = inspector
11
- @options = inspector.options
7
+ formatter_for :array
8
+
9
+ def self.formattable?(object)
10
+ object.is_a?(Array)
12
11
  end
13
12
 
14
- def format
15
- if array.length.zero?
13
+ attr_reader :array
14
+
15
+ def format(object)
16
+ @array = object
17
+
18
+ if object.length.zero?
16
19
  '[]'
17
20
  elsif methods_array?
18
21
  methods_array
@@ -31,7 +34,7 @@ module AwesomePrint
31
34
  if options[:multiline]
32
35
  multiline_array
33
36
  else
34
- "[ #{array.map { |item| inspector.awesome(item) }.join(', ')} ]"
37
+ '[ ' << array.map { |item| inspector.awesome(item) }.join(', ') << ' ]'
35
38
  end
36
39
  end
37
40
 
@@ -1,67 +1,33 @@
1
1
  require_relative '../colorize'
2
+ require_relative '../limiter'
3
+ require_relative '../registrar'
2
4
 
3
5
  module AwesomePrint
4
6
  module Formatters
5
7
  class BaseFormatter
8
+
6
9
  include Colorize
10
+ include Registrar
11
+ include Limiter
7
12
 
8
- DEFAULT_LIMIT_SIZE = 7
13
+ attr_reader :object, :inspector, :options
9
14
 
10
- # To support limited output, for example:
11
- #
12
- # ap ('a'..'z').to_a, :limit => 3
13
- # [
14
- # [ 0] "a",
15
- # [ 1] .. [24],
16
- # [25] "z"
17
- # ]
18
- #
19
- # ap (1..100).to_a, :limit => true # Default limit is 7.
20
- # [
21
- # [ 0] 1,
22
- # [ 1] 2,
23
- # [ 2] 3,
24
- # [ 3] .. [96],
25
- # [97] 98,
26
- # [98] 99,
27
- # [99] 100
28
- # ]
29
- #------------------------------------------------------------------------------
30
- def should_be_limited?
31
- options[:limit] or (options[:limit].is_a?(Integer) and options[:limit] > 0)
15
+ def self.formattable?(obj)
16
+ false
32
17
  end
33
18
 
34
- def get_limit_size
35
- case options[:limit]
36
- when true
37
- DEFAULT_LIMIT_SIZE
38
- else
39
- options[:limit]
40
- end
19
+ def self.core?
20
+ false
41
21
  end
42
22
 
43
- def limited(data, width, is_hash = false)
44
- limit = get_limit_size
45
- if data.length <= limit
46
- data
47
- else
48
- # Calculate how many elements to be displayed above and below the separator.
49
- head = limit / 2
50
- tail = head - (limit - 1) % 2
51
-
52
- # Add the proper elements to the temp array and format the separator.
53
- temp = data[0, head] + [nil] + data[-tail, tail]
54
-
55
- temp[head] = if is_hash
56
- "#{indent}#{data[head].strip} .. #{data[data.length - tail - 1].strip}"
57
- else
58
- "#{indent}[#{head.to_s.rjust(width)}] .. [#{data.length - tail - 1}]"
59
- end
60
-
61
- temp
62
- end
23
+ def initialize(inspector)
24
+ @inspector = inspector
25
+ @options = inspector.options
63
26
  end
64
27
 
28
+ def format(object)
29
+ raise NotImplementedError
30
+ end
65
31
 
66
32
  def method_tuple(method)
67
33
  if method.respond_to?(:parameters) # Ruby 1.9.2+
@@ -90,7 +56,7 @@ module AwesomePrint
90
56
  # #<Method: User(id: integer, username: string)(ActiveRecord::Base).current>
91
57
  # #<UnboundMethod: Hello#world>
92
58
  #
93
- if method.to_s =~ /(Unbound)*Method: (.*?)[#\.]/
59
+ if method.to_s =~ /(Unbound)*Method: (.*)[#\.]/
94
60
  unbound = $1 && '(unbound)'
95
61
  klass = $2
96
62
  if klass && klass =~ /(\(\w+:\s.*?\))/ # Is this ActiveRecord-style class?
@@ -104,13 +70,14 @@ module AwesomePrint
104
70
 
105
71
  #
106
72
  # Indentation related methods
73
+ # FIXME: move to Indentator?...
107
74
  #-----------------------------------------
108
75
  def indentation
109
76
  inspector.current_indentation
110
77
  end
111
78
 
112
- def indented(&block)
113
- inspector.increase_indentation(&block)
79
+ def indented
80
+ inspector.increase_indentation(&Proc.new)
114
81
  end
115
82
 
116
83
  def indent
@@ -0,0 +1,20 @@
1
+ require_relative 'base_formatter'
2
+ require 'bigdecimal'
3
+
4
+ module AwesomePrint
5
+ module Formatters
6
+ class BigdecimalFormatter < BaseFormatter
7
+
8
+ formatter_for :bigdecimal
9
+
10
+ def self.formattable?(object)
11
+ object.is_a?(BigDecimal)
12
+ end
13
+
14
+ def format(object)
15
+ colorize(object.to_s('F'), self.class.formatted_object_type)
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -4,16 +4,15 @@ module AwesomePrint
4
4
  module Formatters
5
5
  class ClassFormatter < BaseFormatter
6
6
 
7
- attr_reader :klass, :inspector, :options
7
+ formatter_for :class
8
8
 
9
- def initialize(klass, inspector)
10
- @klass = klass
11
- @inspector = inspector
12
- @options = inspector.options
9
+ def self.formattable?(object)
10
+ object.is_a?(Class)
13
11
  end
14
12
 
15
- def format
13
+ def format(klass)
16
14
  superclass = klass.superclass
15
+
17
16
  if superclass
18
17
  colorize("#{klass.inspect} < #{superclass}", :class)
19
18
  else
@@ -5,15 +5,13 @@ module AwesomePrint
5
5
  module Formatters
6
6
  class DirFormatter < BaseFormatter
7
7
 
8
- attr_reader :dir, :inspector, :options
8
+ formatter_for :dir
9
9
 
10
- def initialize(dir, inspector)
11
- @dir = dir
12
- @inspector = inspector
13
- @options = inspector.options
10
+ def self.formattable?(object)
11
+ object.kind_of?(Dir)
14
12
  end
15
13
 
16
- def format
14
+ def format(dir)
17
15
  ls = `ls -alF #{dir.path.shellescape}`
18
16
  colorize(ls.empty? ? dir.inspect : "#{dir.inspect}\n#{ls.chop}", :dir)
19
17
  end
@@ -0,0 +1,44 @@
1
+ require_relative '../base_formatter'
2
+
3
+ module AwesomePrint
4
+ module Formatters
5
+ class ActiveModelErrorFormatter < BaseFormatter
6
+
7
+ formatter_for :active_model_error
8
+
9
+ def self.formattable?(object)
10
+ defined?(::ActiveModel) && object.is_a?(::ActiveModel::Errors)
11
+ end
12
+
13
+ def format(object)
14
+ if @options[:raw]
15
+ return Formatters::ObjectFormatter.new(@inspector).format(object)
16
+ end
17
+
18
+ if !defined?(::ActiveSupport::OrderedHash)
19
+ return Formatters::SimpleFormatter.new(@inspector).format(object.inspect)
20
+ end
21
+
22
+ object_dump = object.marshal_dump.first
23
+
24
+ if object_dump.class.column_names != object_dump.attributes.keys
25
+ data = object_dump.attributes
26
+ else
27
+ data = object_dump.class.column_names.inject(::ActiveSupport::OrderedHash.new) do |hash, name|
28
+
29
+ if object_dump.has_attribute?(name) || object_dump.new_record?
30
+ value = object_dump.respond_to?(name) ? object_dump.send(name) : object_dump.read_attribute(name)
31
+ hash[name.to_sym] = value
32
+ end
33
+ hash
34
+ end
35
+ end
36
+
37
+ data.merge!({details: object.details, messages: object.messages})
38
+
39
+ "#{object} " << Formatters::HashFormatter.new(@inspector).format(data)
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,27 @@
1
+ require_relative '../base_formatter'
2
+
3
+ module AwesomePrint
4
+ module Formatters
5
+ class ActiveRecordAttributesetFormatter < BaseFormatter
6
+
7
+ formatter_for :active_record_attributeset
8
+
9
+ def self.core?
10
+ false
11
+ end
12
+
13
+ def self.formattable?(object)
14
+ defined?(::ActiveRecord) &&
15
+ defined?(::ActiveRecord::AttributeSet) &&
16
+ object.is_a?(ActiveRecord::AttributeSet)
17
+ end
18
+
19
+ def format(object)
20
+ # simple formatter for now
21
+ Formatters::ObjectFormatter.new(@inspector).format(object)
22
+ end
23
+
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,43 @@
1
+ require_relative '../base_formatter'
2
+
3
+ module AwesomePrint
4
+ module Formatters
5
+ class ActiveRecordClassFormatter < BaseFormatter
6
+
7
+ formatter_for :activerecord_base_class
8
+
9
+ def self.formattable?(object)
10
+ defined?(::ActiveRecord) && object.is_a?(Class) &&
11
+ (object.superclass == ::ActiveRecord::Base ||
12
+ object.ancestors.include?(::ActiveRecord::Base))
13
+ end
14
+
15
+ def format(object)
16
+ if @options[:raw] || object.to_s == "ActiveRecord::Base"
17
+ return Formatters::ObjectFormatter.new(@inspector).format(object)
18
+ end
19
+
20
+ if object.respond_to?(:abstract_class?) && object.abstract_class?
21
+ return Formatters::ClassFormatter.new(@inspector).format(object)
22
+ end
23
+
24
+ if !defined?(::ActiveSupport::OrderedHash) || !object.respond_to?(:columns)
25
+ return Formatters::SimpleFormatter.new(@inspector).format(object.inspect)
26
+ end
27
+
28
+ data = object.columns.inject(::ActiveSupport::OrderedHash.new) do |hash, c|
29
+ hash[c.name.to_sym] = c.type
30
+ hash
31
+ end
32
+
33
+ [
34
+ "class #{colorize(object.to_s, :class)}",
35
+ "< #{colorize(object.superclass.to_s, :class)}",
36
+ Formatters::HashFormatter.new(@inspector).format(data)
37
+ ].join(' ')
38
+
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,48 @@
1
+ require_relative '../base_formatter'
2
+
3
+ module AwesomePrint
4
+ module Formatters
5
+ class ActiveRecordInstanceFormatter < BaseFormatter
6
+
7
+ formatter_for :active_record_instance
8
+
9
+ def self.formattable?(object)
10
+ defined?(::ActiveRecord) && object.is_a?(::ActiveRecord::Base)
11
+ end
12
+
13
+ # Format ActiveRecord instance object.
14
+ #
15
+ # NOTE: by default only instance attributes (i.e. columns) are shown. To format
16
+ # ActiveRecord instance as regular object showing its instance variables and
17
+ # accessors use :raw => true option:
18
+ #
19
+ # ap record, :raw => true
20
+ #
21
+ #------------------------------------------------------------------------------
22
+ def format(object)
23
+ if @options[:raw]
24
+ return Formatters::ObjectFormatter.new(@inspector).format(object)
25
+ end
26
+
27
+ if !defined?(::ActiveSupport::OrderedHash)
28
+ return Formatters::SimpleFormatter.new(@inspector).format(object.inspect)
29
+ end
30
+
31
+ if object.class.column_names != object.attributes.keys
32
+ data = object.attributes
33
+ else
34
+ data = object.class.column_names.inject(::ActiveSupport::OrderedHash.new) do |hash, name|
35
+ if object.has_attribute?(name) || object.new_record?
36
+ value = object.respond_to?(name) ? object.send(name) : object.read_attribute(name)
37
+ hash[name.to_sym] = value
38
+ end
39
+ hash
40
+ end
41
+ end
42
+
43
+ "#{object} " << Formatters::HashFormatter.new(@inspector).format(data)
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,19 @@
1
+ require_relative '../array_formatter'
2
+
3
+ module AwesomePrint
4
+ module Formatters
5
+ class ActiveRecordRelationFormatter < ArrayFormatter
6
+
7
+ formatter_for :active_record_relation
8
+
9
+ def self.core?
10
+ false
11
+ end
12
+
13
+ def self.formattable?(object)
14
+ defined?(::ActiveRecord) && object.class.ancestors.include?(::ActiveRecord::Relation)
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ require_relative '../base_formatter'
2
+
3
+ module AwesomePrint
4
+ module Formatters
5
+ class BsonObjectidFormatter < BaseFormatter
6
+
7
+ formatter_for :bson_objectid
8
+
9
+ def self.formattable?(object)
10
+ (defined?(::BSON) && object.is_a?(::BSON::ObjectId)) ||
11
+ (defined?(::Moped::BSON) && object.is_a?(::Moped::BSON::ObjectId))
12
+ end
13
+
14
+ def format(object)
15
+ colorize(object.inspect, self.class.formatted_object_type)
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require_relative '../hash_formatter'
2
+
3
+ module AwesomePrint
4
+ module Formatters
5
+ class HashWithIndifferentAccessFormatter < HashFormatter
6
+
7
+ formatter_for :hash_with_indifferent_access
8
+
9
+ def self.core?
10
+ false
11
+ end
12
+
13
+ def self.formattable?(object)
14
+ defined?(::HashWithIndifferentAccess) &&
15
+ object.is_a?(::HashWithIndifferentAccess)
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,59 @@
1
+ require_relative '../base_formatter'
2
+
3
+ module AwesomePrint
4
+ module Formatters
5
+ class MongoidDocument < BaseFormatter
6
+
7
+ formatter_for :mongoid_document
8
+
9
+ def self.formattable?(object)
10
+ defined?(::Mongoid::Document) &&
11
+ (object.class.ancestors.include?(::Mongoid::Document) ||
12
+ (object.respond_to?(:ancestors) && object.ancestors.include?(::Mongoid::Document)))
13
+ end
14
+
15
+ def format(object)
16
+ unless defined?(::ActiveSupport::OrderedHash)
17
+ return Formatters::SimpleFormatter.new(@inspector).format(object.inspect)
18
+ end
19
+
20
+ if object.is_a?(Class)
21
+ puts "[MGD] formatting #{object} as class..." if AwesomePrint.debug
22
+ # mongoid class
23
+ format_as_class(object)
24
+ else
25
+ puts "[MGD] formatting #{object} as instance..." if AwesomePrint.debug
26
+ format_as_instance(object)
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ def format_as_class(object)
33
+ data = object.fields.sort_by { |key| key }.inject(::ActiveSupport::OrderedHash.new) do |hash, c|
34
+ hash[c[1].name.to_sym] = (c[1].type || 'undefined').to_s.underscore.to_sym
35
+ hash
36
+ end
37
+
38
+ [
39
+ "class #{colorize(object.to_s, :class)}",
40
+ "< #{colorize(object.superclass.to_s, :class)}",
41
+ Formatters::HashFormatter.new(@inspector).format(data)
42
+ ].join(' ')
43
+ end
44
+
45
+ def format_as_instance(object)
46
+ data = (object.attributes || {}).sort_by { |key| key }.inject(::ActiveSupport::OrderedHash.new) do |hash, c|
47
+ hash[c[0].to_sym] = c[1]
48
+ hash
49
+ end
50
+
51
+ data = { errors: object.errors, attributes: data } if !object.errors.empty?
52
+
53
+ "#{object} #{Formatters::HashFormatter.new(@inspector).format(data)}"
54
+ end
55
+
56
+ end
57
+ end
58
+ end
59
+