Class: JSLintJohnson::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- JSLintJohnson::RakeTask
- Defined in:
- lib/jslint-johnson/rake_task.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
description for the task.
-
#exclude_pattern ⇒ Object
exclusion glob pattern for files.
-
#include_pattern ⇒ Object
inclusion glob pattern for files.
-
#name ⇒ Object
name of the rake task.
-
#output_stream ⇒ Object
output stream for this task.
Instance Method Summary collapse
-
#files_to_run ⇒ Object
Returns a list of all files to run, sorted.
-
#initialize {|_self| ... } ⇒ RakeTask
constructor
A new instance of RakeTask.
Constructor Details
#initialize {|_self| ... } ⇒ RakeTask
Returns a new instance of RakeTask.
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/jslint-johnson/rake_task.rb', line 21 def initialize # a default name @name = "lint" # a default description @description = "Runs the JSLint Test Suite" # by default a glob pattern that will include javascript files found in rails @include_pattern = "app/javascripts/**/*.js" # by default a glob pattern which will match no files @exclude_pattern = "" # by default use standard output for writing information @output_stream = STDOUT # if a block was given allow the block to call elements on this object yield self if block_given? # create the rake task new_task = task(name) do formatter = JSLintJohnson::Formatter.new(output_stream) lint_result = runner.run do |file, errors| formatter.tick(errors) end # put a separator line in between the ticks and any summary output_stream.print "\n" # print a summary of failed files formatter.summary(files_to_run, lint_result) # raise an exception if there are errors raise "jslint suite failed" unless lint_result.empty? end # assign the description to the rake task new_task.comment = description end |
Instance Attribute Details
#description ⇒ Object
description for the task
10 11 12 |
# File 'lib/jslint-johnson/rake_task.rb', line 10 def description @description end |
#exclude_pattern ⇒ Object
exclusion glob pattern for files
16 17 18 |
# File 'lib/jslint-johnson/rake_task.rb', line 16 def exclude_pattern @exclude_pattern end |
#include_pattern ⇒ Object
inclusion glob pattern for files
13 14 15 |
# File 'lib/jslint-johnson/rake_task.rb', line 13 def include_pattern @include_pattern end |
#name ⇒ Object
name of the rake task
7 8 9 |
# File 'lib/jslint-johnson/rake_task.rb', line 7 def name @name end |
#output_stream ⇒ Object
output stream for this task
19 20 21 |
# File 'lib/jslint-johnson/rake_task.rb', line 19 def output_stream @output_stream end |
Instance Method Details
#files_to_run ⇒ Object
Returns a list of all files to run, sorted
65 66 67 68 69 70 |
# File 'lib/jslint-johnson/rake_task.rb', line 65 def files_to_run included_files = Dir.glob(include_pattern) excluded_files = Dir.glob(exclude_pattern) (included_files - excluded_files).sort end |