keepgoing 0.1.0 → 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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +8 -1
- data/keepgoing.gemspec +1 -1
- data/lib/guard/keepgoing.rb +30 -1
- data/lib/keepgoing/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2589b8ca550c4838aa6d26a76db23d1f838e145bc1c5bf708cd5e2c2fee96c0b
|
4
|
+
data.tar.gz: 8f07d3c67fd50d5061dc6d52cd6388273211296aca33a83b95a247144d2156e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 928419241425b2e3a7eabd2adf89bbd4289bb2acdc2adda598a52959d2eef0c43b786af87050bf0823f35ec6238abe06e98fdf6953ef41a04df769d41617063a
|
7
|
+
data.tar.gz: 937ec8924b4666e4d31beb1f6b9c6238968667104aaaf441441771410d1629d58c7a3e796649f542346167859b04397e54ed5886d467ff0043bbc3f942c4438d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Keepgoing
|
2
2
|
|
3
|
+
https://user-images.githubusercontent.com/467114/168008226-333aeec1-2318-42c1-876b-33096f5010f0.mp4
|
4
|
+
|
3
5
|
keepgoing uses [guard](https://github.com/guard/guard) to tighten the feedback loop on your single-file Ruby script that uses [bundler/inline](https://bundler.io/guides/bundler_in_a_single_file_ruby_script.html).
|
4
6
|
When added as a gem to your script, it will run your script once when started like you are used to, but it won't exit and rather keep it going and re-run it every time you modify your script. You keep tinkering and once you save your script runs again and you 💥 immediately see the result 🤯.
|
5
7
|
|
@@ -30,11 +32,16 @@ puts "Woohoo"
|
|
30
32
|
When you run this script in a terminal with `ruby test.rb`, it will execute like it would without keepgoing, printing out "Woohoo".
|
31
33
|
But you'll notice it won't exit back to your terminal prompt. If you go back to your editor and change something, say add another `puts` and save, you'll notice it gets executed again and you see the results of your edit right away.
|
32
34
|
|
35
|
+
### long-running or blocking scripts
|
36
|
+
If your script has not finished running until you save the next time, whatever it is still doing will be stopped and it will be forced to exit, so keepgoing can run it again with your latest changes.
|
37
|
+
This could be either great, because it allows you to use keepgoing even for things that run something blocking (like a web server that's waiting for requests), or it could be unexpected if keepgoing terminates something that is just taking a long time to finish processing.
|
38
|
+
Anyway, be aware that when you save, your script will be restarted, no matter what.
|
39
|
+
|
33
40
|
## Development
|
34
41
|
|
35
42
|
After checking out the repo, run `bin/setup` to install dependencies.
|
36
43
|
|
37
|
-
To install this gem onto your local machine, run `
|
44
|
+
To install this gem onto your local machine, run `bin/rake install`. To release a new version, update the version number in `version.rb`, and then run `bin/rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
38
45
|
|
39
46
|
## Contributing
|
40
47
|
|
data/keepgoing.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = <<~DESC
|
13
13
|
This gem is intended for use in a single file Ruby script that uses bundler/inline.
|
14
14
|
You start your script once with `ruby your-script.rb` and keepgoing will take control,
|
15
|
-
and re-run
|
15
|
+
and re-run your script every time you save your script.
|
16
16
|
You can concentrate on tinkering, while keepgoing will, well keep going,
|
17
17
|
providing you with a fast and effortless feedback loop for your ruby experiments.
|
18
18
|
DESC
|
data/lib/guard/keepgoing.rb
CHANGED
@@ -16,6 +16,7 @@ module ::Guard
|
|
16
16
|
def start
|
17
17
|
@runs = 1
|
18
18
|
puts "Hi! I'll keepgoing until you press Ctrl+C. Just edit and save away, you can do this 🎉\n\n"
|
19
|
+
setup_interrupt_handler
|
19
20
|
run_all
|
20
21
|
end
|
21
22
|
|
@@ -31,11 +32,39 @@ module ::Guard
|
|
31
32
|
private
|
32
33
|
|
33
34
|
def do_run
|
35
|
+
kill_running
|
36
|
+
|
34
37
|
@runs += 1
|
35
|
-
|
38
|
+
fork_and_load
|
36
39
|
rescue ScriptError, StandardError => e
|
37
40
|
# prevent any script errors from stopping guard/keepgoing, but print error
|
38
41
|
puts e.inspect
|
39
42
|
end
|
43
|
+
|
44
|
+
def kill_running
|
45
|
+
return unless @pid
|
46
|
+
|
47
|
+
Process.kill("HUP", @pid)
|
48
|
+
rescue Errno::ESRCH, RangeError
|
49
|
+
# process was probably already gone, ignore
|
50
|
+
ensure
|
51
|
+
@pid = nil
|
52
|
+
end
|
53
|
+
|
54
|
+
def fork_and_load
|
55
|
+
@pid = fork do
|
56
|
+
Signal.trap("HUP") { exit }
|
57
|
+
load options[:file]
|
58
|
+
end
|
59
|
+
# detach script execution to give control back to guard
|
60
|
+
Process.detach(@pid)
|
61
|
+
end
|
62
|
+
|
63
|
+
def setup_interrupt_handler
|
64
|
+
Signal.trap("INT") do
|
65
|
+
kill_running
|
66
|
+
exit
|
67
|
+
end
|
68
|
+
end
|
40
69
|
end
|
41
70
|
end
|
data/lib/keepgoing/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: keepgoing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wolfgang Rittner
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
@@ -27,7 +27,7 @@ dependencies:
|
|
27
27
|
description: |
|
28
28
|
This gem is intended for use in a single file Ruby script that uses bundler/inline.
|
29
29
|
You start your script once with `ruby your-script.rb` and keepgoing will take control,
|
30
|
-
and re-run
|
30
|
+
and re-run your script every time you save your script.
|
31
31
|
You can concentrate on tinkering, while keepgoing will, well keep going,
|
32
32
|
providing you with a fast and effortless feedback loop for your ruby experiments.
|
33
33
|
email:
|