File: import-once.rb

package info (click to toggle)
ruby-compass 1.0.3~dfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 8,184 kB
  • ctags: 1,789
  • sloc: ruby: 12,904; makefile: 100; perl: 43; xml: 14; sh: 4
file content (28 lines) | stat: -rw-r--r-- 1,056 bytes parent folder | download | duplicates (2)
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
26
27
28
require "compass/import-once/version"
require "compass/import-once/importer"
require "compass/import-once/engine"
require 'set'

module Compass
  # although this is part of the compass suite of gems, it doesn't depend on compass,
  # so any sass-based project can use to to get import-once behavior for all of their
  # importers.
  module ImportOnce
    class << self
      # A map of css filenames to a set of engine cache keys that uniquely identify what has
      # been imported. The lifecycle of each key is handled by code wrapped around Sass's
      # render, to_css and render_with_sourcemap methods on the Sass::Engine.
      #
      # Ideally, Sass would provide a place in it's public API to put
      # information that persists for only the duration of a single compile and would be accessible
      # for all sass engines and sass functions written in ruby.
      def import_tracker
        Thread.current[:import_once_tracker] ||= {}
      end

      def activate!
        require 'compass/import-once/activate'
      end
    end
  end
end