Module: Aquanaut

Defined in:
lib/aquanaut.rb,
lib/aquanaut/node.rb,
lib/aquanaut/version.rb,
lib/aquanaut/page_node.rb,
lib/aquanaut/asset_node.rb

Overview

Main module of Aquanaut

Defined Under Namespace

Classes: AssetNode, Graph, Node, PageNode, Sitemap, Worker

Constant Summary collapse

VERSION =

Version of this gem

"0.1.2"

Class Method Summary collapse

Class Method Details

.process_domain(target_address) ⇒ Graph

Processes the given target domain and creates a page and asset graph.

Parameters:

  • target_address (String)

Returns:

  • (Graph)

    the sitemap graph with pages and static assets



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/aquanaut.rb', line 19

def process_domain(target_address)
  worker = Worker.new(target_address)
  graph = Graph.new

  worker.explore do |page_uri, links, static_assets|
    graph.add_node(PageNode.new(page_uri))

    links.each do |link_uri|
      graph.add_node(PageNode.new(link_uri))
      graph.add_edge(page_uri, link_uri)
    end

    static_assets.each do |asset|
      graph.add_node(AssetNode.new(asset['uri'], asset['type']))
      graph.add_edge(page_uri, asset['uri'])
    end
  end

  return graph
end