module Apropos

The Apropos module provides several functions for configuration and for supplying rules to the Sass functions. See the README for configuration examples.

It also provides convenience functions used by the Sass functions.

Constants

HIDPI_VARIANT_WARNING
SEPARATOR
STYLESHEETS_DIR
VERSION

Attributes

hidpi_only[RW]

Public Instance Methods

add_breakpoint_image_variant(id, query, order=0) click to toggle source
# File lib/apropos/functions.rb, line 30
def add_breakpoint_image_variant(id, query, order=0)
  ExtensionParser.add_parser(id) do |match|
    MediaQuery.new(query, order)
  end
end
add_class_image_variant(id, class_list=[], order=0, &block) click to toggle source
# File lib/apropos/functions.rb, line 36
def add_class_image_variant(id, class_list=[], order=0, &block)
  parser = if block_given?
    lambda do |match|
      result = block.call(match)
      create_class_rule(result) if result
    end
  else
    lambda do |match|
      create_class_rule(class_list, order)
    end
  end

  ExtensionParser.add_parser(id, &parser)
end
add_dpi_image_variant(id, query, order=0) click to toggle source
# File lib/apropos/functions.rb, line 23
def add_dpi_image_variant(id, query, order=0)
  ExtensionParser.add_parser(id) do |match|
    Sass.logger.warn(HIDPI_VARIANT_WARNING) if hidpi_only
    MediaQuery.new(query, order)
  end
end
clear_image_variants() click to toggle source
# File lib/apropos/functions.rb, line 56
def clear_image_variants
  ExtensionParser.parsers.clear
end
convert_to_sass_value(val) click to toggle source
# File lib/apropos/functions.rb, line 65
def convert_to_sass_value(val)
  case val
  when String
    Sass::Script::String.new(val)
  when Array
    converted = val.map {|element| convert_to_sass_value(element) }
    Sass::Script::List.new(converted, :space)
  else
    raise "convert_to_sass_value doesn't understand type #{val.class.inspect}"
  end
end
create_class_rule(class_list, order=0) click to toggle source
# File lib/apropos/functions.rb, line 51
def create_class_rule(class_list, order=0)
  list = Array(class_list).map {|name| name[0] == '.' ? name : ".#{name}"}
  ClassList.new(list, order)
end
image_set(path) click to toggle source
# File lib/apropos/functions.rb, line 15
def image_set(path)
  Set.new(path, images_dir)
end
image_variant_rules(path) click to toggle source
# File lib/apropos/functions.rb, line 19
def image_variant_rules(path)
  image_set(path).valid_variants.map(&:rule)
end
images_dir() click to toggle source
# File lib/apropos/functions.rb, line 60
def images_dir
  config = Compass.configuration
  Pathname.new(config.images_path || config.project_path)
end