Module: Spidr::Actions

Included in:
Agent
Defined in:
lib/spidr/actions/actions.rb,
lib/spidr/actions/exceptions/action.rb,
lib/spidr/actions/exceptions/paused.rb,
lib/spidr/actions/exceptions/skip_link.rb,
lib/spidr/actions/exceptions/skip_page.rb

Overview

The Actions module adds methods to Agent for controlling the spidering of links.

Defined Under Namespace

Classes: Action, Paused, SkipLink, SkipPage

Instance Method Summary collapse

Instance Method Details

#continue! {|page| ... } ⇒ Object

Continue spidering.

Yields:

  • (page)

    If a block is given, it will be passed every page visited.

Yield Parameters:

  • page (Page)

    The page to be visited.



20
21
22
23
# File 'lib/spidr/actions/actions.rb', line 20

def continue!(&block)
  @paused = false
  return run(&block)
end

#initialize_actions(options = {}) ⇒ Object (protected)



79
80
81
# File 'lib/spidr/actions/actions.rb', line 79

def initialize_actions(options={})
  @paused = false
end

#pause!Object

Pauses the agent, causing spidering to temporarily stop.

Raises:

  • (Paused)

    Indicates to the agent, that it should pause spidering.



41
42
43
44
# File 'lib/spidr/actions/actions.rb', line 41

def pause!
  @paused = true
  raise(Paused)
end

#pause=(state) ⇒ Object

Sets the pause state of the agent.

Parameters:

  • state (Boolean)

    The new pause state of the agent.



31
32
33
# File 'lib/spidr/actions/actions.rb', line 31

def pause=(state)
  @paused = state
end

#paused?Boolean

Determines whether the agent is paused.

Returns:

  • (Boolean)

    Specifies whether the agent is paused.



52
53
54
# File 'lib/spidr/actions/actions.rb', line 52

def paused?
  @paused == true
end

#skip_link!Object

Causes the agent to skip the link being enqueued.

Raises:

  • (SkipLink)

    Indicates to the agent, that the current link should be skipped, and not enqueued or visited.



63
64
65
# File 'lib/spidr/actions/actions.rb', line 63

def skip_link!
  raise(SkipLink)
end

#skip_page!Object

Causes the agent to skip the page being visited.

Raises:

  • (SkipPage)

    Indicates to the agent, that the current page should be skipped.



73
74
75
# File 'lib/spidr/actions/actions.rb', line 73

def skip_page!
  raise(SkipPage)
end