diff --git a/.rubocop.yml b/.rubocop.yml index ffebef8..2168d74 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -13,7 +13,6 @@ AllCops: - bin/* - gemfiles/* - spec/dummy/**/* - - lib/generators/**/*.rb Gemspec/RequireMFA: Enabled: false @@ -37,6 +36,7 @@ Layout/LineLength: Exclude: - remotipart.gemspec - spec/remotipart/features/comments_spec.rb + - lib/generators/remotipart/install/install_generator.rb Layout/EmptyLines: Enabled: false diff --git a/lib/generators/remotipart/install/install_generator.rb b/lib/generators/remotipart/install/install_generator.rb index 0e87af2..871e46d 100644 --- a/lib/generators/remotipart/install/install_generator.rb +++ b/lib/generators/remotipart/install/install_generator.rb @@ -1,19 +1,21 @@ -require 'rails' +# frozen_string_literal: true + +require 'rails/generators' module Remotipart module Generators class InstallGenerator < ::Rails::Generators::Base desc "This generator installs IframeTransport.js #{Remotipart::IFRAMETRANSPORT_VERSION} and Remotipart #{Remotipart::VERSION}" - source_root File.expand_path('../../../../../vendor/assets/javascripts', __FILE__) + source_root File.expand_path('../../../../vendor/assets/javascripts', __dir__) def install_iframe_transport - say_status "copying", "IframeTransport.js #{Remotipart::IFRAMETRANSPORT_VERSION}", :green - copy_file "jquery.iframe-transport.js", "public/javascripts/jquery.iframe-transport.js" + say_status 'copying', "IframeTransport.js #{Remotipart::IFRAMETRANSPORT_VERSION}", :green + copy_file 'jquery.iframe-transport.js', 'public/javascripts/jquery.iframe-transport.js' end def install_remotipart - say_status "copying", "Remotipart.js #{Remotipart::VERSION}", :green + say_status 'copying', "Remotipart.js #{Remotipart::VERSION}", :green copy_file 'jquery.remotipart.js', 'public/javascripts/jquery.remotipart.js' end end diff --git a/lib/remotipart.rb b/lib/remotipart.rb index 2003ad1..2f4ebd9 100644 --- a/lib/remotipart.rb +++ b/lib/remotipart.rb @@ -1,11 +1,14 @@ # frozen_string_literal: true +# require external dependencies require 'zeitwerk' -loader = Zeitwerk::Loader.for_gem -generators = "#{__dir__}/generators" -loader.ignore(generators) -loader.setup + +# load zeitwerk +Zeitwerk::Loader.for_gem.tap do |loader| + loader.ignore("#{__dir__}/generators") + loader.setup +end module Remotipart - require 'remotipart/engine' if defined?(Rails) + require_relative 'remotipart/engine' if defined?(Rails) end