Skip to content

Commit

Permalink
Prefer require_relative for internal requires
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
tagliala committed Sep 19, 2024
1 parent 31c1487 commit 208128e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions lib/arbre.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
module Arbre
end

require 'arbre/element'
require 'arbre/context'
require 'arbre/html/attributes'
require 'arbre/html/class_list'
require 'arbre/html/tag'
require 'arbre/html/text_node'
require 'arbre/html/document'
require 'arbre/html/html5_elements'
require 'arbre/component'
require_relative 'arbre/element'
require_relative 'arbre/context'
require_relative 'arbre/html/attributes'
require_relative 'arbre/html/class_list'
require_relative 'arbre/html/tag'
require_relative 'arbre/html/text_node'
require_relative 'arbre/html/document'
require_relative 'arbre/html/html5_elements'
require_relative 'arbre/component'

if defined?(Rails)
require 'arbre/railtie'
require_relative 'arbre/railtie'
end
2 changes: 1 addition & 1 deletion lib/arbre/context.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true
require 'arbre/element'
require_relative 'element'

module Arbre

Expand Down
6 changes: 3 additions & 3 deletions lib/arbre/railtie.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
require 'arbre/rails/template_handler'
require 'arbre/rails/forms'
require 'arbre/rails/rendering'
require_relative 'rails/template_handler'
require_relative 'rails/forms'
require_relative 'rails/rendering'
require 'rails'

Arbre::Element.include(Arbre::Rails::Rendering)
Expand Down

0 comments on commit 208128e

Please sign in to comment.