amazing_print 1.4.0 → 1.6.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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/Appraisals +16 -0
  3. data/CHANGELOG.md +56 -33
  4. data/Gemfile +12 -0
  5. data/Gemfile.lock +61 -44
  6. data/README.md +3 -4
  7. data/lib/amazing_print/colorize.rb +5 -12
  8. data/lib/amazing_print/colors.rb +37 -0
  9. data/lib/amazing_print/core_ext/awesome_method_array.rb +1 -1
  10. data/lib/amazing_print/custom_defaults.rb +7 -1
  11. data/lib/amazing_print/ext/mongoid.rb +14 -2
  12. data/lib/amazing_print/ext_loader.rb +27 -0
  13. data/lib/amazing_print/formatters/array_formatter.rb +1 -1
  14. data/lib/amazing_print/formatters/base_formatter.rb +8 -3
  15. data/lib/amazing_print/formatters/dir_formatter.rb +10 -1
  16. data/lib/amazing_print/formatters/file_formatter.rb +10 -1
  17. data/lib/amazing_print/formatters/hash_formatter.rb +3 -5
  18. data/lib/amazing_print/formatters/mswin_helper.rb +63 -0
  19. data/lib/amazing_print/inspector.rb +6 -3
  20. data/lib/amazing_print/version.rb +1 -1
  21. data/lib/amazing_print.rb +3 -9
  22. data/spec/colors_spec.rb +9 -4
  23. data/spec/ext/action_controller_spec.rb +3 -3
  24. data/spec/ext/active_record_spec.rb +30 -60
  25. data/spec/ext/active_support_spec.rb +2 -2
  26. data/spec/ext/mongoid_spec.rb +110 -47
  27. data/spec/ext/nokogiri_spec.rb +6 -6
  28. data/spec/ext/sequel_spec.rb +1 -1
  29. data/spec/formats_spec.rb +97 -89
  30. data/spec/misc_spec.rb +15 -61
  31. data/spec/spec_helper.rb +7 -1
  32. data/spec/support/active_record_data/7_0_diana.txt +110 -0
  33. data/spec/support/active_record_data/7_0_multi.txt +222 -0
  34. data/spec/support/rails_versions.rb +5 -0
  35. metadata +13 -156
  36. data/lib/amazing_print/core_ext/string.rb +0 -45
  37. data/spec/core_ext/string_spec.rb +0 -15
