Keepgoing

https://user-images.githubusercontent.com/467114/168008226-333aeec1-2318-42c1-876b-33096f5010f0.mp4

keepgoing uses guard to tighten the feedback loop on your single-file Ruby script that uses bundler/inline.
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 🤯.

bundler/inline

When trying out things with Ruby, and maybe a new Ruby gem or even full blown Rails, an awesome way to do this is using "bundler/inline".
It allows you to put a whole application including a "gemfile" into a single-file Ruby script, which gives you a quick feedback loop and allows you to share the whole thing as one self-contained file.

automate > manual

It would be great if we could tighten things up even more and supercharge the feedback loop by combining bundler/inline with guard auto-run.
I was wondering if guard could be inlined into that single-file Ruby script as well, and set up to execute that single file whenever it changed. This would allow us to start things up once, then keep editing and see results immediately.
Turns out you can, meet keepgoing!

Usage

Example Ruby single-file script:

require "bundler/inline"

gemfile do
  source "https://rubygems.org"
  gem "keepgoing"
end

puts "Woohoo"

When you run this script in a terminal with ruby test.rb, it will execute like it would without keepgoing, printing out "Woohoo".
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.

long-running or blocking scripts

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.
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.
Anyway, be aware that when you save, your script will be restarted, no matter what.

Development

After checking out the repo, run bin/setup to install dependencies.

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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/wolfgangrittner/keepgoing. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Keepgoing project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.