### Home Classes Methods

### In Files

- lib/compass/sprite_importer.rb

### Parent

Sass::Importers::Base

### Methods

- ::content_for_images
- ::files
- ::find_all_sprite_map_files
- ::path
- ::path_and_name
- ::sass_engine
- ::sass_options
- ::sprite_name
- ::sprite_names
- #eql?
- #find
- #find_relative
- #hash
- #key
- #mtime
- #to_s

### Class/Module Index

Quicksearch

- Compass
- Compass::Actions
- Compass::AppIntegration
- Compass::AppIntegration::Helpers
- Compass::AppIntegration::Rails
- Compass::AppIntegration::StandAlone
- Compass::AppIntegration::StandAlone::ConfigurationDefaults
- Compass::AppIntegration::StandAlone::Installer
- Compass::BrowserSupport
- Compass::Commands
- Compass::Commands::Base
- Compass::Commands::CleanProject
- Compass::Commands::CleanProjectOptionsParser
- Compass::Commands::CompileProjectOptionsParser
- Compass::Commands::ConfigurationOptionsParser
- Compass::Commands::CreateProject
- Compass::Commands::CreateProjectOptionsParser
- Compass::Commands::Default
- Compass::Commands::DefaultOptionsParser
- Compass::Commands::ExtensionCommand
- Compass::Commands::ExtensionOptionsParser
- Compass::Commands::ExtensionsOptionParser
- Compass::Commands::GenerateGridBackground
- Compass::Commands::GridBackgroundOptionsParser
- Compass::Commands::Help
- Compass::Commands::HelpOptionsParser
- Compass::Commands::Imports
- Compass::Commands::InstallerCommand
- Compass::Commands::Interactive
- Compass::Commands::InteractiveOptionsParser
- Compass::Commands::ListFrameworks
- Compass::Commands::MemoryDebugger
- Compass::Commands::PrintVersion
- Compass::Commands::ProjectBase
- Compass::Commands::ProjectStats
- Compass::Commands::Registry
- Compass::Commands::Sprite
- Compass::Commands::SpriteOptionsParser
- Compass::Commands::StampPattern
- Compass::Commands::StampPatternOptionsParser
- Compass::Commands::StatsOptionsParser
- Compass::Commands::StructureOptionsParser
- Compass::Commands::UnpackExtension
- Compass::Commands::UpdateProject
- Compass::Commands::ValidateProject
- Compass::Commands::ValidationOptionsParser
- Compass::Commands::VersionOptionsParser
- Compass::Commands::WatchProject
- Compass::Commands::WatchProjectOptionsParser
- Compass::Commands::WriteConfiguration
- Compass::Compiler
- Compass::Configuration
- Compass::Configuration::Adapters
- Compass::Configuration::Comments
- Compass::Configuration::Data
- Compass::Configuration::Defaults
- Compass::Configuration::FileData
- Compass::Configuration::Helpers
- Compass::Configuration::Inheritance
- Compass::Configuration::Inheritance::ClassMethods
- Compass::Configuration::Inheritance::ClassMethods::ArrayProxy
- Compass::Configuration::Inheritance::InstanceMethods
- Compass::Configuration::Paths
- Compass::Configuration::Serialization
- Compass::Error
- Compass::Exec
- Compass::Exec::CommandOptionParser
- Compass::Exec::GlobalOptionsParser
- Compass::Exec::Helpers
- Compass::Exec::ProjectOptionsParser
- Compass::Exec::SubCommandUI
- Compass::Exec::SwitchUI
- Compass::FilesystemConflict
- Compass::Frameworks
- Compass::Frameworks::Framework
- Compass::GridBuilder
- Compass::Installers
- Compass::Installers::BareInstaller
- Compass::Installers::Base
- Compass::Installers::Manifest
- Compass::Installers::Manifest::Entry
- Compass::Installers::ManifestInstaller
- Compass::Installers::TemplateContext
- Compass::Logger
- Compass::MissingDependency
- Compass::NullLogger
- Compass::PNG
- Compass::SassExtensions
- Compass::SassExtensions::Functions
- Compass::SassExtensions::Functions::Colors
- Compass::SassExtensions::Functions::Constants
- Compass::SassExtensions::Functions::CrossBrowserSupport
- Compass::SassExtensions::Functions::CrossBrowserSupport::CSS2FallbackValue
- Compass::SassExtensions::Functions::Display
- Compass::SassExtensions::Functions::Enumerate
- Compass::SassExtensions::Functions::Env
- Compass::SassExtensions::Functions::FontFiles
- Compass::SassExtensions::Functions::GradientSupport
- Compass::SassExtensions::Functions::GradientSupport::Assertions
- Compass::SassExtensions::Functions::GradientSupport::ColorStop
- Compass::SassExtensions::Functions::GradientSupport::Functions
- Compass::SassExtensions::Functions::GradientSupport::Gradient
- Compass::SassExtensions::Functions::GradientSupport::Gradient::ClassMethods
- Compass::SassExtensions::Functions::GradientSupport::LinearGradient
- Compass::SassExtensions::Functions::GradientSupport::RadialGradient
- Compass::SassExtensions::Functions::ImageSize
- Compass::SassExtensions::Functions::ImageSize::ImageProperties
- Compass::SassExtensions::Functions::ImageSize::JPEG
- Compass::SassExtensions::Functions::InlineImage
- Compass::SassExtensions::Functions::Lists
- Compass::SassExtensions::Functions::Math
- Compass::SassExtensions::Functions::Selectors
- Compass::SassExtensions::Functions::Sprites
- Compass::SassExtensions::Functions::Sprites::VariableReader
- Compass::SassExtensions::Functions::Urls
- Compass::SassExtensions::Functions::Urls::FontUrl
- Compass::SassExtensions::Functions::Urls::GeneratedImageUrl
- Compass::SassExtensions::Functions::Urls::ImageUrl
- Compass::SassExtensions::Functions::Urls::StylesheetUrl
- Compass::SassExtensions::Sprites
- Compass::SassExtensions::Sprites::ChunkyPngEngine
- Compass::SassExtensions::Sprites::Engine
- Compass::SassExtensions::Sprites::Image
- Compass::SassExtensions::Sprites::ImageMethods
- Compass::SassExtensions::Sprites::ImageRow
- Compass::SassExtensions::Sprites::LayoutMethods
- Compass::SassExtensions::Sprites::RowFitter
- Compass::SassExtensions::Sprites::SpriteMap
- Compass::SassExtensions::Sprites::SpriteMethods
- Compass::SpriteException
- Compass::SpriteImporter
- Compass::Sprites
- Compass::Sprites::Binding
- Compass::Stats
- Compass::Stats::CssFile
- Compass::Stats::SassFile
- Compass::Stats::StatsVisitor
- Compass::TestCase
- Compass::Util
- Compass::Version
- Sass
- Sass::Script
- Sass::Script::CrossBrowserFunctionCall
- Sass::Script::Funcall
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::HasSimpleCrossBrowserFunctionSupport
- Sass::Script::List
- Sass::Tree
- Sass::Tree::Node
- QuickCache

