| Class | W3CValidators::CSSValidator |
| In: |
lib/w3c_validators/css_validator.rb
|
| Parent: | Validator |
| CSS_VALIDATOR_URI | = | 'http://jigsaw.w3.org/css-validator/validator' |
Create a new instance of the CSSValidator.
You can pass in your own validator‘s URI (i.e. CSSValidator.new(:validator_uri => ‘localhost/check’)).
# File lib/w3c_validators/css_validator.rb, line 10
10: def initialize(options = {})
11: if options[:validator_uri]
12: @validator_uri = URI.parse(options[:validator_uri])
13: options.delete(options[:validator_uri])
14: else
15: @validator_uri = URI.parse(CSS_VALIDATOR_URI)
16: end
17: super(options)
18: end
The language used for the response.
# File lib/w3c_validators/css_validator.rb, line 47
47: def set_language!(lang = 'en')
48: @options[:lang] = lang
49: end
The CSS profile used for the validation.
charset can be a string or a symbl from the W3CValidators::CSS_PROFILES hash.
set_profile!('css1')
set_profile!(:css1)
# File lib/w3c_validators/css_validator.rb, line 27
27: def set_profile!(profile)
28: if profile.kind_of?(Symbol)
29: if CSS_PROFILES.has_key?(profile)
30: profile = profile.to_s
31: else
32: return
33: end
34: end
35: @options[:profile] = profile
36: end
The warning level, no for no warnings, 0 for less warnings, 1or 2 for more warnings
# File lib/w3c_validators/css_validator.rb, line 39
39: def set_warn_level!(level = 2)
40: warn_levels = ['0','1','2','no']
41: return unless warn_levels.include?(level.to_s.downcase)
42:
43: @options[:warning] = level
44: end
Validate the CSS of a local file.
file_path may be either the fully-expanded path to the file or an IO object (like File).
Returns W3CValidators::Results.
# File lib/w3c_validators/css_validator.rb, line 71
71: def validate_file(file_path)
72: if file_path.respond_to? :read
73: src = file_path.read
74: else
75: src = read_local_file(file_path)
76: end
77: return validate_text(src)
78: end
Validate the CSS of a string.
Returns W3CValidators::Results.
# File lib/w3c_validators/css_validator.rb, line 61
61: def validate_text(text)
62: return validate({:text => text})
63: end
Validate the CSS of an URI.
Returns W3CValidators::Results.
# File lib/w3c_validators/css_validator.rb, line 54
54: def validate_uri(uri)
55: return validate({:uri => uri})
56: end