vedeu 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu/api.rb +3 -1
- data/lib/vedeu/application.rb +1 -1
- data/lib/vedeu/bindings.rb +68 -101
- data/lib/vedeu/cursor/cursor.rb +1 -1
- data/lib/vedeu/cursor/move_cursor.rb +77 -1
- data/lib/vedeu/cursor/toggle_cursor.rb +2 -0
- data/lib/vedeu/distributed/all.rb +7 -0
- data/lib/vedeu/distributed/client.rb +23 -11
- data/lib/vedeu/distributed/server.rb +8 -0
- data/lib/vedeu/distributed/subprocess.rb +0 -24
- data/lib/vedeu/distributed/uri.rb +1 -8
- data/lib/vedeu/dsl/all.rb +3 -0
- data/lib/vedeu/dsl/components/all.rb +4 -4
- data/lib/vedeu/dsl/components/geometry.rb +2 -0
- data/lib/vedeu/dsl/components/keymap.rb +14 -3
- data/lib/vedeu/dsl/group.rb +69 -0
- data/lib/vedeu/dsl/interface.rb +9 -8
- data/lib/vedeu/dsl/shared/text.rb +3 -1
- data/lib/vedeu/events/event.rb +2 -2
- data/lib/vedeu/input/keymap.rb +1 -1
- data/lib/vedeu/models/geometry.rb +1 -1
- data/lib/vedeu/models/group.rb +24 -10
- data/lib/vedeu/models/view/lines.rb +1 -0
- data/lib/vedeu/output/all.rb +6 -1
- data/lib/vedeu/output/border.rb +1 -1
- data/lib/vedeu/{support → output}/esc.rb +0 -0
- data/lib/vedeu/output/foreground.rb +1 -1
- data/lib/vedeu/output/html_char.rb +2 -0
- data/lib/vedeu/output/html_renderer.rb +6 -0
- data/lib/vedeu/output/output.rb +21 -0
- data/lib/vedeu/{support → output}/refresh.rb +1 -1
- data/lib/vedeu/output/renderer.rb +3 -0
- data/lib/vedeu/{support → output}/text.rb +0 -0
- data/lib/vedeu/output/virtual_terminal.rb +2 -0
- data/lib/vedeu/support/all.rb +0 -7
- data/lib/vedeu/support/coercions.rb +7 -4
- data/lib/vedeu/support/terminal.rb +1 -1
- data/lib/vedeu/support/trace.rb +1 -1
- data/lib/vedeu/support/visible.rb +1 -1
- data/test/lib/vedeu/cursor/move_cursor_test.rb +60 -1
- data/test/lib/vedeu/distributed/client_test.rb +21 -2
- data/test/lib/vedeu/dsl/group_test.rb +52 -0
- data/test/lib/vedeu/models/group_test.rb +11 -4
- data/test/lib/vedeu/{support → output}/esc_test.rb +0 -0
- data/test/lib/vedeu/{support → output}/refresh_test.rb +0 -0
- data/test/lib/vedeu/{support → output}/text_test.rb +0 -0
- data/test/test_helper.rb +2 -0
- data/vedeu.gemspec +2 -1
- metadata +28 -24
- data/lib/vedeu/output/writer.rb +0 -44
- data/lib/vedeu/support/console.rb +0 -90
- data/lib/vedeu/support/node.rb +0 -51
- data/lib/vedeu/support/read.rb +0 -66
- data/lib/vedeu/support/write.rb +0 -86
- data/test/lib/vedeu/output/writer_test.rb +0 -32
- data/test/lib/vedeu/support/console_test.rb +0 -138
- data/test/lib/vedeu/support/read_test.rb +0 -86
- data/test/lib/vedeu/support/write_test.rb +0 -158
data/lib/vedeu/output/all.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'vedeu/output/esc'
|
2
|
+
|
1
3
|
require 'vedeu/output/translator'
|
2
4
|
require 'vedeu/output/background'
|
3
5
|
require 'vedeu/output/foreground'
|
@@ -8,17 +10,20 @@ require 'vedeu/output/compositor'
|
|
8
10
|
|
9
11
|
require 'vedeu/output/presentation'
|
10
12
|
require 'vedeu/output/style'
|
13
|
+
require 'vedeu/output/text'
|
11
14
|
require 'vedeu/output/position_index'
|
12
15
|
require 'vedeu/output/index_position'
|
13
16
|
require 'vedeu/output/virtual_buffer'
|
14
17
|
require 'vedeu/output/html_char'
|
15
18
|
require 'vedeu/output/html_renderer'
|
19
|
+
require 'vedeu/output/refresh'
|
20
|
+
|
16
21
|
require 'vedeu/output/renderer'
|
17
22
|
require 'vedeu/output/output'
|
23
|
+
|
18
24
|
require 'vedeu/output/viewport'
|
19
25
|
require 'vedeu/output/virtual_terminal'
|
20
26
|
require 'vedeu/output/wordwrap'
|
21
|
-
require 'vedeu/output/writer'
|
22
27
|
|
23
28
|
module Vedeu
|
24
29
|
end # Vedeu
|
data/lib/vedeu/output/border.rb
CHANGED
File without changes
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
+
# Renders a {Vedeu::VirtualBuffer} or {Vedeu::Output} as a HTML table.
|
4
|
+
#
|
3
5
|
class HTMLRenderer
|
4
6
|
|
5
7
|
# @param output [Array<Array<Vedeu::Char>>]
|
@@ -25,6 +27,9 @@ module Vedeu
|
|
25
27
|
Template.parse(self, template)
|
26
28
|
end
|
27
29
|
|
30
|
+
# Writes the parsed template to a file (at the given path) and returns the
|
31
|
+
# contents.
|
32
|
+
#
|
28
33
|
# @param path [String]
|
29
34
|
# @return [String]
|
30
35
|
def to_file(path = file_path)
|
@@ -53,6 +58,7 @@ module Vedeu
|
|
53
58
|
|
54
59
|
attr_reader :output
|
55
60
|
|
61
|
+
# @return [String]
|
56
62
|
def template
|
57
63
|
File.dirname(__FILE__) + '/templates/html_renderer.vedeu'
|
58
64
|
end
|
data/lib/vedeu/output/output.rb
CHANGED
@@ -4,6 +4,14 @@ module Vedeu
|
|
4
4
|
#
|
5
5
|
class Output
|
6
6
|
|
7
|
+
# Clears the area defined by the interface.
|
8
|
+
#
|
9
|
+
# @return [Array|String]
|
10
|
+
# @see #initialize
|
11
|
+
def self.clear(interface)
|
12
|
+
new(interface).clear
|
13
|
+
end
|
14
|
+
|
7
15
|
# Writes content (the provided interface object with associated lines,
|
8
16
|
# streams, colours and styles) to the area defined by the interface.
|
9
17
|
#
|
@@ -21,6 +29,19 @@ module Vedeu
|
|
21
29
|
@interface = interface
|
22
30
|
end
|
23
31
|
|
32
|
+
# Clear the view and send to the terminal.
|
33
|
+
#
|
34
|
+
# @return [Array]
|
35
|
+
def clear
|
36
|
+
if Vedeu::Configuration.drb?
|
37
|
+
Vedeu.trigger(:_drb_store_output_, virtual_clear)
|
38
|
+
|
39
|
+
HTMLRenderer.to_file(VirtualBuffer.retrieve)
|
40
|
+
end
|
41
|
+
|
42
|
+
Terminal.output(Renderer.render(virtual_clear))
|
43
|
+
end
|
44
|
+
|
24
45
|
# Send the view to the terminal.
|
25
46
|
#
|
26
47
|
# @return [Array]
|
File without changes
|
data/lib/vedeu/support/all.rb
CHANGED
@@ -1,17 +1,10 @@
|
|
1
1
|
require 'vedeu/support/coercions'
|
2
2
|
require 'vedeu/support/common'
|
3
|
-
require 'vedeu/support/console'
|
4
|
-
require 'vedeu/support/esc'
|
5
|
-
require 'vedeu/support/log'
|
6
|
-
require 'vedeu/support/read'
|
7
|
-
require 'vedeu/support/refresh'
|
8
3
|
require 'vedeu/support/sentence'
|
9
4
|
require 'vedeu/support/template'
|
10
5
|
require 'vedeu/support/terminal'
|
11
|
-
require 'vedeu/support/text'
|
12
6
|
require 'vedeu/support/trace'
|
13
7
|
require 'vedeu/support/visible'
|
14
|
-
require 'vedeu/support/write'
|
15
8
|
|
16
9
|
module Vedeu
|
17
10
|
end # Vedeu
|
@@ -10,13 +10,16 @@ module Vedeu
|
|
10
10
|
|
11
11
|
# Produces new objects of the correct class from the value, ignores objects
|
12
12
|
# that have already been coerced.
|
13
|
+
#
|
14
|
+
# @param value [Object|NilClass]
|
15
|
+
# @return [Object]
|
13
16
|
def coerce(value)
|
14
|
-
if value.
|
15
|
-
value
|
16
|
-
|
17
|
-
elsif value.nil?
|
17
|
+
if value.nil?
|
18
18
|
new
|
19
19
|
|
20
|
+
elsif value.is_a?(self)
|
21
|
+
value
|
22
|
+
|
20
23
|
else
|
21
24
|
new(value)
|
22
25
|
|
data/lib/vedeu/support/trace.rb
CHANGED
@@ -6,7 +6,14 @@ module Vedeu
|
|
6
6
|
|
7
7
|
let(:described) { Vedeu::MoveCursor }
|
8
8
|
let(:instance) { described.new(cursor, interface, dy, dx) }
|
9
|
-
let(:cursor) {
|
9
|
+
let(:cursor) {
|
10
|
+
Cursor.new({ name: 'MoveCursor',
|
11
|
+
ox: ox,
|
12
|
+
oy: oy,
|
13
|
+
state: :show,
|
14
|
+
x: x,
|
15
|
+
y: y })
|
16
|
+
}
|
10
17
|
let(:ox) { 0 }
|
11
18
|
let(:oy) { 0 }
|
12
19
|
let(:x) { 1 }
|
@@ -56,6 +63,58 @@ module Vedeu
|
|
56
63
|
it { instance.instance_variable_get('@dx').must_equal(dx) }
|
57
64
|
end
|
58
65
|
|
66
|
+
describe '.by_name' do
|
67
|
+
let(:direction) { :down }
|
68
|
+
let(:_name) { 'manganese' }
|
69
|
+
|
70
|
+
before do
|
71
|
+
Vedeu.interfaces.reset
|
72
|
+
Vedeu.cursors.reset
|
73
|
+
|
74
|
+
interface_with_border
|
75
|
+
Vedeu::Cursor.new({ name: 'manganese', oy: 2, ox: 3, x: 8, y: 7 }).store
|
76
|
+
end
|
77
|
+
|
78
|
+
subject { MoveCursor.by_name(direction, _name) }
|
79
|
+
|
80
|
+
it { subject.must_be_instance_of(Vedeu::Cursor) }
|
81
|
+
|
82
|
+
context 'when the name is not specified' do
|
83
|
+
let(:_name) {}
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'when the name is specified' do
|
88
|
+
let(:_name) { 'manganese' }
|
89
|
+
|
90
|
+
context 'and the direction is down' do
|
91
|
+
let(:direction) { :down }
|
92
|
+
|
93
|
+
it { subject.oy.must_equal(3) }
|
94
|
+
end
|
95
|
+
context 'and the direction is left' do
|
96
|
+
let(:direction) { :left }
|
97
|
+
|
98
|
+
it { subject.ox.must_equal(2) }
|
99
|
+
end
|
100
|
+
context 'and the direction is right' do
|
101
|
+
let(:direction) { :right }
|
102
|
+
|
103
|
+
it { subject.ox.must_equal(4) }
|
104
|
+
end
|
105
|
+
context 'and the direction is up' do
|
106
|
+
let(:direction) { :up }
|
107
|
+
|
108
|
+
it { subject.oy.must_equal(1) }
|
109
|
+
end
|
110
|
+
|
111
|
+
context 'but the interface does not exist' do
|
112
|
+
before { Vedeu.interfaces.stubs(:find).with(_name).returns(nil) }
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
59
118
|
describe '.down' do
|
60
119
|
subject { MoveCursor.down(cursor, interface) }
|
61
120
|
|
@@ -10,6 +10,13 @@ module Vedeu
|
|
10
10
|
let(:instance) { described.new(uri) }
|
11
11
|
let(:uri) { 'druby://localhost:21420' }
|
12
12
|
|
13
|
+
before { $stdout.stubs(:puts) }
|
14
|
+
|
15
|
+
describe 'alias methods' do
|
16
|
+
it { instance.must_respond_to(:read) }
|
17
|
+
it { instance.must_respond_to(:write) }
|
18
|
+
end
|
19
|
+
|
13
20
|
describe '#initialize' do
|
14
21
|
it { instance.must_be_instance_of(described) }
|
15
22
|
it { instance.instance_variable_get('@uri').must_equal('druby://localhost:21420') }
|
@@ -17,6 +24,10 @@ module Vedeu
|
|
17
24
|
|
18
25
|
describe '.connect' do
|
19
26
|
subject { described.connect(uri) }
|
27
|
+
|
28
|
+
context 'when the DRb server is not available or not enabled' do
|
29
|
+
it { subject.must_equal(:drb_connection_error) }
|
30
|
+
end
|
20
31
|
end
|
21
32
|
|
22
33
|
describe '#input' do
|
@@ -24,17 +35,25 @@ module Vedeu
|
|
24
35
|
|
25
36
|
subject { instance.input(data) }
|
26
37
|
|
27
|
-
|
38
|
+
context 'when the DRb server is not available or not enabled' do
|
39
|
+
it { subject.must_equal(:drb_connection_error) }
|
40
|
+
end
|
28
41
|
end
|
29
42
|
|
30
43
|
describe '#output' do
|
31
44
|
subject { instance.output }
|
32
45
|
|
33
|
-
|
46
|
+
context 'when the DRb server is not available or not enabled' do
|
47
|
+
it { subject.must_equal(:drb_connection_error) }
|
48
|
+
end
|
34
49
|
end
|
35
50
|
|
36
51
|
describe '#shutdown' do
|
37
52
|
subject { instance.shutdown }
|
53
|
+
|
54
|
+
context 'when the DRb server is not available or not enabled' do
|
55
|
+
it { subject.must_equal(:drb_connection_error) }
|
56
|
+
end
|
38
57
|
end
|
39
58
|
|
40
59
|
end # Client
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module DSL
|
6
|
+
|
7
|
+
describe Group do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::DSL::Group }
|
10
|
+
let(:instance) { described.new(model, client) }
|
11
|
+
let(:model) { Vedeu::Group.new }
|
12
|
+
let(:client) {}
|
13
|
+
let(:group_name) { 'main_screen' }
|
14
|
+
|
15
|
+
describe '#initialize' do
|
16
|
+
it { instance.must_be_instance_of(Vedeu::DSL::Group) }
|
17
|
+
it { instance.instance_variable_get('@model').must_equal(model) }
|
18
|
+
it { instance.instance_variable_get('@client').must_equal(client) }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '.group' do
|
22
|
+
context 'when the block is given' do
|
23
|
+
subject {
|
24
|
+
described.group(group_name) do
|
25
|
+
# ...
|
26
|
+
end
|
27
|
+
}
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when the block is not given' do
|
32
|
+
subject { described.group(group_name) }
|
33
|
+
|
34
|
+
it { proc { subject }.must_raise(InvalidSyntax) }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#add' do
|
39
|
+
subject {
|
40
|
+
described.group(group_name) do
|
41
|
+
add('editor_interface')
|
42
|
+
end
|
43
|
+
}
|
44
|
+
|
45
|
+
it { subject.must_be_instance_of(Vedeu::Group) }
|
46
|
+
end
|
47
|
+
|
48
|
+
end # Group
|
49
|
+
|
50
|
+
end # DSL
|
51
|
+
|
52
|
+
end # Vedeu
|
@@ -4,13 +4,20 @@ module Vedeu
|
|
4
4
|
|
5
5
|
describe Group do
|
6
6
|
|
7
|
-
let(:described)
|
8
|
-
let(:instance)
|
9
|
-
let(:
|
10
|
-
|
7
|
+
let(:described) { Vedeu::Group }
|
8
|
+
let(:instance) { described.new(attributes) }
|
9
|
+
let(:attributes) {
|
10
|
+
{
|
11
|
+
name: _name,
|
12
|
+
members: members,
|
13
|
+
}
|
14
|
+
}
|
15
|
+
let(:_name) { 'organics' }
|
16
|
+
let(:members) { ['carbon', 'nitrogen', 'oxygen'] }
|
11
17
|
|
12
18
|
describe '#initialize' do
|
13
19
|
it { instance.must_be_instance_of(Group) }
|
20
|
+
it { instance.instance_variable_get('@attributes').must_be_instance_of(Hash) }
|
14
21
|
it { instance.instance_variable_get('@members').must_equal(members) }
|
15
22
|
it { instance.instance_variable_get('@name').must_equal(_name) }
|
16
23
|
it { instance.instance_variable_get('@repository').must_equal(Vedeu.groups) }
|
File without changes
|
File without changes
|
File without changes
|
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'simplecov'
|
2
|
+
require 'simplecov-console'
|
2
3
|
require 'pry'
|
3
4
|
require 'minitest/autorun'
|
4
5
|
require 'minitest/pride' unless ENV['NO_COLOR']
|
@@ -7,6 +8,7 @@ require 'minitest/hell'
|
|
7
8
|
# GC.disable # uncomment to remove ~20ms from test run speed
|
8
9
|
|
9
10
|
SimpleCov.start do
|
11
|
+
formatter SimpleCov::Formatter::Console
|
10
12
|
command_name 'MiniTest::Spec'
|
11
13
|
add_filter '/test/'
|
12
14
|
add_group 'api', 'vedeu/api'
|