Module: Dspace::Builders::TempfileBuilder

Defined in:
lib/dspace/builders/tempfile_builder.rb

Class Method Summary collapse

Class Method Details

.build(filename, contents = nil, bitstreams_path = '/tmp') ⇒ Object



5
6
7
8
9
10
# File 'lib/dspace/builders/tempfile_builder.rb', line 5

def self.build(filename, contents = nil, bitstreams_path = '/tmp')
  file = Tempfile.new([sanitize_filename(filename), File.extname(filename)], bitstreams_path, encoding: 'ascii-8bit').tap do |f|
    f.write contents
    f.close
  end
end