### Home Classes Methods

### In Files

- lib/sass/importers/base.rb

### Parent

Object

### Methods

- #directories_to_watch
- #find
- #find_relative
- #key
- #mtime
- #public_url
- #to_s
- #watched_file?

### Class/Module Index

Quicksearch

- Sass
- Sass::BaseEnvironment
- Sass::CSS
- Sass::CacheStores
- Sass::CacheStores::Base
- Sass::CacheStores::Chain
- Sass::CacheStores::Filesystem
- Sass::CacheStores::Memory
- Sass::CacheStores::Null
- Sass::Callbacks
- Sass::Callbacks::InstanceMethods
- Sass::Engine
- Sass::Engine::Line
- Sass::Environment
- Sass::Exec
- Sass::Exec::Base
- Sass::Exec::SassConvert
- Sass::Exec::SassScss
- Sass::Exec::SassScss::Sass::Plugin.compiler
- Sass::Features
- Sass::Importers
- Sass::Importers::Base
- Sass::Importers::Filesystem
- Sass::Logger
- Sass::Logger::Base
- Sass::Logger::LogLevel
- Sass::Logger::LogLevel::ClassMethods
- Sass::Media
- Sass::Media::Query
- Sass::Media::QueryList
- Sass::Plugin
- Sass::Plugin::Compiler
- Sass::Plugin::Configuration
- Sass::Plugin::MerbBootLoader
- Sass::Plugin::Rack
- Sass::Plugin::StalenessChecker
- Sass::ReadOnlyEnvironment
- Sass::Repl
- Sass::SCSS
- Sass::SCSS::CssParser
- Sass::SCSS::Parser
- Sass::SCSS::RX
- Sass::SCSS::ScriptLexer
- Sass::SCSS::ScriptParser
- Sass::SCSS::StaticParser
- Sass::Script
- Sass::Script::CssLexer
- Sass::Script::CssParser
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::Lexer
- Sass::Script::Parser
- Sass::Script::Tree
- Sass::Script::Tree::Funcall
- Sass::Script::Tree::Interpolation
- Sass::Script::Tree::ListLiteral
- Sass::Script::Tree::Literal
- Sass::Script::Tree::MapLiteral
- Sass::Script::Tree::Node
- Sass::Script::Tree::Operation
- Sass::Script::Tree::Selector
- Sass::Script::Tree::StringInterpolation
- Sass::Script::Tree::UnaryOperation
- Sass::Script::Tree::Variable
- Sass::Script::Value
- Sass::Script::Value::ArgList
- Sass::Script::Value::Base
- Sass::Script::Value::Bool
- Sass::Script::Value::Color
- Sass::Script::Value::Helpers
- Sass::Script::Value::List
- Sass::Script::Value::Map
- Sass::Script::Value::Null
- Sass::Script::Value::Number
- Sass::Script::Value::String
- Sass::Selector
- Sass::Selector::AbstractSequence
- Sass::Selector::Attribute
- Sass::Selector::Class
- Sass::Selector::CommaSequence
- Sass::Selector::Element
- Sass::Selector::Id
- Sass::Selector::Parent
- Sass::Selector::Placeholder
- Sass::Selector::Pseudo
- Sass::Selector::Sequence
- Sass::Selector::Simple
- Sass::Selector::SimpleSequence
- Sass::Selector::Universal
- Sass::SemiGlobalEnvironment
- Sass::Shared
- Sass::Source
- Sass::Source::Map
- Sass::Source::Map::Mapping
- Sass::Source::Position
- Sass::Source::Range
- Sass::Stack
- Sass::Stack::Frame
- Sass::Supports
- Sass::Supports::Condition
- Sass::Supports::Declaration
- Sass::Supports::Interpolation
- Sass::Supports::Negation
- Sass::Supports::Operator
- Sass::SyntaxError
- Sass::Tree
- Sass::Tree::AtRootNode
- Sass::Tree::CharsetNode
- Sass::Tree::CommentNode
- Sass::Tree::ContentNode
- Sass::Tree::CssImportNode
- Sass::Tree::DebugNode
- Sass::Tree::DirectiveNode
- Sass::Tree::EachNode
- Sass::Tree::ErrorNode
- Sass::Tree::ExtendNode
- Sass::Tree::ForNode
- Sass::Tree::FunctionNode
- Sass::Tree::IfNode
- Sass::Tree::ImportNode
- Sass::Tree::KeyframeRuleNode
- Sass::Tree::MediaNode
- Sass::Tree::MixinDefNode
- Sass::Tree::MixinNode
- Sass::Tree::Node
- Sass::Tree::PropNode
- Sass::Tree::ReturnNode
- Sass::Tree::RootNode
- Sass::Tree::RuleNode
- Sass::Tree::SupportsNode
- Sass::Tree::TraceNode
- Sass::Tree::VariableNode
- Sass::Tree::Visitors
- Sass::Tree::Visitors::Base
- Sass::Tree::Visitors::CheckNesting
- Sass::Tree::Visitors::Convert
- Sass::Tree::Visitors::Cssize
- Sass::Tree::Visitors::Cssize::Bubble
- Sass::Tree::Visitors::DeepCopy
- Sass::Tree::Visitors::Extend
- Sass::Tree::Visitors::Perform
- Sass::Tree::Visitors::SetOptions
- Sass::Tree::Visitors::ToCss
- Sass::Tree::WarnNode
- Sass::Tree::WhileNode
- Sass::UnitConversionError
- Sass::Util
- Sass::Util::CrossPlatformRandom
- Sass::Util::MultibyteStringScanner
- Sass::Util::NormalizedMap
- Sass::Util::StaticConditionalContext
- Sass::Util::SubsetMap
- Sass::Util::Test
- Sass::Version
- ActionController
- ActionController::Base
- Object
- OrderedHash