@@ -0,0 +1,222 @@
1
+ [
2
+ [0] #<User:placeholder_id
3
+ @_start_transaction_state = nil,
4
+ @association_cache = {},
5
+ @destroyed = false,
6
+ @marked_for_destruction = false,
7
+ @new_record = true,
8
+ @previously_new_record = false,
9
+ @primary_key = "id",
10
+ @readonly = false,
11
+ @strict_loading = false,
12
+ attr_accessor :attributes = #<ActiveModel::AttributeSet:placeholder_id
13
+ @attributes = {
14
+ "admin" => #<ActiveModel::Attribute::FromUser:placeholder_id
15
+ @original_attribute = #<ActiveModel::Attribute::FromDatabase:placeholder_id
16
+ @original_attribute = nil,
17
+ attr_reader :name = "admin",
18
+ attr_reader :type = #<ActiveModel::Type::Boolean:placeholder_id
19
+ attr_reader :limit = nil,
20
+ attr_reader :precision = nil,
21
+ attr_reader :scale = nil
22
+ >,
23
+ attr_reader :value_before_type_cast = nil
24
+ >,
25
+ attr_reader :name = "admin",
26
+ attr_reader :type = #<ActiveModel::Type::Boolean:placeholder_id
27
+ attr_reader :limit = nil,
28
+ attr_reader :precision = nil,
29
+ attr_reader :scale = nil
30
+ >,
31
+ attr_reader :value_before_type_cast = false
32
+ >,
33
+ "created_at" => #<ActiveModel::Attribute::FromUser:placeholder_id
34
+ @original_attribute = #<ActiveModel::Attribute::FromDatabase:placeholder_id
35
+ @original_attribute = nil,
36
+ attr_reader :name = "created_at",
37
+ attr_reader :type = #<ActiveRecord::Type::DateTime:placeholder_id
38
+ attr_reader :limit = nil,
39
+ attr_reader :precision = 6,
40
+ attr_reader :scale = nil
41
+ >,
42
+ attr_reader :value_before_type_cast = nil
43
+ >,
44
+ attr_reader :name = "created_at",
45
+ attr_reader :type = #<ActiveRecord::Type::DateTime:placeholder_id
46
+ attr_reader :limit = nil,
47
+ attr_reader :precision = 6,
48
+ attr_reader :scale = nil
49
+ >,
50
+ attr_reader :value_before_type_cast = "1992-10-10 12:30:00"
51
+ >,
52
+ "id" => #<ActiveModel::Attribute::FromDatabase:placeholder_id
53
+ @original_attribute = nil,
54
+ attr_reader :name = "id",
55
+ attr_reader :type = #<ActiveRecord::ConnectionAdapters::SQLite3Adapter::SQLite3Integer:placeholder_id
56
+ @range = -9223372036854775808...9223372036854775808,
57
+ attr_reader :limit = nil,
58
+ attr_reader :precision = nil,
59
+ attr_reader :scale = nil
60
+ >,
61
+ attr_reader :value_before_type_cast = nil
62
+ >,
63
+ "name" => #<ActiveModel::Attribute::FromUser:placeholder_id
64
+ @original_attribute = #<ActiveModel::Attribute::FromDatabase:placeholder_id
65
+ @original_attribute = nil,
66
+ attr_reader :name = "name",
67
+ attr_reader :type = #<ActiveModel::Type::String:placeholder_id
68
+ @false = "f",
69
+ @true = "t",
70
+ attr_reader :limit = nil,
71
+ attr_reader :precision = nil,
72
+ attr_reader :scale = nil
73
+ >,
74
+ attr_reader :value_before_type_cast = nil
75
+ >,
76
+ attr_reader :name = "name",
77
+ attr_reader :type = #<ActiveModel::Type::String:placeholder_id
78
+ @false = "f",
79
+ @true = "t",
80
+ attr_reader :limit = nil,
81
+ attr_reader :precision = nil,
82
+ attr_reader :scale = nil
83
+ >,
84
+ attr_reader :value_before_type_cast = "Diana"
85
+ >,
86
+ "rank" => #<ActiveModel::Attribute::FromUser:placeholder_id
87
+ @original_attribute = #<ActiveModel::Attribute::FromDatabase:placeholder_id
88
+ @original_attribute = nil,
89
+ attr_reader :name = "rank",
90
+ attr_reader :type = #<ActiveRecord::ConnectionAdapters::SQLite3Adapter::SQLite3Integer:placeholder_id
91
+ @range = -9223372036854775808...9223372036854775808,
92
+ attr_reader :limit = nil,
93
+ attr_reader :precision = nil,
94
+ attr_reader :scale = nil
95
+ >,
96
+ attr_reader :value_before_type_cast = nil
97
+ >,
98
+ attr_reader :name = "rank",
99
+ attr_reader :type = #<ActiveRecord::ConnectionAdapters::SQLite3Adapter::SQLite3Integer:placeholder_id
100
+ @range = -9223372036854775808...9223372036854775808,
101
+ attr_reader :limit = nil,
102
+ attr_reader :precision = nil,
103
+ attr_reader :scale = nil
104
+ >,
105
+ attr_reader :value_before_type_cast = 1
106
+ >
107
+ }
108
+ >,
109
+ attr_accessor :destroyed_by_association = nil,
110
+ attr_reader :strict_loading_mode = :all
111
+ >,
112
+ [1] #<User:placeholder_id
113
+ @_start_transaction_state = nil,
114
+ @association_cache = {},
115
+ @destroyed = false,
116
+ @marked_for_destruction = false,
117
+ @new_record = true,
118
+ @previously_new_record = false,
119
+ @primary_key = "id",
120
+ @readonly = false,
121
+ @strict_loading = false,
122
+ attr_accessor :attributes = #<ActiveModel::AttributeSet:placeholder_id
123
+ @attributes = {
124
+ "admin" => #<ActiveModel::Attribute::FromUser:placeholder_id
125
+ @original_attribute = #<ActiveModel::Attribute::FromDatabase:placeholder_id
126
+ @original_attribute = nil,
127
+ attr_reader :name = "admin",
128
+ attr_reader :type = #<ActiveModel::Type::Boolean:placeholder_id
129
+ attr_reader :limit = nil,
130
+ attr_reader :precision = nil,
131
+ attr_reader :scale = nil
132
+ >,
133
+ attr_reader :value_before_type_cast = nil
134
+ >,
135
+ attr_reader :name = "admin",
136
+ attr_reader :type = #<ActiveModel::Type::Boolean:placeholder_id
137
+ attr_reader :limit = nil,
138
+ attr_reader :precision = nil,
139
+ attr_reader :scale = nil
140
+ >,
141
+ attr_reader :value_before_type_cast = true
142
+ >,
143
+ "created_at" => #<ActiveModel::Attribute::FromUser:placeholder_id
144
+ @original_attribute = #<ActiveModel::Attribute::FromDatabase:placeholder_id
145
+ @original_attribute = nil,
146
+ attr_reader :name = "created_at",
147
+ attr_reader :type = #<ActiveRecord::Type::DateTime:placeholder_id
148
+ attr_reader :limit = nil,
149
+ attr_reader :precision = 6,
150
+ attr_reader :scale = nil
151
+ >,
152
+ attr_reader :value_before_type_cast = nil
153
+ >,
154
+ attr_reader :name = "created_at",
155
+ attr_reader :type = #<ActiveRecord::Type::DateTime:placeholder_id
156
+ attr_reader :limit = nil,
157
+ attr_reader :precision = 6,
158
+ attr_reader :scale = nil
159
+ >,
160
+ attr_reader :value_before_type_cast = "2003-05-26 14:15:00"
161
+ >,
162
+ "id" => #<ActiveModel::Attribute::FromDatabase:placeholder_id
163
+ @original_attribute = nil,
164
+ attr_reader :name = "id",
165
+ attr_reader :type = #<ActiveRecord::ConnectionAdapters::SQLite3Adapter::SQLite3Integer:placeholder_id
166
+ @range = -9223372036854775808...9223372036854775808,
167
+ attr_reader :limit = nil,
168
+ attr_reader :precision = nil,
169
+ attr_reader :scale = nil
170
+ >,
171
+ attr_reader :value_before_type_cast = nil
172
+ >,
173
+ "name" => #<ActiveModel::Attribute::FromUser:placeholder_id
174
+ @original_attribute = #<ActiveModel::Attribute::FromDatabase:placeholder_id
175
+ @original_attribute = nil,
176
+ attr_reader :name = "name",
177
+ attr_reader :type = #<ActiveModel::Type::String:placeholder_id
178
+ @false = "f",
179
+ @true = "t",
180
+ attr_reader :limit = nil,
181
+ attr_reader :precision = nil,
182
+ attr_reader :scale = nil
183
+ >,
184
+ attr_reader :value_before_type_cast = nil
185
+ >,
186
+ attr_reader :name = "name",
187
+ attr_reader :type = #<ActiveModel::Type::String:placeholder_id
188
+ @false = "f",
189
+ @true = "t",
190
+ attr_reader :limit = nil,
191
+ attr_reader :precision = nil,
192
+ attr_reader :scale = nil
193
+ >,
194
+ attr_reader :value_before_type_cast = "Laura"
195
+ >,
196
+ "rank" => #<ActiveModel::Attribute::FromUser:placeholder_id
197
+ @original_attribute = #<ActiveModel::Attribute::FromDatabase:placeholder_id
198
+ @original_attribute = nil,
199
+ attr_reader :name = "rank",
200
+ attr_reader :type = #<ActiveRecord::ConnectionAdapters::SQLite3Adapter::SQLite3Integer:placeholder_id
201
+ @range = -9223372036854775808...9223372036854775808,
202
+ attr_reader :limit = nil,
203
+ attr_reader :precision = nil,
204
+ attr_reader :scale = nil
205
+ >,
206
+ attr_reader :value_before_type_cast = nil
207
+ >,
208
+ attr_reader :name = "rank",
209
+ attr_reader :type = #<ActiveRecord::ConnectionAdapters::SQLite3Adapter::SQLite3Integer:placeholder_id
210
+ @range = -9223372036854775808...9223372036854775808,
211
+ attr_reader :limit = nil,
212
+ attr_reader :precision = nil,
213
+ attr_reader :scale = nil
214
+ >,
215
+ attr_reader :value_before_type_cast = 2
216
+ >
217
+ }
218
+ >,
219
+ attr_accessor :destroyed_by_association = nil,
220
+ attr_reader :strict_loading_mode = :all
221
+ >
222
+ ]
@@ -5,6 +5,11 @@ module RailsVersions
5
5
  Gem::Version.new(Rails::VERSION::STRING)
