class Compass::Commands::WriteConfiguration

Public Class Methods

description(command) click to toggle source
# File lib/compass/commands/write_configuration.rb, line 100
def description(command)
  "Generate a configuration file for the provided command line options."
end
new(working_path, options) click to toggle source
# File lib/compass/commands/write_configuration.rb, line 36
def initialize(working_path, options)
  super
  assert_project_directory_exists!
end
option_parser(arguments) click to toggle source
# File lib/compass/commands/write_configuration.rb, line 89
def option_parser(arguments)
  parser = Compass::Exec::CommandOptionParser.new(arguments)
  parser.extend(Compass::Exec::GlobalOptionsParser)
  parser.extend(Compass::Exec::ProjectOptionsParser)
  parser.extend(ConfigurationOptionsParser)
end
parse!(arguments) click to toggle source
# File lib/compass/commands/write_configuration.rb, line 104
def parse!(arguments)
  parser = option_parser(arguments)
  parser.parse!
  parse_arguments!(parser, arguments)
  parser.options
end
parse_arguments!(parser, arguments) click to toggle source
# File lib/compass/commands/write_configuration.rb, line 111
def parse_arguments!(parser, arguments)
  if arguments.size == 1
    parser.options[:configuration_file] = arguments.shift
  elsif arguments.size == 0
    # default to the current directory.
  else
    raise Compass::Error, "Too many arguments were specified."
  end
end
usage() click to toggle source
# File lib/compass/commands/write_configuration.rb, line 96
def usage
  option_parser([]).to_s
end

Public Instance Methods

add_project_configuration() click to toggle source
# File lib/compass/commands/write_configuration.rb, line 41
def add_project_configuration
  Compass.add_project_configuration
end
explicit_config_file_must_be_readable?() click to toggle source
# File lib/compass/commands/write_configuration.rb, line 83
def explicit_config_file_must_be_readable?
  false
end
installer_args() click to toggle source
# File lib/compass/commands/write_configuration.rb, line 79
def installer_args
  [nil, project_directory, options]
end
perform() click to toggle source
# File lib/compass/commands/write_configuration.rb, line 45
def perform
  if options[:display]
    if Compass.configuration.respond_to?(options[:display])
      puts Compass.configuration.send(options[:display])
    else
      raise Compass::Error, "ERROR: configuration property '#{options[:display]}' does not exist"
    end
  elsif options[:debug]
    puts "Configuration sources:"
    c = Compass.configuration
    while c
      print c.name
      c = c.inherited_data
      print ", " if c
    end
    print "\n"
    Compass.configuration.debug.each do |prop, values|
      if options[:debug].is_a?(Symbol)
        next unless prop == options[:debug]
      end
      puts "***** #{prop} = #{values.first[:resolved].inspect} *****"
      [:default, :value, :raw, :resolved].each do |kind|
        puts "#{kind}: " + values.inject([]){|m, v| m << v[kind]}.map{|v| v.nil? ? '-' : v.inspect}.join(", ")
      end
    end
  else
    config_file = options[:configuration_file]
    config_file ||= Compass.detect_configuration_file
    config_file ||= Compass::Configuration::Helpers::KNOWN_CONFIG_LOCATIONS.first
    directory File.dirname(config_file)
    installer.write_configuration_files(config_file)
  end
end