Class: Vedeu::Runtime::Application Private
- Inherits:
-
Object
- Object
- Vedeu::Runtime::Application
- Defined in:
- lib/vedeu/runtime/application.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Orchestrates the running of the main application loop.
Class Method Summary collapse
- .restart ⇒ void private
- .start ⇒ void private
-
.stop ⇒ void
(also: exit)
private
Stops the application! - The ‘:cleanup` event is triggered, which in turn triggers the client event `:cleanup`; the client application may treat this event as Vedeu signalling that it is about to terminate.
Instance Method Summary collapse
-
#initialize ⇒ Vedeu::Runtime::Application
constructor
private
Returns a new instance of Vedeu::Runtime::Application.
-
#main_sequence ⇒ void
private
private
For an interactive application we capture input, (usually from the user), and continue the main loop.
-
#run_many(&block) ⇒ void
private
private
Runs the application in a continuous loop.
- #run_once(&block) ⇒ void private private
-
#runner(&block) ⇒ void
private
private
Runs the application loop either once, or forever (exceptions and signals permitting).
-
#start ⇒ Array
private
Starts the application!.
Constructor Details
#initialize ⇒ Vedeu::Runtime::Application
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Vedeu::Runtime::Application.
50 |
# File 'lib/vedeu/runtime/application.rb', line 50 def initialize; end |
Class Method Details
.restart ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
21 22 23 |
# File 'lib/vedeu/runtime/application.rb', line 21 def restart new.start end |
.start ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
16 17 18 |
# File 'lib/vedeu/runtime/application.rb', line 16 def start new.start end |
.stop ⇒ void Also known as: exit
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Stops the application! - The ‘:cleanup` event is triggered, which in turn triggers the client event `:cleanup`; the client application may treat this event as Vedeu signalling that it is about to terminate. Client applications are encouraged to use this event to close any open buffers, save files, empty trash, etc.
36 37 38 39 40 |
# File 'lib/vedeu/runtime/application.rb', line 36 def stop Vedeu.trigger(:_cleanup_) Vedeu::Runtime::MainLoop.stop! end |
Instance Method Details
#main_sequence ⇒ void (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
For an interactive application we capture input, (usually from the user), and continue the main loop. If the client application does not require user input then Vedeu triggers the ‘:standalone` event for each run of the main loop. The client application is expected to respond to this event and ’do something useful’. When the client application has finished, it should trigger the ‘:exit` event.
103 104 105 106 107 108 109 110 111 112 |
# File 'lib/vedeu/runtime/application.rb', line 103 def main_sequence if Vedeu.config.interactive? Vedeu::Input::Capture.read else Vedeu.trigger(:_standalone_) Vedeu.refresh end end |
#run_many(&block) ⇒ void (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Runs the application in a continuous loop. This loop is stopped when an uncaught exception occurs or when either the ‘:mode_switch` or `:exit` event is triggered.
120 121 122 123 124 125 |
# File 'lib/vedeu/runtime/application.rb', line 120 def run_many(&block) Vedeu::Runtime::MainLoop.start! { yield } rescue Vedeu::Error::ModeSwitch Vedeu::Runtime::Application.restart end |
#run_once(&block) ⇒ void (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
129 130 131 132 133 |
# File 'lib/vedeu/runtime/application.rb', line 129 def run_once(&block) # Vedeu.debug(binding) yield end |
#runner(&block) ⇒ void (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Runs the application loop either once, or forever (exceptions and signals permitting).
84 85 86 87 88 89 90 91 92 |
# File 'lib/vedeu/runtime/application.rb', line 84 def runner(&block) if Vedeu.config.once? run_once { yield } else run_many { yield } end end |
#start ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Starts the application!
-
A new terminal screen is opened (or rather the current terminal is requested into either :raw or :cooked mode).
-
The cursor visibility is then set dependent on this mode. In :raw mode, the cursor is hidden.
-
The ‘:initialize` event is triggered. The client application is may treat this event as Vedeu signalling that it is now ready.
-
We enter into the main sequence where the application will either run once or continuous, interactively or standalone.
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/vedeu/runtime/application.rb', line 65 def start Vedeu.trigger(:_drb_start_) Vedeu::Terminal.open do Vedeu::Terminal.set_cursor_mode Vedeu.trigger(:_initialize_) runner { main_sequence } end end |