File: coffee_script_processor.rb

package info (click to toggle)
ruby-sprockets 3.7.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 2,212 kB
  • sloc: ruby: 10,878; makefile: 3
file content (25 lines) | stat: -rw-r--r-- 613 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require 'sprockets/autoload'

module Sprockets
  # Processor engine class for the CoffeeScript compiler.
  # Depends on the `coffee-script` and `coffee-script-source` gems.
  #
  # For more infomation see:
  #
  #   https://github.com/josh/ruby-coffee-script
  #
  module CoffeeScriptProcessor
    VERSION = '1'

    def self.cache_key
      @cache_key ||= "#{name}:#{Autoload::CoffeeScript::Source.version}:#{VERSION}".freeze
    end

    def self.call(input)
      data = input[:data]
      input[:cache].fetch([self.cache_key, data]) do
        Autoload::CoffeeScript.compile(data)
      end
    end
  end
end