Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
M

magic_frozen_string_literal

> 编程语言
Open source

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

159 stars0 likes1 views
WebsiteGitHub

About

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

= 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}[https://bugs.ruby-lang.org/issues/8976].

Cloned from https://github.com/m-ryan/magic_encoding

== Installation

gem install magic_frozen_string_literal rbenv rehash

== Usage

Run the tool from the command line:

magic_frozen_string_literal

this will prepend every ".rb", ".ru", "Rakefile", ".rake", "Gemfile", ".gemspec", ".rabl", ".jbuilder", ".haml", ".slim" file in the given (recursively) with the following magic comment followed by a blank line:

frozen_string_literal: true

(".haml" and ".slim" files will have a "-" prefix before the comment and no blank line after.)

The parameter is optional. It defaults to the current working directory.

Notes:

  • existing +frozen_string_literal+ magic comments are replaced
  • the rest of the file remains unchanged
  • empty files are not touched
  • if the file starts with #! (shebang), that line is preserved and the magic comment is added just below it

Issues· 4 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Ruby

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言