Sha256: 821fc1ac0c5b087b00db86d3e9c876f61e05e7546928167c463f84e23ff87c3f

Contents?: true

Size: 858 Bytes

Versions: 2

Compression:

Stored size: 858 Bytes

Contents

module Callgraphy
  # Records the information that describes a call graph.
  #
  class Registry
    def initialize
      @registry = { public: [], private: [], callers: [], dependencies: [], calls: [] }
    end

    def register_method(scope, caller)
      @registry.fetch(scope).push(caller.to_s)
    end
    alias register_constant register_method

    def register_call(caller, callee)
      @registry.fetch(:calls).push([caller.to_s, callee.to_s])
    end

    def all_public_methods
      normalized :public
    end

    def all_private_methods
      normalized :private
    end

    def all_calls
      normalized :calls
    end

    def all_callers
      normalized :callers
    end

    def all_dependencies
      normalized :dependencies
    end

    private

    def normalized(category)
      @registry.fetch(category).sort.uniq
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
callgraphy-0.2.1 lib/callgraphy/registry.rb
callgraphy-0.2.0 lib/callgraphy/registry.rb