Module: Compass::Canvas

Defined in:
lib/canvas.rb,
lib/canvas/functions/pattern.rb,
lib/canvas/functions/context.rb,
lib/canvas/functions/canvas.rb,
lib/canvas/functions/path.rb,
lib/canvas/functions.rb,
lib/canvas/constants.rb,
lib/canvas/plugins.rb,
lib/canvas/actions.rb

Overview

Canvas drawing support for Compass with Cairo backend(s).

This module defines the current project version and useful helper functions.

Author:

  • Stan Angeloff

Defined Under Namespace

Modules: Actions, Constants, Functions, Plugins Classes: Exception

Constant Summary collapse

VERSION =

The project and Gem version. When building a Gem file for release, the version is stripped to X.Y.Z. If you are using a Git cloned-repository, the version will end in .git.

'0.0.5.git'
BACKEND =

The default backend for drawing.

'cairo'
PLUGINS_PATH =

Locations where plug-ins are installed. These paths are scanned for *.rb files and loaded in order.

[
  Compass::Canvas.path_to('plugins'),
  File.join(ENV['HOME'], '.compass-canvas', 'plugins'),
  File.join(Dir.getwd, 'plugins')
]

Class Method Summary collapse

Class Method Details

.absolute_path_to(file) ⇒ String

Helper function to normalize a CSS path to a filesystem path.

Parameters:

  • file (String)

    A CSS file, usually with url(..) and optionally a cache buster.

Returns:

  • (String)

    The absolute filesystem path.



27
28
29
30
31
32
33
34
# File 'lib/canvas.rb', line 27

def self.absolute_path_to(file)
  if file.include?('url(')
    file = File.join(Compass.configuration.css_path, file.gsub(/^url\(['"]?|["']?\)$/, ''))
  else
    file = File.join(Compass.configuration.images_path, file)
  end
  file.split('?').shift()
end

.path_to(directory) ⇒ String

Helper function to construct an absolute path to a given directory in the project.

Returns:

  • (String)

    The absolute path to the directory.



19
20
21
# File 'lib/canvas.rb', line 19

def self.path_to(directory)
  File.expand_path(File.join(File.dirname(__FILE__), '..', directory))
end