Method: Packr::SourceMap#initialize

Defined in:
lib/packr/source_map.rb

#initialize(script, options = {}) ⇒ SourceMap

Returns a new instance of SourceMap.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/packr/source_map.rb', line 9

def initialize(script, options = {})
  @header = options[:header]
  if @header
    @header += "\n" unless options[:minify] != false
    @header += "\n"
  else
    @header = ''
  end
  
  @source_code = script
  return if String === @source_code
  
  @generated_file = options[:output_file]
  @base_62        = options[:base62]
  @line_offset    = @base_62 ? 0 : @header.scan(LINE_ENDING).size
  @source_code    = ''
  @source_files   = []
  
  script.each do |section|
    @source_files << [@source_code.size, section[:source]]
    @source_code << section[:code] + "\n"
  end
  
  @source_files << [@source_code.size, nil]
  
  @tokens = tokenize(@source_code, true)
end