6
6
  end
7
7
 
8
+ def rails_7_0?
9
+ Gem::Requirement.new('~> 7.0.0').satisfied_by?(rails_version)
10
+ end
11
+ alias activerecord_7_0? rails_7_0?
12
+
8
13
  def rails_6_1?
9
14
  Gem::Requirement.new('~> 6.1.0').satisfied_by?(rails_version)
10
15
  end
metadata CHANGED
@@ -1,114 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amazing_print
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Dvorkin
8
8
  - Kevin McCormackPatrik Wenger
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-10-06 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: appraisal
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: '2.3'
21
- type: :development
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - "~>"
26
- - !ruby/object:Gem::Version
27
- version: '2.3'
28
- - !ruby/object:Gem::Dependency
29
- name: fakefs
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - "~>"
33
- - !ruby/object:Gem::Version
34
- version: '1.2'
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: '1.2'
42
- - !ruby/object:Gem::Dependency
43
- name: nokogiri
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: '1.10'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: '1.10'
56
- - !ruby/object:Gem::Dependency
57
- name: pry
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: '0'
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- - !ruby/object:Gem::Dependency
71
- name: rspec
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - "~>"
75
- - !ruby/object:Gem::Version
76
- version: '3.9'
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - "~>"
82
- - !ruby/object:Gem::Version
83
- version: '3.9'
84
- - !ruby/object:Gem::Dependency
85
- name: rubocop
86
- requirement: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - "~>"
89
- - !ruby/object:Gem::Version
90
- version: '1.20'
91
- type: :development
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - "~>"
96
- - !ruby/object:Gem::Version
97
- version: '1.20'
98
- - !ruby/object:Gem::Dependency
99
- name: rubocop-rspec
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - "~>"
103
- - !ruby/object:Gem::Version
104
- version: '2.4'
105
- type: :development
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - "~>"
110
- - !ruby/object:Gem::Version
111
- version: '2.4'
12
+ date: 2024-03-08 00:00:00.000000000 Z
13
+ dependencies: []
112
14
  description: 'Great Ruby debugging companion: pretty print Ruby objects to visualize
