Clarify README's installation instructions

Add detail to the Rails installation sections and show default
configuration options. Also simplify example's usage and add link to find
more information on Rails middlewares.
This commit is contained in:
Charles Maresh 2013-09-13 09:32:57 -05:00 committed by Charles Maresh
parent 40a2ab41fb
commit 165f057cd3
1 changed files with 32 additions and 20 deletions

View File

@ -1,3 +1,5 @@
# Rack::LiveReload
<a href="http://travis-ci.org/johnbintz/rack-livereload"><img src="https://secure.travis-ci.org/johnbintz/rack-livereload.png" /></a>
[![Code Climate](https://codeclimate.com/github/johnbintz/rack-livereload.png)](https://codeclimate.com/github/johnbintz/rack-livereload)
@ -7,35 +9,45 @@ Even supports browsers without WebSockets!
Use this with [guard-livereload](http://github.com/guard/guard-livereload) for maximum fun!
## Install
`gem install rack-livereload`
## Using in...
## Installation
### Rails
Add the gem to your Gemfile.
In `config/environments/development.rb`:
```ruby
gem "rack-livereload", :group => :development
```
Then add the middleware to your Rails middleware stack by editing your `config/environments/development.rb`.
```ruby
# config/environments/development.rb
``` ruby
MyApp::Application.configure do
config.middleware.insert_after(ActionDispatch::Static, Rack::LiveReload)
# ...or, change some options...
config.middleware.insert_before(
Rack::Lock, Rack::LiveReload,
:min_delay => 500,
:max_delay => 10000,
:live_reload_port => 56789,
:host => 'myhost.cool.wow',
:ignore => [ %r{dont/modify\.html$} ]
)
# Add Rack::LiveReload to the bottom of the middleware stack with the default options.
config.middleware.use Rack::LiveReload
# ...
end
```
### config.ru/Sinatra
#### Tweaking the options
```ruby
# Specifying Rack::LiveReload options.
config.middleware.use(Rack::LiveReload,
:min_delay => 500, # default 1000
:max_delay => 10_000, # default 60_000
:live_reload_port => 56789, # default 35729
:host => 'myhost.cool.wow',
:ignore => [ %r{dont/modify\.html$} ]
)
```
In addition, Rack::LiveReload's position within middleware stack can be specified by inserting it relative to an exsiting middleware via `insert_before` or `insert_after`. See the [Rails on Rack: Adding a Middleware](http://guides.rubyonrails.org/rails_on_rack.html#adding-a-middleware) section for more detail.
### Sinatra / config.ru
``` ruby
require 'rack-livereload'