Class: Jekyll::AgentAudit::LinkGraph
- Inherits:
-
Object
- Object
- Jekyll::AgentAudit::LinkGraph
- Defined in:
- lib/jekyll/agent_audit/link_graph.rb
Instance Attribute Summary collapse
-
#diagnostics ⇒ Object
readonly
Returns the value of attribute diagnostics.
Instance Method Summary collapse
- #edges ⇒ Object
- #edges_for(document) ⇒ Object
- #incoming(document) ⇒ Object
-
#initialize(documents, resolver, configuration, site_config = {}) ⇒ LinkGraph
constructor
A new instance of LinkGraph.
- #reachable ⇒ Object
Constructor Details
#initialize(documents, resolver, configuration, site_config = {}) ⇒ LinkGraph
Returns a new instance of LinkGraph.
11 12 13 14 15 |
# File 'lib/jekyll/agent_audit/link_graph.rb', line 11 def initialize(documents, resolver, configuration, site_config = {}) @documents, @resolver, @configuration, @site_config = Array(documents), resolver, configuration, site_config || {} @incoming, @edges, @by_source, @diagnostics = Hash.new { |h, k| h[k] = Set.new }, [], Hash.new { |h, k| h[k] = [] }, [] build end |
Instance Attribute Details
#diagnostics ⇒ Object (readonly)
Returns the value of attribute diagnostics.
9 10 11 |
# File 'lib/jekyll/agent_audit/link_graph.rb', line 9 def diagnostics @diagnostics end |
Instance Method Details
#edges ⇒ Object
20 21 22 |
# File 'lib/jekyll/agent_audit/link_graph.rb', line 20 def edges @edges.dup end |
#edges_for(document) ⇒ Object
23 24 25 |
# File 'lib/jekyll/agent_audit/link_graph.rb', line 23 def edges_for(document) @by_source[document[:identity]].dup end |
#incoming(document) ⇒ Object
17 18 19 |
# File 'lib/jekyll/agent_audit/link_graph.rb', line 17 def incoming(document) @incoming[document[:identity]] end |
#reachable ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/jekyll/agent_audit/link_graph.rb', line 27 def reachable roots = roots_config found, queue = Set.new, roots.map { |root| @documents.find { |d| root_match?(d, root) } }.compact until queue.empty? current = queue.shift next if found.include?(current[:identity]) found << current[:identity] @edges.select { |edge| edge[:source][:identity] == current[:identity] && edge[:target] }.each { |edge| queue << edge[:target] } end found end |