rchampourlier / guard-shotgun

Guard gem for Sinatra (shotgun-like)
MIT License
11 stars 9 forks source link

Guard::Shotgun

Guard::Shotgun automatically starts and restarts Rack applications (through rackup) when needed. As useful as Shotgun when developing a Rack app.

Tested on:

Why?

If you have answered 'yes' to any of these questions, you may find some use to this plugin.

Install

Please be sure to have Guard installed before continuing.

Install the gem:

gem install guard-shotgun

Or add it to your Gemfile (inside development group):

gem 'guard-shotgun', :git => 'https://github.com/rchampourlier/guard-shotgun.git'

Add guard definition to your Guardfile by running this command:

guard init shotgun

Usage

This guard plugin is intended to be used when developing a Rack application, loaded through rackup.

It allows automatic reloading of your Rack server when a file is changed.

It provides the same service as the Shotgun gem, relying on Guard to watch for your files.

Please read Guard usage doc

Guardfile

For example, to look at the main.rb file in your application directory, just set this guard:

guard 'shotgun' do
  watch('main.rb')
end

Common config

Here we watch Ruby files within the app and lib directories, as well as the config.ru file. We also use Thin as a server instead of the default WEBRick.

guard 'shotgun', :server => 'thin' do
  watch %r{^(app|lib)/.*\.rb}
  watch 'config.ru'
end

Please read Guard doc for more info about Guardfile DSL.

Options

Testing

There is currently no spec :S. I intend to write some (won't need much). You may however go to the spec/dummy_app directory and run:

bundle install
bundle exec guard

This way, you can check it's working correctly. You can play with the spec/dummy_app/app/base_app.rb file and introduce some bug so that you may see a failing start is correctly handled too.

Compatibility with Guard

History

0.4.0

0.3.1

0.3.0

0.2.0

0.1.0

0.0.6

0.0.4

Killing Rack when reloading on change without waiting for requests to be completed.

0.0.3

Initial release

TODOs

Help is welcome!

Development

Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change you make.

Authors

Romain Champourlier Colin Rymer

Credits

This gem has been built from guard-webrick of Fletcher Nichol.