freezolite 0.2.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46d38f192f8ba9768ac96058e43921c5e86cbf790c7fb909fddc615f78c1e089
4
- data.tar.gz: f90cbf1ee37aeaa829654314d01d5d1faac1fcd55190aafbcbff566888c3e31d
3
+ metadata.gz: ba7e6d9681a85534191c401f217c1d8f184dc86d1f2ac520972352db9d4b7f47
4
+ data.tar.gz: 4f92015d4bb62e597f707dc2fc512730bbeb2c06fc652f6b3b20b9bfaa38379c
5
5
  SHA512:
6
- metadata.gz: ead24d9fd71f4bd68d47a46abf142e41d73db823eacdd9200821b603050f71260c1a80b6a5045f928511ce8f3278076be965bbb6ad111e133fd1bf512e644f4c
7
- data.tar.gz: 51200097eeb7bc815312a9cc13c9690a828ce33deb0be85c51553e9cd9a97c28dabd8a61255dd4f14af82bdd87507d33b1ef590b8742e89241b7d5c38a481d37
6
+ metadata.gz: 71499e074c60a508d907b0fa2e983ad870668fa74430bee8fcc06cbe34ed1d591ae5b6f86e9e0d71d2571d963263a8ad028f745c7be01f2d7b733f09d11a03e2
7
+ data.tar.gz: fb213aaa5f7677908f65154888cb511883ef3e97a2a59b53a7831c8dfc2e9e3a0e9244e465a09677645fd62e6e3d15c1fa45c6a6c41a227e61b60c1e4eadaf09
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.4.0 (2023-08-23)
6
+
7
+ - Upgrade to `require-hooks` 0.2.0. ([@palkan][])
8
+
9
+ ## 0.3.0 (2023-07-19)
10
+
11
+ - Ignore `./vendor` by default when using `freezolite/auto`. ([@palkan][])
12
+
13
+ - Replace `watch_dirs` with `patterns` and `exclude_patterns`. ([@palkan][])
14
+
5
15
  ## 0.2.0 (2023-07-14)
6
16
 
7
17
  - Change name from `freeze_the_lits` to `freezolite`. ([@palkan][])
data/README.md CHANGED
@@ -15,10 +15,17 @@ Add the gem to your Gemfile:
15
15
  gem "freezolite"
16
16
  ```
17
17
 
18
- And drop the following line to your application entrypoint (e.g., `config/boot.rb` for Rails):
18
+ 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:
19
19
 
20
20
  ```ruby
21
+ # config/application.rb
22
+
23
+ #...
24
+ Bundler.require(*Rails.groups)
25
+
21
26
  require "freezolite/auto"
27
+
28
+ # <application configuration>
22
29
  ```
23
30
 
24
31
  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:
@@ -27,43 +34,17 @@ By default, the gem uses `Dir.pwd` to determine the project root. If you want to
27
34
  require "freezolite"
28
35
 
29
36
  Freezolite.setup(
30
- watch_dirs: ["/path/to/dir1", "/path/to/dir2"]
37
+ # You must pass a list of glob patterns
38
+ patterns: ["/path/to/dir1/*.rb", "/path/to/dir2/*.rb"],
39
+ exclude_patterns: ["/path/to/dir1/vendor/*"]
31
40
  )
32
41
  ```
33
42
 
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
43
+ **NOTE**: When using auto mode, the `<project-root>/vendor/bundle` folder is excluded automatically. In manual mode, you may want to exclude it yourself.
47
44
 
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
45
+ ### Using with Bootsnap
65
46
 
66
- 🤷‍♂️
47
+ Freezolite is compatible with Bootsnap. Just make sure you require it **after** Bootsnap. No manual cache invalidation required.
67
48
 
68
49
  ### Supported Ruby versions
69
50
 
@@ -1,3 +1,6 @@
1
1
  require "freezolite"
2
2
 
3
- Freezolite.setup(watch_dirs: [Dir.pwd])
3
+ Freezolite.setup(
4
+ patterns: [File.join(Dir.pwd, "*.rb")],
5
+ exclude_patterns: [File.join(Dir.pwd, "vendor", "*")]
6
+ )
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Freezolite # :nodoc:
4
- VERSION = "0.2.0"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/freezolite.rb CHANGED
@@ -4,22 +4,15 @@ require "freezolite/version"
4
4
 
5
5
  module Freezolite
6
6
  class << self
7
- attr_accessor :watch_dirs
8
-
9
- def setup(watch_dirs:)
10
- self.watch_dirs = watch_dirs.freeze
7
+ def setup(patterns:, exclude_patterns: nil)
11
8
  require "require-hooks/setup"
12
9
 
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
10
+ ::RequireHooks.around_load(patterns: patterns, exclude_patterns: exclude_patterns) do |path, &block|
11
+ was_frozen_string_literal = ::RubyVM::InstructionSequence.compile_option[:frozen_string_literal]
12
+ ::RubyVM::InstructionSequence.compile_option = {frozen_string_literal: true}
13
+ block.call
14
+ ensure
15
+ ::RubyVM::InstructionSequence.compile_option = {frozen_string_literal: was_frozen_string_literal}
23
16
  end
24
17
  end
25
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freezolite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-15 00:00:00.000000000 Z
11
+ date: 2023-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: require-hooks
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.1'
19
+ version: '0.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.1'
26
+ version: '0.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement