class Sprockets::FileReader

Internal: The first processor in the pipeline that reads the file into memory and passes it along as `input`.

Public Class Methods

call(input) click to toggle source
# File lib/volt/server/template_handlers/sprockets_component_handler.rb, line 36
def self.call(input)
  env = input[:environment]
  path = input[:filename]

  # Handle a /components path match.  /components will load up a component.
  if path =~ /\/components\/[^.]+[.]rb$/
    component_name = path.match(/\/components\/([^.]+)[.]rb$/)[1]

    cached = env.cached

    stats = cached.instance_variable_get('@stats')

    stats[path] = Volt::StatStub.new

    # Working with a component path
    volt_app = Thread.current['volt_app'] || $volt_app
    data = Volt::ComponentCode.new(volt_app, component_name, volt_app.component_paths, true).code
  else
    data = env.read_file(input[:filename], input[:content_type])
  end

  # dependencies = Set.new(input[:metadata][:dependencies])
  # dependencies += [env.build_file_digest_uri(input[:filename])]

  dependencies = input[:metadata][:dependencies]
  # dependencies.merge(env.build_file_digest_uri(input[:filename]))

  { data: data, dependencies: dependencies }
end