Class: JRuby::Lint::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/jruby/lint/project.rb

Constant Summary collapse

DEFAULT_TAGS =
%w(error warning info)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = OpenStruct.new) ⇒ Project

Returns a new instance of Project.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/jruby/lint/project.rb', line 10

def initialize(options = OpenStruct.new)
  @tags = DEFAULT_TAGS.dup
  @collectors = []
  @files = Set.new

  if options.eval
    options.eval.each {|e| @collectors << JRuby::Lint::Collectors::Ruby.new(self, '-e', e) }
    @files += @collectors
  end

  if options.tags
    @tags += options.tags
  end

  @sources = options.files || (options.eval ? [] : Dir['./**/*'])
  load_collectors
  load_reporters(options)
  load_libraries
end

Instance Attribute Details

#collectorsObject (readonly)

Returns the value of attribute collectors.



8
9
10
# File 'lib/jruby/lint/project.rb', line 8

def collectors
  @collectors
end

#filesObject (readonly)

Returns the value of attribute files.



8
9
10
# File 'lib/jruby/lint/project.rb', line 8

def files
  @files
end

#findingsObject (readonly)

Returns the value of attribute findings.



8
9
10
# File 'lib/jruby/lint/project.rb', line 8

def findings
  @findings
end

#librariesObject (readonly)

Returns the value of attribute libraries.



8
9
10
# File 'lib/jruby/lint/project.rb', line 8

def libraries
  @libraries
end

#reportersObject (readonly)

Returns the value of attribute reporters.



8
9
10
# File 'lib/jruby/lint/project.rb', line 8

def reporters
  @reporters
end

#tagsObject (readonly)

Returns the value of attribute tags.



8
9
10
# File 'lib/jruby/lint/project.rb', line 8

def tags
  @tags
end

Instance Method Details

#runObject



30
31
32
33
34
35
36
37
38
# File 'lib/jruby/lint/project.rb', line 30

def run
  @findings = []
  collectors.each do |c|
    c.run
    reporters.each {|r| r.report(c.findings)}
    @findings += c.findings
  end
  reporters.each {|r| r.print_report(@findings) if r.respond_to?(:print_report) }
end