{"id":13878036,"url":"https://github.com/ruby-next/freezolite","last_synced_at":"2025-07-16T14:30:48.578Z","repository":{"id":175647163,"uuid":"654269475","full_name":"ruby-next/freezolite","owner":"ruby-next","description":"Automatically add frozen_string_literals to selected files at compile time","archived":false,"fork":false,"pushed_at":"2024-04-29T23:49:46.000Z","size":47,"stargazers_count":114,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-10T19:56:02.722Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ruby-next.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-15T18:49:27.000Z","updated_at":"2024-10-31T01:55:36.000Z","dependencies_parsed_at":"2024-02-06T20:33:18.523Z","dependency_job_id":"f903ac5b-809a-4060-bd07-785658acaf7f","html_url":"https://github.com/ruby-next/freezolite","commit_stats":null,"previous_names":["ruby-next/freeze_the_lits","ruby-next/freezolite"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-next%2Ffreezolite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-next%2Ffreezolite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-next%2Ffreezolite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-next%2Ffreezolite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ruby-next","download_url":"https://codeload.github.com/ruby-next/freezolite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226134226,"owners_count":17578778,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T08:01:38.097Z","updated_at":"2024-11-24T06:31:45.750Z","avatar_url":"https://github.com/ruby-next.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"[![Gem Version](https://badge.fury.io/rb/freezolite.svg)](https://rubygems.org/gems/freezolite)\n[![Build](https://github.com/ruby-next/freezolite/workflows/Build/badge.svg)](https://github.com/palkan/freezolite/actions)\n\n# Freezolite ❄️\n\nTired of adding `# frozen_string_literals: true` to every file in your 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)?\n\nFreezolite is a gem that turns the `frozen_string_literal` compile option on only for the specified files. Thus it's like running Ruby with `--enable=frozen-string-literal` but only for the files you own.\n\n\u003e 📖 Read more about the motivation behind this project in [\"Freezolite: the magic gem for keeping Ruby literals safely frozen\"](https://evilmartians.com/chronicles/freezolite-the-magic-gem-for-keeping-ruby-literals-safely-frozen) post.\n\nFreezolite also comes with experimental support for [freezing constants](#freezing-constants).\n\n## Usage\n\nAdd the gem to your Gemfile:\n\n```ruby\ngem \"freezolite\"\n```\n\nAnd drop the following line into your application entry-point **after loading dependencies** and before loading your application code. For example, in Rails, you can put it in `config/application.rb` after the `Bundler.require(...)` call:\n\n```ruby\n# config/application.rb\n\n#...\nBundler.require(*Rails.groups)\n\nrequire \"freezolite/auto\"\n\n# \u003capplication configuration\u003e\n```\n\nBy 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:\n\n```ruby\nrequire \"freezolite\"\n\nFreezolite.setup(\n  # You must pass a list of glob patterns\n  patterns: [\"/path/to/dir1/*.rb\", \"/path/to/dir2/*.rb\"],\n  exclude_patterns: [\"/path/to/dir1/vendor/*\"]\n)\n```\n\n\u003e [!NOTE]\n\u003e When using auto mode, the `\u003cproject-root\u003e/vendor/bundle` folder is excluded automatically. In manual mode, you may want to exclude it yourself.\n\n### Using with Bootsnap\n\nFreezolite is compatible with Bootsnap. Just make sure you require it **after** Bootsnap. No manual cache invalidation required.\n\n### Freezing constants\n\nRuby 3 introduced a new pragma—[`# shareable_constant_value: ...`](https://bugs.ruby-lang.org/issues/17273). It's meant to be used with Ractor-driven applications to easily turn constants into Ractor-shareable objects within a source file. Making Ractor-shareable implies **deep freezing**, thus, we can leverage this pragma to automatically freeze constants!\n\nFreezolite can automatically inject this pragma for you (only for matching files, similarly to frozen literals). You need to opt-in to enable this feature:\n\n```ruby\nrequire \"freezolite\"\n# You can also specify specific values, such as literal, experimental_copy, etc.\n# Setting to `true` is equal to the `literal` value.\nFreezolite.experimental_freeze_constants = true\nrequire \"freezolite/auto\" # or setup manually\n```\n\n\u003e [!NOTE]\n\u003e This feature is considered experimental for the following reasons: 1) the pragma itself is not widely used and we still need to learn how to use it in our applications; 2) unlike `# frozen_string_literal`, this setting is not a compiler option but a parser context switch; thus, we have to use source transform here, and literally add a line to the source file, thus, breaking the line numbers in your stack traces, etc.\n\n### Supported Ruby versions\n\n- Ruby (MRI) \u003e= 2.7.0\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at [https://github.com/ruby-next/freezolite](https://github.com/ruby-next/freezolite).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruby-next%2Ffreezolite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruby-next%2Ffreezolite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruby-next%2Ffreezolite/lists"}