Class: CSSLint::TestTask
- Inherits:
-
Object
- Object
- CSSLint::TestTask
- Includes:
- Rake::DSL
- Defined in:
- lib/csslint/testtask.rb
Instance Attribute Summary collapse
-
#file_list ⇒ Object
Public: Gets/Sets the Array of JavaScript filenames as Strings, each of which will be run through csslint.
-
#options ⇒ Object
Public: Gets/Sets the Hash of options that will be passed to each call of csslint.
Instance Method Summary collapse
-
#define_task ⇒ Object
Internal: Define the actual Rake task.
-
#initialize(name = :csslint) {|_self| ... } ⇒ TestTask
constructor
Public: Define a new Rake task that runs CSSLint tests over several JavaScript files.
Constructor Details
#initialize(name = :csslint) {|_self| ... } ⇒ TestTask
Public: Define a new Rake task that runs CSSLint tests over several JavaScript files.
name - the name of the defined Rake Task. (default: ‘csslint’)
Yields itself for configuration if a block is given.
23 24 25 26 27 28 29 30 |
# File 'lib/csslint/testtask.rb', line 23 def initialize(name=:csslint) @name = name @file_list = Dir['**/*.css'] @options = {} yield self if block_given? define_task end |
Instance Attribute Details
#file_list ⇒ Object
Public: Gets/Sets the Array of JavaScript filenames as Strings, each of which will be run through csslint. (default: Dir[‘*/.css’])
10 11 12 |
# File 'lib/csslint/testtask.rb', line 10 def file_list @file_list end |
#options ⇒ Object
Public: Gets/Sets the Hash of options that will be passed to each call of csslint. See www.csslint.com/lint.html for allowed options. (default: {})
15 16 17 |
# File 'lib/csslint/testtask.rb', line 15 def @options end |
Instance Method Details
#define_task ⇒ Object
Internal: Define the actual Rake task.
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 |
# File 'lib/csslint/testtask.rb', line 33 def define_task desc "Run #{@name == :csslint ? '' : @name + ' '}CSSLint tests" task @name do t0 = Time.now errors = [] @file_list.each do |f| result = CSSLint.run(File.open(f), @options ) if result.valid? print '.' else errors << result..map {|e| "#{f}:#{e}"} print 'F' end end puts puts if errors.any? puts *errors puts end puts "Finished in %.5f seconds" % [Time.now.to_f - t0.to_f] puts "%d files, %d errors" % [@file_list.length, errors.length] end end |