puma-plugin-dartsass 0.1.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 +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +29 -0
- data/lib/puma/plugin/dartsass.rb +72 -0
- metadata +72 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 419b57fd56aea59c6eb6f7e91f89f5e1e486474341bec6d74c32d87f2a18442f
|
|
4
|
+
data.tar.gz: 98267a3e7c7a321f06bc059824ee2a081de56d5fd86d38493bdcc631ca12726d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 339dedf33bab04bd0b71be5f580d9eb8cb075fcc8c6a5c6484647d23bdf4c8c03ce885af8803ed8f5bedf7cdda516a132e9d1b236884ddbd20ebf6423c36ccbc
|
|
7
|
+
data.tar.gz: a6f509b51f82e36dea6e6cd0f4af7793a907bc8875abbfdd8305c91b6820094357e616de22a8fe4d298e899706240e4862c5f0a294bc3efb3b558de1dafa6090
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Keita Urashima
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# puma-plugin-dartsass
|
|
2
|
+
|
|
3
|
+
A [Puma](https://puma.io) plugin that starts `dartsass:watch` automatically when Puma starts in development. This eliminates the need for [foreman](https://github.com/ddollar/foreman) or `bin/dev` — just run `bin/rails s`.
|
|
4
|
+
|
|
5
|
+
Based on the [Puma plugin in tailwindcss-rails](https://github.com/rails/tailwindcss-rails).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add the gem to your Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'puma-plugin-dartsass'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then add the plugin to `config/puma.rb`:
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
plugin :dartsass if ENV.fetch("RAILS_ENV", "development") == "development"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
That's it. `bin/rails s` will now start the Sass watcher alongside Puma.
|
|
22
|
+
|
|
23
|
+
## How it works
|
|
24
|
+
|
|
25
|
+
When Puma starts, the plugin forks a child process that runs `bin/rails dartsass:watch`. The plugin monitors both processes — if Puma stops, the watcher is stopped; if the watcher crashes, Puma is stopped.
|
|
26
|
+
|
|
27
|
+
## License
|
|
28
|
+
|
|
29
|
+
MIT
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require "puma/plugin"
|
|
2
|
+
|
|
3
|
+
Puma::Plugin.create do
|
|
4
|
+
attr_reader :puma_pid, :dartsass_pid, :log_writer
|
|
5
|
+
|
|
6
|
+
def start(launcher)
|
|
7
|
+
@log_writer = launcher.log_writer
|
|
8
|
+
@puma_pid = $$
|
|
9
|
+
@dartsass_pid = fork do
|
|
10
|
+
Thread.new { monitor_puma }
|
|
11
|
+
begin
|
|
12
|
+
IO.popen(["bin/rails", "dartsass:watch"], "r+") do |io|
|
|
13
|
+
IO.copy_stream(io, $stdout)
|
|
14
|
+
end
|
|
15
|
+
rescue Interrupt
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
if Gem::Version.new(Puma::Const::PUMA_VERSION) >= Gem::Version.new("7")
|
|
20
|
+
launcher.events.after_stopped { stop_dartsass }
|
|
21
|
+
else
|
|
22
|
+
launcher.events.on_stopped { stop_dartsass }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
in_background do
|
|
26
|
+
monitor_dartsass
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
def stop_dartsass
|
|
32
|
+
Process.waitpid(dartsass_pid, Process::WNOHANG)
|
|
33
|
+
log "Stopping dartsass..."
|
|
34
|
+
Process.kill(:INT, dartsass_pid) if dartsass_pid
|
|
35
|
+
Process.wait(dartsass_pid)
|
|
36
|
+
rescue Errno::ECHILD, Errno::ESRCH
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def monitor_puma
|
|
40
|
+
monitor(:puma_dead?, "Detected Puma has gone away, stopping dartsass...")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def monitor_dartsass
|
|
44
|
+
monitor(:dartsass_dead?, "Detected dartsass has gone away, stopping Puma...")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def monitor(process_dead, message)
|
|
48
|
+
loop do
|
|
49
|
+
if send(process_dead)
|
|
50
|
+
log message
|
|
51
|
+
Process.kill(:INT, $$)
|
|
52
|
+
break
|
|
53
|
+
end
|
|
54
|
+
sleep 2
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def dartsass_dead?
|
|
59
|
+
Process.waitpid(dartsass_pid, Process::WNOHANG)
|
|
60
|
+
false
|
|
61
|
+
rescue Errno::ECHILD, Errno::ESRCH
|
|
62
|
+
true
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def puma_dead?
|
|
66
|
+
Process.ppid != puma_pid
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def log(...)
|
|
70
|
+
log_writer.log(...)
|
|
71
|
+
end
|
|
72
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: puma-plugin-dartsass
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Keita Urashima
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: puma
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '5.0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '5.0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: dartsass-rails
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
description: A Puma plugin that starts the dartsass:watch process alongside Puma,
|
|
41
|
+
eliminating the need for foreman or bin/dev during development.
|
|
42
|
+
email:
|
|
43
|
+
- ursm@ursm.jp
|
|
44
|
+
executables: []
|
|
45
|
+
extensions: []
|
|
46
|
+
extra_rdoc_files: []
|
|
47
|
+
files:
|
|
48
|
+
- LICENSE.txt
|
|
49
|
+
- README.md
|
|
50
|
+
- lib/puma/plugin/dartsass.rb
|
|
51
|
+
homepage: https://github.com/ursm/puma-plugin-dartsass
|
|
52
|
+
licenses:
|
|
53
|
+
- MIT
|
|
54
|
+
metadata: {}
|
|
55
|
+
rdoc_options: []
|
|
56
|
+
require_paths:
|
|
57
|
+
- lib
|
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
59
|
+
requirements:
|
|
60
|
+
- - ">="
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: '3.1'
|
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
68
|
+
requirements: []
|
|
69
|
+
rubygems_version: 4.0.6
|
|
70
|
+
specification_version: 4
|
|
71
|
+
summary: Puma plugin to run dartsass:watch automatically during development
|
|
72
|
+
test_files: []
|