Sha256: 988cf1525e3dba09a9c279b1771665cd233918f006c4924525c91fce7931a949

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require 'fukuzatsu'

module Society

  class Parser < Fukuzatsu::Parser

    attr_reader :parsed_files

    def initialize(start_path)
      super(start_path, :none, 0)
      @parsed_files = parse_files
    end

    def class_graph
      @class_graph ||= begin
        graph = ObjectGraph.new
        graph.nodes = parsed_files.map do |parsed_file|
          Node.new(
            name: parsed_file.class_name,
            address: parsed_file.path_to_file,
            edges: parsed_file.class_references
          )
        end
        graph
      end
    end

    def method_graph
      @method_graph ||= begin
        graph = ObjectGraph.new
        target = parsed_files.first
        graph.nodes = target.methods.map do |method|
          Node.new(
            name: method.name,
            address: target.class_name,
            edges: method.references
          )
        end
        graph
      end
    end

    def matrix(graph)
      Society::Matrix.new(graph.nodes)
    end

    def reset_output_directory
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
society-0.13.2 lib/society/parser.rb
society-0.13.1 lib/society/parser.rb
society-0.13.0 lib/society/parser.rb