Sha256: 97dffc0e78d03e3f4b364bee539aad994338ec0619639a065aa17cf4c0298fec

Contents?: true

Size: 1.01 KB

Versions: 97

Compression:

Stored size: 1.01 KB

Contents

module CC
  module Analyzer
    module Formatters
      class Formatter
        def initialize(filesystem, output = $stdout)
          @filesystem = filesystem
          @output = output
        end

        def write(data)
          json = JSON.parse(data)
          json["engine_name"] = current_engine.name

          case json["type"].downcase
          when "issue"
            issues << json
          when "warning"
            warnings << json
          when "measurement"
            measurements << json
          else
            raise "Invalid type found: #{json["type"]}"
          end
        end

        def started
        end

        def engine_running(engine)
          @current_engine = engine
          yield
        ensure
          @current_engine = nil
        end

        def finished
        end

        def close
        end

        def failed(_output)
        end

        InvalidFormatterError = Class.new(StandardError)

        private

        attr_reader :current_engine
      end
    end
  end
end

Version data entries

97 entries across 97 versions & 2 rubygems

Version Path
codeclimate-0.85.27 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.85.26 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.85.25 lib/cc/analyzer/formatters/formatter.rb
codeclimate-0.85.24 lib/cc/analyzer/formatters/formatter.rb
codeclimate-fede-0.85.54 lib/cc/analyzer/formatters/formatter.rb
codeclimate-fede-0.85.53 lib/cc/analyzer/formatters/formatter.rb
codeclimate-fede-0.85.52 lib/cc/analyzer/formatters/formatter.rb
codeclimate-fede-0.85.51 lib/cc/analyzer/formatters/formatter.rb
codeclimate-fede-0.85.50 lib/cc/analyzer/formatters/formatter.rb
codeclimate-fede-0.85.49 lib/cc/analyzer/formatters/formatter.rb
codeclimate-fede-0.85.48 lib/cc/analyzer/formatters/formatter.rb
codeclimate-fede-0.85.47 lib/cc/analyzer/formatters/formatter.rb
codeclimate-fede-0.85.46 lib/cc/analyzer/formatters/formatter.rb
codeclimate-fede-0.85.45 lib/cc/analyzer/formatters/formatter.rb
codeclimate-fede-0.85.44 lib/cc/analyzer/formatters/formatter.rb
codeclimate-fede-0.85.43 lib/cc/analyzer/formatters/formatter.rb
codeclimate-fede-0.85.42 lib/cc/analyzer/formatters/formatter.rb
codeclimate-fede-0.85.41 lib/cc/analyzer/formatters/formatter.rb
codeclimate-fede-0.85.40 lib/cc/analyzer/formatters/formatter.rb
codeclimate-fede-0.85.39 lib/cc/analyzer/formatters/formatter.rb