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