amazing_print 1.5.0 → 1.8.1

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 (74) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +79 -37
  3. data/README.md +11 -11
  4. data/lib/amazing_print/core_ext/awesome_method_array.rb +3 -3
  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/mongo_mapper.rb +2 -2
  8. data/lib/amazing_print/ext/mongoid.rb +14 -2
  9. data/lib/amazing_print/ext/nobrainer.rb +2 -2
  10. data/lib/amazing_print/ext_loader.rb +27 -0
  11. data/lib/amazing_print/formatter.rb +1 -1
  12. data/lib/amazing_print/formatters/array_formatter.rb +1 -1
  13. data/lib/amazing_print/formatters/base_formatter.rb +14 -5
  14. data/lib/amazing_print/formatters/hash_formatter.rb +28 -11
  15. data/lib/amazing_print/formatters/mswin_helper.rb +4 -4
  16. data/lib/amazing_print/formatters/object_formatter.rb +2 -2
  17. data/lib/amazing_print/formatters/struct_formatter.rb +2 -2
  18. data/lib/amazing_print/inspector.rb +8 -5
  19. data/lib/amazing_print/version.rb +1 -1
  20. data/lib/amazing_print.rb +2 -8
  21. metadata +9 -62
  22. data/.gitignore +0 -35
  23. data/Appraisals +0 -50
  24. data/Gemfile +0 -15
  25. data/Gemfile.lock +0 -83
  26. data/LICENSE +0 -22
  27. data/Rakefile +0 -25
  28. data/spec/active_record_helper.rb +0 -43
  29. data/spec/colors_spec.rb +0 -120
  30. data/spec/core_ext/logger_spec.rb +0 -70
  31. data/spec/ext/action_controller_spec.rb +0 -40
  32. data/spec/ext/action_view_spec.rb +0 -24
  33. data/spec/ext/active_model_spec.rb +0 -37
  34. data/spec/ext/active_record_spec.rb +0 -298
  35. data/spec/ext/active_support_spec.rb +0 -37
  36. data/spec/ext/mongo_mapper_spec.rb +0 -265
  37. data/spec/ext/mongoid_spec.rb +0 -72
  38. data/spec/ext/nobrainer_spec.rb +0 -64
  39. data/spec/ext/nokogiri_spec.rb +0 -52
  40. data/spec/ext/ostruct_spec.rb +0 -24
  41. data/spec/ext/ripple_spec.rb +0 -53
  42. data/spec/ext/sequel_spec.rb +0 -45
  43. data/spec/formats_spec.rb +0 -792
  44. data/spec/methods_spec.rb +0 -520
  45. data/spec/misc_spec.rb +0 -206
  46. data/spec/objects_spec.rb +0 -225
  47. data/spec/sequel_helper.rb +0 -18
  48. data/spec/spec_helper.rb +0 -112
  49. data/spec/support/active_record_data/3_2_diana.txt +0 -24
  50. data/spec/support/active_record_data/3_2_diana_legacy.txt +0 -24
  51. data/spec/support/active_record_data/3_2_multi.txt +0 -50
  52. data/spec/support/active_record_data/3_2_multi_legacy.txt +0 -50
  53. data/spec/support/active_record_data/4_0_diana.txt +0 -98
  54. data/spec/support/active_record_data/4_0_multi.txt +0 -198
  55. data/spec/support/active_record_data/4_1_diana.txt +0 -97
  56. data/spec/support/active_record_data/4_1_multi.txt +0 -196
  57. data/spec/support/active_record_data/4_2_diana.txt +0 -109
  58. data/spec/support/active_record_data/4_2_diana_legacy.txt +0 -109
  59. data/spec/support/active_record_data/4_2_multi.txt +0 -220
  60. data/spec/support/active_record_data/4_2_multi_legacy.txt +0 -220
  61. data/spec/support/active_record_data/5_0_diana.txt +0 -105
  62. data/spec/support/active_record_data/5_0_multi.txt +0 -212
  63. data/spec/support/active_record_data/5_1_diana.txt +0 -104
  64. data/spec/support/active_record_data/5_1_multi.txt +0 -210
  65. data/spec/support/active_record_data/5_2_diana.txt +0 -104
  66. data/spec/support/active_record_data/5_2_multi.txt +0 -210
  67. data/spec/support/active_record_data/6_0_diana.txt +0 -104
  68. data/spec/support/active_record_data/6_0_multi.txt +0 -210
  69. data/spec/support/active_record_data/6_1_diana.txt +0 -109
  70. data/spec/support/active_record_data/6_1_multi.txt +0 -220
  71. data/spec/support/active_record_data.rb +0 -22
  72. data/spec/support/ext_verifier.rb +0 -46
  73. data/spec/support/mongoid_versions.rb +0 -24
  74. data/spec/support/rails_versions.rb +0 -57
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # rubocop:disable Lint/ConstantDefinitionInBlock
4
-
5
- require 'spec_helper'
6
-
7
- RSpec.describe 'AmazingPrint/NoBrainer', skip: -> { !ExtVerifier.has_nobrainer? }.call do
8
- if ExtVerifier.has_nobrainer?
9
- before :all do
10
- NoBrainer.configure do |config|
11
- config.app_name = 'ap_test'
12
- config.environment = :test
13
- end
14
- end
15
-
16
- before :all do
17
- class SomeModel
18
- include NoBrainer::Document
19
-
20
- field :first_name, type: String
21
- field :last_name, type: String
22
- field :some_field
23
- end
24
- end
25
-
26
- after :all do
27
- Object.instance_eval { remove_const :SomeModel }
28
- end
29
- end
30
-
31
- before do
32
- @ap = AmazingPrint::Inspector.new plain: true
33
- end
34
-
35
- it 'prints class instance' do
36
- user = SomeModel.new first_name: 'Al', last_name: 'Capone'
37
- out = @ap.send :awesome, user
38
-
39
- object_id = user.id.inspect
40
- str = <<~EOS.strip
41
- #<SomeModel id: #{object_id}> {
42
- :id => #{object_id},
43
- :first_name => "Al",
44
- :last_name => "Capone"
45
- }
46
- EOS
47
- expect(out).to eq(str)
48
- end
49
-
50
- it 'prints the class' do
51
- class_spec = <<~EOS.strip
52
- class SomeModel < Object {
53
- :id => :string,
54
- :first_name => :string,
55
- :last_name => :string,
56
- :some_field => :object
57
- }
58
- EOS
59
-
60
- expect(@ap.send(:awesome, SomeModel)).to eq class_spec
61
- end
62
- end
63
-
64
- # rubocop:enable Lint/ConstantDefinitionInBlock
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe 'AmazingPrint/Nokogiri' do
6
- it 'colorizes tags' do
7
- xml = Nokogiri::XML('<html><body><h1></h1></body></html>')
8
- # FIXME: Due to something strange with Nokogiri and JRuby, we need to remove extra blank lines.
9
- output = xml.ai.gsub(/\n\n/, "\n")
10
- expect(output).to eq <<~EOS
11
- <?xml version="1.0"?>\e[1;32m
12
- \e[0m<\e[1;36mhtml\e[0m>\e[1;32m
13
- \e[0m<\e[1;36mbody\e[0m>\e[1;32m
14
- \e[0m<\e[1;36mh1\e[0m/>\e[1;32m
15
- \e[0m<\e[1;36m/body\e[0m>\e[1;32m
16
- \e[0m<\e[1;36m/html\e[0m>
17
- EOS
18
- end
19
-
20
- it 'colorizes contents' do
21
- xml = Nokogiri::XML('<html><body><h1>Hello</h1></body></html>')
22
- expect(xml.ai).to eq <<~EOS
23
- <?xml version="1.0"?>\e[1;32m
24
- \e[0m<\e[1;36mhtml\e[0m>\e[1;32m
25
- \e[0m<\e[1;36mbody\e[0m>\e[1;32m
26
- \e[0m<\e[1;36mh1\e[0m>\e[1;32mHello\e[0m<\e[1;36m/h1\e[0m>\e[1;32m
27
- \e[0m<\e[1;36m/body\e[0m>\e[1;32m
28
- \e[0m<\e[1;36m/html\e[0m>
29
- EOS
30
- end
31
-
32
- it 'colorizes class and id' do
33
- xml = Nokogiri::XML('<html><body><h1><span class="world" id="hello"></span></h1></body></html>')
34
- # FIXME: Due to something strange with Nokogiri and JRuby, we need to remove extra blank lines.
35
- output = xml.ai.gsub(/\n\n/, "\n")
36
- expect(output).to eq <<~EOS
37
- <?xml version="1.0"?>\e[1;32m
38
- \e[0m<\e[1;36mhtml\e[0m>\e[1;32m
39
- \e[0m<\e[1;36mbody\e[0m>\e[1;32m
40
- \e[0m<\e[1;36mh1\e[0m>\e[1;32m
41
- \e[0m<\e[1;36mspan\e[0m \e[1;33mclass="world"\e[0m \e[1;33mid="hello"\e[0m/>\e[1;32m
42
- \e[0m<\e[1;36m/h1\e[0m>\e[1;32m
43
- \e[0m<\e[1;36m/body\e[0m>\e[1;32m
44
- \e[0m<\e[1;36m/html\e[0m>
45
- EOS
46
- end
47
-
48
- it 'handle empty NodeSet' do
49
- xml = Nokogiri::XML::NodeSet.new(Nokogiri::XML(''))
50
- expect(xml.ai).to eq('[]')
51
- end
52
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe 'AmazingPrint Ostruct extension' do
6
- before do
7
- @ap = AmazingPrint::Inspector.new(plain: true, sort_keys: true)
8
- end
9
-
10
- it 'empty hash' do
11
- struct = OpenStruct.new
12
- expect(@ap.send(:awesome, struct)).to eq('OpenStruct {}')
13
- end
14
-
15
- it 'plain multiline' do
16
- struct = OpenStruct.new name: 'Foo', address: 'Bar'
17
- expect(@ap.send(:awesome, struct)).to eq <<~EOS.strip
18
- OpenStruct {
19
- :address => "Bar",
20
- :name => "Foo"
21
- }
22
- EOS
23
- end
24
- end
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # rubocop:disable Lint/ConstantDefinitionInBlock
4
-
5
- require 'spec_helper'
6
-
7
- RSpec.describe 'AmazingPrint/Ripple', skip: -> { !ExtVerifier.has_ripple? }.call do
8
- if ExtVerifier.has_ripple?
9
- before :all do
10
- class RippleUser
11
- include Ripple::Document
12
-
13
- key_on :_id
14
- property :_id, String
15
- property :first_name, String
16
- property :last_name, String
17
- end
18
- end
19
-
20
- after :all do
21
- Object.instance_eval { remove_const :RippleUser }
22
- end
23
- end
24
-
25
- before do
26
- @ap = AmazingPrint::Inspector.new plain: true, sort_keys: true
27
- end
28
-
29
- it 'prints class instance' do
30
- user = RippleUser.new _id: '12345', first_name: 'Al', last_name: 'Capone'
31
- out = @ap.send :awesome, user
32
-
33
- expect(out).to be_similar_to <<~EOS.strip
34
- #<RippleUser:placeholder_id> {
35
- :_id => "12345",
36
- :first_name => "Al",
37
- :last_name => "Capone"
38
- }
39
- EOS
40
- end
41
-
42
- it 'prints the class' do
43
- expect(@ap.send(:awesome, RippleUser)).to eq <<~EOS.strip
44
- class RippleUser < Object {
45
- :_id => :string,
46
- :first_name => :string,
47
- :last_name => :string
48
- }
49
- EOS
50
- end
51
- end
52
-
53
- # rubocop:enable Lint/ConstantDefinitionInBlock
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'sequel_helper'
5
-
6
- RSpec.describe 'AmazingPrint/Sequel', skip: -> { !ExtVerifier.has_sequel? }.call do
7
- before do
8
- @ap = AmazingPrint::Inspector.new plain: true, sort_keys: true
9
- @user1 = SequelUser.new first_name: 'Jeremy', last_name: 'Evans'
10
- @user2 = SequelUser.new first_name: 'Sequel', last_name: 'Five'
11
- end
12
-
13
- it 'display single record' do
14
- out = @ap.awesome(@user1)
15
- str = <<~EOS.strip
16
- #<SequelUser:placeholder_id> {
17
- :first_name => "Jeremy",
18
- :last_name => "Evans"
19
- }
20
- EOS
21
- expect(out).to be_similar_to(str)
22
- end
23
-
24
- it 'display multiple records' do
25
- out = @ap.awesome([@user1, @user2])
26
- str = <<~EOS.strip
27
- [
28
- [0] #<SequelUser:placeholder_id> {
29
- :first_name => "Jeremy",
30
- :last_name => "Evans"
31
- },
32
- [1] #<SequelUser:placeholder_id> {
33
- :first_name => "Sequel",
34
- :last_name => "Five"
35
- }
36
- ]
37
- EOS
38
- expect(out).to be_similar_to(str)
39
- end
40
-
41
- it 'does not crash if on Sequel::Model' do
42
- out = @ap.awesome(Sequel::Model)
43
- expect(out).to be_similar_to('Sequel::Model < Object')
44
- end
45
- end