leifcr-rack-livereload 0.3.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5aa01f5be40032ff52132b351066f4296ac94240
4
+ data.tar.gz: 141b02772d24047e8b39d167d49f959b5485d7a7
5
+ SHA512:
6
+ metadata.gz: 21045bac36f85bc8446cbdb6d63a82a84e3c89156077c5ffffa2b9b5dcb48720ae9221f812566947eacd51af31ac702edb74a3bd7b87349e4add92b38bb42f04
7
+ data.tar.gz: 968e7e837ec0f3d5462b16dc4bfc31eb30aa664b1712519d2e38f06cc4d8784a3b5286995d2b9a3328a6cf6ad51276f8dedb8651eca4312471845a1463ac781c
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ gemfiles/*.lock
5
+ pkg/*
6
+ *.orig
7
+ tmp/
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+ branches:
5
+ only:
6
+ - master
7
+ gemfile:
8
+ - gemfiles/rails32.gemfile
9
+ - gemfiles/rails40.gemfile
10
+
data/Appraisals ADDED
@@ -0,0 +1,7 @@
1
+ appraise 'rails32' do
2
+ gem 'rails', '~> 3.2.0'
3
+ end
4
+
5
+ appraise 'rails40' do
6
+ gem 'rails', '~> 4.0.0'
7
+ end
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rack-livereload.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,17 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :cli => '-c' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
9
+
10
+ guard 'livereload' do
11
+ watch('index.html')
12
+ end
13
+
14
+ guard 'cucumber' do
15
+ watch(%r{^features/.+\.feature$})
16
+ watch(%r{^features/support/.+$}) { 'features' }
17
+ end
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright © 2012 John Bintz
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the “Software”), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,103 @@
1
+ # Rack::LiveReload
2
+
3
+ <a href="http://travis-ci.org/johnbintz/rack-livereload"><img src="https://secure.travis-ci.org/johnbintz/rack-livereload.png" /></a>
4
+ [![Code Climate](https://codeclimate.com/github/johnbintz/rack-livereload.png)](https://codeclimate.com/github/johnbintz/rack-livereload)
5
+
6
+ Hey, you've got [LiveReload](http://livereload.com/) in my [Rack](http://rack.rubyforge.org/)!
7
+ No need for browser extensions anymore! Just plug it in your middleware stack and go!
8
+ Even supports browsers without WebSockets!
9
+
10
+ Use this with [guard-livereload](http://github.com/guard/guard-livereload) for maximum fun!
11
+
12
+ ## Installation
13
+
14
+ ### Rails
15
+
16
+ Add the gem to your Gemfile.
17
+
18
+ ```ruby
19
+ gem "rack-livereload", group: :development
20
+ ```
21
+
22
+ Then add the middleware to your Rails middleware stack by editing your `config/environments/development.rb`.
23
+
24
+ ```ruby
25
+ # config/environments/development.rb
26
+
27
+ MyApp::Application.configure do
28
+ # Add Rack::LiveReload to the bottom of the middleware stack with the default options:
29
+ config.middleware.insert_after ActionDispatch::Static, Rack::LiveReload
30
+
31
+ # or, if you're using better_errors:
32
+ config.middleware.insert_before Rack::Lock, Rack::LiveReload
33
+
34
+ # ...
35
+ end
36
+ ```
37
+
38
+ #### Tweaking the options
39
+
40
+ ```ruby
41
+ # Specifying Rack::LiveReload options.
42
+ config.middleware.use(Rack::LiveReload,
43
+ min_delay : 500, # default 1000
44
+ max_delay : 10_000, # default 60_000
45
+ live_reload_port : 56789, # default 35729
46
+ host : 'myhost.cool.wow',
47
+ ignore : [ %r{dont/modify\.html$} ]
48
+ )
49
+ ```
50
+
51
+ In addition, Rack::LiveReload's position within middleware stack can be
52
+ specified by inserting it relative to an exsiting middleware via
53
+ `insert_before` or `insert_after`. See the [Rails on Rack: Adding a
54
+ Middleware](http://guides.rubyonrails.org/rails_on_rack.html#adding-a-middleware)
55
+ section for more detail.
56
+
57
+ ### Sinatra / config.ru
58
+
59
+ ``` ruby
60
+ require 'rack-livereload'
61
+
62
+ use Rack::LiveReload
63
+ # ...or...
64
+ use Rack::LiveReload, min_delay: 500, ...
65
+ ```
66
+
67
+ ## How it works
68
+
69
+ The necessary `script` tag to bring in a copy of [livereload.js](https://github.com/livereload/livereload-js) is
70
+ injected right after the opening `head` tag in any `text/html` pages that come through. The `script` tag is built in
71
+ such a way that the `HTTP_HOST` is used as the LiveReload host, so you can connect from external machines (say, to
72
+ `mycomputer:3000` instead of `localhost:3000`) and as long as the LiveReload port is accessible from the external machine,
73
+ you'll connect and be LiveReloading away!
74
+
75
+ ### Which LiveReload script does it use?
76
+
77
+ * If you've got a LiveReload watcher running on the same machine as the app that responds
78
+ to `http://localhost:35729/livereload.js`, that gets used, with the hostname being changed when
79
+ injected into the HTML page.
80
+ * If you don't, the copy vendored with rack-livereload is used.
81
+ * You can force the use of either one (and save on the cost of checking to see if that file
82
+ is available) with the middleware option `:source => :vendored` or `:source => :livereload`.
83
+
84
+ ### How about non-WebSocket-enabled browsers?
85
+
86
+ For browsers that don't support WebSockets, but do support Flash, [web-socket-js](https://github.com/gimite/web-socket-js)
87
+ is loaded. By default, this is done transparently, so you'll get a copy of swfobject.js and web_socket.js loaded even if
88
+ your browser doesn't need it. The SWF WebSocket implementor won't be loaded unless your browser has no native
89
+ WebSockets support or if you force it in the middleware stack:
90
+
91
+ ``` ruby
92
+ use Rack::LiveReload, force_swf: true
93
+ ```
94
+
95
+ If you don't want any of the web-sockets-js code included at all, use the `no_swf` option:
96
+
97
+ ``` ruby
98
+ use Rack::LiveReload, no_swf: true
99
+ ```
100
+
101
+ Once more browsers support WebSockets than don't, this option will be reversed and you'll have
102
+ to explicitly include the Flash shim.
103
+
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ require "bundler/gem_tasks"
2
+ require 'bundler/setup'
3
+ require 'appraisal'
4
+
5
+ desc 'Update livereload.js'
6
+ task :update_livereload_js do
7
+ require 'httparty'
8
+
9
+ File.open('js/livereload.js', 'wb') { |fh|
10
+ fh.print HTTParty.get('https://raw.github.com/livereload/livereload-js/master/dist/livereload.js').body
11
+ }
12
+ end
13
+
14
+ desc 'Update web-socket-js'
15
+ task :update_web_socket_js do
16
+ require 'httparty'
17
+
18
+ %w{swfobject.js web_socket.js WebSocketMain.swf}.each do |file|
19
+ File.open("js/#{file}", 'wb') do |fh|
20
+ fh.print HTTParty.get("https://raw.github.com/gimite/web-socket-js/master/#{file}").body
21
+ end
22
+ end
23
+ end
24
+
25
+ require 'rspec/core/rake_task'
26
+
27
+ RSpec::Core::RakeTask.new(:spec)
28
+
29
+ require 'cucumber/rake/task'
30
+
31
+ Cucumber::Rake::Task.new(:cucumber)
32
+
33
+ task :default => [ :spec, :cucumber ]
34
+
data/config.ru ADDED
@@ -0,0 +1,17 @@
1
+ require 'sinatra'
2
+ $: << 'lib'
3
+
4
+ require 'rack/livereload'
5
+
6
+ use Rack::Logger
7
+ use Rack::LiveReload
8
+ run Rack::Directory.new('.')
9
+
10
+ if false
11
+
12
+ get '/' do
13
+ File.read('index.html')
14
+ end
15
+
16
+ run Sinatra::Application
17
+ end
@@ -0,0 +1,11 @@
1
+ Feature: Skip Certain Browsers
2
+ Scenario Outline:
3
+ Given I have a Rack app with Rack::LiveReload
4
+ When I make a request to "/" with the following headers:
5
+ | HTTP_USER_AGENT | <user agent> |
6
+ Then I should not have any Rack::LiveReload code
7
+
8
+ Scenarios: Browsers to check for
9
+ | user agent |
10
+ | MSIE |
11
+
@@ -0,0 +1,7 @@
1
+ Given /^I have a Rack app with Rack::LiveReload$/ do
2
+ @app = Rack::Builder.new do
3
+ use Rack::LiveReload
4
+
5
+ run lambda { |env| [ 200, { 'Content-Type' => 'text/html' }, [ "<html><head></head><body></body></html>" ] ] }
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ Then /^I should not have any Rack::LiveReload code$/ do
2
+ @response.body.should_not include("rack/livereload.js")
3
+ end
4
+
@@ -0,0 +1,6 @@
1
+ When /^I make a request to "([^"]*)" with the following headers:$/ do |uri, table|
2
+ @request = Rack::MockRequest.new(@app)
3
+
4
+ @response = @request.get(uri, table.rows_hash)
5
+ end
6
+
@@ -0,0 +1,3 @@
1
+ require 'rack'
2
+ require 'rack-livereload'
3
+
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "~> 3.2.0"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "~> 4.0.0"
6
+
7
+ gemspec :path=>"../"
data/index.html ADDED
@@ -0,0 +1,2 @@
1
+ <html>
2
+ <head><title>Hi</title></head><body>Rats</body></html>
Binary file