hotwire-livereload 0.1.4 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f8001c1b5e1ae699af050da2c601fd29ee3242cdcdd87f1487b38d18a395978
4
- data.tar.gz: 0fa2a43353fceb7e14908d1130cb7fcea7c71b59846888c3845e91922b5ac833
3
+ metadata.gz: 05ad19b6e77492fec265a2da6af3ddd9aa8b7b149ae284397644db40b553974b
4
+ data.tar.gz: 7f497acf2a34e1774d80c7a2fa1030b6a2eb9228cc2fe257b73a7cdad0e912fc
5
5
  SHA512:
6
- metadata.gz: 7202fa592b12ab9ef913d0fc62979b998a53357f9d74731df1fe1990ebe1f358a628509ae4a6010ee8dec1fbcadb60281bf9e62def1e829da728af9eeb211684
7
- data.tar.gz: 7b3b8dd4a60f103f2f2b9c673ceab137855a9ceaf583a6ed564384d1e1f617a80b06c7e751d09cdf801d583c7bea9ed60801accce6cd0c11203a1f0b9e996922
6
+ metadata.gz: 554901b08d7d257da5660c5020cbfb8bab03e987eff1d329337fa9943119c6e3a8bead3bc62c97edec32250f7c0bb5503b7d306373e794bd7908a208f211284a
7
+ data.tar.gz: 8e213677c64df89f7903d672c421b7faa9d8a5d12e136ef24e92e7dbc1a0deedc650d92cd882b06627f20e89ddcd4d46ea72943e22cf035152b9aff2e3284c02
data/README.md CHANGED
@@ -10,7 +10,34 @@ The JavaScript for Hotwire::Livereload is installed via asset pipeline, which is
10
10
 
11
11
  1. Add `hotwire-livereload` gem to your Gemfile: `gem 'hotwire-livereload'`
12
12
  2. Run `./bin/bundle install`
13
- 3. Run `./bin/rails hotwire_livereload:install`
13
+ 3. Run `./bin/rails livereload:install`
14
+
15
+ ## Configuration
16
+
17
+ You can watch for changes in additional folders by adding them to `listen_paths`. For example, you can watch for CSS changes:
18
+
19
+ ```ruby
20
+ # config/environments/development.rb
21
+
22
+ Rails.application.configure do
23
+ # ...
24
+ config.hotwire_livereload.listen_paths << Rails.root.join("app/assets/stylesheets")
25
+ end
26
+ ```
27
+
28
+ ## Disable livereload
29
+
30
+ To temporarily disable livereload use:
31
+ ```bash
32
+ bin/rails livereload:disable
33
+ ```
34
+
35
+ To re-enable:
36
+ ```bash
37
+ bin/rails livereload:enable
38
+ ```
39
+
40
+ No server restart is required. Disabling is managed by `tmp/livereload-disabled.txt` file.
14
41
 
15
42
  ## Development
16
43
 
@@ -36,11 +36,13 @@ module Hotwire
36
36
  end
37
37
 
38
38
  config.after_initialize do |app|
39
- if Rails.env.development?
39
+ if Rails.env.development? && defined?(Rails::Server)
40
40
  @listener = Listen.to(*app.config.hotwire_livereload.listen_paths) do |modified, added, removed|
41
- if modified.any? || removed.any? || added.any?
42
- content = { modified: modified, removed: removed, added: added }
43
- ActionCable.server.broadcast("hotwire-reload", content)
41
+ unless File.exists?(DISABLE_FILE)
42
+ if (modified.any? || removed.any? || added.any?)
43
+ content = { modified: modified, removed: removed, added: added }
44
+ ActionCable.server.broadcast("hotwire-reload", content)
45
+ end
44
46
  end
45
47
  end
46
48
  @listener.start
@@ -1,5 +1,5 @@
1
1
  module Hotwire
2
2
  module Livereload
3
- VERSION = "0.1.4"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -2,5 +2,6 @@ require "hotwire/livereload/engine"
2
2
 
3
3
  module Hotwire
4
4
  module Livereload
5
+ DISABLE_FILE = "tmp/livereload-disabled.txt"
5
6
  end
6
7
  end
@@ -0,0 +1,21 @@
1
+ namespace :livereload do
2
+ desc "Install Hotwire::Livereload into the app"
3
+ task :install do
4
+ system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/install.rb", __dir__)}"
5
+ end
6
+
7
+ desc "Disable Hotwire::Livereload"
8
+ task :disable do
9
+ FileUtils.mkdir_p("tmp")
10
+ FileUtils.touch Hotwire::Livereload::DISABLE_FILE
11
+ puts "Livereload disabled."
12
+ end
13
+
14
+ desc "Enable Hotwire::Livereload"
15
+ task :enable do
16
+ if File.exist?(Hotwire::Livereload::DISABLE_FILE)
17
+ File.delete Hotwire::Livereload::DISABLE_FILE
18
+ end
19
+ puts "Livereload enabled."
20
+ end
21
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotwire-livereload
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Platonov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-08 00:00:00.000000000 Z
11
+ date: 2021-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -55,7 +55,7 @@ files:
55
55
  - lib/hotwire/livereload/engine.rb
56
56
  - lib/hotwire/livereload/version.rb
57
57
  - lib/install/install.rb
58
- - lib/tasks/hotwire/livereload/install.rake
58
+ - lib/tasks/livereload_tasks.rake
59
59
  homepage: https://github.com/kirillplatonov/hotwire-livereload
60
60
  licenses:
61
61
  - MIT
@@ -1,6 +0,0 @@
1
- namespace :hotwire_livereload do
2
- desc "Setup Hotwire Livereload"
3
- task :install do
4
- system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../../install/install.rb", __dir__)}"
5
- end
6
- end