hot_reloader 0.7.0 → 0.7.1

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: 9421c166738e6fafb613ca2dac2bc28bd99b53a6229d4c0720db14f2e0c0ae25
4
- data.tar.gz: a5677eaf835907fc683a591bd5e746008aa9fe42f296fa0585372482f2df92fd
3
+ metadata.gz: 2662bca54aa2c3c8037bba0968b11b55ed697649fd4db820605db4a691d87e24
4
+ data.tar.gz: 7233061e421dfffb81445cdd11b2f23a9cfe8ad0b7f713a6c999a673790e5342
5
5
  SHA512:
6
- metadata.gz: 14c1d5918b46577369366f01912de5b1b61907195eedf2c182b87022c1d33796a65ec43a90efe21e72d3211b341b29a247c24383f2da499ed5a7a98116dc136b
7
- data.tar.gz: f6668adecc4df04439245a41d5b7327ec03b0f3e14b8bee313ec529b9275ebc5b57a4667d93c85e1e21118a54b33169d77765bb83eca73e8c24491eeb2091e0a
6
+ metadata.gz: 95f5e16fe369b17f8fd9ec71a8fb32cc285f94b6b18ad1cc4c6b9ef4088863cc4aab229beede4e18a0f49b3e715ddd095eb018f0540cb9c1ffb432ef2d46cba9
7
+ data.tar.gz: 91921b33d2ddb6218452dbcf5ab9069dbd44584fe390dd2c03d25eb28b587d6c6db01f67bb3a15ef1d459c5da8bcb1404eed1306fd44b2f8a8cd13df28fbcaae
data/README.md CHANGED
@@ -20,21 +20,7 @@ Add to your Gemfile
20
20
 
21
21
  Following is a example for use hot_reloader with [Roda](https://github.com/jeremyevans/roda):
22
22
 
23
- `config.ru` which used to start rack based web server with `command rackup -o 0.0.0.0 -p 9393`
24
-
25
- ```rb
26
- # config.ru
27
-
28
- require_relative './config/environment'
29
-
30
- if ENV['RACK_ENV'] == 'development'
31
- run ->(env) { App.call(env) }
32
- else
33
- run App.freeze.app
34
- end
35
- ```
36
-
37
- Add loader initialize code into `config/environment.rb`
23
+ ### Add loader initialize code into `config/environment.rb`
38
24
 
39
25
  For simple use case, you just need pass paths to `HotReloader.eager_load` or `HotReloader.will_listen`.
40
26
 
@@ -125,7 +111,23 @@ else
125
111
  end
126
112
  ```
127
113
 
128
- Write whatever application initialize code which need add into application.rb
114
+ ### Add other app files
115
+
116
+ `config.ru` which used to start rack based web server with `command rackup -o 0.0.0.0 -p 9393`
117
+
118
+ ```rb
119
+ # config.ru
120
+
121
+ require_relative './config/environment'
122
+
123
+ if ENV['RACK_ENV'] == 'development'
124
+ run ->(env) { App.call(env) }
125
+ else
126
+ run App.freeze.app
127
+ end
128
+ ```
129
+
130
+ Write whatever application needed initialize code into config/application.rb
129
131
 
130
132
  ```rb
131
133
  # config/application.rb
@@ -177,8 +179,9 @@ For a more rich WIP sample project, please check my another project [marketbet_c
177
179
 
178
180
  ## Dependency
179
181
 
180
- zeitwerk https://github.com/fxn/zeitwerk
181
- listen https://github.com/guard/listen
182
+ [zeitwerk](https://github.com/fxn/zeitwerk) https://github.com/fxn/zeitwerk
183
+
184
+ [listen](https://github.com/guard/listen) https://github.com/guard/listen
182
185
 
183
186
  ## Contributing
184
187
 
data/lib/hot_reloader.rb CHANGED
@@ -10,10 +10,12 @@ class HotReloader
10
10
  #
11
11
  # @param [*String, Array<String>] folders Folders which should be monitor, can be multi-args or array.
12
12
  # or only one Zeitwerk::Loader object can be provided.
13
- # @param [#call] logger logger or any object should response call, e.g. method(:puts), $stdout, $stderr.
14
- # @param [Array<String>] ignore Glob patterns or Pathname object which should be excluded.
13
+ # @param [#call] logger logger object, e.g. Logger.new($stdout).
14
+ # @param [Array<String>, Array<Pathname>] ignore File names, Glob patterns or Pathname object which should be excluded for zeitwerk.
15
+ # @param [Integer] wait_for_delay Set the delay (in seconds) before call loader.reload when changes exist.
16
+ # @param [Array<Regexp>] listen_ignore The regexp pattern which don't want listen on.
15
17
  # @return nil
16
- def will_listen(*folders, logger: Logger.new(IO::NULL), ignore: [])
18
+ def will_listen(*folders, logger: Logger.new(IO::NULL), ignore: [], wait_for_delay: nil, listen_ignore: [])
17
19
  folders = folders.flatten
18
20
 
19
21
  if folders.first.is_a? Zeitwerk::Loader
@@ -39,7 +41,11 @@ class HotReloader
39
41
 
40
42
  Listen.logger = logger
41
43
 
42
- Listen.to(*(folders + listened_folders), wait_for_delay: 1, ignore: /\.#.*/) { loader.reload }.start
44
+ listen_options = {ignore: [/\A\.?#/]}
45
+ listen_options.merge!({wait_for_delay: wait_for_delay}) if wait_for_delay
46
+ listen_options[:ignore].concat listen_ignore if listen_ignore
47
+
48
+ Listen.to(*(folders + listened_folders), listen_options) { loader.reload }.start
43
49
  end
44
50
 
45
51
  # Enable autoload ruby file based on default Zeitwerk rule.
@@ -47,7 +53,8 @@ class HotReloader
47
53
  #
48
54
  # @param [*String, Array<String>] folders folders which should be autoload, can be multi-args or array.
49
55
  # or only one Zeitwerk::Loader object can be provided.
50
- # @param [#call] logger logger or any object should response call, e.g. method(:puts), $stdout, $stderr.
56
+ # @param [#call] logger logger object, e.g. Logger.new($stdout)
57
+ # @param [Array<String>, Array<Pathname>] ignore File names, Glob patterns or Pathname object which should be excluded for zeitwerk.
51
58
  # @return nil
52
59
  def eager_load(*folders, logger: Logger.new(IO::NULL), ignore: [])
53
60
  folders = folders.flatten
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class HotReloader
4
- VERSION = '0.7.0'
4
+ VERSION = '0.7.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hot_reloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Billy.Zheng(zw963)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-14 00:00:00.000000000 Z
11
+ date: 2021-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk