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.
181 182 183 184 185 |
# File 'lib/daedalus/dependency_grapher.rb', line 181 def initialize(name, parser) super parser @name = name @includes = [] end |
Instance Attribute Details
#includes ⇒ Object (readonly)
Returns the value of attribute includes.
175 176 177 |
# File 'lib/daedalus/dependency_grapher.rb', line 175 def includes @includes end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
175 176 177 |
# File 'lib/daedalus/dependency_grapher.rb', line 175 def name @name end |
Class Method Details
.cache ⇒ Object
177 178 179 |
# File 'lib/daedalus/dependency_grapher.rb', line 177 def self.cache @cache ||= {} end |
Instance Method Details
#collect_dependencies(set) ⇒ Object
220 221 222 223 224 225 |
# File 'lib/daedalus/dependency_grapher.rb', line 220 def collect_dependencies(set) return if set.include? @name set << @name @includes.each { |x| x.collect_dependencies(set) } end |
#execute(defines, node) ⇒ Object
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/daedalus/dependency_grapher.rb', line 204 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
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/daedalus/dependency_grapher.rb', line 187 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 |