Sha256: 905e18fb09ae9c50e2809e298f77b3b250d8055572e62213cbf4a5e88e76c39f

Contents?: true

Size: 758 Bytes

Versions: 1

Compression:

Stored size: 758 Bytes

Contents

module Fukuzatsu

  module Formatters

    class Json

      include Formatters::Base

      def self.index(summaries)
        Fukuzatsu::Formatters::JsonIndex.new(summaries).export
      end

      def as_json
        result = {
          source_file: summary.source_file,
          object: summary.container_name,
          name: summary.entity_name,
          complexity: summary.complexity
        }
        if summary.is_class_or_module?
          result[:average_complexity] = summary.average_complexity
          result[:methods] = summary.summaries.map { |s| Json.new(summary: s).as_json }
        end
        result
      end

      def content
        as_json.to_json
      end

      def file_extension
        ".json"
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fukuzatsu-2.1.1 lib/fukuzatsu/formatters/json.rb