Class: Requirejs::Compiler

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Compiler

Returns a new instance of Compiler.



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

def initialize(options ={})
  Requirejs.config.ensure_cache_location_exists
  @scope, @data, @file = options[:scope], options[:data], options[:file]
end

Instance Attribute Details

#build_script_pathObject

Returns the value of attribute build_script_path.



3
4
5
# File 'lib/requirejs/compiler.rb', line 3

def build_script_path
  @build_script_path
end

#dataObject

Returns the value of attribute data.



3
4
5
# File 'lib/requirejs/compiler.rb', line 3

def data
  @data
end

#fileObject

Returns the value of attribute file.



3
4
5
# File 'lib/requirejs/compiler.rb', line 3

def file
  @file
end

#scopeObject

Returns the value of attribute scope.



3
4
5
# File 'lib/requirejs/compiler.rb', line 3

def scope
  @scope
end

Instance Method Details

#execObject



10
11
12
13
14
15
16
17
18
# File 'lib/requirejs/compiler.rb', line 10

def exec
  if Requirejs.config.optimize?
    OptimizedBuild.new(@scope, @file, @data).data
  elsif Requirejs.config.digest?
    Build.new(@scope, @file, @data).data
  else
    @data
  end
end