awesome_print 1.7.0 → 1.8.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 (77) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/Appraisals +11 -0
  4. data/CHANGELOG.md +10 -0
  5. data/CONTRIBUTING.md +1 -1
  6. data/README.md +47 -38
  7. data/Rakefile +5 -5
  8. data/lib/ap.rb +2 -2
  9. data/lib/awesome_print.rb +18 -17
  10. data/lib/awesome_print/colorize.rb +1 -1
  11. data/lib/awesome_print/core_ext/{array.rb → awesome_method_array.rb} +16 -18
  12. data/lib/awesome_print/core_ext/class.rb +3 -2
  13. data/lib/awesome_print/core_ext/kernel.rb +1 -1
  14. data/lib/awesome_print/core_ext/logger.rb +1 -1
  15. data/lib/awesome_print/core_ext/method.rb +2 -2
  16. data/lib/awesome_print/core_ext/object.rb +3 -2
  17. data/lib/awesome_print/core_ext/string.rb +3 -3
  18. data/lib/awesome_print/custom_defaults.rb +57 -0
  19. data/lib/awesome_print/ext/action_view.rb +8 -4
  20. data/lib/awesome_print/ext/active_record.rb +19 -11
  21. data/lib/awesome_print/ext/active_support.rb +1 -1
  22. data/lib/awesome_print/ext/mongo_mapper.rb +16 -13
  23. data/lib/awesome_print/ext/mongoid.rb +8 -6
  24. data/lib/awesome_print/ext/nobrainer.rb +8 -5
  25. data/lib/awesome_print/ext/nokogiri.rb +4 -4
  26. data/lib/awesome_print/ext/ostruct.rb +1 -1
  27. data/lib/awesome_print/ext/ripple.rb +5 -6
  28. data/lib/awesome_print/ext/sequel.rb +7 -6
  29. data/lib/awesome_print/formatter.rb +11 -19
  30. data/lib/awesome_print/formatters.rb +15 -0
  31. data/lib/awesome_print/formatters/array_formatter.rb +108 -42
  32. data/lib/awesome_print/formatters/base_formatter.rb +13 -11
  33. data/lib/awesome_print/formatters/class_formatter.rb +2 -1
  34. data/lib/awesome_print/formatters/dir_formatter.rb +1 -1
  35. data/lib/awesome_print/formatters/file_formatter.rb +1 -1
  36. data/lib/awesome_print/formatters/hash_formatter.rb +74 -22
  37. data/lib/awesome_print/formatters/object_formatter.rb +9 -14
  38. data/lib/awesome_print/formatters/struct_formatter.rb +71 -0
  39. data/lib/awesome_print/inspector.rb +77 -93
  40. data/lib/awesome_print/version.rb +2 -2
  41. data/spec/active_record_helper.rb +8 -2
  42. data/spec/colors_spec.rb +30 -30
  43. data/spec/core_ext/logger_spec.rb +43 -0
  44. data/spec/core_ext/string_spec.rb +20 -0
  45. data/spec/ext/action_view_spec.rb +18 -0
  46. data/spec/ext/active_record_spec.rb +252 -0
  47. data/spec/ext/active_support_spec.rb +26 -0
  48. data/spec/ext/mongo_mapper_spec.rb +261 -0
  49. data/spec/ext/mongoid_spec.rb +104 -0
  50. data/spec/ext/nobrainer_spec.rb +59 -0
  51. data/spec/ext/nokogiri_spec.rb +46 -0
  52. data/spec/ext/ostruct_spec.rb +22 -0
  53. data/spec/ext/ripple_spec.rb +48 -0
  54. data/spec/formats_spec.rb +193 -165
  55. data/spec/methods_spec.rb +116 -128
  56. data/spec/misc_spec.rb +104 -108
  57. data/spec/objects_spec.rb +70 -28
  58. data/spec/spec_helper.rb +27 -10
  59. data/spec/support/active_record_data.rb +20 -0
  60. data/spec/support/active_record_data/3_2_diana.txt +24 -0
  61. data/spec/support/active_record_data/3_2_diana_legacy.txt +24 -0
  62. data/spec/support/active_record_data/3_2_multi.txt +50 -0
  63. data/spec/support/active_record_data/3_2_multi_legacy.txt +50 -0
  64. data/spec/support/active_record_data/4_0_diana.txt +98 -0
  65. data/spec/support/active_record_data/4_0_multi.txt +198 -0
  66. data/spec/support/active_record_data/4_1_diana.txt +97 -0
  67. data/spec/support/active_record_data/4_1_multi.txt +196 -0
  68. data/spec/support/active_record_data/4_2_diana.txt +109 -0
  69. data/spec/support/active_record_data/4_2_diana_legacy.txt +109 -0
  70. data/spec/support/active_record_data/4_2_multi.txt +220 -0
  71. data/spec/support/active_record_data/4_2_multi_legacy.txt +220 -0
  72. data/spec/support/active_record_data/5_0_diana.txt +105 -0
  73. data/spec/support/active_record_data/5_0_multi.txt +212 -0
  74. data/spec/support/ext_verifier.rb +42 -0
  75. data/spec/support/mongoid_versions.rb +22 -0
  76. data/spec/support/rails_versions.rb +35 -0
  77. metadata +79 -4
