Skip to content

Commit

Permalink
Tidy-up
Browse files Browse the repository at this point in the history
  • Loading branch information
mblumtritt committed May 28, 2024
2 parents a409e33 + cb71805 commit c3f1d04
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -47,7 +49,7 @@ end
# /projects/test.rb:4
```

When you like to know if and when a code point is reached, `ImLost.here` will help:
When you like to know if a code point is reached, `ImLost.here` will help:

```ruby
ImLost.here
Expand Down
22 changes: 12 additions & 10 deletions lib/im-lost.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/im-lost/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

module ImLost
# The version number of the gem.
VERSION = '1.0.2'
VERSION = '1.1.0'
end
8 changes: 4 additions & 4 deletions spec/lib/im-lost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c3f1d04

Please sign in to comment.