Class: Jlint

Inherits:
Object
  • Object
show all
Defined in:
lib/jlint.rb,
lib/jlint/version.rb

Constant Summary collapse

VERSION =
'0.1.3'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(custom_config = nil) ⇒ Jlint

Returns a new instance of Jlint.



14
15
16
# File 'lib/jlint.rb', line 14

def initialize custom_config = nil
  @custom_config = custom_config
end

Class Method Details

.file_lint(file_path) ⇒ Object



9
10
11
# File 'lib/jlint.rb', line 9

def self.file_lint file_path
  new.file_lint file_path
end

.lint(content) ⇒ Object



5
6
7
# File 'lib/jlint.rb', line 5

def self.lint content
  new.lint content
end

Instance Method Details

#file_lint(file_path) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/jlint.rb', line 24

def file_lint file_path
  if @custom_config
    as_file @custom_config, ".xml" do |file|
      parse_lint checkstyle_command, file.path, file_path
    end
  else
    parse_lint checkstyle_command, checkstyle_config, file_path
  end
end

#lint(content) ⇒ Object



18
19
20
21
22
# File 'lib/jlint.rb', line 18

def lint content
  as_file content do |file|
    file_lint file.path
  end
end