Make the Configuration class a singleton + added some access helpers to
the Compass module.
This commit is contained in:
parent
91e081cd50
commit
d2a3046526
@ -1,6 +1,9 @@
|
|||||||
|
require 'singleton'
|
||||||
|
|
||||||
module Compass
|
module Compass
|
||||||
class Configuration
|
class Configuration
|
||||||
attr_accessor :css_dir, :sass_dir, :images_dir, :javascripts_dir
|
include Singleton
|
||||||
|
attr_accessor :project_path, :css_dir, :sass_dir, :images_dir, :javascripts_dir
|
||||||
|
|
||||||
# parses a manifest file which is a ruby script
|
# parses a manifest file which is a ruby script
|
||||||
# evaluated in a Manifest instance context
|
# evaluated in a Manifest instance context
|
||||||
@ -14,4 +17,30 @@ module Compass
|
|||||||
binding
|
binding
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module ConfigHelpers
|
||||||
|
def configuration
|
||||||
|
if block_given?
|
||||||
|
yield Configuration.instance
|
||||||
|
end
|
||||||
|
Configuration.instance
|
||||||
|
end
|
||||||
|
|
||||||
|
def sass_plugin_configuration
|
||||||
|
proj_sass_path = File.join(configuration.project_path, configuration.sass_dir)
|
||||||
|
proj_css_path = File.join(configuration.project_path, configuration.css_dir)
|
||||||
|
locations = {proj_sass_path => proj_css_path}
|
||||||
|
Compass::Frameworks::ALL.each do |framework|
|
||||||
|
locations[framework.stylesheets_directory] = proj_css_path
|
||||||
|
end
|
||||||
|
{:template_location => locations}
|
||||||
|
end
|
||||||
|
|
||||||
|
def configure_sass_plugin!
|
||||||
|
Sass::Plugin.options.merge!(sass_plugin_configuration)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
extend ConfigHelpers
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -4,11 +4,10 @@ module Compass
|
|||||||
class StandAloneInstaller < Base
|
class StandAloneInstaller < Base
|
||||||
|
|
||||||
def configure
|
def configure
|
||||||
@config = Compass::Configuration.new
|
|
||||||
if File.exists?(config_file)
|
if File.exists?(config_file)
|
||||||
@config.parse(config_file)
|
Compass.configuration.parse(config_file)
|
||||||
elsif File.exists?(old_config_file)
|
elsif File.exists?(old_config_file)
|
||||||
@config.parse(old_config_file)
|
Compass.configuration.parse(old_config_file)
|
||||||
end
|
end
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
@ -22,19 +21,19 @@ module Compass
|
|||||||
end
|
end
|
||||||
|
|
||||||
def default_css_dir
|
def default_css_dir
|
||||||
@config.css_dir || "stylesheets"
|
Compass.configuration.css_dir || "stylesheets"
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_sass_dir
|
def default_sass_dir
|
||||||
@config.sass_dir ||"src"
|
Compass.configuration.sass_dir ||"src"
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_images_dir
|
def default_images_dir
|
||||||
@config.images_dir || "images"
|
Compass.configuration.images_dir || "images"
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_javascripts_dir
|
def default_javascripts_dir
|
||||||
@config.javascripts_dir || "javascripts"
|
Compass.configuration.javascripts_dir || "javascripts"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Read the configuration file for this project
|
# Read the configuration file for this project
|
||||||
|
Loading…
Reference in New Issue
Block a user