Sha256: 5771bdc144afcac443970873eeb53a41191c5834133071a55c3a24589f0347b9

Contents?: true

Size: 873 Bytes

Versions: 7

Compression:

Stored size: 873 Bytes

Contents

module CC
  module Analyzer
    module Formatters
      class JSONFormatter < Formatter

        def initialize
          @has_begun = false
        end

        def engine_running(engine)
          @active_engine = engine
          yield
          @active_engine = nil
        end

        def started
          print "[ "
        end

        def finished
          print " ]\n"
        end

        def write(data)
          return unless data.present?

          document = JSON.parse(data)
          document["engine_name"] = @active_engine.name

          if @has_begun
            print ",\n"
          end

          print document.to_json
          @has_begun = true
        end

        def failed(output)
          $stderr.puts "\nAnalysis failed with the following output:"
          $stderr.puts output
          exit 1
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
codeclimate-0.1.2 lib/cc/analyzer/formatters/json_formatter.rb
codeclimate-0.1.0 lib/cc/analyzer/formatters/json_formatter.rb
codeclimate-0.0.25 lib/cc/analyzer/formatters/json_formatter.rb
codeclimate-0.0.24 lib/cc/analyzer/formatters/json_formatter.rb
codeclimate-0.0.23 lib/cc/analyzer/formatters/json_formatter.rb
codeclimate-0.0.22 lib/cc/analyzer/formatters/json_formatter.rb
codeclimate-0.0.21 lib/cc/analyzer/formatters/json_formatter.rb