Compare commits

...

17 Commits

Author SHA1 Message Date
John Bintz 8cf0ebec60 deprecation notice 2018-04-04 08:29:05 -04:00
John Bintz c0c47cc83b Merge pull request #72 from johnbintz/middleware-ordering-update
Middleware ordering update
2016-03-16 07:24:14 -04:00
John Bintz 16c1ba76ed [middleware-ordering] Improve middlware docs, fixes #51 2016-03-16 07:21:22 -04:00
John Bintz f830396dbf [middleware-ordering] Switch from hashrockets -> new hash style 2016-03-16 07:21:00 -04:00
John Bintz 41bdc64bcb Bump version. 2015-07-03 12:33:50 -04:00
John Bintz 651d202dd2 Merge pull request #66 from johnbintz/travis-trimming
No one uses 1.8.7 or 1.9.2 anymore. Sorry, folks.
2015-07-03 12:33:29 -04:00
John Bintz ffa5d63ffc Trim a little more out of the tests. 2015-07-03 12:28:20 -04:00
John Bintz d06a756c8d RSpec modernization fixes. 2015-07-03 12:20:54 -04:00
John Bintz ef3895cbcf No one uses 1.8.7 or 1.9.2 anymore. Sorry, folks. 2015-07-03 09:31:46 -04:00
John Bintz 727296953b Merge pull request #64 from cpjk/cpjk-fix-readme
Fix link to livereload.com
2015-07-03 09:24:56 -04:00
John Bintz 618feb865c Merge pull request #50 from rjocoleman/ignore_fullpath
parse fullpath for ignore
2015-07-03 09:24:47 -04:00
John Bintz f5cbf07d21 Merge pull request #58 from pmoghaddam/fix_middleware_order
Update middleware order to resolve flash.keep issue and unnecessary logging
2015-07-03 09:21:33 -04:00
John Bintz 493aa6255d Merge pull request #53 from samcon/master
Set the protocol of the livereload source
2015-07-03 09:20:53 -04:00
Chris Kelly e7cbf825d9 Fix link to livereload.com 2015-02-10 14:29:15 -08:00
Payam Moghaddam 9a4316ce37 Update middleware order to resolve flash.keep issue and unnecessary logging 2014-10-11 22:09:22 -07:00
samcon 27063b7d20 Set the protocol of the livereload source
This will allow a user to serve livereload from HTTPS
(Also requires using the :source => :livereload option)
2014-03-21 01:26:44 +02:00
Robert Coleman 64449acbc9 parse fullpath for ignore 2013-11-26 13:35:21 +13:00
11 changed files with 48 additions and 56 deletions

View File

@ -1,19 +1,10 @@
rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- 2.0.0
branches:
only:
- master
gemfile:
- gemfiles/rails30.gemfile
- gemfiles/rails31.gemfile
- gemfiles/rails32.gemfile
- gemfiles/rails40.gemfile
matrix:
exclude:
- rvm: 1.8.7
gemfile: gemfiles/rails40.gemfile
- rvm: 1.9.2
gemfile: gemfiles/rails40.gemfile

View File

@ -1,11 +1,3 @@
appraise 'rails30' do
gem 'rails', '~> 3.0.0'
end
appraise 'rails31' do
gem 'rails', '~> 3.1.0'
end
appraise 'rails32' do
gem 'rails', '~> 3.2.0'
end

View File

