Sha256: c7edd67f31e0f6015c404a29502625b89a86166f978675373e192c2f0c97a47c

Contents?: true

Size: 997 Bytes

Versions: 4

Compression:

Stored size: 997 Bytes

Contents

module Pelusa
  class Runner
    # Public: Initializes an Analyzer.
    #
    # lints    - The lints to check the code for.
    # reporter - The Reporter to use. Will be used to report back the results in
    #            methods such as #run.
    def initialize(lints, reporter)
      @lints    = lints
      @reporter = reporter
    end

    # Public: Runs the analyzer on a set of files.
    #
    # Returns an Array of Reports of those file runs.
    def run(files)
      Array(files).map do |file|
        run_file(file)
      end
    end

    # Public: Runs the analyzer on a single file.
    #
    # Returns a Report of the single run.
    def run_file(file)
      ast      = parser.parse_file(file)
      analyzer = Analyzer.new(@lints, @reporter, file)
      analyzer.analyze(ast)
    end

    #######
    private
    #######

    # Internal: Returns the Melbourne 1.9 parser.
    #
    # Returns a Rubinius::Melbourne parser.
    def parser
      Rubinius::Melbourne19
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pelusa-0.2.3 lib/pelusa/runner.rb
pelusa-0.2.2 lib/pelusa/runner.rb
pelusa-0.2.1 lib/pelusa/runner.rb
pelusa-0.2.0 lib/pelusa/runner.rb