Class: Reco::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/reco/compiler.rb

Class Method Summary collapse

Class Method Details

.compile(source, options = {}) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/reco/compiler.rb', line 9

def self.compile(source, options = {})
  compiled_javascript = CoffeeScript.compile preprocess(source), :noWrap => true
  identifier = options[:identifier] || 'module.exports'
  identifier = "var #{identifier}" unless identifier.include? '.'
  
  wrapper % [identifier, compiled_javascript]
end

.preprocess(source) ⇒ Object



5
6
7
# File 'lib/reco/compiler.rb', line 5

def self.preprocess(source)
  Preprocessor.preprocess source
end

.wrapperObject



17
18
19
# File 'lib/reco/compiler.rb', line 17

def self.wrapper
  @wrapper ||= File.read File.join(File.dirname(__FILE__), 'wrapper.js')
end