Sha256: 1ff99eb8aa36febeeb9dbfb36dcf00a57749a276a4dfe00f994341f5f9835b82

Contents?: true

Size: 565 Bytes

Versions: 13

Compression:

Stored size: 565 Bytes

Contents

require 'condenser/utils'

# Writes an asset file to disk
class Condenser::FileWriter
  
  attr_reader :mime_types
  
  def initialize(mime_types: nil)
    @mime_types = mime_types || '*/*'
  end

  def path(asset)
    asset.path
  end
  
  def exist?(asset)
    ::File.exist?(path(asset))
  end

  def call(output_directory, asset)
    filename = File.join(output_directory, asset.path)
    FileUtils.mkdir_p(File.dirname(filename))
    Condenser::Utils.atomic_write(filename) do |file|
      file.write(asset.source)
    end
    
    [asset.filename]
  end
  
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
condenser-1.4 lib/condenser/writers/file_writer.rb
condenser-1.3 lib/condenser/writers/file_writer.rb
condenser-1.2 lib/condenser/writers/file_writer.rb
condenser-1.0 lib/condenser/writers/file_writer.rb
condenser-1.0.rc1 lib/condenser/writers/file_writer.rb
condenser-0.3 lib/condenser/writers/file_writer.rb
condenser-0.2 lib/condenser/writers/file_writer.rb
condenser-0.1 lib/condenser/writers/file_writer.rb
condenser-0.0.12 lib/condenser/writers/file_writer.rb
condenser-0.0.11 lib/condenser/writers/file_writer.rb
condenser-0.0.10 lib/condenser/writers/file_writer.rb
condenser-0.0.9 lib/condenser/writers/file_writer.rb
condenser-0.0.8 lib/condenser/writers/file_writer.rb