Module: Vedeu::Renderers
- Extended by:
- Enumerable, Renderers, Vedeu::Repositories::Storage
- Included in:
- Renderers
- Defined in:
- lib/vedeu/renderers/all.rb,
lib/vedeu/renderers/file.rb,
lib/vedeu/renderers/html.rb,
lib/vedeu/renderers/json.rb,
lib/vedeu/renderers/text.rb,
lib/vedeu/renderers/escape.rb,
lib/vedeu/renderers/options.rb,
lib/vedeu/renderers/terminal.rb
Overview
Provides a single interface to all registered renderers.
Defined Under Namespace
Modules: Options Classes: Escape, File, HTML, JSON, Terminal, Text
Class Method Summary collapse
-
.clear ⇒ Array<void>
Instructs each renderer registered with Vedeu to clear their content.
- .in_memory ⇒ Set private
- .log(message, renderer) ⇒ void private
- .mutex ⇒ Mutex private
-
.render(output) ⇒ Array<void>
Instructs each renderer registered with Vedeu to render the output as content.
-
.renderers ⇒ Module
Provides access to the list of renderers.
-
.reset! ⇒ void
(also: #reset)
extended
from Vedeu::Repositories::Storage
private
Remove all currently stored data for this repository.
-
.storage ⇒ void
(also: #all)
extended
from Vedeu::Repositories::Storage
private
Return whole repository; provides raw access to the storage for this repository.
- .threaded(renderer, &block) ⇒ void private
- .toggle_cursor(&block) ⇒ void private
Instance Method Summary collapse
-
#clear ⇒ Array<void>
Instructs each renderer registered with Vedeu to clear their content.
- #in_memory ⇒ Set private
- #log(message, renderer) ⇒ void private
- #mutex ⇒ Mutex private
-
#render(output) ⇒ Array<void>
Instructs each renderer registered with Vedeu to render the output as content.
-
#renderers ⇒ Module
Provides access to the list of renderers.
- #threaded(renderer, &block) ⇒ void private
- #toggle_cursor(&block) ⇒ void private
Class Method Details
.clear ⇒ Array<void>
Instructs each renderer registered with Vedeu to clear their content.
22 23 24 25 26 27 28 29 30 |
# File 'lib/vedeu/renderers/all.rb', line 22 def clear storage.map do |renderer| log('Clearing', renderer) threaded(renderer) { renderer.clear } end.each(&:join) if Vedeu.ready? '' end |
.in_memory ⇒ Set (private)
63 64 65 66 67 68 69 70 71 |
# File 'lib/vedeu/renderers/all.rb', line 63 def in_memory if Vedeu.config.renderers.any? Set.new(Vedeu.config.renderers) else Set.new([Vedeu::Renderers::Terminal.new]) end end |
.log(message, renderer) ⇒ void (private)
This method returns an undefined value.
76 77 78 79 |
# File 'lib/vedeu/renderers/all.rb', line 76 def log(, renderer) Vedeu.log(type: :render, message: "#{message} via #{renderer.class.name}") end |
.mutex ⇒ Mutex (private)
82 83 84 |
# File 'lib/vedeu/renderers/all.rb', line 82 def mutex @mutex ||= Mutex.new end |
.render(output) ⇒ Array<void>
Instructs each renderer registered with Vedeu to render the output as content.
50 51 52 53 54 55 56 57 58 |
# File 'lib/vedeu/renderers/all.rb', line 50 def render(output) storage.map do |renderer| log('Rendering', renderer) threaded(renderer) { renderer.render(output) } end.each(&:join) if Vedeu.ready? output end |
.renderers ⇒ Module
Provides access to the list of renderers.
38 39 40 |
# File 'lib/vedeu/renderers/all.rb', line 38 def renderers self end |
.reset! ⇒ void Also known as: reset Originally defined in module Vedeu::Repositories::Storage
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.
Remove all currently stored data for this repository.
.storage ⇒ void Also known as: all Originally defined in module Vedeu::Repositories::Storage
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.
Return whole repository; provides raw access to the storage for this repository.
.threaded(renderer, &block) ⇒ void (private)
This method returns an undefined value.
88 89 90 91 92 93 94 95 96 |
# File 'lib/vedeu/renderers/all.rb', line 88 def threaded(renderer, &block) Thread.new(renderer) do mutex.synchronize do toggle_cursor do yield end end end end |
.toggle_cursor(&block) ⇒ void (private)
This method returns an undefined value.
100 101 102 103 104 105 106 |
# File 'lib/vedeu/renderers/all.rb', line 100 def toggle_cursor(&block) Vedeu.trigger(:_hide_cursor_) yield Vedeu.trigger(:_show_cursor_) end |
Instance Method Details
#clear ⇒ Array<void>
Instructs each renderer registered with Vedeu to clear their content.
22 23 24 25 26 27 28 29 30 |
# File 'lib/vedeu/renderers/all.rb', line 22 def clear storage.map do |renderer| log('Clearing', renderer) threaded(renderer) { renderer.clear } end.each(&:join) if Vedeu.ready? '' end |
#in_memory ⇒ Set (private)
63 64 65 66 67 68 69 70 71 |
# File 'lib/vedeu/renderers/all.rb', line 63 def in_memory if Vedeu.config.renderers.any? Set.new(Vedeu.config.renderers) else Set.new([Vedeu::Renderers::Terminal.new]) end end |
#log(message, renderer) ⇒ void (private)
This method returns an undefined value.
76 77 78 79 |
# File 'lib/vedeu/renderers/all.rb', line 76 def log(, renderer) Vedeu.log(type: :render, message: "#{message} via #{renderer.class.name}") end |
#mutex ⇒ Mutex (private)
82 83 84 |
# File 'lib/vedeu/renderers/all.rb', line 82 def mutex @mutex ||= Mutex.new end |
#render(output) ⇒ Array<void>
Instructs each renderer registered with Vedeu to render the output as content.
50 51 52 53 54 55 56 57 58 |
# File 'lib/vedeu/renderers/all.rb', line 50 def render(output) storage.map do |renderer| log('Rendering', renderer) threaded(renderer) { renderer.render(output) } end.each(&:join) if Vedeu.ready? output end |
#renderers ⇒ Module
Provides access to the list of renderers.
38 39 40 |
# File 'lib/vedeu/renderers/all.rb', line 38 def renderers self end |
#threaded(renderer, &block) ⇒ void (private)
This method returns an undefined value.
88 89 90 91 92 93 94 95 96 |
# File 'lib/vedeu/renderers/all.rb', line 88 def threaded(renderer, &block) Thread.new(renderer) do mutex.synchronize do toggle_cursor do yield end end end end |
#toggle_cursor(&block) ⇒ void (private)
This method returns an undefined value.
100 101 102 103 104 105 106 |
# File 'lib/vedeu/renderers/all.rb', line 100 def toggle_cursor(&block) Vedeu.trigger(:_hide_cursor_) yield Vedeu.trigger(:_show_cursor_) end |