Sha256: 6c1828851f512ab2fad26fa767a34daf09857c2716f4a8f58a254b0efed22de7

Contents?: true

Size: 371 Bytes

Versions: 10

Compression:

Stored size: 371 Bytes

Contents

module Dox
  module Formatters
    class Json < Dox::Formatters::Base
      def format
        # in cases where the body isn't valid JSON
        # and the headers specify the Content-Type is application/json
        # an error should be raised
        return '' if body.nil? || body.length < 2

        JSON.pretty_generate(JSON.parse(body))
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
dox-2.4.0 lib/dox/formatters/json.rb
dox-2.3.0 lib/dox/formatters/json.rb
dox-2.2.0 lib/dox/formatters/json.rb
dox-2.1.0 lib/dox/formatters/json.rb
dox-1.3.0 lib/dox/formatters/json.rb
dox-2.0.0 lib/dox/formatters/json.rb
dox-2.0.0.beta3 lib/dox/formatters/json.rb
dox-2.0.0.beta2 lib/dox/formatters/json.rb
dox-2.0.0.beta1 lib/dox/formatters/json.rb
dox-1.2.0 lib/dox/formatters/json.rb