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