Class: Jlint

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

Constant Summary collapse

VERSION =
'0.1.2'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(custom_config = nil) ⇒ Jlint



12
13
14
# File 'lib/jlint.rb', line 12

def initialize custom_config = nil
  @custom_config = custom_config
end

Class Method Details

.file_lint(file_path) ⇒ Object



7
8
9
# File 'lib/jlint.rb', line 7

def self.file_lint file_path
  new.file_lint file_path
end

.lint(content) ⇒ Object



3
4
5
# File 'lib/jlint.rb', line 3

def self.lint content
  new.lint content
end

Instance Method Details

#file_lint(file_path) ⇒ Object



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

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



16
17
18
19
20
# File 'lib/jlint.rb', line 16

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