Module: Jshintrb

Defined in:
lib/jshintrb.rb,
lib/jshintrb/lint.rb,
lib/jshintrb/version.rb,
lib/jshintrb/jshinttask.rb,
lib/jshintrb/reporter/default.rb

Defined Under Namespace

Modules: Reporter Classes: JshintTask, Lint

Constant Summary collapse

VERSION =
"0.3.0"
SUBMODULE =
"bfcc86d6e51f53ae1e05cfdd33618e9bc0a9a957"

Class Method Summary collapse

Class Method Details

.lint(source, options = nil, globals = nil) ⇒ Object



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

def self.lint(source, options = nil, globals = nil)
  Lint.new(options, globals).lint(source)
end

.report(source, options = nil, globals = nil, out = nil) ⇒ Object



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
# File 'lib/jshintrb.rb', line 13

def self.report(source, options = nil, globals = nil, out = nil)
  reporter = Reporter::Default.new
  linter = Lint.new(options, globals)
  report = ''
  if source.is_a?(Array) then
    source.each do |src|
      if !src.is_a?(String) then
        p src.to_s
        raise ArgumentError, 'Expected array of strings. Instead get ' + src.class.to_s
      end
      errors = linter.lint(File.read(src))
      rep = reporter.format errors, src
      if out && rep.size > 0 then
        out.puts rep
      end
      report += rep
    end
  else
    errors = linter.lint(source)
    report = reporter.format errors
    if out then
      out.puts report
    end
  end
  report
end