Class: Generator::CoffeeGenerator
- Inherits:
-
Object
- Object
- Generator::CoffeeGenerator
- Defined in:
- lib/generator/coffee_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
16 17 18 |
# File 'lib/generator/coffee_generator.rb', line 16 def compile file CoffeeScript.compile(File.read(file)) end |
#generate(input_folder, output_folder) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/generator/coffee_generator.rb', line 6 def generate input_folder, output_folder Dir.glob("#{input_folder}/*.coffee").select do |file| next unless File.file? file result = compile(file) file_name = file.split('/')[-1].gsub('.coffee', '.js') write File.join(output_folder, file_name), result end end |
#write(file, content) ⇒ Object
20 21 22 23 24 |
# File 'lib/generator/coffee_generator.rb', line 20 def write file, content File.open(file, "w") do |f| f.write content end end |