Class: Distil::JslDependencyTask
- Inherits:
-
Task
- Object
- Configurable
- Task
- Distil::JslDependencyTask
- Defined in:
- lib/distil/task/jsl-dependency-task.rb
Instance Attribute Summary
Attributes inherited from Configurable
Instance Method Summary collapse
Methods inherited from Task
#find_files, #handles_file?, inherited, #initialize, #process_files, #project, #target, tasks
Methods inherited from Configurable
#get_option, #get_options, #initialize, option
Constructor Details
This class inherits a constructor from Distil::Task
Instance Method Details
#handles_file(file) ⇒ Object
7 8 9 |
# File 'lib/distil/task/jsl-dependency-task.rb', line 7 def handles_file(file) return ["js"].include?(file.content_type) end |
#include_file(file) ⇒ Object
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 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/distil/task/jsl-dependency-task.rb', line 11 def include_file(file) return if !handles_file(file) content= target.get_content_for_file(file).split("\n") line_num=0 content.each { |line| line_num+=1 # handle dependencies line.gsub!(JSL_IMPORT_REGEX) { |match| import_file= File.(File.join(file.parent_folder, $1)) if (File.exists?(import_file)) file.add_dependency SourceFile.from_path(import_file) else dependency= target.find_file($1, file) if (dependency) target.add_file_alias($1, dependency.full_path) file.add_dependency dependency else file.error "Missing import file: #{$1}", line_num end end # replace jsl import with empty string "" } } target.set_content_for_file(file, content.join("\n")) end |