Module: Compass::Configuration

Defined in:
lib/compass/configuration.rb,
lib/compass/configuration/data.rb,
lib/compass/configuration/helpers.rb,
lib/compass/configuration/adapters.rb,
lib/compass/configuration/comments.rb,
lib/compass/configuration/defaults.rb,
lib/compass/configuration/file_data.rb,
lib/compass/configuration/inheritance.rb,
lib/compass/configuration/serialization.rb

Defined Under Namespace

Modules: Adapters, Comments, Defaults, Helpers, Inheritance, Paths, Serialization Classes: Data, FileData

Constant Summary collapse

ATTRIBUTES =
[
  # What kind of project?
  :project_type,
  # Where is the project?
  :project_path,
  :http_path,
  # Where are the various bits of the project
  attributes_for_directory(:css, :stylesheets),
  attributes_for_directory(:sass, nil),
  attributes_for_directory(:images),
  attributes_for_directory(:generated_images),
  attributes_for_directory(:javascripts),
  attributes_for_directory(:fonts),
  attributes_for_directory(:extensions, nil),
  # Compilation options
  :output_style,
  :environment,
  :relative_assets,
  :additional_import_paths,
  :sass_options,
  attributes_for_directory(:cache, nil),
  :cache,
  # Helper configuration
  :asset_host,
  :asset_cache_buster,
  :line_comments,
  :color_output,
  :preferred_syntax,
  :disable_warnings,
  :sprite_engine,
  :chunky_png_options
].flatten
ARRAY_ATTRIBUTES =
[
  :sprite_load_path,
  :required_libraries,
  :loaded_frameworks,
  :framework_path
]

Class Method Summary collapse

Class Method Details

.add_configuration_property(name, comment = nil, &default) ⇒ Object

Registers a new configuration property. Extensions can use this to add new configuration options to compass.

Parameters:

  • name (Symbol)

    The name of the property.

  • comment (String) (defaults to: nil)

    A comment for the property.

  • default (Proc)

    A method to calculate the default value for the property. The proc is executed in the context of the project’s configuration data.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/compass/configuration.rb', line 59

def self.add_configuration_property(name, comment = nil, &default)
  ATTRIBUTES << name
  if comment.is_a?(String)
    unless comment[0..0] == "#"
      comment = "# #{comment}"
    end
    unless comment[-1..-1] == "\n"
      comment = comment + "\n"
    end
    Data.class_eval "      def comment_for_\#{name}\n        \#{comment.inspect}\n      end\n    COMMENT\n  end\n  Data.send(:define_method, :\"default_\#{name}\", &default) if default\n  Data.inherited_accessor(name)\n  if name.to_s =~ /dir|path/\n    strip_trailing_separator(name)\n  end\nend\n"

.attributes_for_directory(dir_name, http_dir_name = dir_name) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/compass/configuration.rb', line 4

def self.attributes_for_directory(dir_name, http_dir_name = dir_name)
  [
    "#{dir_name}_dir",
    "#{dir_name}_path",
    ("http_#{http_dir_name}_dir" if http_dir_name),
    ("http_#{http_dir_name}_path" if http_dir_name)
  ].compact.map{|a| a.to_sym}
end

.remove_configuration_property(name) ⇒ Object

For testing purposes



82
83
84
# File 'lib/compass/configuration.rb', line 82

def self.remove_configuration_property(name)
  ATTRIBUTES.delete(name)
end