Class: Gumbo::CompileToJavaScriptFile

Inherits:
PackageFile show all
Defined in:
lib/gumbo/compile_to_java_script_file.rb

Direct Known Subclasses

CoffeeScriptFile, EcoFile

Instance Attribute Summary

Attributes inherited from PackageFile

#type

Attributes inherited from AssetFile

#context, #name, #output_dir, #source_dir

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PackageFile

#eql?, #hash, #source_file

Methods inherited from AssetFile

class_for, #eql?, ext, for, #hash, #initialize, #logger, #replace_ext, #should_be_rebuilt?, #source_file

Constructor Details

This class inherits a constructor from Gumbo::AssetFile

Class Method Details

.compile(src) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/gumbo/compile_to_java_script_file.rb', line 19

def self.compile(src)
  if compiler
    compiler.compile(src)
  else
    raise "no compiler set for #{name}"
  end
end

.compiler(*args) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/gumbo/compile_to_java_script_file.rb', line 27

def self.compiler(*args)
  if args.empty?
    @compiler
  else
    @compiler = args.first
  end
end

Instance Method Details

#buildObject



7
8
9
10
11
12
13
# File 'lib/gumbo/compile_to_java_script_file.rb', line 7

def build
  logger.info "#{source_file} -> #{output_file}"
  mkdir_p File.dirname(output_file)
  open(output_file, 'w') do |out|
    out << compile(File.read(source_file))
  end
end

#compile(src) ⇒ Object



15
16
17
# File 'lib/gumbo/compile_to_java_script_file.rb', line 15

def compile(src)
  self.class.compile(src)
end

#output_fileObject



3
4
5
# File 'lib/gumbo/compile_to_java_script_file.rb', line 3

def output_file
  @output_file ||= replace_ext(super, "js")
end