Skip to content

Commit 273d4b0

Browse files
author
jordanbreen28
committed
(bug) - Fix ruby 3.x incompatibility
It was noted that this gem was failing spec tests when running on ruby 3.x and above. The root cause of this issue seemed to be the absolute_path property found on the Thread::Backtrace::Location class. Updating this to path allows spec tests to pass on both ruby 2.x and 3.x. Can confirm that when consumed by other tools, this also works as expected. Open to suggested changes and improvements.
1 parent 8008a19 commit 273d4b0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/puppetfile-resolver/puppetfile/parser/r10k_eval.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def self.parse(puppetfile_contents)
2121
rescue StandardError, LoadError => e
2222
# Find the originating error from within the puppetfile
2323
loc = e.backtrace_locations
24-
.select { |item| item.absolute_path == PUPPETFILE_MONIKER }
24+
.select { |item| item.path == PUPPETFILE_MONIKER }
2525
.first
2626
start_line_number = loc.nil? ? 0 : loc.lineno - 1 # Line numbers from ruby are base 1
2727
end_line_number = loc.nil? ? puppetfile_contents.lines.count - 1 : loc.lineno - 1 # Line numbers from ruby are base 1

lib/puppetfile-resolver/puppetfile/parser/r10k_eval/dsl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def method_missing(method_name, *_args) # rubocop:disable Style/MethodMissingSup
4141

4242
def find_load_line_number
4343
loc = Kernel.caller_locations
44-
.find { |call_loc| call_loc.absolute_path == ::PuppetfileResolver::Puppetfile::Parser::R10KEval::PUPPETFILE_MONIKER }
44+
.find { |call_loc| call_loc.path == ::PuppetfileResolver::Puppetfile::Parser::R10KEval::PUPPETFILE_MONIKER }
4545
loc.nil? ? 0 : loc.lineno - 1 # Line numbers from ruby are base 1
4646
end
4747
end

0 commit comments

Comments
 (0)