diff --git a/README.md b/README.md index b03b051..c071a3f 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ File.open('test.txt', 'w') do |file| file.puts(:world!) end end + # output will look like # > IO#<<(?) # /projects/test.rb:1 @@ -38,6 +39,7 @@ ImLost.trace_exceptions do rescue SystemCallError raise('something went wrong!') end + # output will look like # x Errno::EEXIST: File exists @ rb_sysopen - / # /projects/test.rb:2 diff --git a/lib/im-lost.rb b/lib/im-lost.rb index 0db728e..3ec02f4 100644 --- a/lib/im-lost.rb +++ b/lib/im-lost.rb @@ -79,6 +79,7 @@ def trace_calls=(value) # rescue SystemCallError # raise('something went wrong!') # end + # # # output will look like # # x Errno::EEXIST: File exists @ rb_sysopen - / # # /projects/test.rb:2 @@ -170,15 +171,16 @@ def here(test = true) # file.puts(:world!) # end # end - # output will look like - # > IO#<<(?) - # /projects/test.rb:1 - # > IO#write(*) - # /projects/test.rb:1 - # > IO#puts(*) - # /projects/test.rb:2 - # > IO#write(*) - # /projects/test.rb:2 + # + # # output will look like + # # > IO#<<(?) + # # /projects/test.rb:1 + # # > IO#write(*) + # # /projects/test.rb:1 + # # > IO#puts(*) + # # /projects/test.rb:2 + # # > IO#write(*) + # # /projects/test.rb:2 # # @overload trace(*args) # @param args [[Object]] one or more objects to be traced @@ -392,7 +394,7 @@ def _local_vars(binding) end ] - supported = RUBY_VERSION >= '3.3.0' ? %i[raise rescue] : %i[raise] + supported = RUBY_VERSION.to_f >= 3.3 ? %i[raise rescue] : %i[raise] @trace_exceptions = TracePoint.new(*supported) do |tp| ex = tp.raised_exception.inspect diff --git a/spec/lib/im-lost_spec.rb b/spec/lib/im-lost_spec.rb index 26ae900..938a90c 100644 --- a/spec/lib/im-lost_spec.rb +++ b/spec/lib/im-lost_spec.rb @@ -99,7 +99,7 @@ def bar = :bar expect(output).to eq "> TestSample#insp(**{})\n" end - if RUBY_VERSION < '3.1.0' + if RUBY_VERSION.to_f < 3.1 it 'handles argument forwarding' do sample.fwd(40, 2) @@ -206,7 +206,7 @@ def bar = :bar expect(output).to eq "< TestSample#insp(**{})\n = \"{}\"\n" end - if RUBY_VERSION < '3.1.0' + if RUBY_VERSION.to_f < 3.1 it 'handles argument forwarding' do sample.fwd(40, 2) @@ -240,7 +240,7 @@ def bar = :bar end end - if RUBY_VERSION >= '3.3.0' + if RUBY_VERSION.to_f > 3.3 context '.trace_exceptions' do it 'traces exceptions and rescue blocks' do ImLost.trace_exceptions do @@ -299,7 +299,7 @@ def bar = :bar end end - if RUBY_VERSION < '3.3.0' + if RUBY_VERSION.to_f < 3.3 context '.trace_exceptions' do it 'traces exceptions and rescue blocks' do ImLost.trace_exceptions do