Module: CSSLint
- Defined in:
- lib/csslint.rb,
lib/csslint/testtask.rb
Defined Under Namespace
Class Method Summary collapse
-
.context ⇒ Object
Internal: The ExecJS Context in which to run csslint().
-
.run(source, options = {}) ⇒ Object
Public: Run CSSLint over some CSS text.
Class Method Details
.context ⇒ Object
Internal: The ExecJS Context in which to run csslint().
Provides a small helper function CSSLINTR to return both the CSSLint() return value and the CSSLint messages
9 10 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 |
# File 'lib/csslint.rb', line 9 def self.context ExecJS.compile( CSSLint::Source.contents + <<-EOW function gatherRules(options){ var ruleset, warnings = options.rules || options.warnings, errors = options.errors; if (warnings){ ruleset = ruleset || {}; for( var _i = 0, _len = warnings.length; _i < _len; _i++ ) { ruleset[warnings[_i]] = 1; }; } if (errors){ ruleset = ruleset || {}; for( var _i = 0, _len = errors.length; _i < _len; _i++ ) { ruleset[errors[_i]] = 2; }; } return ruleset; } function CSSLINTR(source, options) { var result = CSSLint.verify( source, gatherRules( options ) ); var messages = result.messages || []; return [ messages ]; }; EOW ) end |
.run(source, options = {}) ⇒ Object
Public: Run CSSLint over some CSS text
source - some String-like or IO-like CSS text options - Hash of options passed directly to csslint (default: {})
48 49 50 51 52 53 54 55 |
# File 'lib/csslint.rb', line 48 def self.run(source, ={}) source = source.respond_to?(:read) ? source.read : source if source.respond_to?(:path) [:fullPath] = File.( source.path ) [:filename] = source.path end Result.new(*context.call("CSSLINTR", source, )) end |