module Sprockets::Exporting
‘Exporting` is an internal mixin whose public methods are exposed on the `Environment` and `CachedEnvironment` classes.
Public Instance Methods
export_concurrent()
click to toggle source
Public: Checks if concurrent exporting is allowed
# File lib/sprockets/exporting.rb, line 59 def export_concurrent config[:export_concurrent] end
export_concurrent=(export_concurrent)
click to toggle source
Public: Enable or disable the concurrently exporting files
Defaults to true.
environment.export_concurrent = false
# File lib/sprockets/exporting.rb, line 69 def export_concurrent=(export_concurrent) self.config = config.merge(export_concurrent: export_concurrent).freeze end
exporters()
click to toggle source
Exporters
are ran on the assets:precompile task
# File lib/sprockets/exporting.rb, line 6 def exporters config[:exporters] end
register_exporter(mime_types, klass = nil)
click to toggle source
Public: Registers a new Exporter ‘klass` for `mime_type`.
If your exporter depends on one or more other exporters you can specify this via the ‘depend_on` keyword.
register_exporter '*/*', Sprockets::Exporters::ZlibExporter
This ensures that ‘Sprockets::Exporters::File` will always execute before `Sprockets::Exporters::Zlib`
# File lib/sprockets/exporting.rb, line 19 def register_exporter(mime_types, klass = nil) mime_types = Array(mime_types) mime_types.each do |mime_type| self.config = hash_reassoc(config, :exporters, mime_type) do |_exporters| _exporters << klass end end end
unregister_exporter(mime_types, exporter = nil)
click to toggle source
Public: Remove Exporting
processor ‘klass` for `mime_type`.
environment.unregister_exporter '*/*', Sprockets::Exporters::ZlibExporter
Can be called without a mime type
environment.unregister_exporter Sprockets::Exporters::ZlibExporter
Does not remove any exporters that depend on ‘klass`.
# File lib/sprockets/exporting.rb, line 38 def unregister_exporter(mime_types, exporter = nil) unless mime_types.is_a? Array if mime_types.is_a? String mime_types = [mime_types] else # called with no mime type exporter = mime_types mime_types = nil end end self.config = hash_reassoc(config, :exporters) do |_exporters| _exporters.each do |mime_type, exporters_array| next if mime_types && !mime_types.include?(mime_type) if exporters_array.include? exporter _exporters[mime_type] = exporters_array.dup.delete exporter end end end end