113
15
  their structure. Supports custom object formatting via plugins'
114
16
  email: harlemsquirrel@gmail.com
@@ -127,12 +29,12 @@ files:
127
29
  - Rakefile
128
30
  - lib/amazing_print.rb
129
31
  - lib/amazing_print/colorize.rb
32
+ - lib/amazing_print/colors.rb
130
33
  - lib/amazing_print/core_ext/awesome_method_array.rb
131
34
  - lib/amazing_print/core_ext/class.rb
132
35
  - lib/amazing_print/core_ext/kernel.rb
133
36
  - lib/amazing_print/core_ext/logger.rb
134
37
  - lib/amazing_print/core_ext/object.rb
135
- - lib/amazing_print/core_ext/string.rb
136
38
  - lib/amazing_print/custom_defaults.rb
137
39
  - lib/amazing_print/ext/action_view.rb
138
40
  - lib/amazing_print/ext/active_record.rb
@@ -144,6 +46,7 @@ files:
144
46
  - lib/amazing_print/ext/ostruct.rb
145
47
  - lib/amazing_print/ext/ripple.rb
146
48
  - lib/amazing_print/ext/sequel.rb
49
+ - lib/amazing_print/ext_loader.rb
147
50
  - lib/amazing_print/formatter.rb
148
51
  - lib/amazing_print/formatters.rb
