vedeu 0.6.9 → 0.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/lib/vedeu/all.rb +3 -3
- data/lib/vedeu/api/external.rb +194 -0
- data/lib/vedeu/api/internal.rb +173 -0
- data/lib/vedeu/application/controller.rb +3 -2
- data/lib/vedeu/bindings/application.rb +1 -1
- data/lib/vedeu/bindings/drb.rb +2 -3
- data/lib/vedeu/bindings/movement.rb +1 -1
- data/lib/vedeu/buffers/all.rb +0 -2
- data/lib/vedeu/colours/translator.rb +2 -1
- data/lib/vedeu/common.rb +4 -2
- data/lib/vedeu/configuration/api.rb +1 -1
- data/lib/vedeu/configuration/cli.rb +1 -1
- data/lib/vedeu/cursors/repository.rb +1 -1
- data/lib/vedeu/editor/insert.rb +12 -13
- data/lib/vedeu/geometry/position.rb +1 -1
- data/lib/vedeu/models/cell.rb +35 -21
- data/lib/vedeu/models/escape.rb +18 -1
- data/lib/vedeu/models/page.rb +20 -10
- data/lib/vedeu/models/row.rb +18 -8
- data/lib/vedeu/models/views/char.rb +9 -7
- data/lib/vedeu/models/views/view.rb +1 -1
- data/lib/vedeu/output/compressor.rb +22 -14
- data/lib/vedeu/output/output.rb +1 -10
- data/lib/vedeu/output/renderers/escape_sequence.rb +8 -4
- data/lib/vedeu/output/renderers/file.rb +7 -23
- data/lib/vedeu/output/renderers/html.rb +47 -26
- data/lib/vedeu/output/renderers/json.rb +11 -16
- data/lib/vedeu/output/renderers/null.rb +1 -1
- data/lib/vedeu/output/renderers/renderer_options.rb +2 -1
- data/lib/vedeu/output/renderers/terminal.rb +7 -15
- data/lib/vedeu/output/renderers/text.rb +1 -1
- data/lib/vedeu/output/viewport.rb +154 -143
- data/lib/vedeu/repositories/collection.rb +2 -2
- data/lib/vedeu/repositories/model.rb +25 -26
- data/lib/vedeu/repositories/registerable.rb +9 -8
- data/lib/vedeu/repositories/repository.rb +21 -16
- data/lib/vedeu/repositories/store.rb +6 -4
- data/lib/vedeu/runtime/bootstrap.rb +7 -5
- data/lib/vedeu/runtime/main_loop.rb +2 -0
- data/lib/vedeu/runtime/router.rb +155 -149
- data/lib/vedeu/templating/decoder.rb +8 -5
- data/lib/vedeu/templating/encoder.rb +6 -4
- data/lib/vedeu/templating/template.rb +2 -2
- data/lib/vedeu/templating/view_template.rb +8 -7
- data/lib/vedeu/terminal/buffer.rb +132 -0
- data/lib/vedeu/terminal/terminal.rb +0 -5
- data/lib/vedeu/version.rb +1 -1
- data/lib/vedeu.rb +2 -2
- data/out_ +50 -0
- data/test/lib/vedeu/api/external_test.rb +62 -0
- data/test/lib/vedeu/{internal_api_test.rb → api/internal_test.rb} +6 -2
- data/test/lib/vedeu/application/controller_test.rb +3 -3
- data/test/lib/vedeu/bindings/application_test.rb +2 -2
- data/test/lib/vedeu/models/cell_test.rb +48 -17
- data/test/lib/vedeu/models/escape_test.rb +29 -7
- data/test/lib/vedeu/models/page_test.rb +70 -50
- data/test/lib/vedeu/models/row_test.rb +40 -20
- data/test/lib/vedeu/output/compressor_test.rb +12 -12
- data/test/lib/vedeu/output/output_test.rb +17 -23
- data/test/lib/vedeu/output/renderers/escape_sequence_test.rb +15 -11
- data/test/lib/vedeu/output/renderers/html_test.rb +66 -68
- data/test/lib/vedeu/output/renderers/json_test.rb +36 -83
- data/test/lib/vedeu/output/renderers/terminal_test.rb +22 -2
- data/test/lib/vedeu/output/viewport_test.rb +201 -197
- data/test/lib/vedeu/runtime/router_test.rb +144 -140
- data/test/lib/vedeu/terminal/buffer_test.rb +307 -0
- data/test/support/examples/material_colours_app.rb +2 -2
- data/test/support/templates/html_renderer.vedeu +24 -0
- metadata +14 -17
- data/lib/vedeu/api.rb +0 -190
- data/lib/vedeu/buffers/virtual_buffer.rb +0 -136
- data/lib/vedeu/buffers/virtual_buffers.rb +0 -77
- data/lib/vedeu/internal_api.rb +0 -173
- data/lib/vedeu/terminal/content.rb +0 -88
- data/test/lib/vedeu/api_test.rb +0 -58
- data/test/lib/vedeu/buffers/virtual_buffer_test.rb +0 -148
- data/test/lib/vedeu/buffers/virtual_buffers_test.rb +0 -73
- data/test/lib/vedeu/terminal/content_test.rb +0 -108
data/lib/vedeu/models/escape.rb
CHANGED
|
@@ -34,7 +34,7 @@ module Vedeu
|
|
|
34
34
|
|
|
35
35
|
# An object is equal when its values are the same.
|
|
36
36
|
#
|
|
37
|
-
# @param other [Vedeu::
|
|
37
|
+
# @param other [Vedeu::Models::Escape]
|
|
38
38
|
# @return [Boolean]
|
|
39
39
|
def eql?(other)
|
|
40
40
|
self.class == other.class && value == other.value
|
|
@@ -46,6 +46,23 @@ module Vedeu
|
|
|
46
46
|
Vedeu::Geometry::Position.coerce(@position)
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
+
# Return an empty hash as most escape sequences won't make
|
|
50
|
+
# sense as JSON.
|
|
51
|
+
#
|
|
52
|
+
# @return [Hash<void>]
|
|
53
|
+
def to_hash
|
|
54
|
+
{}
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Return an empty string as most escape sequences won't make
|
|
58
|
+
# sense as HTML.
|
|
59
|
+
#
|
|
60
|
+
# @param options [Hash] Ignored.
|
|
61
|
+
# @return [String]
|
|
62
|
+
def to_html(_options = {})
|
|
63
|
+
''
|
|
64
|
+
end
|
|
65
|
+
|
|
49
66
|
# @return [String]
|
|
50
67
|
def to_s
|
|
51
68
|
"#{position}#{value}"
|
data/lib/vedeu/models/page.rb
CHANGED
|
@@ -52,6 +52,21 @@ module Vedeu
|
|
|
52
52
|
@rows = rows || []
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
# @return [Array<void>]
|
|
56
|
+
def content
|
|
57
|
+
rows.map(&:content).flatten
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# @param row_index [Fixnum]
|
|
61
|
+
# @param cell_index [Fixnum]
|
|
62
|
+
# @return [NilClass|void]
|
|
63
|
+
def cell(row_index = nil, cell_index = nil)
|
|
64
|
+
return nil if row_index.nil? || cell_index.nil?
|
|
65
|
+
return nil unless row(row_index)
|
|
66
|
+
|
|
67
|
+
row(row_index)[cell_index]
|
|
68
|
+
end
|
|
69
|
+
|
|
55
70
|
# Provides iteration over the collection.
|
|
56
71
|
#
|
|
57
72
|
# @param block [Proc]
|
|
@@ -60,6 +75,11 @@ module Vedeu
|
|
|
60
75
|
rows.each(&block)
|
|
61
76
|
end
|
|
62
77
|
|
|
78
|
+
# @return [Boolean]
|
|
79
|
+
def empty?
|
|
80
|
+
rows.empty?
|
|
81
|
+
end
|
|
82
|
+
|
|
63
83
|
# An object is equal when its values are the same.
|
|
64
84
|
#
|
|
65
85
|
# @param other [Vedeu::Models::Page]
|
|
@@ -77,16 +97,6 @@ module Vedeu
|
|
|
77
97
|
rows[index]
|
|
78
98
|
end
|
|
79
99
|
|
|
80
|
-
# @param row_index [Fixnum]
|
|
81
|
-
# @param cell_index [Fixnum]
|
|
82
|
-
# @return [NilClass|void]
|
|
83
|
-
def cell(row_index = nil, cell_index = nil)
|
|
84
|
-
return nil if row_index.nil? || cell_index.nil?
|
|
85
|
-
return nil unless row(row_index)
|
|
86
|
-
|
|
87
|
-
row(row_index)[cell_index]
|
|
88
|
-
end
|
|
89
|
-
|
|
90
100
|
end # Page
|
|
91
101
|
|
|
92
102
|
end # Models
|
data/lib/vedeu/models/row.rb
CHANGED
|
@@ -38,6 +38,19 @@ module Vedeu
|
|
|
38
38
|
@cells = cells || []
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
+
# @param index [Fixnum]
|
|
42
|
+
# @return [NilClass|void]
|
|
43
|
+
def cell(index)
|
|
44
|
+
return nil if index.nil?
|
|
45
|
+
|
|
46
|
+
cells[index]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# @return [Array<void>]
|
|
50
|
+
def content
|
|
51
|
+
cells.flatten
|
|
52
|
+
end
|
|
53
|
+
|
|
41
54
|
# Provides iteration over the collection.
|
|
42
55
|
#
|
|
43
56
|
# @param block [Proc]
|
|
@@ -46,6 +59,11 @@ module Vedeu
|
|
|
46
59
|
cells.each(&block)
|
|
47
60
|
end
|
|
48
61
|
|
|
62
|
+
# @return [Boolean]
|
|
63
|
+
def empty?
|
|
64
|
+
cells.empty?
|
|
65
|
+
end
|
|
66
|
+
|
|
49
67
|
# An object is equal when its values are the same.
|
|
50
68
|
#
|
|
51
69
|
# @param other [Vedeu::Models::Row]
|
|
@@ -55,14 +73,6 @@ module Vedeu
|
|
|
55
73
|
end
|
|
56
74
|
alias_method :==, :eql?
|
|
57
75
|
|
|
58
|
-
# @param index [Fixnum]
|
|
59
|
-
# @return [NilClass|void]
|
|
60
|
-
def cell(index)
|
|
61
|
-
return nil if index.nil?
|
|
62
|
-
|
|
63
|
-
cells[index]
|
|
64
|
-
end
|
|
65
|
-
|
|
66
76
|
end # Row
|
|
67
77
|
|
|
68
78
|
end # Models
|
|
@@ -47,7 +47,7 @@ module Vedeu
|
|
|
47
47
|
@value = @attributes[:value]
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
# When {Vedeu::Viewport#show} has less lines that required to fill
|
|
50
|
+
# When {Vedeu::Output::Viewport#show} has less lines that required to fill
|
|
51
51
|
# the visible area of the interface, it creates a line that contains a
|
|
52
52
|
# single {Vedeu::Views::Char} containing a space (0x20); later, attempts
|
|
53
53
|
# to call `#chars` on an expected {Vedeu::Views::Line} and fail; this
|
|
@@ -114,7 +114,7 @@ module Vedeu
|
|
|
114
114
|
# Vedeu::Views::Char, however, at the moment, `:parent` cannot be
|
|
115
115
|
# coerced.
|
|
116
116
|
#
|
|
117
|
-
# @return [Hash]
|
|
117
|
+
# @return [Hash<Symbol => Hash, String>]
|
|
118
118
|
def to_hash
|
|
119
119
|
{
|
|
120
120
|
border: border.to_s,
|
|
@@ -126,14 +126,16 @@ module Vedeu
|
|
|
126
126
|
}
|
|
127
127
|
end
|
|
128
128
|
|
|
129
|
+
# @param options [Hash<Symbol => String>]
|
|
130
|
+
# See {Vedeu::Views::HTMLChar#initialize}
|
|
129
131
|
# @return [String]
|
|
130
|
-
def to_html
|
|
131
|
-
@to_html ||= Vedeu::Views::HTMLChar.render(self)
|
|
132
|
+
def to_html(options = {})
|
|
133
|
+
@to_html ||= Vedeu::Views::HTMLChar.render(self, options)
|
|
132
134
|
end
|
|
133
135
|
|
|
134
136
|
private
|
|
135
137
|
|
|
136
|
-
# @return [Hash]
|
|
138
|
+
# @return [Hash<Symbol => String>]
|
|
137
139
|
def colour_to_hash
|
|
138
140
|
{
|
|
139
141
|
background: background.to_s,
|
|
@@ -141,7 +143,7 @@ module Vedeu
|
|
|
141
143
|
}
|
|
142
144
|
end
|
|
143
145
|
|
|
144
|
-
# @return [Hash]
|
|
146
|
+
# @return [Hash<Symbol => String>]
|
|
145
147
|
def parent_to_hash
|
|
146
148
|
if parent
|
|
147
149
|
{
|
|
@@ -156,7 +158,7 @@ module Vedeu
|
|
|
156
158
|
end
|
|
157
159
|
end
|
|
158
160
|
|
|
159
|
-
# @return [
|
|
161
|
+
# @return [Has<Symbol => Fixnum>]
|
|
160
162
|
def position_to_hash
|
|
161
163
|
{
|
|
162
164
|
y: y,
|
|
@@ -76,7 +76,7 @@ module Vedeu
|
|
|
76
76
|
output = [
|
|
77
77
|
Vedeu::Cursors::Cursor.hide_cursor(name),
|
|
78
78
|
Vedeu::Clear::NamedInterface.render(name),
|
|
79
|
-
Vedeu::Viewport.render(self),
|
|
79
|
+
Vedeu::Output::Viewport.render(self),
|
|
80
80
|
Vedeu.borders.by_name(name).render,
|
|
81
81
|
Vedeu::Cursors::Cursor.show_cursor(name),
|
|
82
82
|
]
|
|
@@ -29,13 +29,9 @@ module Vedeu
|
|
|
29
29
|
# Takes approximately ~25ms for 2100 chars. (2015-07-25)
|
|
30
30
|
# @return [String]
|
|
31
31
|
def render
|
|
32
|
-
if Vedeu::Configuration.compression?
|
|
33
|
-
compress
|
|
32
|
+
return compress if Vedeu::Configuration.compression?
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
uncompress
|
|
37
|
-
|
|
38
|
-
end
|
|
34
|
+
uncompress
|
|
39
35
|
end
|
|
40
36
|
|
|
41
37
|
protected
|
|
@@ -46,22 +42,34 @@ module Vedeu
|
|
|
46
42
|
|
|
47
43
|
private
|
|
48
44
|
|
|
45
|
+
def content
|
|
46
|
+
return [] if output.nil? || output.empty?
|
|
47
|
+
|
|
48
|
+
output.content.delete_if { |cell| cell.is_a?(Vedeu::Models::Cell) }
|
|
49
|
+
end
|
|
50
|
+
|
|
49
51
|
# @return [String]
|
|
50
52
|
def compress
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
Vedeu.timer('Compression') do
|
|
54
|
+
out = ''
|
|
55
|
+
|
|
56
|
+
content.each do |cell|
|
|
57
|
+
out << cell.position.to_s
|
|
58
|
+
out << colour_for(cell)
|
|
59
|
+
out << style_for(cell)
|
|
60
|
+
out << cell.value
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
out
|
|
57
64
|
end
|
|
58
|
-
out
|
|
59
65
|
end
|
|
60
66
|
|
|
61
67
|
# @return [String]
|
|
62
68
|
def uncompress
|
|
63
69
|
out = ''
|
|
64
|
-
|
|
70
|
+
|
|
71
|
+
content.each { |cell| out << cell.to_s }
|
|
72
|
+
|
|
65
73
|
out
|
|
66
74
|
end
|
|
67
75
|
|
data/lib/vedeu/output/output.rb
CHANGED
|
@@ -26,18 +26,9 @@ module Vedeu
|
|
|
26
26
|
#
|
|
27
27
|
# @return [Array]
|
|
28
28
|
def render
|
|
29
|
-
|
|
30
|
-
Vedeu.trigger(:_drb_store_output_, output)
|
|
31
|
-
|
|
32
|
-
# Vedeu::Renderers::HTML.
|
|
33
|
-
# to_file(Vedeu::Buffers::VirtualBuffers.retrieve)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
Vedeu.renderers.render(output) if Vedeu.ready?
|
|
29
|
+
Vedeu::Terminal::Buffer.write(output).render
|
|
37
30
|
end
|
|
38
31
|
|
|
39
|
-
protected
|
|
40
|
-
|
|
41
32
|
# @!attribute [r] output
|
|
42
33
|
# @return [Array<Array<Vedeu::Views::Char>>]
|
|
43
34
|
attr_reader :output
|
|
@@ -18,12 +18,16 @@ module Vedeu
|
|
|
18
18
|
|
|
19
19
|
# Render the output with the escape sequences escaped.
|
|
20
20
|
#
|
|
21
|
-
# @param output [
|
|
21
|
+
# @param output [Vedeu::Models::Page]
|
|
22
22
|
# @return [String]
|
|
23
23
|
def render(output)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
out = ''
|
|
25
|
+
|
|
26
|
+
output.each do |row|
|
|
27
|
+
row.each { |cell| out << Vedeu::Esc.escape(cell.to_s) }
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
out
|
|
27
31
|
end
|
|
28
32
|
|
|
29
33
|
end # EscapeSequence
|
|
@@ -6,18 +6,22 @@ module Vedeu
|
|
|
6
6
|
#
|
|
7
7
|
class File
|
|
8
8
|
|
|
9
|
+
include Vedeu::RendererOptions
|
|
10
|
+
|
|
9
11
|
# Returns a new instance of Vedeu::Renderers::File.
|
|
10
12
|
#
|
|
11
13
|
# @param options [Hash]
|
|
12
14
|
# @option options filename [String] Provide a filename for the output.
|
|
13
15
|
# Defaults to 'out'.
|
|
14
16
|
# @option options timestamp [Boolean] Append a timestamp to the filename.
|
|
17
|
+
# @option options write_file [Boolean] Whether to write the file to the
|
|
18
|
+
# given filename.
|
|
15
19
|
# @return [Vedeu::Renderers::File]
|
|
16
20
|
def initialize(options = {})
|
|
17
21
|
@options = options || {}
|
|
18
22
|
end
|
|
19
23
|
|
|
20
|
-
# @param output [
|
|
24
|
+
# @param output [Vedeu::Models::Page]
|
|
21
25
|
# @return [String]
|
|
22
26
|
def render(output)
|
|
23
27
|
::File.write(filename, output) if write_file?
|
|
@@ -29,25 +33,12 @@ module Vedeu
|
|
|
29
33
|
|
|
30
34
|
# @return [String]
|
|
31
35
|
def filename
|
|
32
|
-
|
|
33
|
-
"#{options[:filename]}_#{timestamp}"
|
|
34
|
-
|
|
35
|
-
else
|
|
36
|
-
options[:filename]
|
|
37
|
-
|
|
38
|
-
end
|
|
36
|
+
options[:filename] + "_#{timestamp}"
|
|
39
37
|
end
|
|
40
38
|
|
|
41
39
|
# @return [Float]
|
|
42
40
|
def timestamp
|
|
43
|
-
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
# @return [Boolean]
|
|
47
|
-
def timestamp?
|
|
48
|
-
return true if options[:timestamp]
|
|
49
|
-
|
|
50
|
-
false
|
|
41
|
+
Time.now.to_f if options[:timestamp]
|
|
51
42
|
end
|
|
52
43
|
|
|
53
44
|
# @return [Boolean]
|
|
@@ -55,13 +46,6 @@ module Vedeu
|
|
|
55
46
|
options[:write_file]
|
|
56
47
|
end
|
|
57
48
|
|
|
58
|
-
# Combines the options provided at instantiation with the default values.
|
|
59
|
-
#
|
|
60
|
-
# @return [Hash]
|
|
61
|
-
def options
|
|
62
|
-
defaults.merge!(@options)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
49
|
# Returns the default options/attributes for this class.
|
|
66
50
|
#
|
|
67
51
|
# @return [Hash]
|
|
@@ -2,55 +2,74 @@ module Vedeu
|
|
|
2
2
|
|
|
3
3
|
module Renderers
|
|
4
4
|
|
|
5
|
-
# Renders a {Vedeu::
|
|
6
|
-
#
|
|
5
|
+
# Renders a {Vedeu::Terminal::Buffer} as a HTML snippet; a table
|
|
6
|
+
# by default.
|
|
7
7
|
#
|
|
8
8
|
class HTML < Vedeu::Renderers::File
|
|
9
9
|
|
|
10
10
|
# Returns a new instance of Vedeu::Renderers::HTML.
|
|
11
11
|
#
|
|
12
12
|
# @param options [Hash]
|
|
13
|
-
# @option options content [String]
|
|
14
|
-
# @option options
|
|
15
|
-
# @option options
|
|
13
|
+
# @option options content [String] Defaults to an empty string.
|
|
14
|
+
# @option options end_tag [String] Defaults to '</td>'.
|
|
15
|
+
# @option options end_row_tag [String] Defaults to '</tr>'.
|
|
16
|
+
# @option options filename [String] Provide a filename for the output.
|
|
17
|
+
# Defaults to 'out'.
|
|
18
|
+
# @option options start_tag [String] Defaults to '<td' (note the end of
|
|
19
|
+
# the tag is missing, this is so that inline styles can be added later).
|
|
20
|
+
# @option options start_row_tag [String] Defaults to '<tr>'.
|
|
16
21
|
# @option options template [String]
|
|
22
|
+
# @option options timestamp [Boolean] Append a timestamp to the filename.
|
|
23
|
+
# @option options write_file [Boolean] Whether to write the file to the
|
|
24
|
+
# given filename.
|
|
17
25
|
# @return [Vedeu::Renderers::HTML]
|
|
18
26
|
def initialize(options = {})
|
|
19
27
|
@options = options || {}
|
|
28
|
+
@output = nil
|
|
20
29
|
end
|
|
21
30
|
|
|
22
|
-
# @param output [
|
|
31
|
+
# @param output [Vedeu::Models::Page]
|
|
23
32
|
# @return [String]
|
|
24
33
|
def render(output)
|
|
25
|
-
@
|
|
34
|
+
@output = output
|
|
26
35
|
|
|
27
|
-
super(Vedeu::Templating::Template.parse(self, template))
|
|
36
|
+
super(Vedeu::Templating::Template.parse(self, template)) unless escape?
|
|
28
37
|
end
|
|
29
38
|
|
|
30
39
|
# @return [String]
|
|
31
40
|
def html_body
|
|
32
|
-
return '' if
|
|
41
|
+
return '' if output.is_a?(Vedeu::Models::Escape)
|
|
33
42
|
|
|
34
43
|
out = ''
|
|
35
44
|
|
|
36
|
-
|
|
45
|
+
output.each do |line|
|
|
37
46
|
out << "#{start_row_tag}\n"
|
|
38
|
-
line.each
|
|
39
|
-
if char.is_a?(Vedeu::Views::Char)
|
|
40
|
-
out << char.to_html
|
|
41
|
-
out << "\n"
|
|
42
|
-
end
|
|
43
|
-
end
|
|
47
|
+
line.each { |char| out << char.to_html(options) }
|
|
44
48
|
out << "#{end_row_tag}\n"
|
|
45
49
|
end
|
|
50
|
+
|
|
46
51
|
out
|
|
47
52
|
end
|
|
48
53
|
|
|
49
54
|
private
|
|
50
55
|
|
|
56
|
+
# Returns a boolean indicating whether the output is a
|
|
57
|
+
# {Vedeu::Models::Escape}. If it is, it won't be rendered in
|
|
58
|
+
# HTML.
|
|
59
|
+
#
|
|
60
|
+
# @return [Boolean]
|
|
61
|
+
def escape?
|
|
62
|
+
output.is_a?(Vedeu::Models::Escape)
|
|
63
|
+
end
|
|
64
|
+
|
|
51
65
|
# @return [Array<Array<Vedeu::Views::Char>>]
|
|
52
|
-
def
|
|
53
|
-
options[:
|
|
66
|
+
def output
|
|
67
|
+
@output || options[:output]
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# @return [String]
|
|
71
|
+
def end_tag
|
|
72
|
+
options[:end_tag]
|
|
54
73
|
end
|
|
55
74
|
|
|
56
75
|
# @return [String]
|
|
@@ -58,6 +77,11 @@ module Vedeu
|
|
|
58
77
|
options[:end_row_tag]
|
|
59
78
|
end
|
|
60
79
|
|
|
80
|
+
# @return [String]
|
|
81
|
+
def start_tag
|
|
82
|
+
options[:start_tag]
|
|
83
|
+
end
|
|
84
|
+
|
|
61
85
|
# @return [String]
|
|
62
86
|
def start_row_tag
|
|
63
87
|
options[:start_row_tag]
|
|
@@ -68,23 +92,20 @@ module Vedeu
|
|
|
68
92
|
options[:template]
|
|
69
93
|
end
|
|
70
94
|
|
|
71
|
-
# Combines the options provided at instantiation with the
|
|
72
|
-
# default values.
|
|
73
|
-
#
|
|
74
|
-
# @return [Hash<Symbol => void>]
|
|
75
|
-
def options
|
|
76
|
-
defaults.merge!(@options)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
95
|
# The default values for a new instance of this class.
|
|
80
96
|
#
|
|
81
97
|
# @return [Hash<Symbol => void>]
|
|
82
98
|
def defaults
|
|
83
99
|
{
|
|
84
100
|
content: '',
|
|
101
|
+
end_tag: '</td>',
|
|
85
102
|
end_row_tag: '</tr>',
|
|
103
|
+
filename: 'out',
|
|
104
|
+
start_tag: '<td',
|
|
86
105
|
start_row_tag: '<tr>',
|
|
87
106
|
template: default_template,
|
|
107
|
+
timestamp: false,
|
|
108
|
+
write_file: true,
|
|
88
109
|
}
|
|
89
110
|
end
|
|
90
111
|
|
|
@@ -2,8 +2,7 @@ module Vedeu
|
|
|
2
2
|
|
|
3
3
|
module Renderers
|
|
4
4
|
|
|
5
|
-
# Renders a {Vedeu::
|
|
6
|
-
# {Vedeu::Output::Output} as JSON.
|
|
5
|
+
# Renders a {Vedeu::Terminal::Buffer} as JSON.
|
|
7
6
|
#
|
|
8
7
|
class JSON < Vedeu::Renderers::File
|
|
9
8
|
|
|
@@ -15,32 +14,28 @@ module Vedeu
|
|
|
15
14
|
@options = options || {}
|
|
16
15
|
end
|
|
17
16
|
|
|
18
|
-
# @param output [
|
|
17
|
+
# @param output [Vedeu::Models::Page]
|
|
19
18
|
# @return [String]
|
|
20
19
|
def render(output)
|
|
21
|
-
|
|
20
|
+
json = parse(output)
|
|
21
|
+
|
|
22
|
+
super(json)
|
|
23
|
+
|
|
24
|
+
json
|
|
22
25
|
end
|
|
23
26
|
|
|
24
27
|
private
|
|
25
28
|
|
|
26
|
-
# @param output [
|
|
29
|
+
# @param output [Vedeu::Models::Page]
|
|
27
30
|
# @return [String]
|
|
28
|
-
def
|
|
29
|
-
return '' if output.nil? || output.empty?
|
|
30
|
-
|
|
31
|
+
def parse(output)
|
|
31
32
|
::JSON.pretty_generate(as_hash(output))
|
|
32
33
|
end
|
|
33
34
|
|
|
34
|
-
# @param output [
|
|
35
|
+
# @param output [Vedeu::Models::Page]
|
|
35
36
|
# @return [Array]
|
|
36
37
|
def as_hash(output)
|
|
37
|
-
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# @param output [Array<Array<Vedeu::Views::Char>>]
|
|
41
|
-
# @return [Array]
|
|
42
|
-
def sorted(output)
|
|
43
|
-
Array(output).flatten.sort_by(&:position)
|
|
38
|
+
output.content.map(&:to_hash)
|
|
44
39
|
end
|
|
45
40
|
|
|
46
41
|
end # JSON
|
|
@@ -17,28 +17,20 @@ module Vedeu
|
|
|
17
17
|
@options = options || {}
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
# @param output [
|
|
20
|
+
# @param output [Vedeu::Models::Page]
|
|
21
21
|
# @return [Array<String>]
|
|
22
22
|
def render(output)
|
|
23
|
-
|
|
23
|
+
output = parse(output)
|
|
24
|
+
|
|
25
|
+
Vedeu::Terminal.output(output)
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
private
|
|
27
29
|
|
|
28
|
-
# @param output [
|
|
30
|
+
# @param output [Vedeu::Models::Page]
|
|
29
31
|
# @return [Array<Array<Vedeu::Views::Char>>]
|
|
30
|
-
def
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Vedeu.timer('Compression') do
|
|
34
|
-
Vedeu::Output::Compressor.render(output)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# @param output [Array<Array<Vedeu::Views::Char>>]
|
|
39
|
-
# @return [Array<Vedeu::Views::Char>]
|
|
40
|
-
def store!(output)
|
|
41
|
-
Vedeu::Terminal::Content.stores(output)
|
|
32
|
+
def parse(output)
|
|
33
|
+
Vedeu::Output::Compressor.render(output)
|
|
42
34
|
end
|
|
43
35
|
|
|
44
36
|
end # Terminal
|