Class: NibTask
- Inherits:
-
MultipleOutputTask
- Object
- Configurable
- Task
- OutputTask
- MultipleOutputTask
- NibTask
- Defined in:
- lib/tasks/nib-task.rb
Instance Attribute Summary
Attributes inherited from Task
Attributes inherited from Configurable
Class Method Summary collapse
Instance Method Summary collapse
-
#handles_file?(file_name) ⇒ Boolean
NibTask handles files that end in .jsnib.
- #output_type ⇒ Object
- #source_type ⇒ Object
- #validate_file(file) ⇒ Object
- #validate_files ⇒ Object
Methods inherited from MultipleOutputTask
#finish, #finish_file, #initialize, #process_file, #process_files, #products
Methods inherited from OutputTask
#initialize, #minify, #notice_text, #output_extension, #products
Methods inherited from Task
available_tasks, #build_assets, by_name, #cleanup, #copy_assets, #copy_assets_orig, #document_files, #find_files, #finish, #include_file, inherited, #initialize, #need_to_build, #process_files, #products, #replace_tokens, #symlink_assets, task_index, #task_name
Methods inherited from Configurable
#get_options, #initialize, option, option_alias
Constructor Details
This class inherits a constructor from MultipleOutputTask
Class Method Details
.task_name ⇒ Object
6 7 8 |
# File 'lib/tasks/nib-task.rb', line 6 def self.task_name "jsnib" end |
Instance Method Details
#handles_file?(file_name) ⇒ Boolean
NibTask handles files that end in .jsnib
19 20 21 |
# File 'lib/tasks/nib-task.rb', line 19 def handles_file?(file_name) "#{file_name}"[/\.jsnib$/] end |
#output_type ⇒ Object
14 15 16 |
# File 'lib/tasks/nib-task.rb', line 14 def output_type "jsnib" end |
#source_type ⇒ Object
10 11 12 |
# File 'lib/tasks/nib-task.rb', line 10 def source_type "js" end |
#validate_file(file) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/tasks/nib-task.rb', line 23 def validate_file(file) return if (!File.exists?($lint_command)) tmp= Tempfile.new("jsl.conf") conf_files= [ "jsl.conf", "#{ENV['HOME']}/.jsl.conf", @options.jsl_conf ] jsl_conf= conf_files.find { |f| File.exists?(f) } tmp << File.read(jsl_conf) tmp << "\n" external_projects.each { |project| tmp << "+include #{project["include"]}\n" } file.dependencies.each { |f| tmp << "+process #{f}\n" } tmp << "+process #{file}\n" tmp.close() command= "#{$lint_command} -nologo -nofilelisting -conf #{tmp.path}" stdin, stdout, stderr= Open3.popen3(command) stdin.close output= stdout.read errors= stderr.read tmp.delete output= output.split("\n") summary= output.pop match= summary.match(/(\d+)\s+error\(s\), (\d+)\s+warning\(s\)/) if (match) @target.error_count+= match[1].to_i @target.warning_count+= match[2].to_i end output= output.join("\n") if (!output.empty?) puts output puts end end |
#validate_files ⇒ Object
77 78 79 80 81 |
# File 'lib/tasks/nib-task.rb', line 77 def validate_files @included_files.each { |f| validate_file(f) } end |