Skip to content

Commit c56c55d

Browse files
authored
feat: match ruby 3.4 backtrace changes (#113)
1 parent 4909418 commit c56c55d

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
- 3.1
1616
- 3.2
1717
- 3.3
18+
- 3.4
1819
env:
1920
BUNDLE_GEMFILE: Gemfile
2021
name: "RSpec tests: Ruby ${{ matrix.ruby }}"

code_ownership.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |spec|
22
spec.name = 'code_ownership'
3-
spec.version = '1.38.1'
3+
spec.version = '1.38.2'
44
spec.authors = ['Gusto Engineers']
55
spec.email = ['[email protected]']
66
spec.summary = 'A gem to help engineering teams declare ownership of code'

lib/code_ownership.rb

+17-7
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,23 @@ def backtrace_with_ownership(backtrace)
136136
#
137137
# ./app/controllers/some_controller.rb:43:in `block (3 levels) in create'
138138
#
139-
backtrace_line = %r{\A(#{Pathname.pwd}/|\./)?
140-
(?<file>.+) # Matches 'app/controllers/some_controller.rb'
141-
:
142-
(?<line>\d+) # Matches '43'
143-
:in\s
144-
`(?<function>.*)' # Matches "`block (3 levels) in create'"
145-
\z}x
139+
backtrace_line = if RUBY_VERSION >= '3.4.0'
140+
%r{\A(#{Pathname.pwd}/|\./)?
141+
(?<file>.+) # Matches 'app/controllers/some_controller.rb'
142+
:
143+
(?<line>\d+) # Matches '43'
144+
:in\s
145+
'(?<function>.*)' # Matches "`block (3 levels) in create'"
146+
\z}x
147+
else
148+
%r{\A(#{Pathname.pwd}/|\./)?
149+
(?<file>.+) # Matches 'app/controllers/some_controller.rb'
150+
:
151+
(?<line>\d+) # Matches '43'
152+
:in\s
153+
`(?<function>.*)' # Matches "`block (3 levels) in create'"
154+
\z}x
155+
end
146156

147157
backtrace.lazy.filter_map do |line|
148158
match = line.match(backtrace_line)

0 commit comments

Comments
 (0)