No matching classes.

# Sass::Importers::Base

The abstract base class for Sass importers. All importers should inherit from this.

At the most basic level, an importer is given a string and must return a {Sass::Engine} containing some Sass code. This string can be interpreted however the importer wants; however, subclasses are encouraged to use the URI format for pathnames.

Importers that have some notion of "relative imports" should take a single load path in their constructor, and interpret paths as relative to that. They should also implement the {#find_relative} method.

Importers should be serializable via `Marshal.dump`.

@abstract

### Public Instance Methods

directories_to_watch() click to toggle source

If the importer is based on files on the local filesystem this method should return folders which should be watched for changes.

@return [Array<String>] List of absolute paths of directories to watch

    # File lib/sass/importers/base.rb, line 165
    def directories_to_watch
      []
    end

find(uri, options) click to toggle source

Find a Sass file, if it exists.

This is the primary entry point of the Importer. It corresponds directly to an `@import` statement in Sass. It should do three basic things:

- Determine if the URI is in this importer’s format. If not, return nil.

- Determine if the file indicated by the URI actually exists and is readable. If not, return nil.

- Read the file and place the contents in a {Sass::Engine}. Return that engine.

If this importer’s format allows for file extensions, it should treat them the same way as the default {Filesystem} importer. If the URI explicitly has a `.sass` or `.scss` filename, the importer should look for that exact file and import it as the syntax indicated. If it doesn’t exist, the importer should return nil.

If the URI doesn’t have either of these extensions, the importer should look for files with the extensions. If no such files exist, it should return nil.

The {Sass::Engine} to be returned should be passed `options`, with a few modifications. `:syntax` should be set appropriately, `:filename` should be set to `uri`, and `:importer` should be set to this importer.

@param uri [String] The URI to import. @param options [{Symbol => Object}] Options for the Sass file

    containing the `@import` that's currently being resolved.
    This is safe for subclasses to modify destructively.
    Callers should only pass in a value they don't mind being destructively modified.

@return [Sass::Engine, nil] An Engine containing the imported file,

    or nil if it couldn't be found or was in the wrong format.

    # File lib/sass/importers/base.rb, line 82
    def find(uri, options)
      Sass::Util.abstract(self)
    end

find_relative(uri, base, options) click to toggle source

Find a Sass file relative to another file. Importers without a notion of “relative paths” should just return nil here.

If the importer does have a notion of “relative paths”, it should ignore its load path during this method.

See {#find} for important information on how this method should behave.

The `:filename` option passed to the returned {Sass::Engine} should be of a format that could be passed to {#find}.

@param uri [String] The URI to import. This is not necessarily relative,

    but this method should only return true if it is.

@param base [String] The base filename. If `uri` is relative,

    it should be interpreted as relative to `base`.
    `base` is guaranteed to be in a format importable by this importer.

@param options [{Symbol => Object}] Options for the Sass file

    containing the `@import` that's currently being resolved.

@return [Sass::Engine, nil] An Engine containing the imported file,

    or nil if it couldn't be found or was in the wrong format.

    # File lib/sass/importers/base.rb, line 42
    def find_relative(uri, base, options)
      Sass::Util.abstract(self)
    end

key(uri, options) click to toggle source

Get the cache key pair for the given Sass URI. The URI need not be checked for validity.

The only strict requirement is that the returned pair of strings uniquely identify the file at the given URI. However, the first component generally corresponds roughly to the directory, and the second to the basename, of the URI.

Note that keys must be unique *across importers*. Thus it’s probably a good idea to include the importer name at the beginning of the first component.

@param uri [String] A URI known to be valid for this importer. @param options [{Symbol => Object}] Options for the Sass file

    containing the `@import` currently being checked.

@return [(String, String)] The key pair which uniquely identifies

    the file at the given URI.

    # File lib/sass/importers/base.rb, line 117
    def key(uri, options)
      Sass::Util.abstract(self)
    end

mtime(uri, options) click to toggle source

Returns the time the given Sass file was last modified.

If the given file has been deleted or the time can’t be accessed for some other reason, this should return nil.

@param uri [String] The URI of the file to check.

    Comes from a `:filename` option set on an engine returned by this importer.

@param options [{Symbol => Objet}] Options for the Sass file

    containing the `@import` currently being checked.

@return [Time, nil]

    # File lib/sass/importers/base.rb, line 96
    def mtime(uri, options)
      Sass::Util.abstract(self)
    end

public_url(uri, sourcemap_directory) click to toggle source

Get the publicly-visible URL for an imported file. This URL is used by source maps to link to the source stylesheet. This may return `nil` to indicate that no public URL is available; however, this will cause sourcemap generation to fail if any CSS is generated from files imported from this importer.

If an absolute “file:” URI can be produced for an imported file, that should be preferred to returning `nil`. However, a URL relative to `sourcemap_directory` should be preferred over an absolute “file:” URI.

@param uri [String] A URI known to be valid for this importer. @param sourcemap_directory [String, NilClass] The absolute path to a

    directory on disk where the sourcemap will be saved. If uri refers to
    a file on disk that's accessible relative to sourcemap_directory, this
    may return a relative URL. This may be `nil` if the sourcemap's
    eventual location is unknown.

@return [String?] The publicly-visible URL for this file, or `nil`

    indicating that no publicly-visible URL exists. This should be
    appropriately URL-escaped.

    # File lib/sass/importers/base.rb, line 140
    def public_url(uri, sourcemap_directory)
      return if @public_url_warning_issued
      @public_url_warning_issued = true
      Sass::Util.sass_warn WARNING: #{self.class.name} should define the #public_url method.
      nil
    end

to_s() click to toggle source

A string representation of the importer. Should be overridden by subclasses.

This is used to help debugging, and should usually just show the load path encapsulated by this importer.

@return [String]

    # File lib/sass/importers/base.rb, line 156
    def to_s
      Sass::Util.abstract(self)
    end

watched_file?(filename) click to toggle source

If this importer is based on files on the local filesystem This method should return true if the file, when changed, should trigger a recompile.

It is acceptable for non-sass files to be watched and trigger a recompile.

@param filename [String] The absolute filename for a file that has changed. @return [Boolean] When the file changed should cause a recompile.

    # File lib/sass/importers/base.rb, line 177
    def watched_file?(filename)
      false
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.