Class: CSSLint::Lint
- Inherits:
-
Object
- Object
- CSSLint::Lint
- Defined in:
- lib/css_lint.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#css ⇒ Object
readonly
Returns the value of attribute css.
-
#gem_vendor_dir ⇒ Object
readonly
Returns the value of attribute gem_vendor_dir.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #error_message ⇒ Object
- #execute(*compass_options) ⇒ Object
- #get_java_path ⇒ Object
-
#initialize(*args) ⇒ Lint
constructor
A new instance of Lint.
- #run_lint(*options) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Lint
Returns a new instance of Lint.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/css_lint.rb', line 8 def initialize(*args) @gem_vendor_dir = File.join(File.dirname(__FILE__), 'vendor') if args.empty? @css = else @args = [] @css = [] args.each do |arg| arg.start_with?("--") ? @args << arg : @css << arg end end end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
4 5 6 |
# File 'lib/css_lint.rb', line 4 def args @args end |
#css ⇒ Object (readonly)
Returns the value of attribute css.
5 6 7 |
# File 'lib/css_lint.rb', line 5 def css @css end |
#gem_vendor_dir ⇒ Object (readonly)
Returns the value of attribute gem_vendor_dir.
3 4 5 |
# File 'lib/css_lint.rb', line 3 def gem_vendor_dir @gem_vendor_dir end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/css_lint.rb', line 6 def @options end |
Instance Method Details
#error_message ⇒ Object
33 34 35 |
# File 'lib/css_lint.rb', line 33 def 'Must provide css_lint a CSS file or directory' end |
#execute(*compass_options) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/css_lint.rb', line 21 def execute(*) if @css == puts @css else if !.empty? run_lint(*) else run_lint(@args) end end end |
#get_java_path ⇒ Object
37 38 39 |
# File 'lib/css_lint.rb', line 37 def get_java_path `which java`.to_s.rstrip end |
#run_lint(*options) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/css_lint.rb', line 41 def run_lint(*) java_path = get_java_path raise "You do not have a Java installed, but it is required." unless java_path && !java_path.empty? .empty? ? @options = '' : @options = .join(' ') + ' ' if !@css.empty? @css.each do |item| system("java -jar #{@gem_vendor_dir}/js.jar #{@gem_vendor_dir}/csslint-rhino.js #{@options}#{item}") end else system("java -jar #{@gem_vendor_dir}/js.jar #{@gem_vendor_dir}/csslint-rhino.js #{@options}") end end |