Sha256: 84c3511d79bc3a960db754bd4762362a0ea86132f9fbf17dad93a7fb4c5b1221

Contents?: true

Size: 608 Bytes

Versions: 1

Compression:

Stored size: 608 Bytes

Contents

module Codependency
  class Node
    def initialize( filename, parser )
      raise Errno::ENOENT, filename unless File.exist?( filename )
      @filename = filename
      @parser   = parser
    end
    attr_reader :filename, :parser

    ##
    # all of this node's edges
    def edges
      @edges ||= begin
        parser.parse( filename ).map do |f|
          "#{f}#{File.extname( filename )}"
        end
      end
    end

    ##
    # a string representing this node's edges, formatted for `tsort`.
    def dependencies
      edges.map { |edge| [ filename, edge ] }.flatten.join ' '
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
codependency-0.3.1 lib/codependency/node.rb