freezolite 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 46d38f192f8ba9768ac96058e43921c5e86cbf790c7fb909fddc615f78c1e089
4
+ data.tar.gz: f90cbf1ee37aeaa829654314d01d5d1faac1fcd55190aafbcbff566888c3e31d
5
+ SHA512:
6
+ metadata.gz: ead24d9fd71f4bd68d47a46abf142e41d73db823eacdd9200821b603050f71260c1a80b6a5045f928511ce8f3278076be965bbb6ad111e133fd1bf512e644f4c
7
+ data.tar.gz: 51200097eeb7bc815312a9cc13c9690a828ce33deb0be85c51553e9cd9a97c28dabd8a61255dd4f14af82bdd87507d33b1ef590b8742e89241b7d5c38a481d37
data/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Change log
2
+
3
+ ## master
4
+
5
+ ## 0.2.0 (2023-07-14)
6
+
7
+ - Change name from `freeze_the_lits` to `freezolite`. ([@palkan][])
8
+
9
+ - Migrate to `require-hooks`. ([@palkan][])
10
+
11
+ ## 0.1.0 (2023-06-15)
12
+
13
+ - Initial. ([@palkan][])
14
+
15
+ [@palkan]: https://github.com/palkan
data/LICENSE.txt ADDED
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2023 Vladimir Dementyev
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+
data/README.md ADDED
@@ -0,0 +1,78 @@
1
+ [![Gem Version](https://badge.fury.io/rb/freezolite.svg)](https://rubygems.org/gems/freezolite)
2
+ [![Build](https://github.com/ruby-next/freezolite/workflows/Build/badge.svg)](https://github.com/palkan/freezolite/actions)
3
+
4
+ # Freezolite ❄️
5
+
6
+ Tired 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)?
7
+
8
+ Freezolite is a gem that turn 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.
9
+
10
+ ## Usage
11
+
12
+ Add the gem to your Gemfile:
13
+
14
+ ```ruby
15
+ gem "freezolite"
16
+ ```
17
+
18
+ And drop the following line to your application entrypoint (e.g., `config/boot.rb` for Rails):
19
+
20
+ ```ruby
21
+ require "freezolite/auto"
22
+ ```
23
+
24
+ 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:
25
+
26
+ ```ruby
27
+ require "freezolite"
28
+
29
+ Freezolite.setup(
30
+ watch_dirs: ["/path/to/dir1", "/path/to/dir2"]
31
+ )
32
+ ```
33
+
34
+ ### Using with Bootsnap
35
+
36
+ FreezeTheList is compatible with Bootsnap. Just make sure you require it **after** Bootsnap:
37
+
38
+ ```ruby
39
+ # config/boot.rb
40
+
41
+ require "bootsnap/setup"
42
+ require "freezolite/auto"
43
+ require "bundler/setup"
44
+ ```
45
+
46
+ ### Using in tests
47
+
48
+ Usually, when we load tests we use different entry-points. Thus, we need to load `freezolite` differently if we want to enable auto-freezing for test files, too.
49
+
50
+ #### RSpec
51
+
52
+ Put the following line to `spec_helper.rb`:
53
+
54
+ ```ruby
55
+ require "freezolite/auto"
56
+ ```
57
+
58
+ Make sure you have `spec_helper.rb` _preloaded_ by RSpec by putting the following to the `.rspec` file:
59
+
60
+ ```txt
61
+ --require spec_helper
62
+ ```
63
+
64
+ #### Minitest
65
+
66
+ 🤷‍♂️
67
+
68
+ ### Supported Ruby versions
69
+
70
+ - Ruby (MRI) >= 2.7.0
71
+
72
+ ## Contributing
73
+
74
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/ruby-next/freezolite](https://github.com/ruby-next/freezolite).
75
+
76
+ ## License
77
+
78
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,3 @@
1
+ require "freezolite"
2
+
3
+ Freezolite.setup(watch_dirs: [Dir.pwd])
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Freezolite # :nodoc:
4
+ VERSION = "0.2.0"
5
+ end
data/lib/freezolite.rb ADDED
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "freezolite/version"
4
+
5
+ module Freezolite
6
+ class << self
7
+ attr_accessor :watch_dirs
8
+
9
+ def setup(watch_dirs:)
10
+ self.watch_dirs = watch_dirs.freeze
11
+ require "require-hooks/setup"
12
+
13
+ ::RequireHooks.around_load do |path, &block|
14
+ next block.call unless watch_dirs.any? { |dir| path.start_with?(dir) }
15
+
16
+ begin
17
+ was_frozen_string_literal = ::RubyVM::InstructionSequence.compile_option[:frozen_string_literal]
18
+ ::RubyVM::InstructionSequence.compile_option = {frozen_string_literal: true}
19
+ block.call
20
+ ensure
21
+ ::RubyVM::InstructionSequence.compile_option = {frozen_string_literal: was_frozen_string_literal}
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: freezolite
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Vladimir Dementyev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-07-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: require-hooks
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '1.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '1.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '13.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '13.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ description: Example description
70
+ email:
71
+ - Vladimir Dementyev
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - CHANGELOG.md
77
+ - LICENSE.txt
78
+ - README.md
79
+ - lib/freezolite.rb
80
+ - lib/freezolite/auto.rb
81
+ - lib/freezolite/version.rb
82
+ homepage: https://github.com/ruby-next/freezolite
83
+ licenses:
84
+ - MIT
85
+ metadata:
86
+ bug_tracker_uri: https://github.com/ruby-next/freezolite/issues
87
+ changelog_uri: https://github.com/ruby-next/freezolite/blob/master/CHANGELOG.md
88
+ documentation_uri: https://github.com/ruby-next/freezolite
89
+ homepage_uri: https://github.com/ruby-next/freezolite
90
+ source_code_uri: https://github.com/ruby-next/freezolite
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '2.7'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubygems_version: 3.4.8
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Example description
110
+ test_files: []