rack-livereload 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rack-livereload.rb +1 -1
- data/lib/rack/livereload.rb +12 -6
- data/spec/rack/livereload_spec.rb +2 -2
- metadata +32 -32
data/lib/rack-livereload.rb
CHANGED
data/lib/rack/livereload.rb
CHANGED
@@ -42,6 +42,10 @@ module Rack
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def call(env)
|
45
|
+
dup._call(env)
|
46
|
+
end
|
47
|
+
|
48
|
+
def _call(env)
|
45
49
|
_, path, file = (env['PATH_INFO'] || '').split('/')
|
46
50
|
|
47
51
|
if path == '__rack' && ::File.file?(target = ::File.expand_path("../../../js/#{file}", __FILE__))
|
@@ -49,15 +53,19 @@ module Rack
|
|
49
53
|
else
|
50
54
|
status, headers, body = @app.call(env)
|
51
55
|
|
52
|
-
new_body =
|
56
|
+
new_body = []
|
57
|
+
|
58
|
+
body.each do |line|
|
59
|
+
new_body << line
|
60
|
+
end
|
61
|
+
|
62
|
+
body.close if body.respond_to?(:close)
|
53
63
|
|
54
64
|
if !ignored?(env['PATH_INFO']) && !bad_browser?(env['HTTP_USER_AGENT'])
|
55
65
|
if headers['Content-Type'] && headers['Content-Type'][%r{text/html}]
|
56
66
|
content_length = 0
|
57
67
|
|
58
|
-
new_body
|
59
|
-
|
60
|
-
body.each do |line|
|
68
|
+
new_body.each do |line|
|
61
69
|
if !headers['X-Rack-LiveReload'] && line['</head>']
|
62
70
|
host_to_use = (@options[:host] || env['HTTP_HOST'] || 'localhost').gsub(%r{:.*}, '')
|
63
71
|
|
@@ -79,8 +87,6 @@ module Rack
|
|
79
87
|
end
|
80
88
|
|
81
89
|
content_length += line.bytesize
|
82
|
-
|
83
|
-
new_body << line
|
84
90
|
end
|
85
91
|
|
86
92
|
headers['Content-Length'] = content_length.to_s
|
@@ -74,7 +74,7 @@ describe Rack::LiveReload do
|
|
74
74
|
let(:host) { 'host' }
|
75
75
|
let(:env) { { 'HTTP_HOST' => host } }
|
76
76
|
|
77
|
-
let(:ret) { middleware.
|
77
|
+
let(:ret) { middleware._call(env) }
|
78
78
|
let(:body) { ret.last.join }
|
79
79
|
let(:length) { ret[1]['Content-Length'] }
|
80
80
|
|
@@ -174,7 +174,7 @@ describe Rack::LiveReload do
|
|
174
174
|
end
|
175
175
|
|
176
176
|
it 'should return the js file' do
|
177
|
-
middleware.
|
177
|
+
middleware._call(env).should be_true
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-livereload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &2155935560 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2155935560
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: cucumber
|
27
|
-
requirement: &
|
27
|
+
requirement: &2155957660 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2155957660
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: httparty
|
38
|
-
requirement: &
|
38
|
+
requirement: &2155956280 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2155956280
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: sinatra
|
49
|
-
requirement: &
|
49
|
+
requirement: &2155953020 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2155953020
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: shotgun
|
60
|
-
requirement: &
|
60
|
+
requirement: &2155952360 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2155952360
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: thin
|
71
|
-
requirement: &
|
71
|
+
requirement: &2155951720 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2155951720
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rake
|
82
|
-
requirement: &
|
82
|
+
requirement: &2155950700 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2155950700
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: mocha
|
93
|
-
requirement: &
|
93
|
+
requirement: &2156028860 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *2156028860
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: guard
|
104
|
-
requirement: &
|
104
|
+
requirement: &2156027060 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *2156027060
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: guard-rspec
|
115
|
-
requirement: &
|
115
|
+
requirement: &2156026340 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: '0'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *2156026340
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: guard-cucumber
|
126
|
-
requirement: &
|
126
|
+
requirement: &2156025520 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ! '>='
|
@@ -131,10 +131,10 @@ dependencies:
|
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *2156025520
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: guard-livereload
|
137
|
-
requirement: &
|
137
|
+
requirement: &2156022780 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - ! '>='
|
@@ -142,10 +142,10 @@ dependencies:
|
|
142
142
|
version: '0'
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *2156022780
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: webmock
|
148
|
-
requirement: &
|
148
|
+
requirement: &2156053540 !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
151
151
|
- - ! '>='
|
@@ -153,10 +153,10 @@ dependencies:
|
|
153
153
|
version: '0'
|
154
154
|
type: :development
|
155
155
|
prerelease: false
|
156
|
-
version_requirements: *
|
156
|
+
version_requirements: *2156053540
|
157
157
|
- !ruby/object:Gem::Dependency
|
158
158
|
name: rack
|
159
|
-
requirement: &
|
159
|
+
requirement: &2156051820 !ruby/object:Gem::Requirement
|
160
160
|
none: false
|
161
161
|
requirements:
|
162
162
|
- - ! '>='
|
@@ -164,7 +164,7 @@ dependencies:
|
|
164
164
|
version: '0'
|
165
165
|
type: :runtime
|
166
166
|
prerelease: false
|
167
|
-
version_requirements: *
|
167
|
+
version_requirements: *2156051820
|
168
168
|
description: Insert LiveReload into your app easily as Rack middleware
|
169
169
|
email:
|
170
170
|
- john@coswellproductions.com
|
@@ -208,7 +208,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
208
208
|
version: '0'
|
209
209
|
segments:
|
210
210
|
- 0
|
211
|
-
hash:
|
211
|
+
hash: 2680999454446852555
|
212
212
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
213
|
none: false
|
214
214
|
requirements:
|
@@ -217,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
217
|
version: '0'
|
218
218
|
segments:
|
219
219
|
- 0
|
220
|
-
hash:
|
220
|
+
hash: 2680999454446852555
|
221
221
|
requirements: []
|
222
222
|
rubyforge_project: rack-livereload
|
223
223
|
rubygems_version: 1.8.11
|