File: file_reader.rb

package info (click to toggle)
ruby-sprockets 4.2.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,964 kB
  • sloc: ruby: 13,014; javascript: 157; makefile: 4
file content (16 lines) | stat: -rw-r--r-- 529 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# frozen_string_literal: true
require 'set'

module Sprockets
  # Internal: The first processor in the pipeline that reads the file into
  # memory and passes it along as `input[:data]`.  
  class FileReader
    def self.call(input)
      env = input[:environment]
      data = env.read_file(input[:filename], input[:content_type])
      dependencies = Set.new(input[:metadata][:dependencies])
      dependencies += [env.build_file_digest_uri(input[:filename])]
      { data: data, dependencies: dependencies }
    end
  end
end