lib/codependency/node.rb in codependency-0.2.0 vs lib/codependency/node.rb in codependency-0.3.0
- old
+ new
@@ -7,11 +7,23 @@
@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|
+ dirname.join( "#{f}#{extname}" ).to_s
+ end
+ end
+ end
+
+ ##
+ # a string representing this node's edges, formatted for `tsort`.
def dependencies
- parser.parse( filename ).map { |f| dirname.join( "#{f}#{extname}" ).to_s }
+ edges.map { |edge| [ filename, edge ] }.flatten.join ' '
end
protected
def dirname