amazing_print 1.5.0 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +68 -38
  3. data/README.md +2 -2
  4. data/lib/amazing_print/core_ext/awesome_method_array.rb +1 -1
  5. data/lib/amazing_print/custom_defaults.rb +7 -1
  6. data/lib/amazing_print/ext/active_record.rb +32 -2
  7. data/lib/amazing_print/ext/mongoid.rb +14 -2
  8. data/lib/amazing_print/ext/nobrainer.rb +2 -2
  9. data/lib/amazing_print/ext_loader.rb +27 -0
  10. data/lib/amazing_print/formatters/base_formatter.rb +12 -3
  11. data/lib/amazing_print/formatters/hash_formatter.rb +28 -11
  12. data/lib/amazing_print/formatters/mswin_helper.rb +4 -4
  13. data/lib/amazing_print/formatters/object_formatter.rb +1 -1
  14. data/lib/amazing_print/formatters/struct_formatter.rb +1 -1
  15. data/lib/amazing_print/inspector.rb +6 -3
  16. data/lib/amazing_print/version.rb +1 -1
  17. data/lib/amazing_print.rb +2 -8
  18. metadata +7 -61
  19. data/.gitignore +0 -35
  20. data/Appraisals +0 -50
  21. data/Gemfile +0 -15
  22. data/Gemfile.lock +0 -83
  23. data/LICENSE +0 -22
  24. data/Rakefile +0 -25
  25. data/spec/active_record_helper.rb +0 -43
  26. data/spec/colors_spec.rb +0 -120
  27. data/spec/core_ext/logger_spec.rb +0 -70
  28. data/spec/ext/action_controller_spec.rb +0 -40
  29. data/spec/ext/action_view_spec.rb +0 -24
  30. data/spec/ext/active_model_spec.rb +0 -37
  31. data/spec/ext/active_record_spec.rb +0 -298
  32. data/spec/ext/active_support_spec.rb +0 -37
  33. data/spec/ext/mongo_mapper_spec.rb +0 -265
  34. data/spec/ext/mongoid_spec.rb +0 -72
  35. data/spec/ext/nobrainer_spec.rb +0 -64
  36. data/spec/ext/nokogiri_spec.rb +0 -52
  37. data/spec/ext/ostruct_spec.rb +0 -24
  38. data/spec/ext/ripple_spec.rb +0 -53
  39. data/spec/ext/sequel_spec.rb +0 -45
  40. data/spec/formats_spec.rb +0 -792
  41. data/spec/methods_spec.rb +0 -520
  42. data/spec/misc_spec.rb +0 -206
  43. data/spec/objects_spec.rb +0 -225
  44. data/spec/sequel_helper.rb +0 -18
  45. data/spec/spec_helper.rb +0 -112
  46. data/spec/support/active_record_data/3_2_diana.txt +0 -24
  47. data/spec/support/active_record_data/3_2_diana_legacy.txt +0 -24
  48. data/spec/support/active_record_data/3_2_multi.txt +0 -50
  49. data/spec/support/active_record_data/3_2_multi_legacy.txt +0 -50
  50. data/spec/support/active_record_data/4_0_diana.txt +0 -98
  51. data/spec/support/active_record_data/4_0_multi.txt +0 -198
  52. data/spec/support/active_record_data/4_1_diana.txt +0 -97
  53. data/spec/support/active_record_data/4_1_multi.txt +0 -196
  54. data/spec/support/active_record_data/4_2_diana.txt +0 -109
  55. data/spec/support/active_record_data/4_2_diana_legacy.txt +0 -109
  56. data/spec/support/active_record_data/4_2_multi.txt +0 -220
  57. data/spec/support/active_record_data/4_2_multi_legacy.txt +0 -220
  58. data/spec/support/active_record_data/5_0_diana.txt +0 -105
  59. data/spec/support/active_record_data/5_0_multi.txt +0 -212
  60. data/spec/support/active_record_data/5_1_diana.txt +0 -104
  61. data/spec/support/active_record_data/5_1_multi.txt +0 -210
  62. data/spec/support/active_record_data/5_2_diana.txt +0 -104
  63. data/spec/support/active_record_data/5_2_multi.txt +0 -210
  64. data/spec/support/active_record_data/6_0_diana.txt +0 -104
  65. data/spec/support/active_record_data/6_0_multi.txt +0 -210
  66. data/spec/support/active_record_data/6_1_diana.txt +0 -109
  67. data/spec/support/active_record_data/6_1_multi.txt +0 -220
  68. data/spec/support/active_record_data.rb +0 -22
  69. data/spec/support/ext_verifier.rb +0 -46
  70. data/spec/support/mongoid_versions.rb +0 -24
  71. data/spec/support/rails_versions.rb +0 -57
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d771d603c88c997bca4379eba3dc4cd794994e5810edb0859ad5c47c3b2590c
4
- data.tar.gz: 87ea8f90780f57731ad4cff0bfbce9eb2d837681829979bd23e839f62415a1b0
3
+ metadata.gz: 1936b7b4ca5adfa821918412efe3e0dee3ac1bfc82f27c07374169b212fe6014
4
+ data.tar.gz: 40c690d728938fbc4e2e46bde9189007acedecea5b43736ca5d1a5dbc59c5deb
5
5
  SHA512:
