Class: Daedalus::DependencyGrapher::IncludedFile
- Includes:
- Container
- Defined in:
- lib/daedalus/dependency_grapher.rb
Instance Attribute Summary collapse
-
#includes ⇒ Object
readonly
Returns the value of attribute includes.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes included from Container
Class Method Summary collapse
Instance Method Summary collapse
- #collect_dependencies(set) ⇒ Object
- #execute(defines, node) ⇒ Object
- #expand_filename(node) ⇒ Object
-
#initialize(name, parser) ⇒ IncludedFile
constructor
A new instance of IncludedFile.
Methods included from Container
Methods inherited from Node
Constructor Details
#initialize(name, parser) ⇒ IncludedFile
Returns a new instance of IncludedFile.
141 142 143 144 145 |
# File 'lib/daedalus/dependency_grapher.rb', line 141 def initialize(name, parser) super parser @name = name @includes = [] end |
Instance Attribute Details
#includes ⇒ Object (readonly)
Returns the value of attribute includes.
135 136 137 |
# File 'lib/daedalus/dependency_grapher.rb', line 135 def includes @includes end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
135 136 137 |
# File 'lib/daedalus/dependency_grapher.rb', line 135 def name @name end |
Class Method Details
.cache ⇒ Object
137 138 139 |
# File 'lib/daedalus/dependency_grapher.rb', line 137 def self.cache @cache ||= {} end |
Instance Method Details
#collect_dependencies(set) ⇒ Object
180 181 182 183 184 185 |
# File 'lib/daedalus/dependency_grapher.rb', line 180 def collect_dependencies(set) return if set.include? @name set << @name @includes.each { |x| x.collect_dependencies(set) } end |
#execute(defines, node) ⇒ Object
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/daedalus/dependency_grapher.rb', line 164 def execute(defines, node) (node) if cached = self.class.cache[@name.to_sym] @body = cached.body else parser = FileParser.new self, @parser.directories parser.parse_file @name self.class.cache[@name.to_sym] = self end execute_body defines, self node.includes << self end |
#expand_filename(node) ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/daedalus/dependency_grapher.rb', line 147 def (node) return if File.exist? @name @parser.directories.each do |dir| path = File.join dir, @name return @name = path if File.file? path end # Try to find the file in the same directory as where we're looking from dir = File.dirname(node.name) path = File.join dir, @name return @name = path if File.file?(path) raise Errno::ENOENT, "unable to find file to include: #{@name} from #{node.name}" end |