@@ -1,75 +1,71 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe "Single method" do
4
- before do
5
- stub_dotfile!
6
- end
7
-
3
+ RSpec.describe 'Single method' do
8
4
  after do
9
- Object.instance_eval{ remove_const :Hello } if defined?(Hello)
5
+ Object.instance_eval { remove_const :Hello } if defined?(Hello)
10
6
  end
11
7
 
12
- it "plain: should handle a method with no arguments" do
8
+ it 'plain: should handle a method with no arguments' do
13
9
  method = ''.method(:upcase)
14
- expect(method.ai(:plain => true)).to eq('String#upcase()')
10
+ expect(method.ai(plain: true)).to eq('String#upcase()')
15
11
  end
16
12
 
17
- it "color: should handle a method with no arguments" do
13
+ it 'color: should handle a method with no arguments' do
18
14
  method = ''.method(:upcase)
19
15
  expect(method.ai).to eq("\e[1;33mString\e[0m#\e[0;35mupcase\e[0m\e[0;37m()\e[0m")
20
16
  end
21
17
 
22
- it "plain: should handle a method with one argument" do
18
+ it 'plain: should handle a method with one argument' do
23
19
  method = ''.method(:include?)
24
- expect(method.ai(:plain => true)).to eq('String#include?(arg1)')
20
+ expect(method.ai(plain: true)).to eq('String#include?(arg1)')
25
21
  end
26
22
 
27
- it "color: should handle a method with one argument" do
23
+ it 'color: should handle a method with one argument' do
28
24
  method = ''.method(:include?)
29
25
  expect(method.ai).to eq("\e[1;33mString\e[0m#\e[0;35minclude?\e[0m\e[0;37m(arg1)\e[0m")
30
26
  end
31
27
 
32
- it "plain: should handle a method with two arguments" do
28
+ it 'plain: should handle a method with two arguments' do
33
29
  method = ''.method(:tr)
34
- expect(method.ai(:plain => true)).to eq('String#tr(arg1, arg2)')
30
+ expect(method.ai(plain: true)).to eq('String#tr(arg1, arg2)')
35
31
  end
36
32
 
37
- it "color: should handle a method with two arguments" do
33
+ it 'color: should handle a method with two arguments' do
38
34
  method = ''.method(:tr)
39
35
  expect(method.ai).to eq("\e[1;33mString\e[0m#\e[0;35mtr\e[0m\e[0;37m(arg1, arg2)\e[0m")
40
36
  end
41
37
 
