File tree 3 files changed +20
-4
lines changed
3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change 1
1
## master (unreleased)
2
-
2
+ - Handles NoMethodError for IRB implicit ` ai ` [ @ jtnegrotto ] - [ # 212 ]
3
3
4
4
## 1.7.0
5
5
- Refactoring by extracting formatters into their own classes [ @waldyr ] - [ #237 ]
129
129
- Initial Release.
130
130
131
131
[ #200 ] : https://github.com/awesome-print/awesome_print/pull/200
132
+ [ #212 ] : https://github.com/awesome-print/awesome_print/pull/212
132
133
[ #216 ] : https://github.com/awesome-print/awesome_print/pull/216
133
134
[ #217 ] : https://github.com/awesome-print/awesome_print/pull/217
134
135
[ #222 ] : https://github.com/awesome-print/awesome_print/pull/222
145
146
[ @clonezone ] : https://github.com/clonezone
146
147
[ @cyberdelia ] : https://github.com/cyberdelia
147
148
[ @gerrywastaken ] : https://github.com/gerrywastaken
149
+ [ @jtnegrotto ] : https://github.com/jtnegrotto
148
150
[ @kemmason ] : https://github.com/kemmason
149
151
[ @maurogeorge ] : https://github.com/maurogeorge
150
152
[ @MaxPleaner ] : https://github.com/MaxPleaner
Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ def irb!
31
31
IRB ::Irb . class_eval do
32
32
def output_value
33
33
ap @context . last_value
34
+ rescue NoMethodError
35
+ puts "(Object doesn't support #ai)"
34
36
end
35
37
end
36
38
else # MacRuby
@@ -55,7 +57,7 @@ class Inspector
55
57
AP = :__awesome_print__
56
58
57
59
def initialize ( options = { } )
58
- @options = {
60
+ @options = {
59
61
:indent => 4 , # Indent using 4 spaces.
60
62
:index => true , # Display array indices.
61
63
:html => false , # Use ANSI color codes rather than HTML.
@@ -65,7 +67,7 @@ def initialize(options = {})
65
67
:sort_keys => false , # Do not sort hash keys.
66
68
:limit => false , # Limit large output for arrays and hashes. Set to a boolean or integer.
67
69
:new_hash_syntax => false , # Use the JSON like syntax { foo: 'bar' }, when the key is a symbol
68
- :color => {
70
+ :color => {
69
71
:args => :pale ,
70
72
:array => :white ,
71
73
:bigdecimal => :blue ,
@@ -104,7 +106,7 @@ def current_indentation
104
106
def increase_indentation
105
107
indentator . indent ( &Proc . new )
106
108
end
107
-
109
+
108
110
# Dispatcher that detects data nesting and invokes object-aware formatter.
109
111
#------------------------------------------------------------------------------
110
112
def awesome ( object )
Original file line number Diff line number Diff line change @@ -246,5 +246,17 @@ class IRB; end
246
246
expect ( capture! { ap ( { :a => 1 } ) } ) . to eq ( nil )
247
247
Object . instance_eval { remove_const :IRB }
248
248
end
249
+
250
+ it "handles NoMethodError on IRB implicit #ai" do
251
+ module IRB ; class Irb ; end ; end
252
+ irb_context = double ( 'irb_context' , last_value : BasicObject . new )
253
+ IRB . define_singleton_method :version , -> { 'test_version' }
254
+ irb = IRB ::Irb . new
255
+ irb . instance_eval { @context = irb_context }
256
+ AwesomePrint . irb!
257
+ expect ( irb ) . to receive ( :puts ) . with ( "(Object doesn't support #ai)" )
258
+ expect { irb . output_value } . to_not raise_error
259
+ Object . instance_eval { remove_const :IRB }
260
+ end
249
261
end
250
262
end
You can’t perform that action at this time.
0 commit comments