Sha256: 5f540f4035f44b1c80cc5b7c5754dc7056ef7a2684e1c8564149e8f849606a55
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 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="example", 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cssquirt-0.0.2 | lib/cssquirt/file_list.rb |