42
- it "plain: should handle a method with multiple arguments" do
38
+ it 'plain: should handle a method with multiple arguments' do
43
39
  method = ''.method(:split)
44
- expect(method.ai(:plain => true)).to eq('String#split(*arg1)')
40
+ expect(method.ai(plain: true)).to eq('String#split(*arg1)')
45
41
  end
46
42
 
47
- it "color: should handle a method with multiple arguments" do
43
+ it 'color: should handle a method with multiple arguments' do
48
44
  method = ''.method(:split)
49
45
  expect(method.ai).to eq("\e[1;33mString\e[0m#\e[0;35msplit\e[0m\e[0;37m(*arg1)\e[0m")
50
46
  end
51
47
 
52
- it "plain: should handle a method defined in mixin" do
48
+ it 'plain: should handle a method defined in mixin' do
53
49
  method = ''.method(:is_a?)
54
- expect(method.ai(:plain => true)).to eq('String (Kernel)#is_a?(arg1)')
50
+ expect(method.ai(plain: true)).to eq('String (Kernel)#is_a?(arg1)')
55
51
  end
56
52
 
57
- it "color: should handle a method defined in mixin" do
53
+ it 'color: should handle a method defined in mixin' do
58
54
  method = ''.method(:is_a?)
59
55
  expect(method.ai).to eq("\e[1;33mString (Kernel)\e[0m#\e[0;35mis_a?\e[0m\e[0;37m(arg1)\e[0m")
60
56
  end
61
57
 
62
- it "plain: should handle an unbound method" do
58
+ it 'plain: should handle an unbound method' do
63
59
  class Hello
64
60
  def world; end
65
61
  end
66
62
  method = Hello.instance_method(:world)
67
- expect(method.ai(:plain => true)).to eq('Hello (unbound)#world()')
63
+ expect(method.ai(plain: true)).to eq('Hello (unbound)#world()')
68
64
  end
69
65
 
70
- it "color: should handle an unbound method" do
66
+ it 'color: should handle an unbound method' do
71
67
  class Hello
72
- def world(a,b); end
68
+ def world(a, b); end
73
69
  end
74
70
  method = Hello.instance_method(:world)
75
71
  if RUBY_VERSION < '1.9.2'
@@ -80,93 +76,89 @@ RSpec.describe "Single method" do
80
76
  end
81
77
  end
82
78
 
83
- RSpec.describe "Object methods" do
84
- before do
85
- stub_dotfile!
86
- end
87
-
79
+ RSpec.describe 'Object methods' do
88
80
  after do
89
- Object.instance_eval{ remove_const :Hello } if defined?(Hello)
81
+ Object.instance_eval { remove_const :Hello } if defined?(Hello)
90
82
  end
91
83
 
92
- describe "object.methods" do
93
- it "index: should handle object.methods" do
94
- out = nil.methods.ai(:plain => true).split("\n").grep(/is_a\?/).first
84
+ describe 'object.methods' do
85
+ it 'index: should handle object.methods' do
86
+ out = nil.methods.ai(plain: true).split("\n").grep(/is_a\?/).first
95
87
  expect(out).to match(/^\s+\[\s*\d+\]\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/)
96
88
  end
97
89
 
98
- it "no index: should handle object.methods" do
99
- out = nil.methods.ai(:plain => true, :index => false).split("\n").grep(/is_a\?/).first
90
+ it 'no index: should handle object.methods' do
91
+ out = nil.methods.ai(plain: true, index: false).split("\n").grep(/is_a\?/).first
100
92
  expect(out).to match(/^\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/)
101
93
  end
102
94
  end
103
95
 
104
- describe "object.public_methods" do
105
- it "index: should handle object.public_methods" do
106
- out = nil.public_methods.ai(:plain => true).split("\n").grep(/is_a\?/).first
96
+ describe 'object.public_methods' do
97
+ it 'index: should handle object.public_methods' do
98
+ out = nil.public_methods.ai(plain: true).split("\n").grep(/is_a\?/).first
107
99
  expect(out).to match(/^\s+\[\s*\d+\]\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/)
