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
|
||||
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
|
||||
# evaluated in a Manifest instance context
|
||||
@ -14,4 +17,30 @@ module Compass
|
||||
binding
|
||||
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
|
||||
|
@ -4,11 +4,10 @@ module Compass
|
||||
class StandAloneInstaller < Base
|
||||
|
||||
def configure
|
||||
@config = Compass::Configuration.new
|
||||
if File.exists?(config_file)
|
||||
@config.parse(config_file)
|
||||
Compass.configuration.parse(config_file)
|
||||
elsif File.exists?(old_config_file)
|
||||
@config.parse(old_config_file)
|
||||
Compass.configuration.parse(old_config_file)
|
||||
end
|
||||
super
|
||||
end
|
||||
@ -22,19 +21,19 @@ module Compass
|
||||
end
|
||||
|
||||
def default_css_dir
|
||||
@config.css_dir || "stylesheets"
|
||||
Compass.configuration.css_dir || "stylesheets"
|
||||
end
|
||||
|
||||
def default_sass_dir
|
||||
@config.sass_dir ||"src"
|
||||
Compass.configuration.sass_dir ||"src"
|
||||
end
|
||||
|
||||
def default_images_dir
|
||||
@config.images_dir || "images"
|
||||
Compass.configuration.images_dir || "images"
|
||||
end
|
||||
|
||||
def default_javascripts_dir
|
||||
@config.javascripts_dir || "javascripts"
|
||||
Compass.configuration.javascripts_dir || "javascripts"
|
||||
end
|
||||
|
||||
# Read the configuration file for this project
|
||||
|
Loading…
Reference in New Issue
Block a user