Sha256: aac608134666101d262560135cb9a550f1a60e5affceaafeca579bff423364f8

Contents?: true

Size: 1.28 KB

Versions: 6

Compression:

Stored size: 1.28 KB

Contents

require "securerandom"

module CC
  module Analyzer
    class EnginesRunner
      InvalidEngineName = Class.new(StandardError)
      NoEnabledEngines = Class.new(StandardError)

      def initialize(registry, formatter, source_dir, config, requested_paths = [], container_label = nil)
        @registry = registry
        @formatter = formatter
        @source_dir = source_dir
        @config = config
        @requested_paths = requested_paths
        @container_label = container_label
      end

      def run(container_listener = ContainerListener.new)
        raise NoEnabledEngines if engines.empty?

        @formatter.started

        engines.each { |engine| run_engine(engine, container_listener) }

        @formatter.finished
      ensure
        @formatter.close if @formatter.respond_to?(:close)
      end

      private

      attr_reader :requested_paths

      def engines
        @engines ||= Engines.new(
          registry: @registry,
          config: @config,
          container_label: @container_label,
          source_dir: @source_dir,
          requested_paths: @requested_paths
        )
      end

      def run_engine(engine, container_listener)
        @formatter.engine_running(engine) do
          engine.run(@formatter, container_listener)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
codeclimate-0.9.7 lib/cc/analyzer/engines_runner.rb
codeclimate-0.9.6 lib/cc/analyzer/engines_runner.rb
codeclimate-0.9.5 lib/cc/analyzer/engines_runner.rb
codeclimate-0.9.4 lib/cc/analyzer/engines_runner.rb
codeclimate-0.9.3 lib/cc/analyzer/engines_runner.rb
codeclimate-0.9.2 lib/cc/analyzer/engines_runner.rb