108
100
  end
109
101
 
110
- it "no index: should handle object.public_methods" do
111
- out = nil.public_methods.ai(:plain => true, :index => false).split("\n").grep(/is_a\?/).first
102
+ it 'no index: should handle object.public_methods' do
103
+ out = nil.public_methods.ai(plain: true, index: false).split("\n").grep(/is_a\?/).first
112
104
  expect(out).to match(/^\s+is_a\?\(arg1\)\s+NilClass \(Kernel\)$/)
113
105
  end
114
106
  end
115
107
 
116
- describe "object.private_methods" do
117
- it "index: should handle object.private_methods" do
118
- out = nil.private_methods.ai(:plain => true).split("\n").grep(/sleep/).first
108
+ describe 'object.private_methods' do
109
+ it 'index: should handle object.private_methods' do
110
+ out = nil.private_methods.ai(plain: true).split("\n").grep(/sleep/).first
119
111
  expect(out).to match(/^\s+\[\s*\d+\]\s+sleep\(\*arg1\)\s+NilClass \(Kernel\)$/)
120
112
  end
121
113
 
122
- it "no index: should handle object.private_methods" do
123
- out = nil.private_methods.ai(:plain => true, :index => false).split("\n").grep(/sleep/).first
114
+ it 'no index: should handle object.private_methods' do
115
+ out = nil.private_methods.ai(plain: true, index: false).split("\n").grep(/sleep/).first
124
116
  expect(out).to match(/^\s+sleep\(\*arg1\)\s+NilClass \(Kernel\)$/)
125
117
  end
126
118
  end
127
119
 
128
- describe "object.protected_methods" do
129
- it "index: should handle object.protected_methods" do
120
+ describe 'object.protected_methods' do
121
+ it 'index: should handle object.protected_methods' do
130
122
  class Hello
131
123
  protected
132
124
  def m1; end
133
125
  def m2; end
134
126
  end
135
- expect(Hello.new.protected_methods.ai(:plain => true)).to eq("[\n [0] m1() Hello\n [1] m2() Hello\n]")
127
+ expect(Hello.new.protected_methods.ai(plain: true)).to eq("[\n [0] m1() Hello\n [1] m2() Hello\n]")
136
128
  end
137
129
 
138
- it "no index: should handle object.protected_methods" do
130
+ it 'no index: should handle object.protected_methods' do
139
131
  class Hello
140
132
  protected
141
- def m3(a,b); end
133
+ def m3(a, b); end
142
134
  end
143
135
  if RUBY_VERSION < '1.9.2'
144
- expect(Hello.new.protected_methods.ai(:plain => true, :index => false)).to eq("[\n m3(arg1, arg2) Hello\n]")
136
+ expect(Hello.new.protected_methods.ai(plain: true, index: false)).to eq("[\n m3(arg1, arg2) Hello\n]")
145
137
  else
146
- expect(Hello.new.protected_methods.ai(:plain => true, :index => false)).to eq("[\n m3(a, b) Hello\n]")
138
+ expect(Hello.new.protected_methods.ai(plain: true, index: false)).to eq("[\n m3(a, b) Hello\n]")
147
139
  end
148
140
  end
149
141
  end
150
142
 
151
- describe "object.private_methods" do
152
- it "index: should handle object.private_methods" do
143
+ describe 'object.private_methods' do
144
+ it 'index: should handle object.private_methods' do
153
145
  class Hello
154
146
  private
155
147
  def m1; end
156
148
  def m2; end
157
149
  end
158
150
 
159
- out = Hello.new.private_methods.ai(:plain => true).split("\n").grep(/m\d/)
151
+ out = Hello.new.private_methods.ai(plain: true).split("\n").grep(/m\d/)
160
152
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello$/)
161
153
  expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello$/)
162
154
  end
163
155
 
