Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer require_relative for internal requires #170

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .rubocop_todo.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 13 additions & 12 deletions lib/inline_svg.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
require "inline_svg/version"
require "inline_svg/action_view/helpers"
require "inline_svg/asset_file"
require "inline_svg/cached_asset_file"
require "inline_svg/finds_asset_paths"
require "inline_svg/propshaft_asset_finder"
require "inline_svg/static_asset_finder"
require "inline_svg/webpack_asset_finder"
require "inline_svg/transform_pipeline"
require "inline_svg/io_resource"

require "inline_svg/railtie" if defined?(Rails)
require_relative "inline_svg/version"
require_relative "inline_svg/action_view/helpers"
require_relative "inline_svg/asset_file"
require_relative "inline_svg/cached_asset_file"
require_relative "inline_svg/finds_asset_paths"
require_relative "inline_svg/propshaft_asset_finder"
require_relative "inline_svg/static_asset_finder"
require_relative "inline_svg/webpack_asset_finder"
require_relative "inline_svg/transform_pipeline"
require_relative "inline_svg/io_resource"

require_relative "inline_svg/railtie" if defined?(Rails)

require 'active_support'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/string'
Expand Down
2 changes: 1 addition & 1 deletion lib/inline_svg/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module InlineSvg
class Railtie < ::Rails::Railtie
initializer "inline_svg.action_view" do |app|
ActiveSupport.on_load :action_view do
require "inline_svg/action_view/helpers"
require_relative "action_view/helpers"
include InlineSvg::ActionView::Helpers
end
end
Expand Down
30 changes: 15 additions & 15 deletions lib/inline_svg/transform_pipeline/transformations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ def self.no_transform
end
end

require 'inline_svg/transform_pipeline/transformations/transformation'
require 'inline_svg/transform_pipeline/transformations/no_comment'
require 'inline_svg/transform_pipeline/transformations/class_attribute'
require 'inline_svg/transform_pipeline/transformations/style_attribute'
require 'inline_svg/transform_pipeline/transformations/title'
require 'inline_svg/transform_pipeline/transformations/description'
require 'inline_svg/transform_pipeline/transformations/size'
require 'inline_svg/transform_pipeline/transformations/height'
require 'inline_svg/transform_pipeline/transformations/width'
require 'inline_svg/transform_pipeline/transformations/view_box'
require 'inline_svg/transform_pipeline/transformations/id_attribute'
require 'inline_svg/transform_pipeline/transformations/data_attributes'
require 'inline_svg/transform_pipeline/transformations/preserve_aspect_ratio'
require 'inline_svg/transform_pipeline/transformations/aria_attributes'
require "inline_svg/transform_pipeline/transformations/aria_hidden_attribute"
require_relative 'transformations/transformation'
require_relative 'transformations/no_comment'
require_relative 'transformations/class_attribute'
require_relative 'transformations/style_attribute'
require_relative 'transformations/title'
require_relative 'transformations/description'
require_relative 'transformations/size'
require_relative 'transformations/height'
require_relative 'transformations/width'
require_relative 'transformations/view_box'
require_relative 'transformations/id_attribute'
require_relative 'transformations/data_attributes'
require_relative 'transformations/preserve_aspect_ratio'
require_relative 'transformations/aria_attributes'
require_relative 'transformations/aria_hidden_attribute'
4 changes: 2 additions & 2 deletions spec/asset_file_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require_relative '../lib/inline_svg/finds_asset_paths'
require_relative '../lib/inline_svg/asset_file'
require "inline_svg/finds_asset_paths"
require "inline_svg/asset_file"

describe InlineSvg::AssetFile do
it "reads data from a file, after qualifying a full path" do
Expand Down
2 changes: 1 addition & 1 deletion spec/cached_asset_file_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require 'pathname'
require_relative '../lib/inline_svg'
require "inline_svg"

describe InlineSvg::CachedAssetFile do
let(:fixture_path) { Pathname.new(File.expand_path("../files/static_assets", __FILE__)) }
Expand Down
2 changes: 1 addition & 1 deletion spec/finds_asset_paths_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'pathname'
require_relative '../lib/inline_svg'
require "inline_svg"

describe InlineSvg::FindsAssetPaths do
context "when sprockets finder returns an object which supports only the pathname method" do
Expand Down
2 changes: 1 addition & 1 deletion spec/id_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require_relative '../lib/inline_svg/id_generator'
require "inline_svg/id_generator"

describe InlineSvg::IdGenerator do
it "generates a hexencoded ID based on a salt and a random value" do
Expand Down
2 changes: 1 addition & 1 deletion spec/inline_svg_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require_relative '../lib/inline_svg'
require "inline_svg"

class MyCustomTransform
def self.create_with_value(value); end
Expand Down
2 changes: 1 addition & 1 deletion spec/io_resource_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require_relative '../lib/inline_svg'
require "inline_svg"
require "stringio"
require "tempfile"

Expand Down
2 changes: 1 addition & 1 deletion spec/propshaft_asset_finder_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require_relative '../lib/inline_svg'
require "inline_svg"

describe InlineSvg::PropshaftAssetFinder do
context "when the file is not found" do
Expand Down
2 changes: 1 addition & 1 deletion spec/static_asset_finder_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require_relative '../lib/inline_svg'
require "inline_svg"

describe InlineSvg::StaticAssetFinder do
context "when the file is not found" do
Expand Down
2 changes: 1 addition & 1 deletion spec/webpack_asset_finder_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require_relative '../lib/inline_svg'
require "inline_svg"

describe InlineSvg::WebpackAssetFinder do
context "when the file is not found" do
Expand Down