lib/guard/livereload/snippet.rb in guard-livereload-2.5.0 vs lib/guard/livereload/snippet.rb in guard-livereload-2.5.1
- old
+ new
@@ -9,15 +9,17 @@
attr_reader :path
attr_reader :options
def initialize(template, options)
@options = options # for ERB context
- tmpfile = Tempfile.new('livereload.js')
+
+ # NOTE: use instance variable for Tempfile, so it's not GC'ed before sending
+ @tmpfile = Tempfile.new('livereload.js')
source = IO.read(template)
data = ERB.new(source).result(binding)
- tmpfile.write(data)
- tmpfile.close
- @path = tmpfile.path
+ @tmpfile.write(data)
+ @tmpfile.close
+ @path = @tmpfile.path
end
end
end
end