6
- metadata.gz: d1d1d0eb8ca306adbf3af3eec93d9cbb3fa6a47f1ad0e3b836d473bc4a0595be02dcd27af60de86a3f524bb373e5e0d2b9053f6b40dfac437add803dc075a315
7
- data.tar.gz: 3c74f2a0333fad6e5c34b5209124767b931d56c88423960f55945b694e27dadd41636259f7a1a395e64d4971887c2d1f095b64714acd525748dae5423d670872
6
+ metadata.gz: 2e406d97f347bab6f9cd2ece415bc15a1edc0d0f655d08c4f09e21802f293b5f94199f81a0fa3b80857307b0988688eb5a940da6ec1cb79e6583334db5d6b704
7
+ data.tar.gz: d6f5ec436363f8ea1c48e5db11ff6ca62b3198d82be5b33dd949e98d0e700c7735c4b624a36f176cd1c5a08a2785047bfcaad0ea12f674d7138a4a32fb699861
data/CHANGELOG.md CHANGED
@@ -1,58 +1,88 @@
1
- ## Unreleased
1
+ # CHANGELOG
2
+
3
+ ## v1.7.2
4
+
5
+ - update the version string in `AmazingPrint.version`
6
+
7
+ ## v1.7.1
8
+
9
+ - no changes, only linting
10
+
11
+ ## v1.7.0
12
+
13
+ - Require Ruby >= 3.0
14
+ - Add support for `::ActiveModel::Attributes`
15
+ - Preserve user defined color defaults
16
+ - Micro-optimization to `AmazingPrint::ActiveRecord#cast` (avoid calls to `#ancestors`)
17
+
18
+ ## v1.6.0
19
+
20
+ - Use pager with Pry #96
21
+ - Add Rails 7 appraisal #98
22
+ - Allow Hash keys to be colorized #99
23
+ - Use CI merge queue #104
24
+ - Add support for Ruby 3.3 #105
25
+ - Add Mongoid field aliases #106
26
+ - Add bigdecimal gem #109
27
+ - Add ExtLoader to help with require order issues #110
2
28
 
3
29
  ## v1.5.0
4
- - Drop support for Ruby 2.3 and 2.4 as well as JRuby 9.1
5
- - Add File/Dir formatters for mswin platform #48
6
- - Don't monkey patch String class #91
7
- - Fix ruby19 hash syntax so it can be copy-pasted #94
30
+
31
+ - Drop support for Ruby 2.3 and 2.4 as well as JRuby 9.1
32
+ - Add File/Dir formatters for mswin platform #48
33
+ - Don't monkey patch String class #91
34
+ - Fix ruby19 hash syntax so it can be copy-pasted #94
8
35
 
9
36
  ## v1.4.0
10
- - Support loading config from `$XDG_CONFIG_HOME/aprc` - #63
11
- - Remove support for Rails 5.1 #75
12
- - Update AR specs for Ruby 2.6.7 #76
13
- - Load .aprc configs only once. #74
14
- - Add XDG config support #77
15
- - Rubocop updates #79
16
- - Update Irb integration for v1.2.6+ #81
37
+
38
+ - Support loading config from `$XDG_CONFIG_HOME/aprc` - #63
39
+ - Remove support for Rails 5.1 #75
40
+ - Update AR specs for Ruby 2.6.7 #76
41
+ - Load .aprc configs only once. #74
42
+ - Add XDG config support #77
43
+ - Rubocop updates #79
44
+ - Update Irb integration for v1.2.6+ #81
17
45
 
