Class: SassC::Engine

Inherits:
Object
  • Object
show all
Defined in:
lib/tebako-runtime/adapters/sassc.rb

Overview

Load style files for sassc

Constant Summary collapse

@@loaded_pathes =

rubocop:disable Style/ClassVars

[]
@@loaded_pathes_semaphore =
Mutex.new

Instance Method Summary collapse

Instance Method Details

#load_files(path, m_path) ⇒ Object

rubocop:enable Style/ClassVars



39
40
41
42
43
# File 'lib/tebako-runtime/adapters/sassc.rb', line 39

def load_files(path, m_path)
  FileUtils.mkdir_p(m_path)
  FileUtils.cp_r(File.join(path, "."), m_path) if File.exist?(path)
  @@loaded_pathes << m_path
end

#load_path(path, new_paths) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/tebako-runtime/adapters/sassc.rb', line 45

def load_path(path, new_paths)
  if path.start_with?(TebakoRuntime::COMPILER_MEMFS)
    m_path = path.sub(TebakoRuntime::COMPILER_MEMFS, TebakoRuntime::COMPILER_MEMFS_LIB_CACHE.to_s)
    @@loaded_pathes_semaphore.synchronize do
      load_files(path, m_path) unless @@loaded_pathes.include?(m_path)
    end
    new_paths << m_path
  else
    new_paths << path
  end
end

#load_pathsObject



57
58
59
60
61
62
63
# File 'lib/tebako-runtime/adapters/sassc.rb', line 57

def load_paths
  paths = (@options[:load_paths] || []) + SassC.load_paths
  new_paths = []
  paths.each { |path| load_path path, new_paths }
  pp = new_paths.join(File::PATH_SEPARATOR) unless new_paths.empty?
  pp
end