@ -1,9 +1,11 @@
# Rack::LiveReload
_This fork is deprecated: Go check out https://github.com/onesupercoder/rack-livereload instead._
<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)
Hey, you've got [LiveReload](http://www.livereload.com/) in my [Rack](http://rack.rubyforge.org/)!
Hey, you've got [LiveReload](http://livereload.com/) in my [Rack](http://rack.rubyforge.org/)!
No need for browser extensions anymore! Just plug it in your middleware stack and go!
Even supports browsers without WebSockets!
@ -16,7 +18,7 @@ Use this with [guard-livereload](http://github.com/guard/guard-livereload) for m
Add the gem to your Gemfile.
```ruby
gem "rack-livereload", :group => :development
gem "rack-livereload", group: :development
```
Then add the middleware to your Rails middleware stack by editing your `config/environments/development.rb`.
@ -25,8 +27,11 @@ Then add the middleware to your Rails middleware stack by editing your `config/e
# config/environments/development.rb
MyApp::Application.configure do
# Add Rack::LiveReload to the bottom of the middleware stack with the default options.
config.middleware.use Rack::LiveReload
# Add Rack::LiveReload to the bottom of the middleware stack with the default options:
config.middleware.insert_after ActionDispatch::Static, Rack::LiveReload
# or, if you're using better_errors:
config.middleware.insert_before Rack::Lock, Rack::LiveReload
# ...
end
@ -37,15 +42,19 @@ end
```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$} ]
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.
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
@ -54,7 +63,7 @@ require 'rack-livereload'
use Rack::LiveReload
# ...or...
use Rack::LiveReload, :min_delay => 500, ...
use Rack::LiveReload, min_delay: 500, ...
```
## How it works
@ -82,13 +91,13 @@ your browser doesn't need it. The SWF WebSocket implementor won't be loaded unle
WebSockets support or if you force it in the middleware stack:
``` ruby
use Rack::LiveReload, :force_swf => true
use Rack::LiveReload, force_swf: true
```
If you don't want any of the web-sockets-js code included at all, use the `no_swf` option:
``` ruby
use Rack::LiveReload, :no_swf => true
use Rack::LiveReload, no_swf: true
```
Once more browsers support WebSockets than don't, this option will be reversed and you'll have

View File

@ -1,7 +0,0 @@
# This file was generated by Appraisal
source "http://rubygems.org"
gem "rails", "~> 3.0.0"
gemspec :path=>"../"

View File

@ -1,7 +0,0 @@
# This file was generated by Appraisal
source "http://rubygems.org"
gem "rails", "~> 3.1.0"
gemspec :path=>"../"

View File

@ -1,6 +1,6 @@
require "rack/livereload"
class Rack::LiveReload
VERSION = '0.3.15'
VERSION = '0.3.16'
end

View File

@ -9,8 +9,12 @@ module Rack
attr_reader :content_length, :new_body, :livereload_added
def protocol
@options[:protocol] || "http"
end
def livereload_local_uri
"http://localhost:#{@options[:live_reload_port]}/livereload.js"
"#{protocol}://localhost:#{@options[:live_reload_port]}/livereload.js"
end
def initialize(body, options)

View File

@ -28,7 +28,8 @@ module Rack
end
def ignored?
@options[:ignore] and @options[:ignore].any? { |filter| @env['PATH_INFO'][filter] }
path = @env['QUERY_STRING'].empty? ? @env['PATH_INFO'] : "#{@env['PATH_INFO']}?#{@env['QUERY_STRING']}"
@options[:ignore] and @options[:ignore].any? { |filter| path[filter] }
end
def bad_browser?

View File

@ -15,7 +15,7 @@ describe Rack::LiveReload::BodyProcessor do
end
it 'responds false when no head tag' do
regex.match("<header></header>").should be_false
regex.match("<header></header>").should be_falsey
end
end

View File

@ -14,7 +14,7 @@ describe Rack::LiveReload::ProcessingSkipAnalyzer do
describe '#skip_processing?' do
it "should skip processing" do
subject.skip_processing?.should be_true
subject.skip_processing?.should be_truthy
end
end
@ -22,13 +22,13 @@ describe Rack::LiveReload::ProcessingSkipAnalyzer do
let(:options) { { :ignore => [ %r{file} ] } }
context 'path contains ignore pattern' do
let(:env) { { 'PATH_INFO' => '/this/file' } }
let(:env) { { 'PATH_INFO' => '/this/file', 'QUERY_STRING' => '' } }
it { should be_ignored }
end
context 'root path' do
let(:env) { { 'PATH_INFO' => '/' } }
let(:env) { { 'PATH_INFO' => '/', 'QUERY_STRING' => '' } }
it { should_not be_ignored }
end
@ -56,7 +56,8 @@ describe Rack::LiveReload::ProcessingSkipAnalyzer do
describe '#ignored?' do
let(:path_info) { 'path info' }
let(:env) { { 'PATH_INFO' => path_info } }
let(:query_string) { 'query_string' }
let(:env) { { 'PATH_INFO' => path_info, 'QUERY_STRING' => query_string } }
context 'no ignore set' do
it { should_not be_ignored }
@ -67,6 +68,12 @@ describe Rack::LiveReload::ProcessingSkipAnalyzer do
it { should be_ignored }
end
context 'ignore set including query_string' do
let(:options) { { :ignore => [ %r{#{path_info}\?#{query_string}} ] } }
it { should be_ignored }
end
end
describe '#bad_browser?' do

View File

@ -7,7 +7,9 @@ describe Rack::LiveReload do
subject { middleware }
its(:app) { should == app }
it 'should be an app' do
middleware.app.should be == app
end
let(:env) { {} }
let(:options) { {} }
@ -20,7 +22,7 @@ describe Rack::LiveReload do
end
it 'should return the js file' do
middleware._call(env).should be_true
middleware._call(env).should be_truthy
end
end
end