164
- it "no index: should handle object.private_methods" do
156
+ it 'no index: should handle object.private_methods' do
165
157
  class Hello
166
158
  private
167
- def m3(a,b); end
159
+ def m3(a, b); end
168
160
  end
169
- out = Hello.new.private_methods.ai(:plain => true).split("\n").grep(/m\d/)
161
+ out = Hello.new.private_methods.ai(plain: true).split("\n").grep(/m\d/)
170
162
  if RUBY_VERSION < '1.9.2'
171
163
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m3\(arg1, arg2\)\s+Hello$/)
172
164
  else
@@ -175,24 +167,24 @@ RSpec.describe "Object methods" do
175
167
  end
176
168
  end
177
169
 
178
- describe "object.singleton_methods" do
179
- it "index: should handle object.singleton_methods" do
170
+ describe 'object.singleton_methods' do
171
+ it 'index: should handle object.singleton_methods' do
180
172
  class Hello
181
173
  class << self
182
174
  def m1; end
183
175
  def m2; end
184
176
  end
185
177
  end
186
- out = Hello.singleton_methods.ai(:plain => true).split("\n").grep(/m\d/)
178
+ out = Hello.singleton_methods.ai(plain: true).split("\n").grep(/m\d/)
187
179
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello$/)
188
180
  expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello$/)
189
181
  end
190
182
 
191
- it "no index: should handle object.singleton_methods" do
183
+ it 'no index: should handle object.singleton_methods' do
192
184
  class Hello
193
- def self.m3(a,b); end
185
+ def self.m3(a, b); end
194
186
  end
195
- out = Hello.singleton_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
187
+ out = Hello.singleton_methods.ai(plain: true, index: false).split("\n").grep(/m\d/)
196
188
  if RUBY_VERSION < '1.9.2'
197
189
  expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello$/)
198
190
  else
@@ -202,31 +194,27 @@ RSpec.describe "Object methods" do
202
194
  end
203
195
  end
204
196
 
205
- RSpec.describe "Class methods" do
206
- before do
207
- stub_dotfile!
208
- end
209
-
197
+ RSpec.describe 'Class methods' do
210
198
  after do
211
- Object.instance_eval{ remove_const :Hello } if defined?(Hello)
199
+ Object.instance_eval { remove_const :Hello } if defined?(Hello)
212
200
  end
213
201
 
214
- describe "class.instance_methods" do
215
- it "index: should handle unbound class.instance_methods" do
202
+ describe 'class.instance_methods' do
203
+ it 'index: should handle unbound class.instance_methods' do
216
204
  class Hello
217
205
  def m1; end
218
206
  def m2; end
219
207
  end
220
- out = Hello.instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
208
+ out = Hello.instance_methods.ai(plain: true).split("\n").grep(/m\d/)
221
209
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/)
222
210
  expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/)
223
211
  end
224
212
 
225
- it "no index: should handle unbound class.instance_methods" do
213
+ it 'no index: should handle unbound class.instance_methods' do
226
214
  class Hello
227
- def m3(a,b); end
215
+ def m3(a, b); end
228
216
  end
229
- out = Hello.instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
217
+ out = Hello.instance_methods.ai(plain: true, index: false).split("\n").grep(/m\d/)
230
218
  if RUBY_VERSION < '1.9.2'
231
219
  expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/)
232
220
  else
@@ -235,22 +223,22 @@ RSpec.describe "Class methods" do
235
223
  end
236
224
  end
237
225
 
238
- describe "class.public_instance_methods" do
239
- it "index: should handle class.public_instance_methods" do
226
+ describe 'class.public_instance_methods' do
227
+ it 'index: should handle class.public_instance_methods' do
240
228
  class Hello
241
229
  def m1; end
242
230
  def m2; end
243
231
  end
244
- out = Hello.public_instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
232
+ out = Hello.public_instance_methods.ai(plain: true).split("\n").grep(/m\d/)
245
233
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/)
246
234
  expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/)
