freezolite 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46d38f192f8ba9768ac96058e43921c5e86cbf790c7fb909fddc615f78c1e089
4
- data.tar.gz: f90cbf1ee37aeaa829654314d01d5d1faac1fcd55190aafbcbff566888c3e31d
3
+ metadata.gz: 2bed25358ffb5313cf2816282bc8a2e38516a283d7373987808c17d476962a07
4
+ data.tar.gz: 70c3a3a89ebbb11d3d8c81f40450124c0edfc20026e3deae1456ecde3bd09812
5
5
  SHA512:
6
- metadata.gz: ead24d9fd71f4bd68d47a46abf142e41d73db823eacdd9200821b603050f71260c1a80b6a5045f928511ce8f3278076be965bbb6ad111e133fd1bf512e644f4c
7
- data.tar.gz: 51200097eeb7bc815312a9cc13c9690a828ce33deb0be85c51553e9cd9a97c28dabd8a61255dd4f14af82bdd87507d33b1ef590b8742e89241b7d5c38a481d37
6
+ metadata.gz: c41594c8e976f6df02aa30854ac9dc3dab9b601fe73e648946704d3107b046dee1c2e10a072e1bed5d35b6782e783e45e23a4b43ee0de1606a3c549b8c99605b
7
+ data.tar.gz: 8739d41c3cca71d36ff559de8e6ce5f25b51208af997ff2555ceaeb088bd47e2a2f404db7fe5f682e6c1699a7940d65a4d6faf205133072e842882a81be22ffa
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.3.0 (2023-07-19)
6
+
7
+ - Ignore `./vendor` by default when using `freezolite/auto`. ([@palkan][])
8
+
9
+ - Replace `watch_dirs` with `patterns` and `exclude_patterns`. ([@palkan][])
10
+
5
11
  ## 0.2.0 (2023-07-14)
6
12
 
7
13
  - 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.3.0"
5
5
  end
data/lib/freezolite.rb CHANGED
@@ -4,14 +4,17 @@ require "freezolite/version"
4
4
 
5
5
  module Freezolite
6
6
  class << self
7
- attr_accessor :watch_dirs
7
+ attr_accessor :patterns, :exclude_patterns
8
+
9
+ def setup(patterns:, exclude_patterns: nil)
10
+ self.patterns = patterns
11
+ self.exclude_patterns = exclude_patterns
8
12
 
9
- def setup(watch_dirs:)
10
- self.watch_dirs = watch_dirs.freeze
11
13
  require "require-hooks/setup"
12
14
 
13
15
  ::RequireHooks.around_load do |path, &block|
14
- next block.call unless watch_dirs.any? { |dir| path.start_with?(dir) }
16
+ next block.call unless patterns.any? { |pattern| File.fnmatch?(pattern, path) }
17
+ next block.call if exclude_patterns&.any? { |pattern| File.fnmatch?(pattern, path) }
15
18
 
16
19
  begin
17
20
  was_frozen_string_literal = ::RubyVM::InstructionSequence.compile_option[:frozen_string_literal]
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.3.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-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: require-hooks