# File lib/compass/commands/sprite.rb, line 66 def description(command) "Generate an import for your sprites." end
# File lib/compass/commands/sprite.rb, line 35 def initialize(working_path, options) super assert_project_directory_exists! end
# File lib/compass/commands/sprite.rb, line 55 def option_parser(arguments) parser = Compass::Exec::CommandOptionParser.new(arguments) parser.extend(Compass::Exec::GlobalOptionsParser) parser.extend(Compass::Exec::ProjectOptionsParser) parser.extend(SpriteOptionsParser) end
# File lib/compass/commands/sprite.rb, line 70 def parse!(arguments) parser = option_parser(arguments) parser.parse! parse_arguments!(parser, arguments) parser.options end
# File lib/compass/commands/sprite.rb, line 77 def parse_arguments!(parser, arguments) parser.options[:uri] = arguments.shift unless arguments.size == 0 raise Compass::Error, "Please specify at least one image to sprite." end end
# File lib/compass/commands/sprite.rb, line 62 def usage option_parser([]).to_s end
# File lib/compass/commands/sprite.rb, line 40 def perform relative_uri = options[:uri].gsub(%r^#{Compass.configuration.images_dir}\//, '') sprites = Compass::SpriteImporter.new(:uri => relative_uri, :options => Compass.sass_engine_options) options[:output_file] ||= File.join(Compass.configuration.sass_path, "sprites", "_#{sprites.name}.#{Compass.configuration.preferred_syntax}") options[:skip_overrides] ||= false contents = sprites.content_for_images(options[:skip_overrides]) if options[:output_file][-4..-1] != "scss" contents = Sass::Engine.new(contents, Compass.sass_engine_options.merge(:syntax => :scss)).to_tree.to_sass end directory File.dirname(options[:output_file]) write_file options[:output_file], contents end