247
235
  end
248
236
 
249
- it "no index: should handle class.public_instance_methods" do
237
+ it 'no index: should handle class.public_instance_methods' do
250
238
  class Hello
251
- def m3(a,b); end
239
+ def m3(a, b); end
252
240
  end
253
- out = Hello.public_instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
241
+ out = Hello.public_instance_methods.ai(plain: true, index: false).split("\n").grep(/m\d/)
254
242
  if RUBY_VERSION < '1.9.2'
255
243
  expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/)
256
244
  else
@@ -259,24 +247,24 @@ RSpec.describe "Class methods" do
259
247
  end
260
248
  end
261
249
 
262
- describe "class.protected_instance_methods" do
263
- it "index: should handle class.protected_instance_methods" do
250
+ describe 'class.protected_instance_methods' do
251
+ it 'index: should handle class.protected_instance_methods' do
264
252
  class Hello
265
253
  protected
266
254
  def m1; end
267
255
  def m2; end
268
256
  end
269
- out = Hello.protected_instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
257
+ out = Hello.protected_instance_methods.ai(plain: true).split("\n").grep(/m\d/)
270
258
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/)
271
259
  expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/)
272
260
  end
273
261
 
274
- it "no index: should handle class.protected_instance_methods" do
262
+ it 'no index: should handle class.protected_instance_methods' do
275
263
  class Hello
276
264
  protected
277
- def m3(a,b); end
265
+ def m3(a, b); end
278
266
  end
279
- out = Hello.protected_instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
267
+ out = Hello.protected_instance_methods.ai(plain: true, index: false).split("\n").grep(/m\d/)
280
268
  if RUBY_VERSION < '1.9.2'
281
269
  expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/)
282
270
  else
@@ -285,24 +273,24 @@ RSpec.describe "Class methods" do
285
273
  end
286
274
  end
287
275
 
288
- describe "class.private_instance_methods" do
289
- it "index: should handle class.private_instance_methods" do
276
+ describe 'class.private_instance_methods' do
277
+ it 'index: should handle class.private_instance_methods' do
290
278
  class Hello
291
279
  private
292
280
  def m1; end
293
281
  def m2; end
294
282
  end
295
- out = Hello.private_instance_methods.ai(:plain => true).split("\n").grep(/m\d/)
283
+ out = Hello.private_instance_methods.ai(plain: true).split("\n").grep(/m\d/)
296
284
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello\s\(unbound\)$/)
297
285
  expect(out.last).to match(/^\s+\[\s*\d+\]\s+m2\(\)\s+Hello\s\(unbound\)$/)
298
286
  end
299
287
 
300
- it "no index: should handle class.private_instance_methods" do
288
+ it 'no index: should handle class.private_instance_methods' do
301
289
  class Hello
302
290
  private
303
- def m3(a,b); end
291
+ def m3(a, b); end
304
292
  end
305
- out = Hello.private_instance_methods.ai(:plain => true, :index => false).split("\n").grep(/m\d/)
293
+ out = Hello.private_instance_methods.ai(plain: true, index: false).split("\n").grep(/m\d/)
306
294
  if RUBY_VERSION < '1.9.2'
307
295
  expect(out.first).to match(/^\s+m3\(arg1, arg2\)\s+Hello\s\(unbound\)$/)
308
296
  else
@@ -313,73 +301,73 @@ RSpec.describe "Class methods" do
313
301
  end
314
302
 
315
303
  if RUBY_VERSION >= '1.9.2'
316
- RSpec.describe "Ruby 1.9.2+ Method#parameters" do
304
+ RSpec.describe 'Ruby 1.9.2+ Method#parameters' do
317
305
  before do
318
306
  stub_dotfile!
319
307
  end
320
308
 
321
309
  after do
