Sass::Importers::Base
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
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
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
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
# 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
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
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
Name of this spite
# File lib/compass/sprite_importer.rb, line 64 def self.sprite_name(uri) _, name = path_and_name(uri) name end
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
# File lib/compass/sprite_importer.rb, line 41 def eql?(other) other.class == self.class end
# 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
# File lib/compass/sprite_importer.rb, line 29 def find_relative(uri, base, options) nil end
# File lib/compass/sprite_importer.rb, line 37 def hash self.class.name.hash end
# 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
Generated with the Darkfish Rdoc Generator 2.