Class: FrontEndTasks::Documents::JsDocument
Instance Attribute Summary
Attributes inherited from BaseDocument
#compiled_path
Instance Method Summary
collapse
#initialize
Instance Method Details
#compile(opts = {}) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/front_end_tasks/documents/js_document.rb', line 8
def compile(opts = {})
path_content_pairs = {}
workers = find_worker_references(@public_root, @content)
workers.each do |worker|
new_files = worker.compile
path_content_pairs.merge!(new_files)
end
@content = replace_worker_import_scripts(@public_root, @content)
if opts[:js_concat_only]
path_content_pairs.merge!({
@compiled_path => @content
})
else
compiled_content = Uglifier.compile(@content)
path_content_pairs.merge!({
@compiled_path => compiled_content
})
end
path_content_pairs
end
|
#included_scripts(public_root = nil) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/front_end_tasks/documents/js_document.rb', line 33
def included_scripts(public_root = nil)
paths = []
import_scripts = @content.scan(/importScripts\(([^)]+)\)/)
import_scripts.each do |import_script|
argument_content = import_script[0]
paths = argument_content.split(",").map { |p| p.strip.chop.reverse.chop.reverse }
end
paths.map do |path|
if public_root
File.expand_path(File.join(public_root, path))
else
path
end
end
end
|