Class: MilkTea::PackageGraph::Node
- Inherits:
-
Data
- Object
- Data
- MilkTea::PackageGraph::Node
- Defined in:
- lib/milk_tea/packages/graph.rb,
lib/milk_tea/packages/graph.rb
Instance Attribute Summary collapse
-
#edges ⇒ Object
readonly
Returns the value of attribute edges.
-
#manifest ⇒ Object
readonly
Returns the value of attribute manifest.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #package_for_path(path, matches = []) ⇒ Object
- #packages(nodes = [], visited = {}) ⇒ Object
- #source_roots(roots = [], visited = {}) ⇒ Object
- #tree_lines(indent = 0) ⇒ Object
Instance Attribute Details
#edges ⇒ Object (readonly)
Returns the value of attribute edges
8 9 10 |
# File 'lib/milk_tea/packages/graph.rb', line 8 def edges @edges end |
#manifest ⇒ Object (readonly)
Returns the value of attribute manifest
8 9 10 |
# File 'lib/milk_tea/packages/graph.rb', line 8 def manifest @manifest end |
#source ⇒ Object (readonly)
Returns the value of attribute source
8 9 10 |
# File 'lib/milk_tea/packages/graph.rb', line 8 def source @source end |
Instance Method Details
#package_for_path(path, matches = []) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/milk_tea/packages/graph.rb', line 58 def package_for_path(path, matches = []) return nil unless path = File.(path) matches << self if package_path?() edges.each do |edge| edge.node&.package_for_path(, matches) end matches.max_by { |node| node.manifest.root_dir.length } end |
#packages(nodes = [], visited = {}) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/milk_tea/packages/graph.rb', line 36 def packages(nodes = [], visited = {}) return nodes if visited[manifest.manifest_path] visited[manifest.manifest_path] = true nodes << self edges.each do |edge| edge.node&.packages(nodes, visited) end nodes end |
#source_roots(roots = [], visited = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/milk_tea/packages/graph.rb', line 47 def source_roots(roots = [], visited = {}) return roots if visited[manifest.manifest_path] visited[manifest.manifest_path] = true roots << manifest.source_root edges.each do |edge| edge.node&.source_roots(roots, visited) end roots end |
#tree_lines(indent = 0) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/milk_tea/packages/graph.rb', line 70 def tree_lines(indent = 0) lines = [(" " * indent) + manifest.package_name] edges.each do |edge| if edge.node lines.concat(edge.node.tree_lines(indent + 1)) else lines << ((" " * (indent + 1)) + edge.dependency.name) end end lines end |