class Compass::Commands::GenerateGridBackground

Public Class Methods

description(command) click to toggle source
# File lib/compass/commands/generate_grid_background.rb, line 54
def description(command)
  "Generates a grid background image."
end
new(working_path, options) click to toggle source
Calls superclass method
# File lib/compass/commands/generate_grid_background.rb, line 69
def initialize(working_path, options)
  super
  assert_project_directory_exists!
  Compass.add_configuration(options, 'command_line')
end
option_parser(arguments) click to toggle source
# File lib/compass/commands/generate_grid_background.rb, line 44
def option_parser(arguments)
  parser = Compass::Exec::CommandOptionParser.new(arguments)
  parser.extend(Compass::Exec::GlobalOptionsParser)
  parser.extend(GridBackgroundOptionsParser)
end
parse!(arguments) click to toggle source
# File lib/compass/commands/generate_grid_background.rb, line 58
def parse!(arguments)
  parser = option_parser(arguments)
  parser.parse!
  if arguments.size == 0
    raise OptionParser::ParseError, "Please specify the grid dimensions."
  end
  parser.options[:grid_dimensions] = arguments.shift
  parser.options[:grid_filename] = arguments.shift
  parser.options
end
usage() click to toggle source
# File lib/compass/commands/generate_grid_background.rb, line 50
def usage
  option_parser([]).to_s
end

Public Instance Methods

perform() click to toggle source
# File lib/compass/commands/generate_grid_background.rb, line 75
def perform
  unless options[:grid_dimensions] =~ /^(\d+)\+(\d+)(?:x(\d+))?$/
    puts "ERROR: '#{options[:grid_dimensions]}' is not valid."
    puts "Dimensions should be specified like: 30+10x20"
    puts "where 30 is the column width, 10 is the gutter width, and 20 is the (optional) height."
    return
  end
  logger.yellow do
    $stderr.puts "Unless you need to check layouts in legacy browsers, it's preferable"
    $stderr.puts "to use the pure CSS3-based grid background mixin:"
    $stderr.puts
    $stderr.puts "http://compass-style.org/reference/compass/layout/grid_background/"
  end
  column_width = $1.to_i
  gutter_width = $2.to_i
  height = $3.to_i if $3
  filename = options[:grid_filename] || projectize("#{project_images_subdirectory}/grid.png")
  GridBuilder.new(options.merge(:column_width => column_width, :gutter_width => gutter_width, :height => height, :filename => filename, :working_path => self.working_path)).generate!
end