Class: Daedalus::DependencyGrapher::SourceFile
- Includes:
- Container
- Defined in:
- lib/daedalus/dependency_grapher.rb
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#includes ⇒ Object
readonly
Returns the value of attribute includes.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#object_name ⇒ Object
readonly
Returns the value of attribute object_name.
Attributes included from Container
Instance Method Summary collapse
- #collect_dependencies ⇒ Object
- #execute(defines) ⇒ Object
-
#initialize(name, parser) ⇒ SourceFile
constructor
A new instance of SourceFile.
- #print_dependencies(out, max) ⇒ Object
Methods included from Container
Methods inherited from Node
Constructor Details
#initialize(name, parser) ⇒ SourceFile
Returns a new instance of SourceFile.
92 93 94 95 96 97 |
# File 'lib/daedalus/dependency_grapher.rb', line 92 def initialize(name, parser) super parser @name = name @object_name = name.sub(/((c(pp)?)|S)$/, 'o') @includes = [] end |
Instance Attribute Details
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
90 91 92 |
# File 'lib/daedalus/dependency_grapher.rb', line 90 def dependencies @dependencies end |
#includes ⇒ Object (readonly)
Returns the value of attribute includes.
90 91 92 |
# File 'lib/daedalus/dependency_grapher.rb', line 90 def includes @includes end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
90 91 92 |
# File 'lib/daedalus/dependency_grapher.rb', line 90 def name @name end |
#object_name ⇒ Object (readonly)
Returns the value of attribute object_name.
90 91 92 |
# File 'lib/daedalus/dependency_grapher.rb', line 90 def object_name @object_name end |
Instance Method Details
#collect_dependencies ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/daedalus/dependency_grapher.rb', line 103 def collect_dependencies set = Set.new set << @name @includes.each { |x| x.collect_dependencies(set) } @dependencies = set.to_a.sort end |
#execute(defines) ⇒ Object
99 100 101 |
# File 'lib/daedalus/dependency_grapher.rb', line 99 def execute(defines) execute_body defines, self end |
#print_dependencies(out, max) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/daedalus/dependency_grapher.rb', line 112 def print_dependencies(out, max) str = "#{@object_name}:" out.print str width = str.size @dependencies.each do |name| size = name.size + 1 if width + size > max width = 0 out.print " \\\n " end out.print " ", name width += size end out.print "\n" end |