Clean up the creation and management of importers and compilers
This commit is contained in:
parent
830a44868a
commit
30e01c7cbd
@ -59,10 +59,18 @@ module Compass
|
||||
compiler_opts
|
||||
end
|
||||
|
||||
Compass::Compiler.new(working_path,
|
||||
@memory_store ||= Sass::CacheStores::Memory.new
|
||||
@backing_store ||= compiler_opts[:cache_store]
|
||||
@backing_store ||= Sass::CacheStores::Filesystem.new(determine_cache_location)
|
||||
@cache_store ||= Sass::CacheStores::Chain.new(@memory_store, @backing_store)
|
||||
@memory_store.reset!
|
||||
|
||||
Compass::Compiler.new(
|
||||
working_path,
|
||||
Compass.configuration.sass_path,
|
||||
Compass.configuration.css_path,
|
||||
@compiler_opts.merge(additional_options))
|
||||
@compiler_opts.merge(:cache_store => @cache_store).merge(additional_options)
|
||||
)
|
||||
end
|
||||
|
||||
def explicit_sass_files
|
||||
@ -76,6 +84,9 @@ module Compass
|
||||
end
|
||||
end
|
||||
|
||||
def determine_cache_location
|
||||
Compass.configuration.cache_path || Sass::Plugin.options[:cache_location] || File.join(working_path, ".sass-cache")
|
||||
end
|
||||
|
||||
class << self
|
||||
def option_parser(arguments)
|
||||
|
@ -2,6 +2,7 @@ require 'fileutils'
|
||||
require 'pathname'
|
||||
require 'compass/commands/base'
|
||||
require 'compass/commands/update_project'
|
||||
require 'sass/plugin'
|
||||
|
||||
module Compass
|
||||
module Commands
|
||||
@ -33,8 +34,9 @@ module Compass
|
||||
GC.start
|
||||
sleep options.fetch(:gc_pause, 1)
|
||||
count = ObjectSpace.each_object(type) do |obj|
|
||||
if options.fetch(:verbose, true)
|
||||
if @@runs > 2
|
||||
if options.fetch(:verbose, true) && !@@object_id_tracker[type].include?(obj.object_id)
|
||||
if !@@object_id_tracker[type].include?(obj.object_id)
|
||||
begin
|
||||
puts obj.inspect
|
||||
rescue
|
||||
@ -44,6 +46,7 @@ module Compass
|
||||
end
|
||||
@@object_id_tracker[type] << obj.object_id
|
||||
end
|
||||
end
|
||||
puts "#{type}: #{count} instances."
|
||||
end
|
||||
end
|
||||
@ -61,19 +64,6 @@ module Compass
|
||||
exit 0
|
||||
end
|
||||
|
||||
unless Compass.sass_engine_options[:cache_store]
|
||||
@memory_cache = Sass::CacheStores::Memory.new
|
||||
Compass.configuration.sass_options ||= {}
|
||||
Sass::CacheStores::Chain.new(
|
||||
@memory_cache,
|
||||
Sass::CacheStores::Filesystem.new(
|
||||
Compass.sass_engine_options[:cache_location] ||
|
||||
Sass::Engine::DEFAULT_OPTIONS[:cache_location]
|
||||
)
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
check_for_sass_files!(new_compiler_instance)
|
||||
recompile
|
||||
|
||||
@ -92,8 +82,10 @@ module Compass
|
||||
|
||||
puts ">>> Compass is #{action} for changes. Press Ctrl-C to Stop."
|
||||
|
||||
begin
|
||||
FSSM.monitor do |monitor|
|
||||
Compass.configuration.sass_load_paths.each do |load_path|
|
||||
load_path = load_path.root if load_path.respond_to?(:root)
|
||||
next unless load_path.is_a? String
|
||||
monitor.path load_path do |path|
|
||||
path.glob '**/*.s[ac]ss'
|
||||
@ -122,7 +114,12 @@ module Compass
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
rescue FSSM::CallbackError => e
|
||||
# FSSM catches exit? WTF.
|
||||
if e.message =~ /exit/
|
||||
exit
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def remove_obsolete_css(base = nil, relative = nil)
|
||||
@ -143,7 +140,7 @@ module Compass
|
||||
begin
|
||||
puts ">>> Change detected to: #{relative}"
|
||||
compiler.run
|
||||
# report_on_instances(Sass::Importers::Base, :verbose => false)
|
||||
report_on_instances(Sass::Importers::Base, :verbose => false)
|
||||
rescue StandardError => e
|
||||
::Compass::Exec::Helpers.report_error(e, options)
|
||||
end
|
||||
|
@ -11,9 +11,7 @@ module Compass
|
||||
self.logger = options.delete(:logger)
|
||||
self.options = options
|
||||
self.options[:cache_location] ||= determine_cache_location
|
||||
Compass.configure_sass_plugin!
|
||||
|
||||
self.options[:importer] = self.importer = Sass::Importers::Filesystem.new(from)
|
||||
options[:importer] = self.importer = Sass::Importers::Filesystem.new(from)
|
||||
self.staleness_checker = Sass::Plugin::StalenessChecker.new(options)
|
||||
end
|
||||
|
||||
|
@ -55,10 +55,14 @@ module Compass
|
||||
def sass_load_paths
|
||||
load_paths = []
|
||||
load_paths << sass_path if sass_path
|
||||
Compass::Frameworks::ALL.each do |framework|
|
||||
load_paths << framework.stylesheets_directory if File.exists?(framework.stylesheets_directory)
|
||||
Compass::Frameworks::ALL.each do |f|
|
||||
load_paths << f.stylesheets_directory if File.directory?(f.stylesheets_directory)
|
||||
end
|
||||
load_paths += resolve_additional_import_paths
|
||||
load_paths.map! do |p|
|
||||
next p if p.respond_to?(:find_relative)
|
||||
Sass::Importers::Filesystem.new(p.to_s)
|
||||
end
|
||||
load_paths << Compass::Sprites.new
|
||||
load_paths
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user