rack-livereload 0.3.17 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +7 -7
- data/README.md +13 -9
- data/features/step_definitions/given/i_have_a_rack_app_with_live_reload.rb +1 -1
- data/gemfiles/rails602.gemfile +5 -0
- data/gemfiles/rails7.gemfile +5 -0
- data/js/livereload.js +991 -990
- data/lib/rack/livereload/body_processor.rb +5 -2
- data/lib/rack/livereload/processing_skip_analyzer.rb +3 -3
- data/lib/rack/livereload.rb +3 -3
- data/lib/rack-livereload.rb +1 -1
- data/skel/livereload.html.erb +1 -0
- data/spec/rack/livereload/processing_skip_analyzer_spec.rb +10 -4
- metadata +5 -7
- data/.ruby-version +0 -1
- data/gemfiles/rails32.gemfile +0 -7
- data/gemfiles/rails40.gemfile +0 -7
@@ -4,8 +4,9 @@ module Rack
|
|
4
4
|
class LiveReload
|
5
5
|
class BodyProcessor
|
6
6
|
LIVERELOAD_JS_PATH = '/__rack/livereload.js'
|
7
|
-
HEAD_TAG_REGEX = /<head
|
7
|
+
HEAD_TAG_REGEX = /<head( [^<]+)?>/
|
8
8
|
LIVERELOAD_PORT = 35729
|
9
|
+
LIVERELOAD_SCHEME = "ws"
|
9
10
|
|
10
11
|
attr_reader :content_length, :new_body, :livereload_added
|
11
12
|
|
@@ -14,12 +15,14 @@ module Rack
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def livereload_local_uri
|
17
|
-
"#{protocol}://localhost:#{@options[:live_reload_port]}/
|
18
|
+
"#{protocol}://localhost:#{@options[:live_reload_port]}/" +
|
19
|
+
'livereload.js'
|
18
20
|
end
|
19
21
|
|
20
22
|
def initialize(body, options)
|
21
23
|
@body, @options = body, options
|
22
24
|
@options[:live_reload_port] ||= LIVERELOAD_PORT
|
25
|
+
@options[:live_reload_scheme] ||= LIVERELOAD_SCHEME
|
23
26
|
|
24
27
|
@processed = false
|
25
28
|
end
|
@@ -20,11 +20,11 @@ module Rack
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def chunked?
|
23
|
-
@headers['
|
23
|
+
@headers['transfer-encoding'] == 'chunked'
|
24
24
|
end
|
25
25
|
|
26
26
|
def inline?
|
27
|
-
@headers['
|
27
|
+
@headers['content-disposition'] =~ %r{^inline}
|
28
28
|
end
|
29
29
|
|
30
30
|
def ignored?
|
@@ -37,7 +37,7 @@ module Rack
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def html?
|
40
|
-
@headers['
|
40
|
+
@headers['content-type'] =~ %r{text/html|application/xhtml\+xml}
|
41
41
|
end
|
42
42
|
|
43
43
|
def get?
|
data/lib/rack/livereload.rb
CHANGED
@@ -27,10 +27,10 @@ module Rack
|
|
27
27
|
processor = BodyProcessor.new(body, @options)
|
28
28
|
processor.process!(env)
|
29
29
|
|
30
|
-
headers['
|
30
|
+
headers['content-length'] = processor.content_length.to_s
|
31
31
|
|
32
32
|
if processor.livereload_added
|
33
|
-
headers['
|
33
|
+
headers['x-rack-livereload'] = '1'
|
34
34
|
end
|
35
35
|
|
36
36
|
[ status, headers, processor.new_body ]
|
@@ -46,7 +46,7 @@ module Rack
|
|
46
46
|
'application/swf'
|
47
47
|
end
|
48
48
|
|
49
|
-
[ 200, { '
|
49
|
+
[ 200, { 'content-type' => type, 'content-length' => ::File.size(file).to_s }, [ ::File.read(file) ] ]
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
data/lib/rack-livereload.rb
CHANGED
data/skel/livereload.html.erb
CHANGED
@@ -10,6 +10,7 @@
|
|
10
10
|
<% end %>
|
11
11
|
<script type="text/javascript">
|
12
12
|
RACK_LIVERELOAD_PORT = <%= @options[:live_reload_port] %>;
|
13
|
+
RACK_LIVERELOAD_SCHEME = "<%= @options[:live_reload_scheme] %>";
|
13
14
|
</script>
|
14
15
|
<script type="text/javascript" src="<%= livereload_source %>"></script>
|
15
16
|
|
@@ -40,7 +40,7 @@ describe Rack::LiveReload::ProcessingSkipAnalyzer do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
context 'chunked response' do
|
43
|
-
let(:headers) { { '
|
43
|
+
let(:headers) { { 'transfer-encoding' => 'chunked' } }
|
44
44
|
|
45
45
|
it { should be_chunked }
|
46
46
|
end
|
@@ -48,7 +48,7 @@ describe Rack::LiveReload::ProcessingSkipAnalyzer do
|
|
48
48
|
|
49
49
|
describe '#inline?' do
|
50
50
|
context 'inline disposition' do
|
51
|
-
let(:headers) { { '
|
51
|
+
let(:headers) { { 'content-disposition' => 'inline; filename=my_inlined_file' } }
|
52
52
|
|
53
53
|
it { should be_inline }
|
54
54
|
end
|
@@ -90,13 +90,19 @@ describe Rack::LiveReload::ProcessingSkipAnalyzer do
|
|
90
90
|
|
91
91
|
describe '#html?' do
|
92
92
|
context 'HTML content' do
|
93
|
-
let(:headers) { { '
|
93
|
+
let(:headers) { { 'content-type' => 'text/html' } }
|
94
|
+
|
95
|
+
it { should be_html }
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'XHTML content' do
|
99
|
+
let(:headers) { { 'content-type' => 'application/xhtml+xml' } }
|
94
100
|
|
95
101
|
it { should be_html }
|
96
102
|
end
|
97
103
|
|
98
104
|
context 'PDF content' do
|
99
|
-
let(:headers) { { '
|
105
|
+
let(:headers) { { 'content-type' => 'application/pdf' } }
|
100
106
|
|
101
107
|
it { should_not be_html }
|
102
108
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-livereload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Bintz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -256,7 +256,6 @@ extensions: []
|
|
256
256
|
extra_rdoc_files: []
|
257
257
|
files:
|
258
258
|
- ".gitignore"
|
259
|
-
- ".ruby-version"
|
260
259
|
- ".travis.yml"
|
261
260
|
- Appraisals
|
262
261
|
- Gemfile
|
@@ -270,9 +269,9 @@ files:
|
|
270
269
|
- features/step_definitions/then/i_should_not_have_livereload_code.rb
|
271
270
|
- features/step_definitions/when/i_make_a_request_with_headers.rb
|
272
271
|
- features/support/env.rb
|
273
|
-
- gemfiles/rails32.gemfile
|
274
|
-
- gemfiles/rails40.gemfile
|
275
272
|
- gemfiles/rails51.gemfile
|
273
|
+
- gemfiles/rails602.gemfile
|
274
|
+
- gemfiles/rails7.gemfile
|
276
275
|
- index.html
|
277
276
|
- js/WebSocketMain.swf
|
278
277
|
- js/livereload.js
|
@@ -307,8 +306,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
307
306
|
- !ruby/object:Gem::Version
|
308
307
|
version: '0'
|
309
308
|
requirements: []
|
310
|
-
|
311
|
-
rubygems_version: 2.7.6
|
309
|
+
rubygems_version: 3.0.3.1
|
312
310
|
signing_key:
|
313
311
|
specification_version: 4
|
314
312
|
summary: Insert LiveReload into your app easily as Rack middleware
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.5.1
|
data/gemfiles/rails32.gemfile
DELETED