Module: Vedeu::Renderers
- Extended by:
- Enumerable, Renderers, Vedeu::Repositories::Storage
- Included in:
- Renderers
- Defined in:
- lib/vedeu/renderers/all.rb,
lib/vedeu/renderers/html.rb,
lib/vedeu/renderers/json.rb,
lib/vedeu/renderers/text.rb,
lib/vedeu/renderers/escape.rb,
lib/vedeu/renderers/terminal.rb,
lib/vedeu/renderers/support/file.rb,
lib/vedeu/renderers/support/options.rb
Overview
Provides a single interface to all registered renderers.
Defined Under Namespace
Modules: Options Classes: Escape, File, HTML, JSON, Terminal, Text
Instance Method Summary collapse
-
#clear ⇒ Array<void>
Instructs each renderer registered with Vedeu to clear their content.
- #in_memory ⇒ Set private
- #mutex ⇒ Mutex private
- #perform(renderer, &block) ⇒ Object 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
- #unthreaded(&block) ⇒ void private
Methods included from Vedeu::Repositories::Storage
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 31 |
# File 'lib/vedeu/renderers/all.rb', line 22 def clear storage.map do |renderer| Vedeu.log(type: :render, message: "Clearing via #{renderer.class.name}") perform(renderer) { renderer.clear } end.each(&:join) if Vedeu.ready? '' end |
#in_memory ⇒ Set (private)
65 66 67 68 69 70 71 72 73 |
# File 'lib/vedeu/renderers/all.rb', line 65 def in_memory if Vedeu.config.renderers.any? Set.new(Vedeu.config.renderers) else Set.new([Vedeu::Renderers::Terminal.new]) end end |
#mutex ⇒ Mutex (private)
88 89 90 |
# File 'lib/vedeu/renderers/all.rb', line 88 def mutex @_mutex ||= Mutex.new end |
#perform(renderer, &block) ⇒ Object (private)
77 78 79 80 81 82 83 84 85 |
# File 'lib/vedeu/renderers/all.rb', line 77 def perform(renderer, &block) if Vedeu.config.threaded? threaded(renderer) { yield } else unthreaded { yield } end end |
#render(output) ⇒ Array<void>
Instructs each renderer registered with Vedeu to render the output as content.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/vedeu/renderers/all.rb', line 51 def render(output) storage.map do |renderer| Vedeu.log(type: :render, message: "Rendering via #{renderer.class.name}") perform(renderer) { renderer.render(output) } end.each(&:join) if Vedeu.ready? output end |
#renderers ⇒ Module
Provides access to the list of renderers.
39 40 41 |
# File 'lib/vedeu/renderers/all.rb', line 39 def renderers self end |
#threaded(renderer, &block) ⇒ void (private)
This method returns an undefined value.
94 95 96 97 98 99 100 101 102 |
# File 'lib/vedeu/renderers/all.rb', line 94 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.
106 107 108 109 110 111 112 |
# File 'lib/vedeu/renderers/all.rb', line 106 def toggle_cursor(&block) Vedeu.trigger(:_hide_cursor_) yield Vedeu.trigger(:_show_cursor_) end |
#unthreaded(&block) ⇒ void (private)
This method returns an undefined value.
116 117 118 119 120 |
# File 'lib/vedeu/renderers/all.rb', line 116 def unthreaded(&block) toggle_cursor do yield end end |