149
52
  - lib/amazing_print/formatters/array_formatter.rb
@@ -153,6 +56,7 @@ files:
153
56
  - lib/amazing_print/formatters/file_formatter.rb
154
57
  - lib/amazing_print/formatters/hash_formatter.rb
155
58
  - lib/amazing_print/formatters/method_formatter.rb
59
+ - lib/amazing_print/formatters/mswin_helper.rb
156
60
  - lib/amazing_print/formatters/object_formatter.rb
157
61
  - lib/amazing_print/formatters/simple_formatter.rb
158
62
  - lib/amazing_print/formatters/struct_formatter.rb
@@ -163,7 +67,6 @@ files:
163
67
  - spec/active_record_helper.rb
164
68
  - spec/colors_spec.rb
165
69
  - spec/core_ext/logger_spec.rb
166
- - spec/core_ext/string_spec.rb
167
70
  - spec/ext/action_controller_spec.rb
168
71
  - spec/ext/action_view_spec.rb
169
72
  - spec/ext/active_model_spec.rb
@@ -205,6 +108,8 @@ files:
205
108
  - spec/support/active_record_data/6_0_multi.txt
206
109
  - spec/support/active_record_data/6_1_diana.txt
207
110
  - spec/support/active_record_data/6_1_multi.txt
111
+ - spec/support/active_record_data/7_0_diana.txt
112
+ - spec/support/active_record_data/7_0_multi.txt
208
113
  - spec/support/ext_verifier.rb
209
114
  - spec/support/mongoid_versions.rb
210
115
  - spec/support/rails_versions.rb
@@ -212,7 +117,7 @@ homepage: https://github.com/amazing-print/amazing_print
212
117
  licenses:
213
118
  - MIT
214
119
  metadata: {}
215
- post_install_message:
120
+ post_install_message:
216
121
  rdoc_options: []
217
122
  require_paths:
218
123
  - lib
@@ -227,56 +132,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
132
  - !ruby/object:Gem::Version
228
133
  version: '0'
229
134
  requirements: []
230
- rubygems_version: 3.2.22
231
- signing_key:
135
+ rubygems_version: 3.5.6
136
+ signing_key:
232
137
  specification_version: 4
233
138
  summary: Pretty print Ruby objects with proper indentation and colors
