Class: Generator::SassGenerator
- Inherits:
-
Object
- Object
- Generator::SassGenerator
- Defined in:
- lib/generator/sass_generator.rb
Instance Method Summary collapse
- #compile(file) ⇒ Object
- #generate(input_folder, output_folder) ⇒ Object
- #write(file, content) ⇒ Object
Instance Method Details
#compile(file) ⇒ Object
22 23 24 25 |
# File 'lib/generator/sass_generator.rb', line 22 def compile file engine = Sass::Engine.new(File.read(file)) engine.render end |
#generate(input_folder, output_folder) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/generator/sass_generator.rb', line 11 def generate input_folder, output_folder Dir.glob("#{input_folder}/*.sass").select do |file| file_name = file.split('/')[-1] next unless File.file? file and file_name[0] != '_' result = compile(file) file_name = file.split('/')[-1].gsub('.sass', '.css') write File.join(output_folder, file_name), result end end |
#write(file, content) ⇒ Object
27 28 29 30 31 |
# File 'lib/generator/sass_generator.rb', line 27 def write file, content File.open(file, "w") do |f| f.write content end end |