18
46
  ## v1.3.0
19
- - Fix HTML escaping problems #53
20
- - Update test suite for Ruby 2.7.2 and JRuby #61
21
- - Add ActionView spec for html_safe #65
22
- - Add support for Rails 6.1 #68
23
- - Update specs for Ruby 3.0 #69
47
+
48
+ - Fix HTML escaping problems #53
49
+ - Update test suite for Ruby 2.7.2 and JRuby #61
50
+ - Add ActionView spec for html_safe #65
51
+ - Add support for Rails 6.1 #68
52
+ - Update specs for Ruby 3.0 #69
24
53
 
25
54
  ## v1.2.2
26
- - Support Ruby 3.0 / IRB 1.2.6 - #57
27
- - Fix FrozenError - #51
28
- - Drop support for Ruby 2.3 and 2.4 as well as JRuby 9.1 - #46
29
- - Add passing of `options` to `Logger#ap` - #55
55
+
56
+ - Support Ruby 3.0 / IRB 1.2.6 - #57
57
+ - Fix FrozenError - #51
58
+ - Drop support for Ruby 2.3 and 2.4 as well as JRuby 9.1 - #46
59
+ - Add passing of `options` to `Logger#ap` - #55
30
60
 
31
61
  ## v1.2.1
32
- - Correctly print active_model_errors for models that don't have tables - #42 by sahglie
33
- - Update AmazingPrint::MongoMapper for frozen strings - #44
34
62
 
35
- ## v1.2.0
63
+ - Correctly print active_model_errors for models that don't have tables - #42 by sahglie
64
+ - Update AmazingPrint::MongoMapper for frozen strings - #44
36
65
 
37
- - Fix frozen string literal issue with ActiveRecord
38
- - Add uncolor String method to remove ANSI color codes - #30 by duffyjp
39
- - Restore original copyright - #33 by amarshall
40
- - Remove method core extension since it is not needed since ruby 1.9 - #37 by grosser
41
- - Remove pale and black string color aliases - #38
42
- - Fix formatting ActionController::Parameters - #29
66
+ ## v1.2.0
43
67
 
68
+ - Fix frozen string literal issue with ActiveRecord
69
+ - Add uncolor String method to remove ANSI color codes - #30 by duffyjp
70
+ - Restore original copyright - #33 by amarshall
71
+ - Remove method core extension since it is not needed since ruby 1.9 - #37 by grosser
72
+ - Remove pale and black string color aliases - #38
73
+ - Fix formatting ActionController::Parameters - #29
44
74
 
45
75
  ## v1.1.0
46
- - Print out method keyword arguments
47
- - Fix NoMethodError with Sequel
48
- - Code cleanups
49
76
 
50
- Thanks for the great contributions from:
51
-
52
- - andydna
53
- - beanieboi
77
+ - Print out method keyword arguments
78
+ - Fix NoMethodError with Sequel
79
+ - Code cleanups
54
80
 
81
+ Thanks for the great contributions from:
55
82
 
83
+ - andydna
84
+ - beanieboi
56
85
 
57
86
  ## v1.0.0
58
- - Initial Release.
87
+
88
+ - Initial Release.
data/README.md CHANGED
@@ -315,11 +315,11 @@ formatting:
315
315
 
316
316
  <%= ap @accounts.first, :html => true %>
317
317
 
318
- ### String Convenience Methods ###
318
+ ### Colorizing Strings ###
319
319
  Use methods such as `.red` to set string color:
320
320
 
321
321
  ```ruby
322
- irb> puts "red text".red
322
+ irb> puts AmazingPrint::Colors.red("red text")
323
323
  red text # (it's red)
324
324
  ```
325
325
 
@@ -78,7 +78,7 @@ module AwesomeMethodArray # :nodoc:
78
78
  super(pattern)
79
79
  end
80
80
  arr.instance_variable_set(:@__awesome_methods__, instance_variable_get(:@__awesome_methods__))
