/magic_frozen_string_literal

easily add '# frozen_string_literal: true' comments to the top of all your project's .rb files

Primary LanguageRubyMIT LicenseMIT

Magic_frozen_string_literal

Magic_frozen_string_literal is a little tool that allows you to quickly add the magic comment that indicates that the file can safely have its string literals frozen, as will be the default in Ruby 3.0.

Cloned from github.com/m-ryan/magic_encoding

Installation

gem install magic_frozen_string_literal
rbenv rehash

Usage

you can call the tool from the console with default parameters like so

magic_frozen_string_literal

this will prepend every “.rb” file in the working directory (recursively) with the following line:

# frozen_string_literal: true

Notes:

  • existing frozen_string_literal magic comments are replaced

  • the rest of the file remains unchanged

  • empty files are not touched