lib/scaffoldhub/template_file.rb in scaffoldhub-0.1.1 vs lib/scaffoldhub/template_file.rb in scaffoldhub-0.1.2
- old
+ new
@@ -12,14 +12,18 @@
def src
if @local
File.join(@base_url, @src)
else
- @local_path
+ @temp_file.path
end
end
+ def close
+ @temp_file.close if @temp_file
+ end
+
def dest
if @rename
File.join(@dest, @rename)
else
File.join(@dest, File.basename(@src))
@@ -28,11 +32,11 @@
def download!
if @local
raise Errno::ENOENT.new(src) unless File.exists?(src)
else
- @local_path = Tempfile.new(File.basename(@src)).path
- open(@local_path, "wb") do |file|
+ @temp_file = Tempfile.new(File.basename(@src))
+ File.open(@temp_file.path, "wb") do |file|
file.write(remote_file_contents!)
end
end
self
end