Sha256: af2024703976b20bff72ca417b53504c5f690e2b0793ab5234b8420be14302ee
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
require 'rake' module CSSquirt class ImageFileList < Rake::FileList # Public: return a CSS document of all images # # prefix - an optional String to automatically prefix all class names with, useful # for namespacing, etc. Default: nil. # header - a optional Boolean value representing whether or not to include the # "generated by" credit in the header of the CSS document. Default: true. # # Returns a CSS document as a String. def to_css(prefix=nil, header=true) css_classes = self.zip(self.to_images).map do |item| item_filelist,item_imagefile = item[0],item[1] item_imagefile.as_css_background_with_class( prefix + "-#{item_filelist.pathmap('%n')}" ) end header_msg = "/* Generated with CSSquirt! (http://github.com/mroth/cssquirt/) */\n" header_msg = '' if header == false header_msg + css_classes.join("\n") end # Public: map the filelist to ImageFiles, handling any errors. # For now, this just reports errors to STDERR so they can be noted. # # Returns an Array of ImageFiles. def to_images image_map = [] self.each do |file| begin image_map << ImageFile.new(file) rescue Exception => e $stderr.puts "WARNING: skipped file - #{e.message}" end end image_map end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cssquirt-0.0.1 | lib/cssquirt/file_list.rb |
cssquirt-0.0.1.pre.1 | lib/cssquirt/file_list.rb |