rack-unreloader 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +8 -0
- data/README.rdoc +10 -5
- data/Rakefile +6 -5
- data/lib/rack/unreloader/reloader.rb +52 -25
- data/spec/unreloader_spec.rb +71 -41
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c8f1734dc2b5c882473017b36c57ebd8ec83ce9
|
4
|
+
data.tar.gz: 77139686abfd0970924657fd236717be42b70da5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15eb8fac861e37af6c853b115ab64c38d0ec270273fb13a09f0aa72fc94fe5007b884541f6c5732de1146564342a8b69d05435f22fd076c2fdd842564ebf22b7
|
7
|
+
data.tar.gz: b43aad4ee73d6218cad149d523aaa1e1f086bb7020719b78ec7b14e028e4f8530fb4c8e90429a3463344737f4dc4d6332431eecbd6e13d4cbec911f836a00c8c
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
= 1.3.0 (2015-04-06)
|
2
|
+
|
3
|
+
* Log when specified constant exists before loading file or does not exist after loading (jeremyevans)
|
4
|
+
|
5
|
+
* Improve logging, making it explicit when files are unloaded and reloaded (jeremyevans)
|
6
|
+
|
7
|
+
* Allow returning :ObjectSpace for require block to signal that ObjectSpace should be used to determine constants (jeremyevans)
|
8
|
+
|
1
9
|
= 1.2.1 (2015-01-27)
|
2
10
|
|
3
11
|
* Fix homepage in gemspec (jeremyevans)
|
data/README.rdoc
CHANGED
@@ -224,6 +224,11 @@ your models just use a capitalized version of the filename:
|
|
224
224
|
|
225
225
|
Unreloader.require('models'){|f| File.basename(f).sub(/\.rb\z/, '').capitalize}
|
226
226
|
|
227
|
+
In some cases, you may want to pass a block to require, but inside the block
|
228
|
+
decide that instead of specifying the constants, ObjectSpace should be used to
|
229
|
+
automatically determine the constants loaded. You can specify this by having the
|
230
|
+
block return the :ObjectSpace symbol.
|
231
|
+
|
227
232
|
== Usage Outside Rack
|
228
233
|
|
229
234
|
While <tt>Rack::Unreloader</tt> is usually in the development of rack applications,
|
@@ -234,10 +239,9 @@ reload the application.
|
|
234
239
|
|
235
240
|
== History
|
236
241
|
|
237
|
-
Rack::Unreloader was derived from Padrino's reloader.
|
238
|
-
|
239
|
-
|
240
|
-
fixes.
|
242
|
+
Rack::Unreloader was derived from Padrino's reloader. The Padrino-specific parts
|
243
|
+
were removed, and it now requires the user manually specify which files to monitor.
|
244
|
+
It has additional features, improvements, and bug fixes.
|
241
245
|
|
242
246
|
== Caveats
|
243
247
|
|
@@ -248,7 +252,8 @@ will not handle correctly. If it isn't doing what you expect, add a logger:
|
|
248
252
|
|
249
253
|
Unloading constants causes issues whenever references to the constant are
|
250
254
|
cached anywhere instead of looking up the constant by name. This is fairly
|
251
|
-
common, and using this library can cause a memory leak
|
255
|
+
common, and using this library can cause a memory leak or unexpected
|
256
|
+
behavior in such a case.
|
252
257
|
|
253
258
|
Approaches that load a fresh environment for every request (or a fresh
|
254
259
|
environment anytime there are any changes) are going to be more robust than
|
data/Rakefile
CHANGED
@@ -12,15 +12,16 @@ end
|
|
12
12
|
|
13
13
|
begin
|
14
14
|
begin
|
15
|
-
|
16
|
-
require "spec/rake/spectask"
|
17
|
-
spec_class = Spec::Rake::SpecTask
|
18
|
-
spec_files_meth = :spec_files=
|
19
|
-
rescue LoadError
|
15
|
+
raise LoadError if ENV['RSPEC1']
|
20
16
|
# RSpec 2
|
21
17
|
require "rspec/core/rake_task"
|
22
18
|
spec_class = RSpec::Core::RakeTask
|
23
19
|
spec_files_meth = :pattern=
|
20
|
+
rescue LoadError
|
21
|
+
# RSpec 1
|
22
|
+
require "spec/rake/spectask"
|
23
|
+
spec_class = Spec::Rake::SpecTask
|
24
|
+
spec_files_meth = :spec_files=
|
24
25
|
end
|
25
26
|
|
26
27
|
spec = lambda do |name, files, d|
|
@@ -15,7 +15,7 @@ module Rack
|
|
15
15
|
# Rack::Unloader.new for details.
|
16
16
|
def initialize(opts={})
|
17
17
|
@logger = opts[:logger]
|
18
|
-
@classes = opts[:subclasses] ? Array(opts[:subclasses]).map
|
18
|
+
@classes = opts[:subclasses] ? Array(opts[:subclasses]).map(&:to_s) : %w'Object'
|
19
19
|
|
20
20
|
# Hash of files being monitored for changes, keyed by absolute path of file name,
|
21
21
|
# with values being the last modified time (or nil if the file has not yet been loaded).
|
@@ -176,7 +176,7 @@ module Rack
|
|
176
176
|
if m = VALID_CONSTANT_NAME_REGEXP.match(s)
|
177
177
|
Object.module_eval("::#{m[1]}", __FILE__, __LINE__)
|
178
178
|
else
|
179
|
-
log("#{s
|
179
|
+
log("Invalid constant name: #{s}")
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
@@ -229,8 +229,8 @@ module Rack
|
|
229
229
|
return unless @monitor_files.has_key?(file)
|
230
230
|
return unless options[:force] || file_changed?(file)
|
231
231
|
|
232
|
-
log "#{@monitor_files[file] ? 'Reloading' : 'Loading'} #{file}"
|
233
232
|
prepare(file) # might call #safe_load recursively
|
233
|
+
log "Loading #{file}"
|
234
234
|
begin
|
235
235
|
require(file)
|
236
236
|
commit(file)
|
@@ -257,8 +257,8 @@ module Rack
|
|
257
257
|
# can be required again.
|
258
258
|
def remove_feature(file)
|
259
259
|
if @monitor_files.has_key?(file)
|
260
|
+
log "Unloading #{file}"
|
260
261
|
$LOADED_FEATURES.delete(file)
|
261
|
-
log "Removed feature #{file}"
|
262
262
|
end
|
263
263
|
end
|
264
264
|
|
@@ -266,24 +266,24 @@ module Rack
|
|
266
266
|
# by the file.
|
267
267
|
def remove(name)
|
268
268
|
file = @files[name] || return
|
269
|
-
|
269
|
+
remove_feature(name) if $LOADED_FEATURES.include?(name)
|
270
270
|
file[:features].each{|feature| remove_feature(feature)}
|
271
|
+
remove_constants(name){file[:constants]}
|
271
272
|
@files.delete(name)
|
272
|
-
remove_feature(name) if $LOADED_FEATURES.include?(name)
|
273
273
|
end
|
274
274
|
|
275
275
|
# Remove constants defined in file. Uses the stored block if there is
|
276
276
|
# one for the file name, or the given block.
|
277
277
|
def remove_constants(name)
|
278
|
-
|
279
|
-
|
280
|
-
else
|
281
|
-
yield
|
282
|
-
end
|
278
|
+
yield.each{|constant| remove_constant(constant)}
|
279
|
+
end
|
283
280
|
|
284
|
-
|
285
|
-
|
286
|
-
|
281
|
+
# True if the constant is already defined, false if not
|
282
|
+
def constant_defined?(const)
|
283
|
+
constantize(const)
|
284
|
+
true
|
285
|
+
rescue
|
286
|
+
false
|
287
287
|
end
|
288
288
|
|
289
289
|
# Store the currently loaded classes and features, so in case of an error
|
@@ -291,33 +291,60 @@ module Rack
|
|
291
291
|
def prepare(name)
|
292
292
|
file = remove(name)
|
293
293
|
@old_entries[name] = {:features => monitored_features}
|
294
|
+
if constants = constants_for(name)
|
295
|
+
defs = constants.select{|c| constant_defined?(c)}
|
296
|
+
unless defs.empty?
|
297
|
+
log "Constants already defined before loading #{name}: #{defs.join(" ")}"
|
298
|
+
end
|
299
|
+
@old_entries[name][:constants] = constants
|
300
|
+
else
|
301
|
+
@old_entries[name][:all_classes] = all_classes
|
302
|
+
end
|
303
|
+
end
|
294
304
|
|
295
|
-
|
296
|
-
|
305
|
+
# Returns nil if ObjectSpace should be used to load the constants. Returns an array of
|
306
|
+
# constant name symbols loaded by the file if they have been manually specified.
|
307
|
+
def constants_for(name)
|
308
|
+
if (pr = @constants_defined[name]) && (constants = pr.call(name)) != :ObjectSpace
|
309
|
+
Array(constants)
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
# The constants that were loaded by the given file. If ObjectSpace was used to check
|
314
|
+
# all classes loaded previously, then check for new classes loaded since. If the constants
|
315
|
+
# were explicitly specified, then use them directly
|
316
|
+
def constants_loaded_by(name)
|
317
|
+
if @old_entries[name][:all_classes]
|
318
|
+
new_classes(@old_entries[name][:all_classes])
|
319
|
+
else
|
320
|
+
@old_entries[name][:constants]
|
297
321
|
end
|
298
322
|
end
|
299
323
|
|
300
324
|
# Commit the changed state after requiring the the file, recording the new
|
301
325
|
# classes and features added by the file.
|
302
326
|
def commit(name)
|
303
|
-
entry = {:features
|
304
|
-
unless constants_defined = @constants_defined[name]
|
305
|
-
entry[:constants] = new_classes(@old_entries[name][:constants])
|
306
|
-
end
|
327
|
+
entry = {:features => monitored_features - @old_entries[name][:features] - [name], :constants=>constants_loaded_by(name)}
|
307
328
|
|
308
329
|
@files[name] = entry
|
309
330
|
@old_entries.delete(name)
|
310
331
|
@monitor_files[name] = modified_at(name)
|
311
332
|
|
312
|
-
|
313
|
-
|
333
|
+
defs, not_defs = entry[:constants].partition{|c| constant_defined?(c)}
|
334
|
+
unless not_defs.empty?
|
335
|
+
log "Constants not defined after loading #{name}: #{not_defs.join(' ')}"
|
336
|
+
end
|
337
|
+
unless defs.empty?
|
338
|
+
log("New classes in #{name}: #{defs.join(' ')}")
|
339
|
+
end
|
340
|
+
unless entry[:features].empty?
|
341
|
+
log("New features in #{name}: #{entry[:features].to_a.join(' ')}")
|
314
342
|
end
|
315
|
-
log("New features in #{name}: #{entry[:features].to_a.join(' ')}") unless entry[:features].empty?
|
316
343
|
end
|
317
344
|
|
318
345
|
# Rollback the changes made by requiring the file, restoring the previous state.
|
319
346
|
def rollback(name)
|
320
|
-
remove_constants(name){
|
347
|
+
remove_constants(name){constants_loaded_by(name)}
|
321
348
|
@old_entries.delete(name)
|
322
349
|
end
|
323
350
|
|
@@ -330,7 +357,7 @@ module Rack
|
|
330
357
|
def all_classes
|
331
358
|
rs = Set.new
|
332
359
|
|
333
|
-
ObjectSpace.each_object(Module).each do |mod|
|
360
|
+
::ObjectSpace.each_object(Module).each do |mod|
|
334
361
|
if !mod.name.to_s.empty? && monitored_module?(mod)
|
335
362
|
rs << mod
|
336
363
|
end
|
data/spec/unreloader_spec.rb
CHANGED
@@ -62,7 +62,7 @@ describe Rack::Unreloader do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def log_match(*logs)
|
65
|
-
|
65
|
+
@logger.length.should == logs.length
|
66
66
|
logs.zip(@logger).each{|l, log| l.is_a?(String) ? log.should == l : log.should =~ l}
|
67
67
|
end
|
68
68
|
|
@@ -102,9 +102,24 @@ describe Rack::Unreloader do
|
|
102
102
|
ru.call({}).should == [2]
|
103
103
|
log_match %r{\ALoading.*spec/app\.rb\z},
|
104
104
|
%r{\ANew classes in .*spec/app\.rb: App\z},
|
105
|
-
%r{\
|
105
|
+
%r{\AUnloading.*spec/app\.rb\z},
|
106
106
|
"Removed constant App",
|
107
|
-
%r{\
|
107
|
+
%r{\ALoading.*spec/app\.rb\z},
|
108
|
+
%r{\ANew classes in .*spec/app\.rb: App\z}
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should check constants using ObjectSpace if require proc returns :ObjectSpace" do
|
112
|
+
base_ru
|
113
|
+
update_app(code(1))
|
114
|
+
@ru.require(@filename){|f| :ObjectSpace}
|
115
|
+
ru.call({}).should == [1]
|
116
|
+
update_app(code(2))
|
117
|
+
ru.call({}).should == [2]
|
118
|
+
log_match %r{\ALoading.*spec/app\.rb\z},
|
119
|
+
%r{\ANew classes in .*spec/app\.rb: App\z},
|
120
|
+
%r{\AUnloading.*spec/app\.rb\z},
|
121
|
+
"Removed constant App",
|
122
|
+
%r{\ALoading.*spec/app\.rb\z},
|
108
123
|
%r{\ANew classes in .*spec/app\.rb: App\z}
|
109
124
|
end
|
110
125
|
|
@@ -117,16 +132,16 @@ describe Rack::Unreloader do
|
|
117
132
|
ru.call({}).should == [[2], [4]]
|
118
133
|
log_match %r{\ALoading.*spec/app\.rb\z},
|
119
134
|
%r{\ANew classes in .*spec/app\.rb: App\z},
|
120
|
-
%r{\
|
135
|
+
%r{\AUnloading.*spec/app\.rb\z},
|
121
136
|
"Removed constant App",
|
122
|
-
%r{\
|
137
|
+
%r{\ALoading.*spec/app\.rb\z},
|
123
138
|
%r{\ALoading.*spec/app2\.rb\z},
|
124
139
|
%r{\ANew classes in .*spec/app2\.rb: App2\z},
|
125
140
|
%r{\ANew classes in .*spec/app\.rb: (App App2|App2 App)\z},
|
126
141
|
%r{\ANew features in .*spec/app\.rb: .*spec/app2\.rb\z},
|
127
|
-
%r{\
|
142
|
+
%r{\AUnloading.*spec/app2\.rb\z},
|
128
143
|
"Removed constant App2",
|
129
|
-
%r{\
|
144
|
+
%r{\ALoading.*spec/app2\.rb\z},
|
130
145
|
%r{\ANew classes in .*spec/app2\.rb: App2\z}
|
131
146
|
end
|
132
147
|
|
@@ -139,23 +154,23 @@ describe Rack::Unreloader do
|
|
139
154
|
ru.call({}).should == [[1, 2], [4]]
|
140
155
|
update_app("RU.require 'spec/app2.rb'; class App; def self.call(env) [@a, App2.call(env)] end; @a ||= []; @a << 2; end")
|
141
156
|
log_match %r{\ALoading.*spec/app\.rb\z},
|
142
|
-
%r{\
|
143
|
-
%r{\
|
157
|
+
%r{\AUnloading.*spec/app\.rb\z},
|
158
|
+
%r{\ALoading.*spec/app\.rb\z},
|
144
159
|
%r{\ALoading.*spec/app2\.rb\z},
|
145
160
|
%r{\ANew classes in .*spec/app2\.rb: App2\z},
|
146
161
|
%r{\ANew classes in .*spec/app\.rb: App2\z},
|
147
162
|
%r{\ANew features in .*spec/app\.rb: .*spec/app2\.rb\z},
|
148
|
-
%r{\
|
163
|
+
%r{\AUnloading.*spec/app2\.rb\z},
|
149
164
|
"Removed constant App2",
|
150
|
-
%r{\
|
165
|
+
%r{\ALoading.*spec/app2\.rb\z},
|
151
166
|
%r{\ANew classes in .*spec/app2\.rb: App2\z}
|
152
167
|
end
|
153
168
|
|
154
169
|
it "should log invalid constant names in :subclasses options" do
|
155
170
|
ru(:subclasses=>%w'1 Object').call({}).should == [1]
|
156
171
|
logger.uniq!
|
157
|
-
log_match
|
158
|
-
|
172
|
+
log_match 'Invalid constant name: 1',
|
173
|
+
%r{\ALoading.*spec/app\.rb\z},
|
159
174
|
%r{\ANew classes in .*spec/app\.rb: App\z}
|
160
175
|
end
|
161
176
|
|
@@ -165,9 +180,9 @@ describe Rack::Unreloader do
|
|
165
180
|
ru.call({}).should == [2]
|
166
181
|
log_match %r{\ALoading.*spec/app\.rb\z},
|
167
182
|
%r{\ANew classes in .*spec/app\.rb: App\z},
|
168
|
-
%r{\
|
183
|
+
%r{\AUnloading.*spec/app\.rb\z},
|
169
184
|
"Removed constant App",
|
170
|
-
%r{\
|
185
|
+
%r{\ALoading.*spec/app\.rb\z},
|
171
186
|
%r{\ANew classes in .*spec/app\.rb: App\z}
|
172
187
|
end
|
173
188
|
|
@@ -177,9 +192,9 @@ describe Rack::Unreloader do
|
|
177
192
|
ru.call({}).should == [2]
|
178
193
|
log_match %r{\ALoading.*spec/app\.rb\z},
|
179
194
|
%r{\ANew classes in .*spec/app\.rb: App\z},
|
180
|
-
%r{\
|
195
|
+
%r{\AUnloading.*spec/app\.rb\z},
|
181
196
|
"Removed constant App",
|
182
|
-
%r{\
|
197
|
+
%r{\ALoading.*spec/app\.rb\z},
|
183
198
|
%r{\ANew classes in .*spec/app\.rb: App\z}
|
184
199
|
end
|
185
200
|
|
@@ -188,8 +203,8 @@ describe Rack::Unreloader do
|
|
188
203
|
update_app("module App; def self.call(env) @a end; @a ||= []; @a << 2; end")
|
189
204
|
ru.call({}).should == [1, 2]
|
190
205
|
log_match %r{\ALoading.*spec/app\.rb\z},
|
191
|
-
%r{\
|
192
|
-
%r{\
|
206
|
+
%r{\AUnloading.*spec/app\.rb\z},
|
207
|
+
%r{\ALoading.*spec/app\.rb\z}
|
193
208
|
end
|
194
209
|
|
195
210
|
it "should unload partially loaded modules if loading fails, and allow future loading" do
|
@@ -201,12 +216,12 @@ describe Rack::Unreloader do
|
|
201
216
|
ru.call({}).should == [2]
|
202
217
|
log_match %r{\ALoading.*spec/app\.rb\z},
|
203
218
|
%r{\ANew classes in .*spec/app\.rb: App\z},
|
204
|
-
%r{\
|
219
|
+
%r{\AUnloading.*spec/app\.rb\z},
|
205
220
|
"Removed constant App",
|
206
|
-
%r{\
|
221
|
+
%r{\ALoading.*spec/app\.rb\z},
|
207
222
|
%r{\AFailed to load .*spec/app\.rb; removing partially defined constants\z},
|
208
223
|
"Removed constant App",
|
209
|
-
%r{\
|
224
|
+
%r{\ALoading.*spec/app\.rb\z},
|
210
225
|
%r{\ANew classes in .*spec/app\.rb: App\z}
|
211
226
|
end
|
212
227
|
|
@@ -216,9 +231,9 @@ describe Rack::Unreloader do
|
|
216
231
|
ru.call({}).should == [2]
|
217
232
|
log_match %r{\ALoading.*spec/app\.rb\z},
|
218
233
|
%r{\ANew classes in .*spec/app\.rb: Array::App\z},
|
219
|
-
%r{\
|
234
|
+
%r{\AUnloading.*spec/app\.rb\z},
|
220
235
|
"Removed constant Array::App",
|
221
|
-
%r{\
|
236
|
+
%r{\ALoading.*spec/app\.rb\z},
|
222
237
|
%r{\ANew classes in .*spec/app\.rb: Array::App\z}
|
223
238
|
end
|
224
239
|
|
@@ -236,12 +251,12 @@ describe Rack::Unreloader do
|
|
236
251
|
%r{\ALoading.*spec/app2\.rb\z},
|
237
252
|
%r{\ANew classes in .*spec/app\.rb: App\z},
|
238
253
|
%r{\ANew features in .*spec/app\.rb: .*spec/app2\.rb\z},
|
239
|
-
%r{\
|
240
|
-
%r{\
|
241
|
-
%r{\
|
254
|
+
%r{\AUnloading.*spec/app2\.rb\z},
|
255
|
+
%r{\ALoading.*spec/app2\.rb\z},
|
256
|
+
%r{\AUnloading.*spec/app\.rb\z},
|
257
|
+
%r{\AUnloading.*spec/app2\.rb\z},
|
242
258
|
"Removed constant App",
|
243
|
-
%r{\
|
244
|
-
%r{\ARemoved feature .*/spec/app.rb\z},
|
259
|
+
%r{\ALoading.*spec/app\.rb\z},
|
245
260
|
%r{\ALoading.*spec/app2\.rb\z},
|
246
261
|
%r{\ANew classes in .*spec/app\.rb: App\z},
|
247
262
|
%r{\ANew features in .*spec/app\.rb: .*spec/app2\.rb\z}
|
@@ -255,9 +270,11 @@ describe Rack::Unreloader do
|
|
255
270
|
update_app("class App; def self.call(env) [@a, App2.a] end; @a ||= []; @a << 3; end; class App2; def self.a; @a end; @a ||= []; @a << 4; end")
|
256
271
|
ru.call({}).should == [[3], [2, 4]]
|
257
272
|
log_match %r{\ALoading.*spec/app\.rb\z},
|
258
|
-
%r{\
|
273
|
+
%r{\ANew classes in .*spec/app\.rb: App\z},
|
274
|
+
%r{\AUnloading.*spec/app\.rb\z},
|
259
275
|
"Removed constant App",
|
260
|
-
%r{\
|
276
|
+
%r{\ALoading.*spec/app\.rb\z},
|
277
|
+
%r{\ANew classes in .*spec/app\.rb: App\z}
|
261
278
|
end
|
262
279
|
|
263
280
|
it "should handle anonymous classes" do
|
@@ -268,8 +285,8 @@ describe Rack::Unreloader do
|
|
268
285
|
update_app("$app = Class.new do def self.call(env) @a end; @a ||= []; @a << 2; end")
|
269
286
|
ru.call({}).should == [2]
|
270
287
|
log_match %r{\ALoading.*spec/app\.rb\z},
|
271
|
-
%r{\
|
272
|
-
%r{\
|
288
|
+
%r{\AUnloading.*spec/app\.rb\z},
|
289
|
+
%r{\ALoading.*spec/app\.rb\z}
|
273
290
|
end
|
274
291
|
|
275
292
|
it "should log when attempting to remove a class that doesn't exist" do
|
@@ -280,9 +297,22 @@ describe Rack::Unreloader do
|
|
280
297
|
update_app(code(2))
|
281
298
|
ru.call({}).should == [1, 2]
|
282
299
|
log_match %r{\ALoading.*spec/app\.rb\z},
|
283
|
-
%r{\
|
300
|
+
%r{\AConstants not defined after loading .*spec/app\.rb: Foo\z},
|
301
|
+
%r{\AUnloading.*spec/app\.rb\z},
|
284
302
|
"Error removing constant: Foo",
|
285
|
-
%r{\
|
303
|
+
%r{\ALoading.*spec/app\.rb\z},
|
304
|
+
%r{\AConstants not defined after loading .*spec/app\.rb: Foo\z}
|
305
|
+
end
|
306
|
+
|
307
|
+
it "should log when specifying a constant that already exists" do
|
308
|
+
base_ru
|
309
|
+
update_app(code(1))
|
310
|
+
::App2 = 1
|
311
|
+
@ru.require('spec/app.rb'){|f| 'App2'}
|
312
|
+
ru.call({}).should == [1]
|
313
|
+
log_match %r{\AConstants already defined before loading .*spec/app\.rb: App2\z},
|
314
|
+
%r{\ALoading.*spec/app\.rb\z},
|
315
|
+
%r{\ANew classes in .*spec/app\.rb: App2\z}
|
286
316
|
end
|
287
317
|
|
288
318
|
it "should handle recorded dependencies" do
|
@@ -404,8 +434,8 @@ describe Rack::Unreloader do
|
|
404
434
|
%r{\ALoading.*spec/dir/a\.rb\z},
|
405
435
|
%r{\ANew classes in .*spec/app\.rb: App\z},
|
406
436
|
%r{\ANew features in .*spec/app\.rb: .*spec/dir/a\.rb\z},
|
407
|
-
%r{\
|
408
|
-
%r{\
|
437
|
+
%r{\AUnloading .*/spec/dir/a.rb\z},
|
438
|
+
%r{\ALoading .*/spec/dir/a.rb\z}
|
409
439
|
end
|
410
440
|
|
411
441
|
it "should pick up changes to files in subdirectories" do
|
@@ -420,8 +450,8 @@ describe Rack::Unreloader do
|
|
420
450
|
%r{\ALoading.*spec/dir/subdir/a\.rb\z},
|
421
451
|
%r{\ANew classes in .*spec/app\.rb: App\z},
|
422
452
|
%r{\ANew features in .*spec/app\.rb: .*spec/dir/subdir/a\.rb\z},
|
423
|
-
%r{\
|
424
|
-
%r{\
|
453
|
+
%r{\AUnloading .*/spec/dir/subdir/a.rb\z},
|
454
|
+
%r{\ALoading .*/spec/dir/subdir/a.rb\z}
|
425
455
|
end
|
426
456
|
|
427
457
|
it "should pick up new files added to the directory" do
|
@@ -461,7 +491,7 @@ describe Rack::Unreloader do
|
|
461
491
|
%r{\ALoading.*spec/dir/a\.rb\z},
|
462
492
|
%r{\ANew classes in .*spec/app\.rb: App\z},
|
463
493
|
%r{\ANew features in .*spec/app\.rb: .*spec/dir/a\.rb\z},
|
464
|
-
%r{\
|
494
|
+
%r{\AUnloading .*/spec/dir/a.rb\z},
|
465
495
|
%r{\ALoading.*spec/dir/b\.rb\z}
|
466
496
|
end
|
467
497
|
|
@@ -478,7 +508,7 @@ describe Rack::Unreloader do
|
|
478
508
|
%r{\ALoading.*spec/dir/subdir/a\.rb\z},
|
479
509
|
%r{\ANew classes in .*spec/app\.rb: App\z},
|
480
510
|
%r{\ANew features in .*spec/app\.rb: .*spec/dir/subdir/a\.rb\z},
|
481
|
-
%r{\
|
511
|
+
%r{\AUnloading .*/spec/dir/subdir/a.rb\z},
|
482
512
|
%r{\ALoading.*spec/dir/subdir/b\.rb\z}
|
483
513
|
end
|
484
514
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-unreloader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
Rack::Unreloader is a rack middleware that reloads application files when it
|