Class: Generator::CoffeeGenerator
- Inherits:
-
Base
- Object
- Base
- Generator::CoffeeGenerator
show all
- Defined in:
- lib/generator/coffee_generator.rb
Instance Method Summary
collapse
Methods inherited from Base
cache, changed?, checksum, #compile_file, #write
Instance Method Details
#compile(input, *args) ⇒ Object
27
28
29
30
31
|
# File 'lib/generator/coffee_generator.rb', line 27
def compile(input, *args)
CoffeeScript.compile(input)
rescue Exception => e
raise $!, "#{$!} TEMPLATE::#{args.to_s} ", $!.backtrace
end
|
#generate(input_folder, output_folder) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/generator/coffee_generator.rb', line 8
def generate(input_folder, output_folder)
input_folder = "#{input_folder}/coffee"
output_folder = "#{output_folder}/js"
Dir.glob("#{input_folder}/*.coffee").select do |input_file|
next unless File.file? input_file
output_file_name = input_file.split('/')[-1].gsub('.coffee', '.js')
outpu_file = File.join(output_folder, output_file_name)
compile_file(input_file, outpu_file)
min_file_name = outpu_file.sub '.js', '.min.js'
File.write(min_file_name,
Uglifier.compile(
File.read(outpu_file)))
end
end
|