Tired of adding # frozen_string_literals: true
to every file in your Ruby project, or running rubocop -A
to make it do that for you? What if I told you that you can just add a single gem to your project and activate this option for the project’s files automatically (without enabling it globally)?
Usage
Add the gem to your Gemfile
:
gem "freezolite"
And drop the following line to your application entry-point after loading dependencies and before loading your application code. For example, in Rails, you can put it to config/application.rb
after the Bundler.require(...)
call:
# config/application.rb
#...
Bundler.require(*Rails.groups)
require "freezolite/auto"
# <application configuration>
By default, the gem uses Dir.pwd
to determine the project root. If you want to use a different directory or multiple directories, configure the gem like this:
require "freezolite"
Freezolite.setup(
# You must pass a list of glob patterns
patterns: ["/path/to/dir1/*.rb", "/path/to/dir2/*.rb"],
exclude_patterns: ["/path/to/dir1/vendor/*"]
)