Sha256: 7081d7162832926c888fd55d3cb58d6d9a04cd1c64800dc7a01fbb99d90d1e6f

Contents?: true

Size: 910 Bytes

Versions: 774

Compression:

Stored size: 910 Bytes

Contents

class MockImporter < Sass::Importers::Base
  def initialize(name = "mock")
    @name = name
    @imports = Hash.new({})
  end

  def find_relative(uri, base, options)
    nil
  end

  def find(uri, options)
    contents = @imports[uri][:contents]
    return unless contents
    options[:syntax] = @imports[uri][:syntax]
    options[:filename] = uri
    options[:importer] = self
    @imports[uri][:engine] = Sass::Engine.new(contents, options)
  end

  def mtime(uri, options)
    @imports[uri][:mtime]
  end

  def key(uri, options)
    ["mock", uri]
  end

  def to_s
    @name
  end

  # Methods for testing

  def add_import(uri, contents, syntax = :scss, mtime = Time.now - 10)
    @imports[uri] = {
      :contents => contents,
      :mtime => mtime,
      :syntax => syntax
    }
  end

  def touch(uri)
    @imports[uri][:mtime] = Time.now
  end

  def engine(uri)
    @imports[uri][:engine]
  end
end

Version data entries

774 entries across 484 versions & 21 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/sass-3.4.25/test/sass/mock_importer.rb
sass-3.6.0 test/sass/mock_importer.rb
sass-3.5.7 test/sass/mock_importer.rb
brakeman-4.3.1 bundle/ruby/2.5.0/gems/sass-3.4.25/test/sass/mock_importer.rb
brakeman-4.3.0 bundle/ruby/2.5.0/gems/sass-3.4.25/test/sass/mock_importer.rb
brakeman-4.2.1 bundle/ruby/2.5.0/gems/sass-3.4.25/test/sass/mock_importer.rb
sass-3.5.6 test/sass/mock_importer.rb
brakeman-4.2.0 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/mock_importer.rb
sass-3.5.5 test/sass/mock_importer.rb
brakeman-4.1.1 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/mock_importer.rb
sass-3.5.4 test/sass/mock_importer.rb
brakeman-4.1.0 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/mock_importer.rb
sass-3.5.3 test/sass/mock_importer.rb
sass-3.5.2 test/sass/mock_importer.rb
brakeman-4.0.1 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/mock_importer.rb
brakeman-4.0.1.pre1 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/mock_importer.rb
brakeman-4.0.0 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/mock_importer.rb
brakeman-3.7.2 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/mock_importer.rb
brakeman-3.7.1 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/mock_importer.rb
sass-3.5.1 test/sass/mock_importer.rb