diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..bc48b1c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +rvm: + - 1.8.7 + - 1.9.2 + - 1.9.3 +branches: + only: + - master +gemfile: + - gemfiles/rails30.gemfile + - gemfiles/rails31.gemfile + - gemfiles/rails32.gemfile \ No newline at end of file diff --git a/Appraisals b/Appraisals new file mode 100644 index 0000000..1885fb9 --- /dev/null +++ b/Appraisals @@ -0,0 +1,11 @@ +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 \ No newline at end of file diff --git a/README.md b/README.md index 56988ef..9f7eb59 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ + + Hey, you've got [LiveReload](http://www.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! @@ -12,6 +14,7 @@ Use this with [guard-livereload](http://github.com/guard/guard-livereload) for m ### Rails + In `config/environments/development.rb`: ``` ruby diff --git a/Rakefile b/Rakefile index 791b9fd..d5bf453 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,6 @@ require "bundler/gem_tasks" +require 'bundler/setup' +require 'appraisal' desc 'Update livereload.js' task :update_livereload_js do diff --git a/gemfiles/rails30.gemfile b/gemfiles/rails30.gemfile new file mode 100644 index 0000000..eaf7f8d --- /dev/null +++ b/gemfiles/rails30.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "http://rubygems.org" + +gem "rails", "~> 3.0.0" + +gemspec :path=>"../" \ No newline at end of file diff --git a/gemfiles/rails30.gemfile.lock b/gemfiles/rails30.gemfile.lock new file mode 100644 index 0000000..9eec6a2 --- /dev/null +++ b/gemfiles/rails30.gemfile.lock @@ -0,0 +1,157 @@ +PATH + remote: /Volumes/work/current/open_source/rack-livereload + specs: + rack-livereload (0.3.6) + rack + +GEM + remote: http://rubygems.org/ + specs: + abstract (1.0.0) + actionmailer (3.0.12) + actionpack (= 3.0.12) + mail (~> 2.2.19) + actionpack (3.0.12) + activemodel (= 3.0.12) + activesupport (= 3.0.12) + builder (~> 2.1.2) + erubis (~> 2.6.6) + i18n (~> 0.5.0) + rack (~> 1.2.5) + rack-mount (~> 0.6.14) + rack-test (~> 0.5.7) + tzinfo (~> 0.3.23) + activemodel (3.0.12) + activesupport (= 3.0.12) + builder (~> 2.1.2) + i18n (~> 0.5.0) + activerecord (3.0.12) + activemodel (= 3.0.12) + activesupport (= 3.0.12) + arel (~> 2.0.10) + tzinfo (~> 0.3.23) + activeresource (3.0.12) + activemodel (= 3.0.12) + activesupport (= 3.0.12) + activesupport (3.0.12) + addressable (2.2.8) + appraisal (0.4.1) + bundler + rake + arel (2.0.10) + builder (2.1.2) + crack (0.3.1) + cucumber (1.2.0) + builder (>= 2.1.2) + diff-lcs (>= 1.1.3) + gherkin (~> 2.10.0) + json (>= 1.4.6) + daemons (1.1.8) + diff-lcs (1.1.3) + em-websocket (0.3.6) + addressable (>= 2.1.1) + eventmachine (>= 0.12.9) + erubis (2.6.6) + abstract (>= 1.0.0) + eventmachine (0.12.10) + ffi (1.0.11) + gherkin (2.10.0) + json (>= 1.4.6) + guard (1.0.3) + ffi (>= 0.5.0) + thor (>= 0.14.6) + guard-cucumber (0.8.0) + cucumber (>= 1.2.0) + guard (>= 0.8.3) + guard-livereload (0.4.2) + em-websocket (>= 0.2.0) + guard (>= 0.10.0) + multi_json (~> 1.0) + guard-rspec (0.7.3) + guard (>= 0.10.0) + httparty (0.8.3) + multi_json (~> 1.0) + multi_xml + i18n (0.5.0) + json (1.7.3) + mail (2.2.19) + activesupport (>= 2.3.6) + i18n (>= 0.4.0) + mime-types (~> 1.16) + treetop (~> 1.4.8) + metaclass (0.0.1) + mime-types (1.18) + mocha (0.11.4) + metaclass (~> 0.0.1) + multi_json (1.3.6) + multi_xml (0.5.1) + polyglot (0.3.3) + rack (1.2.5) + rack-mount (0.6.14) + rack (>= 1.0.0) + rack-test (0.5.7) + rack (>= 1.0) + rails (3.0.12) + actionmailer (= 3.0.12) + actionpack (= 3.0.12) + activerecord (= 3.0.12) + activeresource (= 3.0.12) + activesupport (= 3.0.12) + bundler (~> 1.0) + railties (= 3.0.12) + railties (3.0.12) + actionpack (= 3.0.12) + activesupport (= 3.0.12) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (~> 0.14.4) + rake (0.9.2.2) + rdoc (3.12) + json (~> 1.4) + rspec (2.10.0) + rspec-core (~> 2.10.0) + rspec-expectations (~> 2.10.0) + rspec-mocks (~> 2.10.0) + rspec-core (2.10.1) + rspec-expectations (2.10.0) + diff-lcs (~> 1.1.3) + rspec-mocks (2.10.1) + shotgun (0.9) + rack (>= 1.0) + sinatra (1.2.8) + rack (~> 1.1) + tilt (>= 1.2.2, < 2.0) + thin (1.3.1) + daemons (>= 1.0.9) + eventmachine (>= 0.12.6) + rack (>= 1.0.0) + thor (0.14.6) + tilt (1.3.3) + treetop (1.4.10) + polyglot + polyglot (>= 0.3.1) + tzinfo (0.3.33) + webmock (1.8.7) + addressable (>= 2.2.7) + crack (>= 0.1.7) + +PLATFORMS + ruby + +DEPENDENCIES + appraisal (~> 0.4) + cucumber + guard + guard-cucumber + guard-livereload + guard-rspec + httparty + mocha + rack-livereload! + rails (~> 3.0.0) + rake + rspec + shotgun + sinatra + thin + webmock diff --git a/gemfiles/rails31.gemfile b/gemfiles/rails31.gemfile new file mode 100644 index 0000000..5a7622b --- /dev/null +++ b/gemfiles/rails31.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "http://rubygems.org" + +gem "rails", "~> 3.1.0" + +gemspec :path=>"../" \ No newline at end of file diff --git a/gemfiles/rails31.gemfile.lock b/gemfiles/rails31.gemfile.lock new file mode 100644 index 0000000..afe9122 --- /dev/null +++ b/gemfiles/rails31.gemfile.lock @@ -0,0 +1,169 @@ +PATH + remote: /Volumes/work/current/open_source/rack-livereload + specs: + rack-livereload (0.3.6) + rack + +GEM + remote: http://rubygems.org/ + specs: + actionmailer (3.1.4) + actionpack (= 3.1.4) + mail (~> 2.3.0) + actionpack (3.1.4) + activemodel (= 3.1.4) + activesupport (= 3.1.4) + builder (~> 3.0.0) + erubis (~> 2.7.0) + i18n (~> 0.6) + rack (~> 1.3.6) + rack-cache (~> 1.1) + rack-mount (~> 0.8.2) + rack-test (~> 0.6.1) + sprockets (~> 2.0.3) + activemodel (3.1.4) + activesupport (= 3.1.4) + builder (~> 3.0.0) + i18n (~> 0.6) + activerecord (3.1.4) + activemodel (= 3.1.4) + activesupport (= 3.1.4) + arel (~> 2.2.3) + tzinfo (~> 0.3.29) + activeresource (3.1.4) + activemodel (= 3.1.4) + activesupport (= 3.1.4) + activesupport (3.1.4) + multi_json (~> 1.0) + addressable (2.2.8) + appraisal (0.4.1) + bundler + rake + arel (2.2.3) + builder (3.0.0) + crack (0.3.1) + cucumber (1.2.0) + builder (>= 2.1.2) + diff-lcs (>= 1.1.3) + gherkin (~> 2.10.0) + json (>= 1.4.6) + daemons (1.1.8) + diff-lcs (1.1.3) + em-websocket (0.3.6) + addressable (>= 2.1.1) + eventmachine (>= 0.12.9) + erubis (2.7.0) + eventmachine (0.12.10) + ffi (1.0.11) + gherkin (2.10.0) + json (>= 1.4.6) + guard (1.0.3) + ffi (>= 0.5.0) + thor (>= 0.14.6) + guard-cucumber (0.8.0) + cucumber (>= 1.2.0) + guard (>= 0.8.3) + guard-livereload (0.4.2) + em-websocket (>= 0.2.0) + guard (>= 0.10.0) + multi_json (~> 1.0) + guard-rspec (0.7.3) + guard (>= 0.10.0) + hike (1.2.1) + httparty (0.8.3) + multi_json (~> 1.0) + multi_xml + i18n (0.6.0) + json (1.7.3) + mail (2.3.3) + i18n (>= 0.4.0) + mime-types (~> 1.16) + treetop (~> 1.4.8) + metaclass (0.0.1) + mime-types (1.18) + mocha (0.11.4) + metaclass (~> 0.0.1) + multi_json (1.3.6) + multi_xml (0.5.1) + polyglot (0.3.3) + rack (1.3.6) + rack-cache (1.2) + rack (>= 0.4) + rack-mount (0.8.3) + rack (>= 1.0.0) + rack-protection (1.2.0) + rack + rack-ssl (1.3.2) + rack + rack-test (0.6.1) + rack (>= 1.0) + rails (3.1.4) + actionmailer (= 3.1.4) + actionpack (= 3.1.4) + activerecord (= 3.1.4) + activeresource (= 3.1.4) + activesupport (= 3.1.4) + bundler (~> 1.0) + railties (= 3.1.4) + railties (3.1.4) + actionpack (= 3.1.4) + activesupport (= 3.1.4) + rack-ssl (~> 1.3.2) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (~> 0.14.6) + rake (0.9.2.2) + rdoc (3.12) + json (~> 1.4) + rspec (2.10.0) + rspec-core (~> 2.10.0) + rspec-expectations (~> 2.10.0) + rspec-mocks (~> 2.10.0) + rspec-core (2.10.1) + rspec-expectations (2.10.0) + diff-lcs (~> 1.1.3) + rspec-mocks (2.10.1) + shotgun (0.9) + rack (>= 1.0) + sinatra (1.3.2) + rack (~> 1.3, >= 1.3.6) + rack-protection (~> 1.2) + tilt (~> 1.3, >= 1.3.3) + sprockets (2.0.4) + hike (~> 1.2) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + thin (1.3.1) + daemons (>= 1.0.9) + eventmachine (>= 0.12.6) + rack (>= 1.0.0) + thor (0.14.6) + tilt (1.3.3) + treetop (1.4.10) + polyglot + polyglot (>= 0.3.1) + tzinfo (0.3.33) + webmock (1.8.7) + addressable (>= 2.2.7) + crack (>= 0.1.7) + +PLATFORMS + ruby + +DEPENDENCIES + appraisal (~> 0.4) + cucumber + guard + guard-cucumber + guard-livereload + guard-rspec + httparty + mocha + rack-livereload! + rails (~> 3.1.0) + rake + rspec + shotgun + sinatra + thin + webmock diff --git a/gemfiles/rails32.gemfile b/gemfiles/rails32.gemfile new file mode 100644 index 0000000..6f5dbe6 --- /dev/null +++ b/gemfiles/rails32.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "http://rubygems.org" + +gem "rails", "~> 3.2.0" + +gemspec :path=>"../" \ No newline at end of file diff --git a/gemfiles/rails32.gemfile.lock b/gemfiles/rails32.gemfile.lock new file mode 100644 index 0000000..0ed680f --- /dev/null +++ b/gemfiles/rails32.gemfile.lock @@ -0,0 +1,167 @@ +PATH + remote: /Volumes/work/current/open_source/rack-livereload + specs: + rack-livereload (0.3.6) + rack + +GEM + remote: http://rubygems.org/ + specs: + actionmailer (3.2.3) + actionpack (= 3.2.3) + mail (~> 2.4.4) + actionpack (3.2.3) + activemodel (= 3.2.3) + activesupport (= 3.2.3) + builder (~> 3.0.0) + erubis (~> 2.7.0) + journey (~> 1.0.1) + rack (~> 1.4.0) + rack-cache (~> 1.2) + rack-test (~> 0.6.1) + sprockets (~> 2.1.2) + activemodel (3.2.3) + activesupport (= 3.2.3) + builder (~> 3.0.0) + activerecord (3.2.3) + activemodel (= 3.2.3) + activesupport (= 3.2.3) + arel (~> 3.0.2) + tzinfo (~> 0.3.29) + activeresource (3.2.3) + activemodel (= 3.2.3) + activesupport (= 3.2.3) + activesupport (3.2.3) + i18n (~> 0.6) + multi_json (~> 1.0) + addressable (2.2.8) + appraisal (0.4.1) + bundler + rake + arel (3.0.2) + builder (3.0.0) + crack (0.3.1) + cucumber (1.2.0) + builder (>= 2.1.2) + diff-lcs (>= 1.1.3) + gherkin (~> 2.10.0) + json (>= 1.4.6) + daemons (1.1.8) + diff-lcs (1.1.3) + em-websocket (0.3.6) + addressable (>= 2.1.1) + eventmachine (>= 0.12.9) + erubis (2.7.0) + eventmachine (0.12.10) + ffi (1.0.11) + gherkin (2.10.0) + json (>= 1.4.6) + guard (1.0.3) + ffi (>= 0.5.0) + thor (>= 0.14.6) + guard-cucumber (0.8.0) + cucumber (>= 1.2.0) + guard (>= 0.8.3) + guard-livereload (0.4.2) + em-websocket (>= 0.2.0) + guard (>= 0.10.0) + multi_json (~> 1.0) + guard-rspec (0.7.3) + guard (>= 0.10.0) + hike (1.2.1) + httparty (0.8.3) + multi_json (~> 1.0) + multi_xml + i18n (0.6.0) + journey (1.0.3) + json (1.7.3) + mail (2.4.4) + i18n (>= 0.4.0) + mime-types (~> 1.16) + treetop (~> 1.4.8) + metaclass (0.0.1) + mime-types (1.18) + mocha (0.11.4) + metaclass (~> 0.0.1) + multi_json (1.3.6) + multi_xml (0.5.1) + polyglot (0.3.3) + rack (1.4.1) + rack-cache (1.2) + rack (>= 0.4) + rack-protection (1.2.0) + rack + rack-ssl (1.3.2) + rack + rack-test (0.6.1) + rack (>= 1.0) + rails (3.2.3) + actionmailer (= 3.2.3) + actionpack (= 3.2.3) + activerecord (= 3.2.3) + activeresource (= 3.2.3) + activesupport (= 3.2.3) + bundler (~> 1.0) + railties (= 3.2.3) + railties (3.2.3) + actionpack (= 3.2.3) + activesupport (= 3.2.3) + rack-ssl (~> 1.3.2) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (~> 0.14.6) + rake (0.9.2.2) + rdoc (3.12) + json (~> 1.4) + rspec (2.10.0) + rspec-core (~> 2.10.0) + rspec-expectations (~> 2.10.0) + rspec-mocks (~> 2.10.0) + rspec-core (2.10.1) + rspec-expectations (2.10.0) + diff-lcs (~> 1.1.3) + rspec-mocks (2.10.1) + shotgun (0.9) + rack (>= 1.0) + sinatra (1.3.2) + rack (~> 1.3, >= 1.3.6) + rack-protection (~> 1.2) + tilt (~> 1.3, >= 1.3.3) + sprockets (2.1.3) + hike (~> 1.2) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + thin (1.3.1) + daemons (>= 1.0.9) + eventmachine (>= 0.12.6) + rack (>= 1.0.0) + thor (0.14.6) + tilt (1.3.3) + treetop (1.4.10) + polyglot + polyglot (>= 0.3.1) + tzinfo (0.3.33) + webmock (1.8.7) + addressable (>= 2.2.7) + crack (>= 0.1.7) + +PLATFORMS + ruby + +DEPENDENCIES + appraisal (~> 0.4) + cucumber + guard + guard-cucumber + guard-livereload + guard-rspec + httparty + mocha + rack-livereload! + rails (~> 3.2.0) + rake + rspec + shotgun + sinatra + thin + webmock diff --git a/lib/rack/livereload.rb b/lib/rack/livereload.rb index 45b5798..d9fdb21 100644 --- a/lib/rack/livereload.rb +++ b/lib/rack/livereload.rb @@ -62,7 +62,7 @@ module Rack body.close if body.respond_to?(:close) if !ignored?(env['PATH_INFO']) && !bad_browser?(env['HTTP_USER_AGENT']) - if headers['Content-Type'] && headers['Content-Type'][%r{text/html}] + if headers['Content-Type'] && status == 200 && headers['Content-Type'][%r{text/html}] content_length = 0 new_body.each do |line| diff --git a/rack-livereload.gemspec b/rack-livereload.gemspec index 80b29d1..f029d3c 100644 --- a/rack-livereload.gemspec +++ b/rack-livereload.gemspec @@ -32,7 +32,7 @@ Gem::Specification.new do |s| s.add_development_dependency "guard-cucumber" s.add_development_dependency "guard-livereload" s.add_development_dependency "webmock" - + s.add_development_dependency 'appraisal', '~> 0.4' s.add_runtime_dependency "rack" end