81
- arr.select! { |item| (item.is_a?(Symbol) || item.is_a?(String)) } # grep block might return crap.
81
+ arr.select! { |item| item.is_a?(Symbol) || item.is_a?(String) } # grep block might return crap.
82
82
  arr
83
83
  end
84
84
  end
@@ -44,7 +44,13 @@ module AmazingPrint
44
44
  end
45
45
 
46
46
  def pry!
47
- Pry.print = proc { |output, value| output.puts value.ai } if defined?(Pry)
47
+ return unless defined?(Pry)
48
+
49
+ Pry.print = proc do |_output, value, pry_instance|
50
+ pry_instance.pager.open do |pager|
51
+ pager.print "#{value.ai}\n"
52
+ end
53
+ end
48
54
  end
49
55
 
50
56
  ##
@@ -20,11 +20,15 @@ module AmazingPrint
20
20
 
21
21
  if object.is_a?(::ActiveRecord::Base)
22
22
  cast = :active_record_instance
23
+ elsif object.is_a?(Class) && object.include?(::ActiveModel::Attributes)
24
+ cast = :active_model_class
25
+ elsif object.is_a?(::ActiveModel::Attributes)
26
+ cast = :active_model_instance
23
27
  elsif object.is_a?(::ActiveModel::Errors)
24
28
  cast = :active_model_error
25
- elsif object.is_a?(Class) && object.ancestors.include?(::ActiveRecord::Base)
29
+ elsif object.is_a?(Class) && object <= ::ActiveRecord::Base
26
30
  cast = :active_record_class
27
- elsif type == :activerecord_relation || object.class.ancestors.include?(::ActiveRecord::Relation)
31
+ elsif type == :activerecord_relation || object.is_a?(::ActiveRecord::Relation)
28
32
  cast = :array
29
33
  end
30
34
  cast
@@ -71,6 +75,32 @@ module AmazingPrint
71
75
  [awesome_simple("class #{object} < #{object.superclass}", :class), awesome_hash(data)].join(' ')
72
76
  end
73
77
 
78
+ # Format ActiveModel instance object.
79
+ #------------------------------------------------------------------------------
80
+ def awesome_active_model_instance(object)
81
+ return object.inspect unless defined?(::ActiveSupport::OrderedHash)
82
+ return awesome_object(object) if @options[:raw]
83
+
84
+ data = object.attributes.each_with_object(::ActiveSupport::OrderedHash.new) do |c, hash|
85
+ hash[c.first.to_sym] = c.last
86
+ end
87
+
88
+ [awesome_simple(object.to_s, :active_model_instance), awesome_hash(data)].join(' ')
89
+ end
90
+
91
+ # Format ActiveModel class object.
92
+ #------------------------------------------------------------------------------
93
+ def awesome_active_model_class(object)
94
+ return object.inspect unless defined?(::ActiveSupport::OrderedHash)
95
+ return awesome_class(object) if @options[:raw]
96
+
97
+ data = object.attribute_types.each_with_object(::ActiveSupport::OrderedHash.new) do |c, hash|
98
+ hash[c.first.to_sym] = c.last.type
99
+ end
100
+
101
+ [awesome_simple("class #{object} < #{object.superclass}", :class), awesome_hash(data)].join(' ')
102
+ end
103
+
74
104
  # Format ActiveModel error object.
75
105
  #------------------------------------------------------------------------------
76
106
  def awesome_active_model_error(object)
@@ -33,8 +33,14 @@ module AmazingPrint
33
33
  def awesome_mongoid_class(object)
34
34
  return object.inspect if !defined?(::ActiveSupport::OrderedHash) || !object.respond_to?(:fields)
35
35
 
36
+ aliases = object.aliased_fields.invert
36
37
  data = object.fields.sort.each_with_object(::ActiveSupport::OrderedHash.new) do |c, hash|
37
- hash[c[1].name.to_sym] = (c[1].type || 'undefined').to_s.underscore.intern
38
+ name = c[1].name
39
+ alias_name = aliases[name] unless name == '_id'
40
+ printed_name = alias_name ? "#{alias_name}(#{name})" : name
41
+
42
+ hash[printed_name.to_sym] = (c[1].type || 'undefined').to_s.underscore.intern
43
+ hash
38
44
  end
39
45
 
40
46
  name = "class #{awesome_simple(object.to_s, :class)}"
