rack-livereload 0.3.17 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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>|<head[^(er)][^<]*>/
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]}/livereload.js"
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['Transfer-Encoding'] == 'chunked'
23
+ @headers['transfer-encoding'] == 'chunked'
24
24
  end
25
25
 
26
26
  def inline?
27
- @headers['Content-Disposition'] =~ %r{^inline}
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['Content-Type'] =~ %r{text/html}
40
+ @headers['content-type'] =~ %r{text/html|application/xhtml\+xml}
41
41
  end
42
42
 
43
43
  def get?
@@ -27,10 +27,10 @@ module Rack
27
27
  processor = BodyProcessor.new(body, @options)
28
28
  processor.process!(env)
29
29
 
30
- headers['Content-Length'] = processor.content_length.to_s
30
+ headers['content-length'] = processor.content_length.to_s
31
31
 
32
32
  if processor.livereload_added
33
- headers['X-Rack-LiveReload'] = '1'
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, { 'Content-Type' => type, 'Content-Length' => ::File.size(file).to_s }, [ ::File.read(file) ] ]
49
+ [ 200, { 'content-type' => type, 'content-length' => ::File.size(file).to_s }, [ ::File.read(file) ] ]
50
50
  end
51
51
  end
52
52
  end
@@ -1,6 +1,6 @@
1
1
  require "rack/livereload"
2
2
 
3
3
  class Rack::LiveReload
4
- VERSION = '0.3.17'
4
+ VERSION = '0.5.1'
5
5
  end
6
6
 
@@ -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) { { 'Transfer-Encoding' => 'chunked' } }
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) { { 'Content-Disposition' => 'inline; filename=my_inlined_file' } }
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) { { 'Content-Type' => 'text/html' } }
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) { { 'Content-Type' => 'application/pdf' } }
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.3.17
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: 2018-04-06 00:00:00.000000000 Z
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
- rubyforge_project: rack-livereload
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
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "~> 3.2.0"
6
-
7
- gemspec :path=>"../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "~> 4.0.0"
6
-
7
- gemspec :path=>"../"