Class: Sprockets::Exporters::FileExporter

Inherits:
Base
  • Object
show all
Defined in:
lib/sprockets/exporters/file_exporter.rb

Overview

Writes a an asset file to disk

Instance Attribute Summary

Attributes inherited from Base

#asset, #directory, #environment, #target

Instance Method Summary collapse

Methods inherited from Base

#initialize, #setup, #write

Constructor Details

This class inherits a constructor from Sprockets::Exporters::Base

Instance Method Details

#callObject



17
18
19
20
21
# File 'lib/sprockets/exporters/file_exporter.rb', line 17

def call
  write(target) do |file|
    file.write(asset.source)
  end
end

#skip?(logger) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
15
# File 'lib/sprockets/exporters/file_exporter.rb', line 7

def skip?(logger)
  if ::File.exist?(target)
    logger.debug "Skipping #{ target }, already exists"
    true
  else
    logger.info "Writing #{ target }"
    false
  end
end