Class: Generator::SassGenerator
- Inherits:
-
Base
- Object
- Base
- Generator::SassGenerator
show all
- Defined in:
- lib/generator/sass_generator.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
cache, checksum, #compile_file, #write
Class Method Details
.add_load_path(path) ⇒ Object
10
11
12
|
# File 'lib/generator/sass_generator.rb', line 10
def self.add_load_path(path)
::Sass.load_paths << path unless ::Sass.load_paths.include?(path)
end
|
.changed?(path) ⇒ Boolean
40
41
42
|
# File 'lib/generator/sass_generator.rb', line 40
def self.changed?(path)
true end
|
Instance Method Details
#compile(input, *args) ⇒ Object
35
36
37
38
|
# File 'lib/generator/sass_generator.rb', line 35
def compile(input, *args)
engine = Sass::Engine.new(input)
engine.render
end
|
#generate(input_folder, output_folder) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/generator/sass_generator.rb', line 14
def generate(input_folder, output_folder)
input_folder = "#{input_folder}/sass"
output_folder = "#{output_folder}/css"
Dir.glob("#{input_folder}/*.sass").select do |input_file|
file_name = input_file.split('/')[-1]
next unless File.file? input_file and file_name[0] != '_'
self.class.add_load_path input_folder
output_file_name = file_name.gsub('.sass', '.css')
output_file = File.join(output_folder, output_file_name)
compile_file(input_file, output_file)
min_file_name = output_file.sub '.css', '.min.css'
File.write(min_file_name,
CSSminify.compress(
File.read(output_file)))
end
end
|