@@ -48,8 +54,14 @@ module AmazingPrint
48
54
  def awesome_mongoid_document(object)
49
55
  return object.inspect unless defined?(::ActiveSupport::OrderedHash)
50
56
 
57
+ aliases = object.aliased_fields.invert
51
58
  data = (object.attributes || {}).sort.each_with_object(::ActiveSupport::OrderedHash.new) do |c, hash|
52
- hash[c[0].to_sym] = c[1]
59
+ name = c[0]
60
+ alias_name = aliases[name] unless name == '_id'
61
+ printed_name = alias_name ? "#{alias_name}(#{name})" : name
62
+
63
+ hash[printed_name.to_sym] = c[1]
64
+ hash
53
65
  end
54
66
  data = { errors: object.errors, attributes: data } unless object.errors.empty?
55
67
  "#{object} #{awesome_hash(data)}"
@@ -32,9 +32,9 @@ module AmazingPrint
32
32
  #------------------------------------------------------------------------------
33
33
  def awesome_nobrainer_class(object)
34
34
  name = "#{awesome_simple(object, :class)} < #{awesome_simple(object.superclass, :class)}"
35
- data = object.fields.map do |field, options|
35
+ data = object.fields.to_h do |field, options|
36
36
  [field, (options[:type] || Object).to_s.underscore.to_sym]
37
- end.to_h
37
+ end
38
38
 
39
39
  name = "class #{awesome_simple(object.to_s, :class)}"
40
40
  base = "< #{awesome_simple(object.superclass.to_s, :class)}"
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AmazingPrint
4
+ ##
5
+ # Attempt to load extensions up to 3 times since this library may be required
6
+ # before dependencies that we have extensions for.
7
+ #
8
+ class ExtLoader
9
+ EXT_LOAD_ATTEMPT_LIMIT = 3
10
+
11
+ @load_attemps = 0
12
+
13
+ def self.call
14
+ return if @load_attemps >= EXT_LOAD_ATTEMPT_LIMIT
15
+
16
+ require_relative 'ext/mongo_mapper' if defined?(MongoMapper)
17
+ require_relative 'ext/mongoid' if defined?(Mongoid)
18
+ require_relative 'ext/nobrainer' if defined?(NoBrainer)
19
+ require_relative 'ext/nokogiri' if defined?(Nokogiri)
20
+ require_relative 'ext/ostruct' if defined?(OpenStruct) # rubocop:disable Style/OpenStructUse
21
+ require_relative 'ext/ripple' if defined?(Ripple)
22
+ require_relative 'ext/sequel' if defined?(Sequel)
23
+
24
+ @load_attemps += 1
25
+ end
26
+ end
27
+ end
@@ -130,17 +130,26 @@ module AmazingPrint
130
130
  def align(value, width)
131
131
  if options[:multiline]
132
132
  indent_option = options[:indent]
133
+ effective_width = width + value.size - colorless_size(value)
133
134
  if indent_option.positive?
134
- value.rjust(width)
135
+ value.rjust(effective_width)
135
136
  elsif indent_option.zero?
136
- "#{indent}#{value.ljust(width)}"
137
+ "#{indent}#{value.ljust(effective_width)}"
137
138
  else
138
- "#{indent(indentation + indent_option)}#{value.ljust(width)}"
139
+ "#{indent(indentation + indent_option)}#{value.ljust(effective_width)}"
139
140
  end
140
141
  else
141
142
  value
142
143
  end
143
144
  end
