mata 0.8.0 → 0.10.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: 22c5e26cd983f1031f3d717496815e4250e3d7fa3e4ee66551ca23e0adef9146
4
- data.tar.gz: f0ec9cdf014a771c112b853cc745d593e6dae01b728321ff92722cb35d4d5c68
3
+ metadata.gz: ab070e4aa36426eec7fdc324a6f493665bb6fbda68280cca8d8e98bbbd15df4d
4
+ data.tar.gz: 372274d8821279df66b0ddbf8b5c8f59254aa4e61f7f0ed7b343fbbc5891269e
5
5
  SHA512:
6
- metadata.gz: 45a5624b8f699c5751cb38798e8856ee4a120c591060efdcda5e4e36e9a4027213d883df09f3cc343fd114d46ed095d46a0afdb73da44ba503eba7b6759d408c
7
- data.tar.gz: 0e32957741e3094c2b41bfb35e5ae58df6799bf5b95a48ff8b333dfaace1e4739c35e7cb674f8de5b6b4b843ad08075df27c453bc6a3f59975bdc33641c2ac1f
6
+ metadata.gz: 3343f58cd5a1cc9bef0aaa7fdb8d8eb102839631c1b5ae1cb141b340f387b00e5f44743ea5742d5eac53dfdb26816231d5643a33158a6a465b11fabd154366d1
7
+ data.tar.gz: 3dc12dbb74eaac619279b2d92c0721913f71f46a9cb184370861b7945c84610856466d2a14c24c0ee7595046dc603f249b3f96a2d7e43ebf82eaf2308d08b266
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
 
@@ -36,7 +37,6 @@ config.middleware.insert_before(
36
37
 
37
38
 
38
39
  ### Other rack-based apps
39
-
40
40
  ```ruby
41
41
  # config.ru
42
42
  require "mata"
@@ -50,6 +50,43 @@ run YourApp
50
50
  > Do share your snippets on how to add Mata into your specific Rack-based apps 💙
51
51
 
52
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
+
53
90
  ## Used in
54
91
 
55
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.
@@ -57,7 +94,7 @@ This gem powers live reloading in [Perron](https://github.com/rails-designer/per
57
94
 
58
95
  ## Why this gem?
59
96
 
60
- 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. ❤️
61
98
 
62
99
 
63
100
  ## Who is Mata?
data/lib/mata/agent.rb CHANGED
@@ -26,7 +26,7 @@ class Mata
26
26
 
27
27
  def extract(body)
28
28
  if body.respond_to?(:each)
29
- body.each.to_a.join
29
+ [].tap { |parts| body.each { |part| parts << part } }.join
30
30
  else
31
31
  body.to_s
32
32
  end
@@ -14,10 +14,10 @@ class Mata
14
14
  end
15
15
 
16
16
  headers = {
17
- "Content-Type" => "text/event-stream",
18
- "Cache-Control" => "no-cache",
19
- "Connection" => "keep-alive",
20
- "Access-Control-Allow-Origin" => "*"
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|
@@ -27,12 +27,6 @@ class Mata
27
27
 
28
28
  begin
29
29
  stream << "data: {\"type\":\"connected\"}\n\n"
30
-
31
- Thread.new do
32
- loop { sleep 30 }
33
- rescue
34
- @clients_mutex.synchronize { @clients.delete(stream) }
35
- end
36
30
  rescue
37
31
  @clients_mutex.synchronize { @clients.delete(stream) }
38
32
  end
@@ -45,7 +39,7 @@ class Mata
45
39
 
46
40
  script = "#{idiomorph_js}\n\n#{client_js}"
47
41
 
48
- [200, {"Content-Type" => "application/javascript"}, [script]]
42
+ [200, {"content-type" => "application/javascript"}, [script]]
49
43
  end
50
44
 
51
45
  def broadcast_to_all(files)
@@ -87,6 +81,7 @@ class Mata
87
81
  @clients_mutex.synchronize do
88
82
  @clients.reject! do |client|
89
83
  client << ""
84
+
90
85
  false
91
86
  rescue
92
87
  true
data/lib/mata/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Mata
2
- VERSION = "0.8.0"
2
+ VERSION = "0.10.0"
3
3
  end
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.8.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rails Designer
@@ -52,11 +52,11 @@ files:
52
52
  - lib/mata/idiomorph.min.js
53
53
  - lib/mata/version.rb
54
54
  - lib/mata/watch_tower.rb
55
- homepage: https://railsdesigner.com/mata/
55
+ homepage: https://railsdesigner.com/open-source/mata/
56
56
  licenses:
57
57
  - MIT
58
58
  metadata:
59
- homepage_uri: https://railsdesigner.com/mata/
59
+ homepage_uri: https://railsdesigner.com/open-source/mata/
60
60
  source_code_uri: https://github.com/Rails-Designer/mata
61
61
  rdoc_options: []
62
62
  require_paths:
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  requirements: []
75
- rubygems_version: 4.0.6
75
+ rubygems_version: 4.0.14
76
76
  specification_version: 4
77
77
  summary: Hot module reloading for Rack applications
78
78
  test_files: []