Sha256: 7e062ce6576304b8802e8b10fa2b141e885dc3ba55a24621add61bddcae0373b

Contents?: true

Size: 742 Bytes

Versions: 12

Compression:

Stored size: 742 Bytes

Contents

module CC
  module Analyzer
    module Formatters
      class JSONFormatter < Formatter

        def initialize
          @has_begun = false
        end

        def started
          print "["
        end

        def finished
          print "]\n"
        end

        def write(data)
          return unless data.present?

          document = JSON.parse(data)
          document["engine_name"] = current_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

12 entries across 12 versions & 1 rubygems

Version Path
codeclimate-0.2.12 lib/cc/analyzer/formatters/json_formatter.rb
codeclimate-0.2.11 lib/cc/analyzer/formatters/json_formatter.rb
codeclimate-0.2.9 lib/cc/analyzer/formatters/json_formatter.rb
codeclimate-0.2.7 lib/cc/analyzer/formatters/json_formatter.rb
codeclimate-0.2.6 lib/cc/analyzer/formatters/json_formatter.rb
codeclimate-0.2.4 lib/cc/analyzer/formatters/json_formatter.rb
codeclimate-0.2.2 lib/cc/analyzer/formatters/json_formatter.rb
codeclimate-0.2.1 lib/cc/analyzer/formatters/json_formatter.rb
codeclimate-0.2 lib/cc/analyzer/formatters/json_formatter.rb
codeclimate-0.1.5 lib/cc/analyzer/formatters/json_formatter.rb
codeclimate-0.1.4 lib/cc/analyzer/formatters/json_formatter.rb
codeclimate-0.1.3 lib/cc/analyzer/formatters/json_formatter.rb