vedeu 0.4.50 → 0.4.51
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +0 -5
- data/examples/material_colours_app.rb +1 -1
- data/examples/panel_app.rb +1 -1
- data/lib/vedeu/cli/generator/templates/application/config/configuration.erb +7 -2
- data/lib/vedeu/configuration/configuration.rb +1 -1
- data/lib/vedeu/output/border.rb +0 -6
- data/lib/vedeu/output/clear/named_interface.rb +2 -2
- data/lib/vedeu/output/output.rb +12 -12
- data/lib/vedeu/output/render_border.rb +1 -1
- data/lib/vedeu/output/renderers/all.rb +10 -5
- data/lib/vedeu/output/renderers/escape_sequence.rb +21 -23
- data/lib/vedeu/output/renderers/file.rb +16 -27
- data/lib/vedeu/output/renderers/html.rb +36 -42
- data/lib/vedeu/output/renderers/json.rb +22 -5
- data/lib/vedeu/output/renderers/null.rb +28 -3
- data/lib/vedeu/output/renderers/terminal.rb +23 -19
- data/lib/vedeu/output/renderers/text.rb +18 -20
- data/lib/vedeu/output/virtual_terminal.rb +1 -1
- data/lib/vedeu/support/template.rb +1 -1
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/application/application_controller_test.rb +2 -0
- data/test/lib/vedeu/application/application_helper_test.rb +2 -0
- data/test/lib/vedeu/application/controller_test.rb +1 -1
- data/test/lib/vedeu/application/helper_test.rb +2 -0
- data/test/lib/vedeu/application/view_test.rb +2 -0
- data/test/lib/vedeu/buffers/buffer_test.rb +1 -1
- data/test/lib/vedeu/buffers/display_buffer_test.rb +2 -0
- data/test/lib/vedeu/cli/generator/application_test.rb +2 -0
- data/test/lib/vedeu/cli/generator/helpers_test.rb +1 -0
- data/test/lib/vedeu/configuration/api_test.rb +3 -0
- data/test/lib/vedeu/cursor/move_test.rb +5 -0
- data/test/lib/vedeu/distributed/client_test.rb +4 -0
- data/test/lib/vedeu/distributed/server_test.rb +9 -0
- data/test/lib/vedeu/dsl/use_test.rb +4 -0
- data/test/lib/vedeu/launcher_test.rb +2 -0
- data/test/lib/vedeu/main_loop_test.rb +2 -0
- data/test/lib/vedeu/null/interface_test.rb +1 -0
- data/test/lib/vedeu/output/border_test.rb +0 -8
- data/test/lib/vedeu/output/output_test.rb +12 -11
- data/test/lib/vedeu/output/refresh_test.rb +1 -0
- data/test/lib/vedeu/output/render_border_test.rb +1 -0
- data/test/lib/vedeu/output/renderers/all_test.rb +4 -8
- data/test/lib/vedeu/output/renderers/escape_sequence_test.rb +5 -4
- data/test/lib/vedeu/output/renderers/file_test.rb +14 -19
- data/test/lib/vedeu/output/renderers/html_test.rb +55 -56
- data/test/lib/vedeu/output/renderers/json_test.rb +4 -5
- data/test/lib/vedeu/output/renderers/null_test.rb +9 -3
- data/test/lib/vedeu/output/renderers/terminal_test.rb +5 -4
- data/test/lib/vedeu/output/renderers/text_test.rb +5 -4
- data/test/lib/vedeu/output/text_test.rb +2 -0
- data/test/lib/vedeu/output/virtual_terminal_test.rb +10 -28
- data/test/lib/vedeu/repositories/collection_test.rb +1 -0
- data/test/lib/vedeu/repositories/model_test.rb +3 -0
- data/test/lib/vedeu/repositories/repository_test.rb +1 -0
- data/test/lib/vedeu/support/visibility_test.rb +1 -0
- data/test/lib/vedeu/traps_test.rb +1 -0
- data/test/lib/vedeu_test.rb +1 -0
- data/vedeu.gemspec +0 -2
- metadata +2 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51f8100764995bff505583f3dc874821dcb56fc9
|
4
|
+
data.tar.gz: 9064e5dfd73320ad37281d8cb112d77439ebc641
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae6180723fb6977e5da0efd16ae9a0250feaa89a1ff5e0d813ae8a24d0c399b9086aaa49ab33940fb9fc5ea9652fadf87fb21933c96af17f201cfdc403d51cf5
|
7
|
+
data.tar.gz: 9aafcd3c738dde584d38ae6dc0a5e26b552c18f2c498d00dca86cf755dfe76b60d3b518e93343304646cb02d856916774c9400ca23c393cd20c8cc10fb16778a
|
data/Guardfile
CHANGED
data/examples/panel_app.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
Vedeu.configure do
|
2
|
-
|
2
|
+
# base_path
|
3
3
|
|
4
|
-
colour_mode 16_777_216
|
4
|
+
# colour_mode 16_777_216 # Some terminals don't render colour at all if this
|
5
|
+
# value is not one of 8, 16, 256 or 16777216.
|
5
6
|
|
6
7
|
# debug! # Add "gem 'ruby-prof'" to your Gemfile if uncommenting this line.
|
7
8
|
# drb!
|
@@ -13,6 +14,10 @@ Vedeu.configure do
|
|
13
14
|
# cooked!
|
14
15
|
# raw!
|
15
16
|
|
17
|
+
log "/tmp/<%= object.name %>.log"
|
18
|
+
|
19
|
+
# renderers
|
20
|
+
|
16
21
|
# run_once!
|
17
22
|
|
18
23
|
# interactive!
|
data/lib/vedeu/output/border.rb
CHANGED
@@ -66,8 +66,8 @@ module Vedeu
|
|
66
66
|
@height = geometry.height
|
67
67
|
@colour = interface.colour
|
68
68
|
|
69
|
-
@clear ||= Array.new(@
|
70
|
-
Array.new(@
|
69
|
+
@clear ||= Array.new(@height) do |iy|
|
70
|
+
Array.new(@width) do |ix|
|
71
71
|
Vedeu::Char.new(value: ' ',
|
72
72
|
colour: @colour,
|
73
73
|
position: [@y + iy, @x + ix])
|
data/lib/vedeu/output/output.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
# Sends the
|
3
|
+
# Sends the output to the renderers.
|
4
4
|
#
|
5
5
|
# @api private
|
6
6
|
class Output
|
7
7
|
|
8
|
-
# Writes
|
8
|
+
# Writes output to the defined renderers.
|
9
9
|
#
|
10
10
|
# @return [Array|String]
|
11
11
|
# @see #initialize
|
12
|
-
def self.render(
|
13
|
-
new(
|
12
|
+
def self.render(output)
|
13
|
+
new(output).render
|
14
14
|
end
|
15
15
|
|
16
16
|
# Return a new instance of Vedeu::Output.
|
17
17
|
#
|
18
|
-
# @param
|
18
|
+
# @param output [Array<Array<Vedeu::Char>>]
|
19
19
|
# @return [Output]
|
20
|
-
def initialize(
|
21
|
-
@
|
20
|
+
def initialize(output)
|
21
|
+
@output = output
|
22
22
|
end
|
23
23
|
|
24
24
|
# Send the view to the renderers.
|
@@ -26,19 +26,19 @@ module Vedeu
|
|
26
26
|
# @return [Array]
|
27
27
|
def render
|
28
28
|
if Vedeu::Configuration.drb?
|
29
|
-
Vedeu.trigger(:_drb_store_output_,
|
29
|
+
Vedeu.trigger(:_drb_store_output_, output)
|
30
30
|
|
31
|
-
Vedeu::Renderers::HTML.to_file(Vedeu::VirtualBuffer.retrieve)
|
31
|
+
# Vedeu::Renderers::HTML.to_file(Vedeu::VirtualBuffer.retrieve)
|
32
32
|
end
|
33
33
|
|
34
|
-
Vedeu.renderers.render(
|
34
|
+
Vedeu.renderers.render(output)
|
35
35
|
end
|
36
36
|
|
37
37
|
protected
|
38
38
|
|
39
|
-
# @!attribute [r]
|
39
|
+
# @!attribute [r] output
|
40
40
|
# @return [Array<Array<Vedeu::Char>>]
|
41
|
-
attr_reader :
|
41
|
+
attr_reader :output
|
42
42
|
|
43
43
|
end # Output
|
44
44
|
|
@@ -28,15 +28,18 @@ module Vedeu
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# @example
|
31
|
-
# Vedeu.renderers.render(
|
31
|
+
# Vedeu.renderers.render(output)
|
32
32
|
#
|
33
|
+
# @api public
|
34
|
+
# @param output [void]
|
33
35
|
# @return [Array<void>]
|
34
|
-
def render(
|
36
|
+
def render(output)
|
35
37
|
threads = storage.map do |renderer|
|
36
38
|
Thread.new(renderer) do
|
37
39
|
mutex.synchronize do
|
38
40
|
Vedeu.log(type: :debug, message: "Rendering with: '#{renderer}'")
|
39
|
-
|
41
|
+
|
42
|
+
renderer.render(output)
|
40
43
|
end
|
41
44
|
end
|
42
45
|
end
|
@@ -51,6 +54,7 @@ module Vedeu
|
|
51
54
|
# @note
|
52
55
|
# A renderer class must respond to the '.render' class method.
|
53
56
|
#
|
57
|
+
# @api public
|
54
58
|
# @param renderers [Class]
|
55
59
|
# @return [Set]
|
56
60
|
def renderer(*renderers)
|
@@ -62,18 +66,19 @@ module Vedeu
|
|
62
66
|
# @example
|
63
67
|
# Vedeu.renderers.reset
|
64
68
|
#
|
69
|
+
# @api public
|
65
70
|
# @return [Set]
|
66
71
|
def reset
|
67
72
|
@storage = Set.new
|
68
73
|
end
|
69
74
|
|
75
|
+
private
|
76
|
+
|
70
77
|
# @return [Set]
|
71
78
|
def storage
|
72
79
|
@storage ||= reset
|
73
80
|
end
|
74
81
|
|
75
|
-
private
|
76
|
-
|
77
82
|
# @return [Mutex]
|
78
83
|
def mutex
|
79
84
|
@mutex ||= Mutex.new
|
@@ -7,39 +7,37 @@ module Vedeu
|
|
7
7
|
# @api private
|
8
8
|
class EscapeSequence
|
9
9
|
|
10
|
-
# @param output [Array<Array<Vedeu::Char>>]
|
11
|
-
# @return [String]
|
12
|
-
def self.render(output)
|
13
|
-
new(output).render
|
14
|
-
end
|
15
|
-
|
16
10
|
# Returns a new instance of Vedeu::Renderers::EscapeSequence.
|
17
11
|
#
|
18
|
-
# @param
|
19
|
-
def initialize(
|
20
|
-
@
|
12
|
+
# @param options [Hash]
|
13
|
+
def initialize(options = {})
|
14
|
+
@options = options || {}
|
21
15
|
end
|
22
16
|
|
17
|
+
# Render the output with the escape sequences escaped.
|
18
|
+
#
|
19
|
+
# @param output [Array<Array<Vedeu::Char>>]
|
23
20
|
# @return [String]
|
24
|
-
def render
|
25
|
-
parsed
|
21
|
+
def render(output)
|
22
|
+
@parsed ||= Array(output).flatten.map do |char|
|
23
|
+
Esc.escape(char.to_s) + "\n"
|
24
|
+
end.join
|
26
25
|
end
|
27
26
|
|
28
|
-
protected
|
29
|
-
|
30
|
-
# @!attribute [r] output
|
31
|
-
# @return [Array<Array<Vedeu::Char>>]
|
32
|
-
attr_reader :output
|
33
|
-
|
34
27
|
private
|
35
28
|
|
36
|
-
#
|
29
|
+
# Combines the options provided at instantiation with the default values.
|
37
30
|
#
|
38
|
-
# @return [
|
39
|
-
def
|
40
|
-
@
|
41
|
-
|
42
|
-
|
31
|
+
# @return [Hash<Symbol => void>]
|
32
|
+
def options
|
33
|
+
defaults.merge!(@options)
|
34
|
+
end
|
35
|
+
|
36
|
+
# The default values for a new instance of this class.
|
37
|
+
#
|
38
|
+
# @return [Hash<Symbol => void>]
|
39
|
+
def defaults
|
40
|
+
{}
|
43
41
|
end
|
44
42
|
|
45
43
|
end # EscapeSequence
|
@@ -7,46 +7,27 @@ module Vedeu
|
|
7
7
|
# @api private
|
8
8
|
class File
|
9
9
|
|
10
|
-
# @return [String]
|
11
|
-
# @see Vedeu::Renderers::File#initialize
|
12
|
-
def self.render(output, options = {})
|
13
|
-
new(output, options).render
|
14
|
-
end
|
15
|
-
|
16
10
|
# Returns a new instance of Vedeu::Renderers::File.
|
17
11
|
#
|
18
|
-
# @param output [String]
|
19
12
|
# @param options [Hash]
|
20
13
|
# @option options filename [String] Provide a filename for the output.
|
21
14
|
# Defaults to 'out'.
|
22
15
|
# @option options timestamp [Boolean] Append a timestamp to the filename.
|
23
16
|
# @return [Vedeu::Renderers::File]
|
24
|
-
def initialize(
|
25
|
-
@
|
26
|
-
@options = options
|
17
|
+
def initialize(options = {})
|
18
|
+
@options = options || {}
|
27
19
|
end
|
28
20
|
|
21
|
+
# @param output [Array<Array<Vedeu::Char>>]
|
29
22
|
# @return [String]
|
30
|
-
def render
|
31
|
-
::File.
|
23
|
+
def render(output)
|
24
|
+
::File.write(filename, output) if write_file?
|
32
25
|
|
33
|
-
|
26
|
+
output
|
34
27
|
end
|
35
28
|
|
36
|
-
protected
|
37
|
-
|
38
|
-
# @!attribute [r] output
|
39
|
-
# @return [String]
|
40
|
-
attr_reader :output
|
41
|
-
alias_method :parsed, :output
|
42
|
-
|
43
29
|
private
|
44
30
|
|
45
|
-
# @return [String]
|
46
|
-
def path
|
47
|
-
"/tmp/#{filename}"
|
48
|
-
end
|
49
|
-
|
50
31
|
# @return [String]
|
51
32
|
def filename
|
52
33
|
if timestamp?
|
@@ -70,6 +51,13 @@ module Vedeu
|
|
70
51
|
false
|
71
52
|
end
|
72
53
|
|
54
|
+
# @return [Boolean]
|
55
|
+
def write_file?
|
56
|
+
options[:write_file]
|
57
|
+
end
|
58
|
+
|
59
|
+
# Combines the options provided at instantiation with the default values.
|
60
|
+
#
|
73
61
|
# @return [Hash]
|
74
62
|
def options
|
75
63
|
defaults.merge!(@options)
|
@@ -80,8 +68,9 @@ module Vedeu
|
|
80
68
|
# @return [Hash]
|
81
69
|
def defaults
|
82
70
|
{
|
83
|
-
filename:
|
84
|
-
timestamp:
|
71
|
+
filename: 'out',
|
72
|
+
timestamp: false,
|
73
|
+
write_file: true,
|
85
74
|
}
|
86
75
|
end
|
87
76
|
|
@@ -5,51 +5,34 @@ module Vedeu
|
|
5
5
|
# Renders a {Vedeu::VirtualBuffer} or {Vedeu::Output} as a HTML table.
|
6
6
|
#
|
7
7
|
# @api private
|
8
|
-
class HTML
|
9
|
-
|
10
|
-
# @param output [Array<Array<Vedeu::Char>>]
|
11
|
-
# @return [String]
|
12
|
-
def self.render(output)
|
13
|
-
new(output).to_file
|
14
|
-
end
|
15
|
-
|
16
|
-
# @param output [Array<Array<Vedeu::Char>>]
|
17
|
-
# @param path [String]
|
18
|
-
# @return [String]
|
19
|
-
def self.to_file(output, path = nil)
|
20
|
-
new(output).to_file(path)
|
21
|
-
end
|
8
|
+
class HTML < Vedeu::Renderers::File
|
22
9
|
|
23
10
|
# Returns a new instance of Vedeu::Renderers::HTML.
|
24
11
|
#
|
25
|
-
# @param
|
12
|
+
# @param options [Hash]
|
26
13
|
# @return [Vedeu::Renderers::HTML]
|
27
|
-
def initialize(
|
28
|
-
@
|
14
|
+
def initialize(options = {})
|
15
|
+
@options = options || {}
|
29
16
|
end
|
30
17
|
|
18
|
+
# @param output [Array<Array<Vedeu::Char>>]
|
31
19
|
# @return [String]
|
32
|
-
def render
|
33
|
-
|
34
|
-
end
|
20
|
+
def render(output)
|
21
|
+
@options[:content] = output
|
35
22
|
|
36
|
-
|
37
|
-
|
38
|
-
#
|
39
|
-
# @param path [String]
|
40
|
-
# @return [String]
|
41
|
-
def to_file(path = file_path)
|
42
|
-
content = render
|
23
|
+
if write_file?
|
24
|
+
super(Vedeu::Template.parse(self, template))
|
43
25
|
|
44
|
-
|
26
|
+
else
|
27
|
+
Vedeu::Template.parse(self, template)
|
45
28
|
|
46
|
-
|
29
|
+
end
|
47
30
|
end
|
48
31
|
|
49
32
|
# @return [String]
|
50
33
|
def html_body
|
51
34
|
out = ''
|
52
|
-
Array(
|
35
|
+
Array(content).each do |line|
|
53
36
|
out << "<tr>\n"
|
54
37
|
line.each do |char|
|
55
38
|
if char.is_a?(Vedeu::Char)
|
@@ -62,27 +45,38 @@ module Vedeu
|
|
62
45
|
out
|
63
46
|
end
|
64
47
|
|
65
|
-
|
48
|
+
private
|
66
49
|
|
67
|
-
# @!attribute [r] output
|
68
50
|
# @return [Array<Array<Vedeu::Char>>]
|
69
|
-
|
70
|
-
|
71
|
-
|
51
|
+
def content
|
52
|
+
options[:content]
|
53
|
+
end
|
72
54
|
|
73
55
|
# @return [String]
|
74
56
|
def template
|
75
|
-
|
57
|
+
options[:template]
|
76
58
|
end
|
77
59
|
|
78
|
-
#
|
79
|
-
|
80
|
-
|
60
|
+
# Combines the options provided at instantiation with the default values.
|
61
|
+
#
|
62
|
+
# @return [Hash<Symbol => void>]
|
63
|
+
def options
|
64
|
+
defaults.merge!(@options)
|
65
|
+
end
|
66
|
+
|
67
|
+
# The default values for a new instance of this class.
|
68
|
+
#
|
69
|
+
# @return [Hash<Symbol => void>]
|
70
|
+
def defaults
|
71
|
+
{
|
72
|
+
content: '',
|
73
|
+
template: default_template,
|
74
|
+
}
|
81
75
|
end
|
82
76
|
|
83
|
-
# return [
|
84
|
-
def
|
85
|
-
|
77
|
+
# @return [String]
|
78
|
+
def default_template
|
79
|
+
::File.dirname(__FILE__) + '/../templates/html_renderer.vedeu'
|
86
80
|
end
|
87
81
|
|
88
82
|
end # HTML
|