Class: Crabfarm::Live::Manager
- Inherits:
-
Object
- Object
- Crabfarm::Live::Manager
- Extended by:
- Forwardable
- Defined in:
- lib/crabfarm/live/manager.rb
Instance Attribute Summary collapse
-
#browser_adapter ⇒ Object
readonly
Returns the value of attribute browser_adapter.
-
#primary_driver ⇒ Object
readonly
Returns the value of attribute primary_driver.
-
#proxy_port ⇒ Object
readonly
Returns the value of attribute proxy_port.
Instance Method Summary collapse
- #block_requests ⇒ Object
-
#initialize ⇒ Manager
constructor
A new instance of Manager.
- #reset ⇒ Object
- #restart_crabtrap(_memento = nil) ⇒ Object
- #show_content(_content) ⇒ Object
- #show_file(_path) ⇒ Object
- #show_primary_contents ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize ⇒ Manager
Returns a new instance of Manager.
15 16 17 |
# File 'lib/crabfarm/live/manager.rb', line 15 def initialize reserve_port end |
Instance Attribute Details
#browser_adapter ⇒ Object (readonly)
Returns the value of attribute browser_adapter.
11 12 13 |
# File 'lib/crabfarm/live/manager.rb', line 11 def browser_adapter @browser_adapter end |
#primary_driver ⇒ Object (readonly)
Returns the value of attribute primary_driver.
11 12 13 |
# File 'lib/crabfarm/live/manager.rb', line 11 def primary_driver @primary_driver end |
#proxy_port ⇒ Object (readonly)
Returns the value of attribute proxy_port.
11 12 13 |
# File 'lib/crabfarm/live/manager.rb', line 11 def proxy_port @proxy_port end |
Instance Method Details
#block_requests ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/crabfarm/live/manager.rb', line 37 def block_requests begin stop_crabtrap return yield ensure restart_crabtrap nil end end |
#reset ⇒ Object
32 33 34 35 |
# File 'lib/crabfarm/live/manager.rb', line 32 def reset reset_primary_driver @viewer.reset end |
#restart_crabtrap(_memento = nil) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/crabfarm/live/manager.rb', line 60 def restart_crabtrap(_memento=nil) = if _memento path = Utils::Resolve.memento_path _memento raise ConfigurationError.new "No memento found at #{path}" unless File.exists? path { mode: :replay, bucket_path: path } else { mode: :pass } end stop_crabtrap start_crabtrap end |
#show_content(_content) ⇒ Object
50 51 52 |
# File 'lib/crabfarm/live/manager.rb', line 50 def show_content(_content) block_requests { @viewer.show_content(_content) } end |
#show_file(_path) ⇒ Object
46 47 48 |
# File 'lib/crabfarm/live/manager.rb', line 46 def show_file(_path) block_requests { @viewer.show_file(_path) } end |
#show_primary_contents ⇒ Object
54 55 56 57 58 |
# File 'lib/crabfarm/live/manager.rb', line 54 def show_primary_contents unless @viewer_driver.nil? @viewer.show_content(primary_driver.to_html) end end |
#start ⇒ Object
19 20 21 22 23 24 |
# File 'lib/crabfarm/live/manager.rb', line 19 def start restart_crabtrap load_browser_adapter load_primary_driver_and_viewer @viewer.welcome end |
#stop ⇒ Object
26 27 28 29 30 |
# File 'lib/crabfarm/live/manager.rb', line 26 def stop release_primary_driver release_viewer_driver stop_crabtrap end |