def run!(&block)
raise RuntimeError, "unknown layout #{layout_name}" if !Layout.respond_to?(layout_name)
raise RuntimeError, "unknown style #{style_name}" if !Style.respond_to?(style_name)
raise RuntimeError, "unknown library #{library_name}" if !Library.respond_to?(library_name)
raise RuntimeError, "input must be a single directory" if input.nil? || input.to_s.empty? || !File.directory?(input)
raise RuntimeError, "no image files found" if image_files.empty?
raise RuntimeError, "no output file specified" if output.to_s.empty?
raise RuntimeError, "no output image file specified" if output_image_file.to_s.empty?
raise RuntimeError, "no output style file specified" if output_style_file.to_s.empty?
raise RuntimeError, "set :width for fixed width, or :hpadding for horizontal padding, but not both." if width && !hpadding.zero?
raise RuntimeError, "set :height for fixed height, or :vpadding for vertical padding, but not both." if height && !vpadding.zero?
raise RuntimeError, "set :width for fixed width, or :hmargin for horizontal margin, but not both." if width && !hmargin.zero?
raise RuntimeError, "set :height for fixed height, or :vmargin for vertical margin, but not both." if height && !hmargin.zero?
raise RuntimeError, "The legacy :csspath attribute is no longer supported, please use :cssurl instead (see README)" unless @config[:csspath].nil?
images = load_images
max = layout_images(images)
header = summary(images, max)
report(header)
css = []
css << style_comment(header) unless nocomments?
css << style(selector, css_url, images, &block)
css << IO.read(custom_style_file) if File.exists?(custom_style_file)
css = css.join("\n")
create_sprite(images, max[:width], max[:height])
unless nocss?
css_file = File.open(output_style_file, "w+")
css_file.puts css
css_file.close
end
if config[:return] == :images
images
else
css
end
end