145
+
146
+ def colorless(string)
147
+ string.gsub(/\e\[[\d;]+m/, '')
148
+ end
149
+
150
+ def colorless_size(string)
151
+ colorless(string).size
152
+ end
144
153
  end
145
154
  end
146
155
  end
@@ -65,8 +65,18 @@ module AmazingPrint
65
65
  result
66
66
  end
67
67
 
68
+ def key_size(key)
69
+ return key.inspect.size if symbol?(key)
70
+
71
+ if options[:html]
72
+ single_line { inspector.awesome(key) }.size
73
+ else
74
+ plain_single_line { inspector.awesome(key) }.size
75
+ end
76
+ end
77
+
68
78
  def max_key_width(keys)
69
- keys.map { |key, _value| key.size }.max || 0
79
+ keys.map { |key, _value| key_size(key) }.max || 0
70
80
  end
71
81
 
72
82
  def printable_keys
@@ -75,34 +85,41 @@ module AmazingPrint
75
85
  keys.sort! { |a, b| a.to_s <=> b.to_s } if options[:sort_keys]
76
86
 
77
87
  keys.map! do |key|
78
- plain_single_line do
79
- [inspector.awesome(key), hash[key]]
88
+ single_line do
89
+ [key, hash[key]]
80
90
  end
81
91
  end
82
92
  end
83
93
 
84
94
  def symbol?(key)
85
- key[0] == ':'
95
+ key.is_a?(Symbol)
86
96
  end
87
97
 
88
98
  def ruby19_syntax(key, value, width)
89
- key[0] = ''
90
- key << ':'
91
- "#{align(key, width)} #{inspector.awesome(value)}"
99
+ # Move the colon to the right side of the symbol
100
+ awesome_key = inspector.awesome(key).sub(/#{key.inspect}/, "#{key}:")
101
+
102
+ "#{align(awesome_key, width)} #{inspector.awesome(value)}"
92
103
  end
93
104
 
94
105
  def pre_ruby19_syntax(key, value, width)
95
- "#{align(key, width)}#{colorize(' => ', :hash)}#{inspector.awesome(value)}"
106
+ awesome_key = single_line { inspector.awesome(key) }
107
+ "#{align(awesome_key, width)}#{colorize(' => ', :hash)}#{inspector.awesome(value)}"
96
108
  end
97
109
 
98
- def plain_single_line
110
+ def plain_single_line(&block)
99
111
  plain = options[:plain]
100
- multiline = options[:multiline]
101
112
  options[:plain] = true
113
+ single_line(&block)
114
+ ensure
115
+ options[:plain] = plain
116
+ end
117
+
118
+ def single_line
119
+ multiline = options[:multiline]
102
120
  options[:multiline] = false
103
121
  yield
104
122
  ensure
105
- options[:plain] = plain
106
123
  options[:multiline] = multiline
107
124
  end
108
125
  end
@@ -27,10 +27,10 @@ module AmazingPrint
27
27
  def mode
28
28
  r = ['-'] * 6
29
29
  r[0] = 'd' if @stat.directory?
30
- r[1] = 'a' unless (@attrs & FILE_ATTRIBUTE_ARCHIVE).zero?
31
- r[2] = 'r' unless (@attrs & FILE_ATTRIBUTE_READONLY).zero?
32
- r[3] = 'h' unless (@attrs & FILE_ATTRIBUTE_HIDDEN).zero?
33
- r[4] = 's' unless (@attrs & FILE_ATTRIBUTE_SYSTEM).zero?
30
+ r[1] = 'a' unless @attrs.nobits?(FILE_ATTRIBUTE_ARCHIVE)
31
+ r[2] = 'r' unless @attrs.nobits?(FILE_ATTRIBUTE_READONLY)
32
+ r[3] = 'h' unless @attrs.nobits?(FILE_ATTRIBUTE_HIDDEN)
33
+ r[4] = 's' unless @attrs.nobits?(FILE_ATTRIBUTE_SYSTEM)
34
34
  r[5] = 'l' if File.symlink? @fname
35
35
  r.join
36
36
  end
@@ -17,7 +17,7 @@ module AmazingPrint
17
17
 
18
18
  def format
19
19
  vars = variables.map do |var|
20
- property = var.to_s[1..-1].to_sym # to_s because of some monkey patching done by Puppet.
20
+ property = var.to_s[1..].to_sym # to_s because of some monkey patching done by Puppet.
21
21
  accessor = if object.respond_to?(:"#{property}=")
22
22
  object.respond_to?(property) ? :accessor : :writer
23
23
  else
@@ -17,7 +17,7 @@ module AmazingPrint
17
17
 
18
18
  def format
19
19
  vars = variables.map do |var|
20
- property = var.to_s[1..-1].to_sym # to_s because of some monkey patching done by Puppet.
20
+ property = var.to_s[1..].to_sym # to_s because of some monkey patching done by Puppet.
21
21
  accessor = if struct.respond_to?(:"#{property}=")
22
22
  struct.respond_to?(property) ? :accessor : :writer
23
23
  else
@@ -6,9 +6,10 @@
6
6
  # See LICENSE file or http://www.opensource.org/licenses/mit-license.php
7
7
  #------------------------------------------------------------------------------
8
8
 
9
- # rubocop:disable Metrics/ClassLength
9
+ # rubocop:disable Metrics/ClassLength, Metrics/MethodLength
10
10
 
11
11
  require_relative 'indentator'
12
+ require_relative 'ext_loader'
12
13
 
13
14
  module AmazingPrint
14
15
  class Inspector
@@ -70,6 +71,8 @@ module AmazingPrint
70
71
  @formatter = AmazingPrint::Formatter.new(self)
71
72
  @indentator = AmazingPrint::Indentator.new(@options[:indent].abs)
72
73
  Thread.current[AP] ||= []
74
+
75
+ ExtLoader.call
73
76
  end
74
77
 
75
78
  def current_indentation
@@ -189,11 +192,11 @@ module AmazingPrint
189
192
  #---------------------------------------------------------------------------
190
193
  def merge_custom_defaults!
191
194
  load_dotfile
192
- merge_options!(AmazingPrint.defaults) if AmazingPrint.defaults.is_a?(Hash)
195
+ merge_options!(AmazingPrint.defaults.dup) if AmazingPrint.defaults.is_a?(Hash)
193
196
  rescue StandardError => e
194
197
  warn "Could not load '.aprc' from ENV['HOME']: #{e}"
195
198
  end
196
199
  end
197
200
  end
198
201
 
199
- # rubocop:enable Metrics/ClassLength
202
+ # rubocop:enable Metrics/ClassLength, Metrics/MethodLength
@@ -7,6 +7,6 @@
7
7
  #------------------------------------------------------------------------------
8
8
  module AmazingPrint
9
9
  def self.version
10
- '1.5.0'
10
+ '1.7.2'
11
11
  end
12
12
  end
data/lib/amazing_print.rb CHANGED
@@ -33,12 +33,6 @@ unless defined?(AmazingPrint::Inspector)
33
33
  require_relative 'amazing_print/ext/action_view'
34
34
  end
35
35
  end
36
- require_relative 'amazing_print/ext/mongo_mapper' if defined?(MongoMapper)
37
- require_relative 'amazing_print/ext/mongoid' if defined?(Mongoid)
38
- require_relative 'amazing_print/ext/nokogiri' if defined?(Nokogiri)
39
- require_relative 'amazing_print/ext/nobrainer' if defined?(NoBrainer)
40
- require_relative 'amazing_print/ext/ripple' if defined?(Ripple)
41
- require_relative 'amazing_print/ext/sequel' if defined?(Sequel)
42
- require_relative 'amazing_print/ext/ostruct' if defined?(OpenStruct)
36
+
37
+ AmazingPrint::ExtLoader.call
43
38
  end
44
- # test
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amazing_print
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Dvorkin
8
8
  - Kevin McCormackPatrik Wenger
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2023-05-24 00:00:00.000000000 Z
11
+ date: 2025-01-07 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: 'Great Ruby debugging companion: pretty print Ruby objects to visualize
15
14
  their structure. Supports custom object formatting via plugins'
@@ -18,15 +17,9 @@ executables: []
18
17
  extensions: []
19
18
  extra_rdoc_files: []
20
19
  files:
21
- - ".gitignore"
22
- - Appraisals
23
20
  - CHANGELOG.md
24
21
  - CONTRIBUTING.md
25
- - Gemfile
26
- - Gemfile.lock
27
- - LICENSE
28
22
  - README.md
29
- - Rakefile
30
23
  - lib/amazing_print.rb
31
24
  - lib/amazing_print/colorize.rb
32
25
  - lib/amazing_print/colors.rb
@@ -46,6 +39,7 @@ files:
46
39
  - lib/amazing_print/ext/ostruct.rb
47
40
  - lib/amazing_print/ext/ripple.rb
48
41
  - lib/amazing_print/ext/sequel.rb
42
+ - lib/amazing_print/ext_loader.rb
49
43
  - lib/amazing_print/formatter.rb
50
44
  - lib/amazing_print/formatters.rb
51
45
  - lib/amazing_print/formatters/array_formatter.rb
@@ -63,58 +57,11 @@ files:
63
57
  - lib/amazing_print/inspector.rb
64
58
  - lib/amazing_print/version.rb
65
59
  - lib/ap.rb
66
- - spec/active_record_helper.rb
67
- - spec/colors_spec.rb
68
- - spec/core_ext/logger_spec.rb
69
- - spec/ext/action_controller_spec.rb
70
- - spec/ext/action_view_spec.rb
71
- - spec/ext/active_model_spec.rb
72
- - spec/ext/active_record_spec.rb
73
- - spec/ext/active_support_spec.rb
74
- - spec/ext/mongo_mapper_spec.rb
75
- - spec/ext/mongoid_spec.rb
76
- - spec/ext/nobrainer_spec.rb
77
- - spec/ext/nokogiri_spec.rb
78
- - spec/ext/ostruct_spec.rb
79
- - spec/ext/ripple_spec.rb
80
- - spec/ext/sequel_spec.rb
81
- - spec/formats_spec.rb
82
- - spec/methods_spec.rb
83
- - spec/misc_spec.rb
84
- - spec/objects_spec.rb
85
- - spec/sequel_helper.rb
86
- - spec/spec_helper.rb
87
- - spec/support/active_record_data.rb
88
- - spec/support/active_record_data/3_2_diana.txt
89
- - spec/support/active_record_data/3_2_diana_legacy.txt
90
- - spec/support/active_record_data/3_2_multi.txt
91
- - spec/support/active_record_data/3_2_multi_legacy.txt
92
- - spec/support/active_record_data/4_0_diana.txt
93
- - spec/support/active_record_data/4_0_multi.txt
94
- - spec/support/active_record_data/4_1_diana.txt
95
- - spec/support/active_record_data/4_1_multi.txt
96
- - spec/support/active_record_data/4_2_diana.txt
97
- - spec/support/active_record_data/4_2_diana_legacy.txt
98
- - spec/support/active_record_data/4_2_multi.txt
99
- - spec/support/active_record_data/4_2_multi_legacy.txt
100
- - spec/support/active_record_data/5_0_diana.txt
101
- - spec/support/active_record_data/5_0_multi.txt
102
- - spec/support/active_record_data/5_1_diana.txt
103
- - spec/support/active_record_data/5_1_multi.txt
104
- - spec/support/active_record_data/5_2_diana.txt
105
- - spec/support/active_record_data/5_2_multi.txt
106
- - spec/support/active_record_data/6_0_diana.txt
107
- - spec/support/active_record_data/6_0_multi.txt
108
- - spec/support/active_record_data/6_1_diana.txt
109
- - spec/support/active_record_data/6_1_multi.txt
110
- - spec/support/ext_verifier.rb
111
- - spec/support/mongoid_versions.rb
112
- - spec/support/rails_versions.rb
113
60
  homepage: https://github.com/amazing-print/amazing_print
114
61
  licenses:
115
62
  - MIT
116
- metadata: {}
117
- post_install_message:
63
+ metadata:
64
+ changelog_uri: https://github.com/amazing-print/amazing_print/blob/master/CHANGELOG.md
118
65
  rdoc_options: []
119
66
  require_paths:
120
67
  - lib
@@ -122,15 +69,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
122
69
  requirements:
123
70
  - - ">="
124
71
  - !ruby/object:Gem::Version
125
- version: 2.5.0
72
+ version: 3.0.0
126
73
  required_rubygems_version: !ruby/object:Gem::Requirement
127
74
  requirements:
128
75
  - - ">="
129
76
  - !ruby/object:Gem::Version
130
77
  version: '0'
131
78
  requirements: []
132
- rubygems_version: 3.4.10
133
- signing_key:
79
+ rubygems_version: 3.6.2
134
80
  specification_version: 4
135
81
  summary: Pretty print Ruby objects with proper indentation and colors
136
82
  test_files: []
data/.gitignore DELETED
@@ -1,35 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## RUBYMINE
17
- .idea
18
-
19
- ## PROJECT::GENERAL
20
- coverage
21
- rdoc
22
- pkg
23
- .ruby-version
24
- gemfiles/*.gemfile.lock
25
- Gemfile.lock
26
- /tmp
27
- /.bundle
28
- /gemfiles/.bundle
29
-
30
- ## PROJECT::RVM
31
- .rvmrc
32
-
33
- # PROJECT::RBENV
34
- .ruby-gemset
35
- *.gem