class Sprig::Reap::FileAttribute::LocalFile
Public Instance Methods
file()
click to toggle source
# File lib/sprig/reap/file_attribute.rb, line 50 def file @file ||= File.open(unique_location, 'w', :encoding => encoding).tap do |file| io.rewind file.write(io.read) io.close end end
io()
click to toggle source
# File lib/sprig/reap/file_attribute.rb, line 58 def io @io ||= open uri end
sprig_location()
click to toggle source
# File lib/sprig/reap/file_attribute.rb, line 62 def sprig_location "<%= sprig_file('#{File.basename(file.path)}') %>" end
Private Instance Methods
basename()
click to toggle source
# File lib/sprig/reap/file_attribute.rb, line 77 def basename @basename ||= File.basename(target_location).gsub(File.extname(target_location), '') end
encoding()
click to toggle source
# File lib/sprig/reap/file_attribute.rb, line 72 def encoding io.rewind io.read.encoding end
unique_location()
click to toggle source
# File lib/sprig/reap/file_attribute.rb, line 68 def unique_location File.exist?(target_location) ? target_location.to_s.gsub(basename, basename + SecureRandom::uuid.to_s) : target_location end