234
- test_files:
235
- - spec/active_record_helper.rb
236
- - spec/colors_spec.rb
237
- - spec/core_ext/logger_spec.rb
238
- - spec/core_ext/string_spec.rb
239
- - spec/ext/action_controller_spec.rb
240
- - spec/ext/action_view_spec.rb
241
- - spec/ext/active_model_spec.rb
242
- - spec/ext/active_record_spec.rb
243
- - spec/ext/active_support_spec.rb
244
- - spec/ext/mongo_mapper_spec.rb
245
- - spec/ext/mongoid_spec.rb
246
- - spec/ext/nobrainer_spec.rb
247
- - spec/ext/nokogiri_spec.rb
248
- - spec/ext/ostruct_spec.rb
249
- - spec/ext/ripple_spec.rb
250
- - spec/ext/sequel_spec.rb
251
- - spec/formats_spec.rb
252
- - spec/methods_spec.rb
253
- - spec/misc_spec.rb
254
- - spec/objects_spec.rb
255
- - spec/sequel_helper.rb
256
- - spec/spec_helper.rb
257
- - spec/support/active_record_data/3_2_diana.txt
258
- - spec/support/active_record_data/3_2_diana_legacy.txt
259
- - spec/support/active_record_data/3_2_multi.txt
260
- - spec/support/active_record_data/3_2_multi_legacy.txt
261
- - spec/support/active_record_data/4_0_diana.txt
262
- - spec/support/active_record_data/4_0_multi.txt
263
- - spec/support/active_record_data/4_1_diana.txt
264
- - spec/support/active_record_data/4_1_multi.txt
265
- - spec/support/active_record_data/4_2_diana.txt
266
- - spec/support/active_record_data/4_2_diana_legacy.txt
267
- - spec/support/active_record_data/4_2_multi.txt
268
- - spec/support/active_record_data/4_2_multi_legacy.txt
269
- - spec/support/active_record_data/5_0_diana.txt
270
- - spec/support/active_record_data/5_0_multi.txt
271
- - spec/support/active_record_data/5_1_diana.txt
272
- - spec/support/active_record_data/5_1_multi.txt
273
- - spec/support/active_record_data/5_2_diana.txt
274
- - spec/support/active_record_data/5_2_multi.txt
275
- - spec/support/active_record_data/6_0_diana.txt
276
- - spec/support/active_record_data/6_0_multi.txt
277
- - spec/support/active_record_data/6_1_diana.txt
278
- - spec/support/active_record_data/6_1_multi.txt
279
- - spec/support/active_record_data.rb
280
- - spec/support/ext_verifier.rb
281
- - spec/support/mongoid_versions.rb
282
- - spec/support/rails_versions.rb
139
+ test_files: []
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
- # Copyright (c) 2010-2016 Michael Dvorkin and contributors
3
- #
4
- # AmazingPrint is freely distributable under the terms of MIT license.
5
- # See LICENSE file or http://www.opensource.org/licenses/mit-license.php
6
- #------------------------------------------------------------------------------
7
-
8
- # frozen_string_literal: true
9
-
10
- class String
11
- #
12
- # ANSI color codes:
13
- # \e => escape
14
- # 30 => color base
15
- # 1 => bright
16
- # 0 => normal
17
- #
18
- # For HTML coloring we use <kbd> tag instead of <span> to require monospace
19
- # font. Note that beloved <tt> has been removed from HTML5.
20
- #
21
- %w[gray red green yellow blue purple cyan white].zip(
22
- %w[black darkred darkgreen brown navy darkmagenta darkcyan slategray]
23
- ).each_with_index do |(color, shade), i|
24
- # NOTE: Format strings are created once only, for performance, and remembered by closures.
25
-
26
- term_bright_seq = "\e[1;#{30 + i}m%s\e[0m"
27
- html_bright_seq = %(<kbd style="color:#{color}">%s</kbd>)
28
-
29
- define_method color do |html = false, *|
30
- (html ? html_bright_seq : term_bright_seq) % self
31
- end
32
-
33
- term_normal_seq = "\e[0;#{30 + i}m%s\e[0m"
34
- html_normal_seq = %(<kbd style="color:#{shade}">%s</kbd>)
35
-
36
- define_method "#{color}ish" do |html = false, *|
37
- (html ? html_normal_seq : term_normal_seq) % self
38
- end
39
- end
40
-
41
- # Remove ANSI color codes.
42
- def uncolor
43
- gsub(/\e\[[0-9;]*m/, '')
44
- end
45
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe 'String extensions' do
6
- %i[gray red green yellow blue purple cyan white].each_with_index do |color, i|
7
- it "has #{color} color" do
8
- expect(color.to_s.send(color)).to eq("\e[1;#{30 + i}m#{color}\e[0m")
9
- end
10
-
11
- it "has #{color}ish color" do
12
- expect(color.to_s.send(:"#{color}ish")).to eq("\e[0;#{30 + i}m#{color}\e[0m")
13
- end
14
- end
15
- end