322
- Object.instance_eval{ remove_const :Hello } if defined?(Hello)
310
+ Object.instance_eval { remove_const :Hello } if defined?(Hello)
323
311
  end
324
312
 
325
- it "()" do
313
+ it '()' do
326
314
  class Hello
327
315
  def m1; end
328
316
  end
329
- out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
317
+ out = Hello.new.methods.ai(plain: true).split("\n").grep(/m1/)
330
318
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\)\s+Hello$/)
331
319
  end
332
320
 
333
- it ":req" do
321
+ it ':req' do
334
322
  class Hello
335
323
  def m1(a, b, c); end
336
324
  end
337
- out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
325
+ out = Hello.new.methods.ai(plain: true).split("\n").grep(/m1/)
338
326
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(a, b, c\)\s+Hello$/)
339
327
  end
340
328
 
341
- it ":opt" do
329
+ it ':opt' do
342
330
  class Hello
343
331
  def m1(a, b = 1, c = 2); end # m1(a, *b, *c)
344
332
  end
345
- out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
333
+ out = Hello.new.methods.ai(plain: true).split("\n").grep(/m1/)
346
334
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(a, \*b, \*c\)\s+Hello$/)
347
335
  end
348
336
 
349
- it ":rest" do
337
+ it ':rest' do
350
338
  class Hello
351
339
  def m1(*a); end # m1(*a)
352
340
  end
353
- out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
341
+ out = Hello.new.methods.ai(plain: true).split("\n").grep(/m1/)
354
342
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(\*a\)\s+Hello$/)
355
343
  end
356
344
 
357
- it ":block" do
345
+ it ':block' do
358
346
  class Hello
359
347
  def m1(a, b = nil, &blk); end # m1(a, *b, &blk)
360
348
  end
361
- out = Hello.new.methods.ai(:plain => true).split("\n").grep(/m1/)
349
+ out = Hello.new.methods.ai(plain: true).split("\n").grep(/m1/)
362
350
  expect(out.first).to match(/^\s+\[\s*\d+\]\s+m1\(a, \*b, &blk\)\s+Hello$/)
363
351
  end
364
352
  end
365
353
  end
366
354
 
367
- RSpec.describe "Methods arrays" do
355
+ RSpec.describe 'Methods arrays' do
368
356
  after do
369
- Object.instance_eval{ remove_const :Hello } if defined?(Hello)
370
- Object.instance_eval{ remove_const :World } if defined?(World)
357
+ Object.instance_eval { remove_const :Hello } if defined?(Hello)
358
+ Object.instance_eval { remove_const :World } if defined?(World)
371
359
  end
372
360
 
373
- it "obj1.methods - obj2.methods should be awesome printed" do
361
+ it 'obj1.methods - obj2.methods should be awesome printed' do
374
362
  stub_dotfile!
375
363
  class Hello
376
364
  def self.m1; end
377
365
  end
378
- out = (Hello.methods - Class.methods).ai(:plain => true)
366
+ out = (Hello.methods - Class.methods).ai(plain: true)
379
367
  expect(out).to eq("[\n [0] m1() Hello\n]")
380
368
  end
381
369
 
382
- it "obj1.methods & obj2.methods should be awesome printed" do
370
+ it 'obj1.methods & obj2.methods should be awesome printed' do
383
371
  stub_dotfile!
384
372
  class Hello
385
373
  def self.m1; end
@@ -388,24 +376,24 @@ RSpec.describe "Methods arrays" do
388
376
  class World
389
377
  def self.m1; end
390
378
  end
391
- out = (Hello.methods & World.methods - Class.methods).ai(:plain => true)
379
+ out = (Hello.methods & World.methods - Class.methods).ai(plain: true)
392
380
  expect(out).to eq("[\n [0] m1() Hello\n]")
393
381
  end
394
382
 
395
- it "obj1.methods.grep(pattern) should be awesome printed" do
383
+ it 'obj1.methods.grep(pattern) should be awesome printed' do
396
384
  stub_dotfile!
