mata 0.6.0 → 0.7.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: 48edf5af987fb9cd1ea941500d85504e5452408a26d5440f1220a4ef5f83a87c
4
- data.tar.gz: fb1d9dc61b09a3731fb27056443062265b1237a31e23201485152331a14a449c
3
+ metadata.gz: 959629ea5fdd32e3175367b7ddf0ceed61679a9652349f2cd130b4ee4eb70ff4
4
+ data.tar.gz: 7113f529003ecc704a8f66056a32c036da85a6e05d47c9622ac4eb9545f737c3
5
5
  SHA512:
6
- metadata.gz: 2576d4f01252a0de82cad9d1ab18a5da52517222377e43f0e4e06fbda35a3928f323d272eaac6d58fe5f1acaaec52629370dad48db276072ba5e42bc8fa44445
7
- data.tar.gz: 0bd6bc37b21b58318685fb313bc6a0ae7ba1b192b7106f532dc5842225786bc3c691ac677415f516475402fc9c90b0174034e04a3db43251a26541dc8dfff55a
6
+ metadata.gz: 0eb68cc7feb9071eecdc8d528be0713a680caeae621dd5bf1d45d766efc16222f42d7c71c6e4eb3b21b50d0034c6812b71a46be9ad83d4f0a971ecb8d743280d
7
+ data.tar.gz: f15cf5f31841fecc076ed8cbd36d3d6e3775e6e7d74232475eb96947237650a0530af18bcab5abde6c4236ddef54b75110752dab561872f3a116128787cc9d95
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Mata
2
2
 
3
- Hot module reloading for Rack applications using Server-Sent Events and DOM morphing.
3
+ Live Reload with DOM Morphing for Rack applications using Server-Sent Events.
4
4
 
5
5
 
6
6
  **Sponsored By [Rails Designer](https://railsdesigner.com/)**
@@ -17,75 +17,46 @@ Hot module reloading for Rack applications using Server-Sent Events and DOM morp
17
17
  ## Installation
18
18
 
19
19
  ```ruby
20
- gem "mata"
20
+ bundle add mata --group=development
21
21
  ```
22
22
 
23
-
24
23
  ## Usage
25
24
 
26
25
  ### Rails
27
26
 
27
+ Mata automatically sets up middleware in development with sensible defaults. You can optionally configure:
28
28
  ```ruby
29
- # config/environments/development.rb
30
- Rails.application.configure do
31
- config.middleware.insert_before(
32
- ActionDispatch::Static,
33
- Mata,
34
- watch: %w[app/views app/assets],
35
- skip: %w[tmp log node_modules]
36
- )
29
+ # config/initializers/mata.rb
30
+ Mata::Railtie.configure do |config|
31
+ config.watch_paths = %w[app]
32
+ config.skip_paths = %w[app/assets/builds app/assets/cache]
37
33
  end
38
34
  ```
39
35
 
40
- ### Sinatra
41
36
 
42
- ```ruby
43
- require "sinatra"
44
- require "mata"
45
-
46
- configure :development do
47
- use Mata, watch: %w[views public]
48
- end
49
- ```
50
-
51
- ### Hanami
37
+ ### Other rack-based apps
52
38
 
53
39
  ```ruby
54
40
  # config.ru
55
- require "hanami/boot"
56
41
  require "mata"
57
42
 
58
- use Mata, watch: %w[apps lib] if Hanami.env?(:development)
59
-
60
- run Hanami.app
61
- ```
62
-
63
- ### Basic Rack app
64
-
65
- ```ruby
66
- # config.ru
67
- require "mata"
68
-
69
- use Mata, watch: %w[views assets], skip: %w[tmp log]
43
+ use Mata, watch: %w[views assets], skip: %w[views/tmp]
70
44
 
71
45
  run YourApp
72
46
  ```
73
47
 
74
-
75
- ## Options
76
-
77
- - **watch**; array of paths to monitor (default: `%w[app views assets]`)
78
- - **skip**; array of paths to ignore (default: `%w[tmp log]`)
48
+ > [!NOTE]
49
+ > Do share your snippets on how to add Mata into your specific Rack-based apps 💙
79
50
 
80
51
 
81
52
  ## Used in
82
53
 
83
- This gem powers hot reloading in [Perron](https://github.com/rails-designer/perron), a Rails-based static site generator. It can be enabled with `config.hrm = true` in your Perron initializer.
54
+ This gem powers live reloading in [Perron](https://github.com/rails-designer/perron), a Rails-based static site generator. It can be enabled with `config.live_reload = true` in your Perron initializer.
84
55
 
85
56
 
86
57
  ## Why this gem?
87
58
 
88
- I needed hot module reloading for Perron-powered Rails applications. These are minimal Rails apps typically without Hotwire or ActionCable dependencies. Existing solutions either required ActionCable (adding unnecessary complexity) or provided only basic full-page reloads without state preservation.
59
+ I needed a way to reload pages for Perron-powered Rails applications. These are minimal Rails apps typically without Hotwire or ActionCable dependencies. Existing solutions either required ActionCable or provided only basic full-page reloads without state preservation.
89
60
 
90
61
 
91
62
  ## Who is Mata?
@@ -0,0 +1,27 @@
1
+ require "rails/railtie"
2
+
3
+ class Mata
4
+ class Railtie < Rails::Railtie
5
+ class << self
6
+ attr_accessor :watch_paths, :skip_paths
7
+
8
+ def configure
9
+ yield(self)
10
+ end
11
+ end
12
+
13
+ self.watch_paths = %w[app/views app/assets]
14
+ self.skip_paths = %w[tmp log node_modules]
15
+
16
+ config.before_configuration do |app|
17
+ if Rails.env.development?
18
+ app.config.middleware.insert_before(
19
+ ActionDispatch::Static,
20
+ Mata,
21
+ watch: watch_paths,
22
+ skip: skip_paths
23
+ )
24
+ end
25
+ end
26
+ end
27
+ end
data/lib/mata/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Mata
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -3,8 +3,8 @@
3
3
  class Mata
4
4
  class WatchTower
5
5
  def initialize(options)
6
- @watch_paths = Array(options[:watch] || %w[app views assets])
7
- @skip_paths = skipped_patterns(options[:skip] || options[:ignore] || %w[tmp log])
6
+ @watch_paths = Array(options[:watch] || [])
7
+ @skip_paths = skipped_patterns(options[:skip] || options[:ignore] || [])
8
8
  @on_change = nil
9
9
  @listener = nil
10
10
 
data/lib/mata.rb CHANGED
@@ -6,6 +6,7 @@ require "json"
6
6
  require "mata/agent"
7
7
  require "mata/broadcaster"
8
8
  require "mata/watch_tower"
9
+ require "mata/railtie" if defined?(Rails::Railtie)
9
10
 
10
11
  class Mata
11
12
  def initialize(app, options = {})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rails Designer
@@ -50,6 +50,7 @@ files:
50
50
  - lib/mata/broadcaster.rb
51
51
  - lib/mata/client.js
52
52
  - lib/mata/idiomorph.min.js
53
+ - lib/mata/railtie.rb
53
54
  - lib/mata/version.rb
54
55
  - lib/mata/watch_tower.rb
55
56
  homepage: https://railsdesigner.com/mata/
@@ -72,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
73
  - !ruby/object:Gem::Version
73
74
  version: '0'
74
75
  requirements: []
75
- rubygems_version: 4.0.4
76
+ rubygems_version: 4.0.6
76
77
  specification_version: 4
77
78
  summary: Hot module reloading for Rack applications
78
79
  test_files: []