From c8c11f6a9cc08e5268d1a65683f07aece82461f7 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Wed, 25 Sep 2024 19:18:24 +0200 Subject: [PATCH] Prefer `require_relative` for internal requires `require_relative` is preferred over `require` for files within the same project because it uses paths relative to the current file, making code more portable and less dependent on the load path. This change updates internal requires to use `require_relative` for consistency, performance, and improved portability. Ref: - ruby/psych#522 - ruby/logger#20 - ruby/rdoc#658 - panorama-ed/memo_wise#349 - rubocop/rubocop#8748 --- CHANGELOG.md | 2 ++ lib/memo_wise.rb | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 558527d..9f23ac0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm **Gem enhancements:** +- Changed internal `require`s to `require_relative` to make code less dependent on the load path [[#350](https://github.com/panorama-ed/memo_wise/pull/350)] + _No breaking changes!_ **Project enhancements:** diff --git a/lib/memo_wise.rb b/lib/memo_wise.rb index 47248b8..15605a9 100644 --- a/lib/memo_wise.rb +++ b/lib/memo_wise.rb @@ -2,8 +2,8 @@ require "set" # Ruby < 3.2 does not load `set` by default. -require "memo_wise/internal_api" -require "memo_wise/version" +require_relative "memo_wise/internal_api" +require_relative "memo_wise/version" # MemoWise is the wise choice for memoization in Ruby. #