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
- rubocop/rubocop#8748
  • Loading branch information
tagliala committed Sep 22, 2024
1 parent 7103d57 commit c856bd8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions lib/premailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
require 'addressable/uri'
require 'css_parser'

require 'premailer/adapter'
require 'premailer/adapter/rgb_to_hex'
require 'premailer/html_to_plain_text'
require 'premailer/premailer'
require 'premailer/cached_rule_set'
require_relative 'premailer/adapter'
require_relative 'premailer/adapter/rgb_to_hex'
require_relative 'premailer/html_to_plain_text'
require_relative 'premailer/premailer'
require_relative 'premailer/cached_rule_set'
3 changes: 2 additions & 1 deletion lib/premailer/executor.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true
require 'optparse'
require 'premailer'

require_relative '../premailer'

# defaults
options = {
Expand Down
2 changes: 1 addition & 1 deletion lib/premailer/premailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# puts premailer.to_inline_css
# ```
#
require 'premailer/version'
require_relative 'version'

class Premailer
include HtmlToPlainText
Expand Down

0 comments on commit c856bd8

Please sign in to comment.