No matching classes.

# Compass::SpriteImporter

### Constants

CONTENT_TEMPLATE
CONTENT_TEMPLATE_FILE
SPRITE_IMPORTER_REGEX
TEMPLATE_FOLDER
VAILD_FILE_NAME
VALID_EXTENSIONS

### Public Class Methods

content_for_images(uri, name, skip_overrides = false) click to toggle source

Generates the Sass for this sprite file

    # File lib/compass/sprite_importer.rb, line 110
    def self.content_for_images(uri, name, skip_overrides = false)
      binder = Compass::Sprites::Binding.new(:name => name, :uri => uri, :skip_overrides => skip_overrides, :sprite_names => sprite_names(uri), :files => files(uri))
      CONTENT_TEMPLATE.result(binder.get_binding)
    end

files(uri) click to toggle source

Returns the Glob of image files for the uri

    # File lib/compass/sprite_importer.rb, line 76
    def self.files(uri)
      Compass.configuration.sprite_load_path.compact.each do |folder|
        files = Dir[File.join(folder, uri)].sort
        next if files.empty?
        return files
      end

      path = Compass.configuration.sprite_load_path.to_a.join(', ')
      raise Compass::SpriteException, %{No files were found in the load path matching "#{uri}". Your current load paths are: #{path}}
    end

find_all_sprite_map_files(path) click to toggle source

finds all sprite files

    # File lib/compass/sprite_importer.rb, line 16
    def self.find_all_sprite_map_files(path)
      hex = "[0-9a-f]"
      glob = "*-s#{hex*10}{#{VALID_EXTENSIONS.join(",")}}"
      Dir.glob(File.join(path, "**", glob))
    end

path(uri) click to toggle source

The on-disk location of this sprite

    # File lib/compass/sprite_importer.rb, line 70
    def self.path(uri)
      path, _ = path_and_name(uri)
      path
    end

path_and_name(uri) click to toggle source

    # File lib/compass/sprite_importer.rb, line 55
    def self.path_and_name(uri)
      if uri =~ SPRITE_IMPORTER_REGEX
        [$1, $3]
      else
        raise Compass::Error, "invalid sprite path"
      end
    end

sass_engine(uri, name, importer, options) click to toggle source

Returns a Sass::Engine for this sprite object

    # File lib/compass/sprite_importer.rb, line 104
    def self.sass_engine(uri, name, importer, options)
      content = content_for_images(uri, name, options[:skip_overrides])
      Sass::Engine.new(content, sass_options(uri, importer, options))
    end

sass_options(uri, importer, options) click to toggle source

Returns the sass_options for this sprite

    # File lib/compass/sprite_importer.rb, line 99
    def self.sass_options(uri, importer, options)
      options.merge!(:filename => uri.gsub(%{\*/},"*\\/"), :syntax => :scss, :importer => importer)
    end

sprite_name(uri) click to toggle source

Name of this spite

    # File lib/compass/sprite_importer.rb, line 64
    def self.sprite_name(uri)
      _, name = path_and_name(uri)
      name
    end

sprite_names(uri) click to toggle source

Returns an Array of image names without the file extension

    # File lib/compass/sprite_importer.rb, line 88
    def self.sprite_names(uri)
      files(uri).collect do |file|
        filename = File.basename(file, '.png')
        unless VAILD_FILE_NAME =~ filename
          raise Compass::Error, "Sprite file names must be legal css identifiers. Please rename #{File.basename(file)}"
        end
        filename
      end
    end

### Public Instance Methods

eql?(other) click to toggle source

    # File lib/compass/sprite_importer.rb, line 41
    def eql?(other)
      other.class == self.class
    end

find(uri, options) click to toggle source

    # File lib/compass/sprite_importer.rb, line 22
    def find(uri, options)
      if uri =~ SPRITE_IMPORTER_REGEX
        return self.class.sass_engine(uri, self.class.sprite_name(uri), self, options)
      end
      nil
    end

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

    # File lib/compass/sprite_importer.rb, line 29
    def find_relative(uri, base, options)
      nil
    end

hash() click to toggle source

    # File lib/compass/sprite_importer.rb, line 37
    def hash
      self.class.name.hash
    end

key(uri, options={}) click to toggle source

    # File lib/compass/sprite_importer.rb, line 51
    def key(uri, options={})
      [self.class.name + ":sprite:" + File.dirname(File.expand_path(uri)), File.basename(uri)]
    end

mtime(uri, options) click to toggle source

    # File lib/compass/sprite_importer.rb, line 45
    def mtime(uri, options)
      self.class.files(uri).sort.inject(Time.at(0)) do |max_time, file|
        (t = File.mtime(file)) > max_time ? t : max_time
      end
    end

to_s() click to toggle source

    # File lib/compass/sprite_importer.rb, line 33
    def to_s
      self.class.name
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.