mata 0.7.0 → 0.9.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 +4 -4
- data/README.md +47 -9
- data/lib/mata/broadcaster.rb +5 -5
- data/lib/mata/version.rb +1 -1
- data/lib/mata.rb +2 -1
- metadata +2 -3
- data/lib/mata/railtie.rb +0 -27
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e57a04054693fd5c3b092f6c028d8cac79e9c374c043a6c29c34bda658836060
|
|
4
|
+
data.tar.gz: fb9c2cdb01e636273c4e13a5e55321dd5da252bda4a0cd3ed1942565336c2814
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d5736a691cd06abf3ec90a561f3ebe5f88c5e88d5445b67ae21a32ff3f39757f49e0a88f3171dbed10afb587018ffc43980a110cf861541a660662d3222a05fe
|
|
7
|
+
data.tar.gz: b5ab2d3ebb6496ffee7f113d2f143b91170ec9f7baa9f4b1257090fe3bc20f1ed4ef2d9858df6164a35dd3eca3f19d0f69791b563acbe2109d841cd67d923243
|
data/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# Mata
|
|
2
2
|
|
|
3
|
-
Live Reload with DOM Morphing for Rack applications using Server-Sent Events.
|
|
3
|
+
Live Reload with DOM Morphing for Rack applications using Server-Sent Events (SSE).
|
|
4
4
|
|
|
5
|
+
<img src="https://raw.githubusercontent.com/Rails-Designer/mata/HEAD/.github/mata-preview.gif">
|
|
5
6
|
|
|
6
7
|
**Sponsored By [Rails Designer](https://railsdesigner.com/)**
|
|
7
8
|
|
|
@@ -24,18 +25,18 @@ bundle add mata --group=development
|
|
|
24
25
|
|
|
25
26
|
### Rails
|
|
26
27
|
|
|
27
|
-
Mata automatically sets up middleware in development with sensible defaults. You can optionally configure:
|
|
28
28
|
```ruby
|
|
29
|
-
# config/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
# config/environments/development.rb
|
|
30
|
+
config.middleware.insert_before(
|
|
31
|
+
ActionDispatch::Static,
|
|
32
|
+
Mata,
|
|
33
|
+
watch: %w[app/views app/assets],
|
|
34
|
+
skip: %w[app/assets/build]
|
|
35
|
+
)
|
|
34
36
|
```
|
|
35
37
|
|
|
36
38
|
|
|
37
39
|
### Other rack-based apps
|
|
38
|
-
|
|
39
40
|
```ruby
|
|
40
41
|
# config.ru
|
|
41
42
|
require "mata"
|
|
@@ -49,6 +50,43 @@ run YourApp
|
|
|
49
50
|
> Do share your snippets on how to add Mata into your specific Rack-based apps 💙
|
|
50
51
|
|
|
51
52
|
|
|
53
|
+
### Hanami
|
|
54
|
+
```ruby
|
|
55
|
+
# config.ru
|
|
56
|
+
require "mata"
|
|
57
|
+
|
|
58
|
+
require_relative "config/app"
|
|
59
|
+
require_relative "config/routes"
|
|
60
|
+
|
|
61
|
+
use Mata, watch: %w[app/templates app/views app/actions], skip: %w[tmp logs node_modules]
|
|
62
|
+
|
|
63
|
+
run Hanami.app
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Sinatra
|
|
67
|
+
```ruby
|
|
68
|
+
# config.ru
|
|
69
|
+
require "mata"
|
|
70
|
+
require "./app"
|
|
71
|
+
|
|
72
|
+
use Mata, watch: %w[views templates assets], skip: %w[tmp vendor]
|
|
73
|
+
|
|
74
|
+
run Sinatra::Application
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Roda
|
|
78
|
+
```ruby
|
|
79
|
+
# config.ru
|
|
80
|
+
require "mata"
|
|
81
|
+
require "./app"
|
|
82
|
+
|
|
83
|
+
use Mata, watch: %w[templates assets], skip: %w[tmp]
|
|
84
|
+
|
|
85
|
+
route do |r|
|
|
86
|
+
r.on { r.root { view("index") } }
|
|
87
|
+
end
|
|
88
|
+
```
|
|
89
|
+
|
|
52
90
|
## Used in
|
|
53
91
|
|
|
54
92
|
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.
|
|
@@ -56,7 +94,7 @@ This gem powers live reloading in [Perron](https://github.com/rails-designer/per
|
|
|
56
94
|
|
|
57
95
|
## Why this gem?
|
|
58
96
|
|
|
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.
|
|
97
|
+
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. So I built a light-weight gem that uses SSE and idiomorph for a smooth developer experience. Not just specific for Perron but for any Rack-based Ruby app. ❤️
|
|
60
98
|
|
|
61
99
|
|
|
62
100
|
## Who is Mata?
|
data/lib/mata/broadcaster.rb
CHANGED
|
@@ -14,10 +14,10 @@ class Mata
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
headers = {
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
17
|
+
"content-type" => "text/event-stream",
|
|
18
|
+
"cache-control" => "no-cache",
|
|
19
|
+
"connection" => "keep-alive",
|
|
20
|
+
"access-control-allow-origin" => "*"
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
[200, headers, proc { |stream|
|
|
@@ -45,7 +45,7 @@ class Mata
|
|
|
45
45
|
|
|
46
46
|
script = "#{idiomorph_js}\n\n#{client_js}"
|
|
47
47
|
|
|
48
|
-
[200, {"
|
|
48
|
+
[200, {"content-type" => "application/javascript"}, [script]]
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def broadcast_to_all(files)
|
data/lib/mata/version.rb
CHANGED
data/lib/mata.rb
CHANGED
|
@@ -6,12 +6,13 @@ 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)
|
|
10
9
|
|
|
11
10
|
class Mata
|
|
12
11
|
def initialize(app, options = {})
|
|
13
12
|
@app = app
|
|
14
13
|
|
|
14
|
+
return if ENV["MATA_DISABLED"] == "true"
|
|
15
|
+
|
|
15
16
|
@watch_tower = WatchTower.new(options)
|
|
16
17
|
@broadcaster = Broadcaster.new
|
|
17
18
|
@agent = Agent.new
|
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.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rails Designer
|
|
@@ -50,7 +50,6 @@ 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
|
|
54
53
|
- lib/mata/version.rb
|
|
55
54
|
- lib/mata/watch_tower.rb
|
|
56
55
|
homepage: https://railsdesigner.com/mata/
|
|
@@ -73,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
73
72
|
- !ruby/object:Gem::Version
|
|
74
73
|
version: '0'
|
|
75
74
|
requirements: []
|
|
76
|
-
rubygems_version: 4.0.
|
|
75
|
+
rubygems_version: 4.0.10
|
|
77
76
|
specification_version: 4
|
|
78
77
|
summary: Hot module reloading for Rack applications
|
|
79
78
|
test_files: []
|
data/lib/mata/railtie.rb
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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
|