397
385
  class Hello
398
386
  def self.m1; end
399
387
  def self.m2; end
400
388
  def self.m3; end
401
389
  end
402
- out = Hello.methods.grep(/^m1$/).ai(:plain => true)
390
+ out = Hello.methods.grep(/^m1$/).ai(plain: true)
403
391
  expect(out).to eq("[\n [0] m1() Hello\n]")
404
- out = Hello.methods.grep(/^m\d$/).ai(:plain => true)
392
+ out = Hello.methods.grep(/^m\d$/).ai(plain: true)
405
393
  expect(out).to eq("[\n [0] m1() Hello\n [1] m2() Hello\n [2] m3() Hello\n]")
406
394
  end
407
395
 
408
- it "obj1.methods.grep(pattern, &block) should pass the matching string within the block" do
396
+ it 'obj1.methods.grep(pattern, &block) should pass the matching string within the block' do
409
397
  class Hello
410
398
  def self.m_one; end
411
399
  def self.m_two; end
@@ -415,7 +403,7 @@ RSpec.describe "Methods arrays" do
415
403
  expect(out).to eq([:one, :two])
416
404
  end
417
405
 
418
- it "obj1.methods.grep(pattern, &block) should be awesome printed" do
406
+ it 'obj1.methods.grep(pattern, &block) should be awesome printed' do
419
407
  stub_dotfile!
420
408
  class Hello
421
409
  def self.m0; end
@@ -424,12 +412,12 @@ RSpec.describe "Methods arrays" do
424
412
  def self.one; end
425
413
  end
426
414
 
427
- out = Hello.methods.grep(/^m(\d)$/) { %w(none one)[$1.to_i] }.ai(:plain => true)
415
+ out = Hello.methods.grep(/^m(\d)$/) { %w(none one)[$1.to_i] }.ai(plain: true)
428
416
  expect(out).to eq("[\n [0] none() Hello\n [1] one() Hello\n]")
429
417
  end
430
418
 
431
- # See https://github.com/michaeldv/awesome_print/issues/30 for details.
432
- it "grepping methods and converting them to_sym should work as expected" do
419
+ # See https://github.com/awesome-print/awesome_print/issues/30 for details.
420
+ it 'grepping methods and converting them to_sym should work as expected' do
433
421
  class Hello
434
422
  private
435
423
  def him; end
@@ -444,16 +432,16 @@ RSpec.describe "Methods arrays" do
444
432
  end
445
433
 
446
434
  hello = Hello.new
447
- expect((hello.send(:his) - hello.send(:her)).sort_by { |x| x.to_s }).to eq([ :him, :his ])
435
+ expect((hello.send(:his) - hello.send(:her)).sort_by { |x| x.to_s }).to eq([:him, :his])
448
436
  end
449
437
 
450
- it "appending garbage to methods array should not raise error" do
451
- arr = 42.methods << [ :wtf ]
452
- expect { arr.ai(:plain => true) }.not_to raise_error
438
+ it 'appending garbage to methods array should not raise error' do
439
+ arr = 42.methods << [:wtf]
440
+ expect { arr.ai(plain: true) }.not_to raise_error
453
441
  if RUBY_VERSION < '1.9.2'
454
- expect(arr.ai(:plain => true)).to match(/\s+wtf\(\?\)\s+\?/) # [ :wtf ].to_s => "wtf"
442
+ expect(arr.ai(plain: true)).to match(/\s+wtf\(\?\)\s+\?/) # [ :wtf ].to_s => "wtf"
455
443
  else
456
- expect(arr.ai(:plain => true)).to match(/\s+\[:wtf\]\(\?\)\s+\?/) # [ :wtf ].to_s => [:wtf]
444
+ expect(arr.ai(plain: true)).to match(/\s+\[:wtf\]\(\?\)\s+\?/) # [ :wtf ].to_s => [:wtf]
457
445
  end
458
446
  end
459
447
  end