Class: Compass::Commands::GenerateGridBackground
Instance Attribute Summary
Attributes included from Actions
#logger
Attributes inherited from ProjectBase
#options, #project_name
Attributes inherited from Base
#options, #working_path
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Actions
#basename, #compile, #copy, #directory, #process_erb, #relativize, #remove, #separate, #strip_trailing_separator, #write_file
Methods inherited from ProjectBase
#execute
Methods inherited from Base
#execute, register
Constructor Details
Returns a new instance of GenerateGridBackground.
66
67
68
69
70
|
# File 'lib/compass/commands/generate_grid_background.rb', line 66
def initialize(working_path, options)
super
assert_project_directory_exists!
Compass.add_configuration(options, 'command_line')
end
|
Class Method Details
.description(command) ⇒ Object
51
52
53
|
# File 'lib/compass/commands/generate_grid_background.rb', line 51
def description(command)
"Generates a grid background image."
end
|
.option_parser(arguments) ⇒ Object
.parse!(arguments) ⇒ Object
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/compass/commands/generate_grid_background.rb', line 55
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 ⇒ Object
47
48
49
|
# File 'lib/compass/commands/generate_grid_background.rb', line 47
def usage
option_parser([]).to_s
end
|
Instance Method Details
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/compass/commands/generate_grid_background.rb', line 72
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
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")
unless GridBuilder.new(options.merge(:column_width => column_width, :gutter_width => gutter_width, :height => height, :filename => filename, :working_path => self.working_path)).generate!
puts "ERROR: Some library dependencies appear to be missing."
puts "Have you installed rmagick? If not, please run:"
puts "sudo gem install rmagick"
end
end
|