vedeu 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +6 -0
- data/bin/vedeu_drb_client +8 -3
- data/bin/vedeu_drb_server +113 -0
- data/bin/vedeu_test +1 -1
- data/docs/events.md +0 -127
- data/examples/borders_app.rb +17 -7
- data/examples/configuration_app.rb +1 -1
- data/examples/cursor_app.rb +4 -2
- data/examples/drb_app.rb +113 -0
- data/examples/focus_app.rb +1 -1
- data/examples/geometry_app.rb +1 -1
- data/examples/hello_world.rb +1 -1
- data/examples/lines_app.rb +1 -1
- data/features/start_stop.feature +1 -1
- data/inch.yml +5 -0
- data/lib/vedeu/all.rb +2 -0
- data/lib/vedeu/api.rb +1 -0
- data/lib/vedeu/application.rb +17 -36
- data/lib/vedeu/bindings.rb +134 -27
- data/lib/vedeu/buffers/display_buffer.rb +1 -4
- data/lib/vedeu/configuration/api.rb +15 -14
- data/lib/vedeu/configuration/cli.rb +17 -16
- data/lib/vedeu/configuration/configuration.rb +3 -1
- data/lib/vedeu/cursor/cursor.rb +6 -8
- data/lib/vedeu/cursor/move_cursor.rb +1 -0
- data/lib/vedeu/cursor/toggle_cursor.rb +1 -0
- data/lib/vedeu/debug.rb +23 -0
- data/lib/vedeu/distributed/all.rb +1 -1
- data/lib/vedeu/distributed/client.rb +55 -13
- data/lib/vedeu/distributed/server.rb +207 -0
- data/lib/vedeu/distributed/subprocess.rb +22 -21
- data/lib/vedeu/distributed/templates/default_application.vedeu +3 -1
- data/lib/vedeu/distributed/test_application.rb +2 -1
- data/lib/vedeu/distributed/uri.rb +1 -0
- data/lib/vedeu/dsl/all.rb +4 -2
- data/lib/vedeu/dsl/components/border.rb +11 -10
- data/lib/vedeu/dsl/components/geometry.rb +1 -0
- data/lib/vedeu/dsl/components/keymap.rb +1 -0
- data/lib/vedeu/dsl/components/menu.rb +1 -0
- data/lib/vedeu/dsl/interface.rb +1 -0
- data/lib/vedeu/dsl/line.rb +3 -1
- data/lib/vedeu/dsl/shared/colour.rb +1 -0
- data/lib/vedeu/dsl/shared/style.rb +1 -0
- data/lib/vedeu/dsl/shared/text.rb +2 -0
- data/lib/vedeu/dsl/shared/use.rb +3 -0
- data/lib/vedeu/dsl/stream.rb +3 -1
- data/lib/vedeu/dsl/view.rb +1 -0
- data/lib/vedeu/events/event.rb +9 -6
- data/lib/vedeu/events/trigger.rb +18 -7
- data/lib/vedeu/exceptions.rb +4 -1
- data/lib/vedeu/input/input.rb +1 -0
- data/lib/vedeu/input/key.rb +0 -1
- data/lib/vedeu/input/keymap.rb +5 -3
- data/lib/vedeu/input/keys.rb +1 -0
- data/lib/vedeu/input/mapper.rb +1 -0
- data/lib/vedeu/launcher.rb +35 -12
- data/lib/vedeu/main_loop.rb +53 -0
- data/lib/vedeu/models/collection.rb +11 -3
- data/lib/vedeu/models/focus.rb +3 -3
- data/lib/vedeu/models/geometry.rb +8 -16
- data/lib/vedeu/models/group.rb +1 -0
- data/lib/vedeu/models/menu.rb +2 -1
- data/lib/vedeu/models/model.rb +7 -1
- data/lib/vedeu/models/view/char.rb +52 -44
- data/lib/vedeu/models/view/chars.rb +1 -0
- data/lib/vedeu/models/view/composition.rb +2 -1
- data/lib/vedeu/models/view/interface.rb +5 -3
- data/lib/vedeu/models/view/interfaces.rb +1 -0
- data/lib/vedeu/models/view/line.rb +2 -1
- data/lib/vedeu/models/view/stream.rb +2 -1
- data/lib/vedeu/models/view/streams.rb +1 -0
- data/lib/vedeu/output/all.rb +4 -0
- data/lib/vedeu/output/border.rb +75 -206
- data/lib/vedeu/output/compositor.rb +1 -0
- data/lib/vedeu/output/html_char.rb +119 -0
- data/lib/vedeu/output/html_renderer.rb +89 -0
- data/lib/vedeu/output/output.rb +48 -44
- data/lib/vedeu/output/position_index.rb +12 -1
- data/lib/vedeu/output/renderer.rb +28 -0
- data/lib/vedeu/output/viewport.rb +14 -14
- data/lib/vedeu/output/virtual_buffer.rb +56 -0
- data/lib/vedeu/output/virtual_terminal.rb +42 -34
- data/lib/vedeu/output/wordwrap.rb +3 -0
- data/lib/vedeu/output/writer.rb +13 -1
- data/lib/vedeu/presentation/background.rb +1 -0
- data/lib/vedeu/presentation/colour.rb +8 -7
- data/lib/vedeu/presentation/foreground.rb +1 -0
- data/lib/vedeu/presentation/presentation.rb +43 -7
- data/lib/vedeu/presentation/translator.rb +12 -0
- data/lib/vedeu/repositories/repository.rb +8 -8
- data/lib/vedeu/support/bounding_area.rb +2 -0
- data/lib/vedeu/support/coercions.rb +2 -1
- data/lib/vedeu/support/common.rb +1 -0
- data/lib/vedeu/support/console.rb +17 -23
- data/lib/vedeu/support/content_geometry.rb +2 -0
- data/lib/vedeu/support/coordinate.rb +1 -0
- data/lib/vedeu/support/esc.rb +58 -29
- data/lib/vedeu/support/grid.rb +1 -0
- data/lib/vedeu/support/limit.rb +9 -0
- data/lib/vedeu/support/log.rb +31 -9
- data/lib/vedeu/support/node.rb +8 -18
- data/lib/vedeu/support/position.rb +13 -34
- data/lib/vedeu/support/position_validator.rb +3 -0
- data/lib/vedeu/support/read.rb +1 -0
- data/lib/vedeu/support/refresh.rb +3 -2
- data/lib/vedeu/support/terminal.rb +11 -5
- data/lib/vedeu/support/trace.rb +16 -1
- data/lib/vedeu/support/visible.rb +2 -0
- data/lib/vedeu/support/write.rb +1 -0
- data/lib/vedeu/traps.rb +1 -0
- data/lib/vedeu.rb +2 -0
- data/test/integration/distributed_test.rb +10 -8
- data/test/lib/vedeu/api_test.rb +3 -7
- data/test/lib/vedeu/application_test.rb +2 -5
- data/test/lib/vedeu/configuration/api_test.rb +12 -0
- data/test/lib/vedeu/cursor/cursor_test.rb +2 -0
- data/test/lib/vedeu/distributed/client_test.rb +17 -7
- data/test/lib/vedeu/distributed/server_test.rb +56 -0
- data/test/lib/vedeu/distributed/test_application_test.rb +7 -3
- data/test/lib/vedeu/dsl/components/border_test.rb +10 -2
- data/test/lib/vedeu/dsl/interface_test.rb +6 -0
- data/test/lib/vedeu/dsl/line_test.rb +19 -0
- data/test/lib/vedeu/dsl/shared/colour_test.rb +4 -26
- data/test/lib/vedeu/dsl/shared/text_test.rb +8 -1
- data/test/lib/vedeu/dsl/stream_test.rb +13 -1
- data/test/lib/vedeu/input/input_test.rb +1 -1
- data/test/lib/vedeu/input/key_test.rb +3 -16
- data/test/lib/vedeu/launcher_test.rb +11 -1
- data/test/lib/vedeu/main_loop_test.rb +41 -0
- data/test/lib/vedeu/models/geometry_test.rb +15 -34
- data/test/lib/vedeu/models/view/char_test.rb +44 -45
- data/test/lib/vedeu/models/view/interface_test.rb +6 -0
- data/test/lib/vedeu/models/view/line_test.rb +1 -1
- data/test/lib/vedeu/models/view/stream_test.rb +1 -1
- data/test/lib/vedeu/output/border_test.rb +6 -5
- data/test/lib/vedeu/output/compositor_test.rb +2 -20
- data/test/lib/vedeu/output/html_char_test.rb +85 -0
- data/test/lib/vedeu/output/html_renderer_test.rb +37 -0
- data/test/lib/vedeu/output/position_index_test.rb +2 -10
- data/test/lib/vedeu/output/renderer_test.rb +24 -0
- data/test/lib/vedeu/output/virtual_buffer_test.rb +53 -0
- data/test/lib/vedeu/output/virtual_terminal_test.rb +32 -2
- data/test/lib/vedeu/presentation/background_test.rb +41 -1
- data/test/lib/vedeu/presentation/colour_test.rb +10 -6
- data/test/lib/vedeu/presentation/foreground_test.rb +46 -6
- data/test/lib/vedeu/presentation/presentation_test.rb +44 -1
- data/test/lib/vedeu/presentation/translator_test.rb +34 -0
- data/test/lib/vedeu/repositories/repository_test.rb +1 -1
- data/test/lib/vedeu/support/bounding_area_test.rb +4 -12
- data/test/lib/vedeu/support/console_test.rb +9 -50
- data/test/lib/vedeu/support/esc_test.rb +7 -7
- data/test/lib/vedeu/support/position_test.rb +42 -0
- data/test/lib/vedeu/support/terminal_test.rb +5 -20
- data/test/lib/vedeu/support/write_test.rb +42 -18
- data/test/support/helpers/all.rb +0 -1
- data/test/support/helpers/repository_test_module.rb +1 -0
- data/test/test_helper.rb +5 -2
- data/vedeu.gemspec +7 -5
- metadata +60 -14
- data/lib/vedeu/distributed/application.rb +0 -91
- data/test/lib/vedeu/distributed/application_test.rb +0 -24
- data/test/support/helpers/presentation.rb +0 -16
@@ -3,6 +3,7 @@ module Vedeu
|
|
3
3
|
# Change coordinates into an escape sequence to set the cursor position.
|
4
4
|
#
|
5
5
|
# @api private
|
6
|
+
#
|
6
7
|
class Position
|
7
8
|
|
8
9
|
attr_reader :y,
|
@@ -11,6 +12,8 @@ module Vedeu
|
|
11
12
|
alias_method :first, :y
|
12
13
|
alias_method :last, :x
|
13
14
|
|
15
|
+
# @param value [Array<Fixnum>|Vedeu::Position]
|
16
|
+
# @return [void]
|
14
17
|
def self.coerce(value)
|
15
18
|
if value.is_a?(self)
|
16
19
|
value
|
@@ -26,32 +29,34 @@ module Vedeu
|
|
26
29
|
|
27
30
|
# Initializes a new instance of Position.
|
28
31
|
#
|
29
|
-
# @param y [Fixnum]
|
30
|
-
# @param x [Fixnum]
|
32
|
+
# @param y [Fixnum] The row/line position.
|
33
|
+
# @param x [Fixnum] The column/character position.
|
31
34
|
# @return [Position]
|
32
35
|
def initialize(y = 1, x = 1)
|
33
|
-
@y = y
|
34
|
-
@x = x
|
36
|
+
@y = (y.nil? || y < 1) ? 1 : y
|
37
|
+
@x = (x.nil? || x < 1) ? 1 : x
|
35
38
|
end
|
36
39
|
|
40
|
+
# @return [String]
|
37
41
|
def inspect
|
38
42
|
"<#{self.class.name} (y:#{@y} x:#{@x})>"
|
39
43
|
end
|
40
44
|
|
41
|
-
# @param other []
|
45
|
+
# @param other [Vedeu::Position]
|
42
46
|
# @return [Boolean]
|
43
47
|
def ==(other)
|
44
48
|
eql?(other)
|
45
49
|
end
|
46
50
|
|
47
|
-
# @param other []
|
51
|
+
# @param other [Vedeu::Position]
|
48
52
|
# @return [Boolean]
|
49
53
|
def eql?(other)
|
50
54
|
self.class == other.class && (x == other.x && y == other.y)
|
51
55
|
end
|
52
56
|
|
53
|
-
#
|
54
|
-
#
|
57
|
+
# Return the escape sequence required to position the cursor at a particular
|
58
|
+
# point on the screen. When passed a block, will do the aforementioned,
|
59
|
+
# call the block and then reposition to this location.
|
55
60
|
#
|
56
61
|
# @param block [Proc]
|
57
62
|
# @return [String]
|
@@ -75,32 +80,6 @@ module Vedeu
|
|
75
80
|
["\e[", y, ';', x, 'H'].join
|
76
81
|
end
|
77
82
|
|
78
|
-
# Returns the y coordinate.
|
79
|
-
#
|
80
|
-
# @return [Fixnum]
|
81
|
-
def y
|
82
|
-
if @y < 1 || @y.nil?
|
83
|
-
1
|
84
|
-
|
85
|
-
else
|
86
|
-
@y
|
87
|
-
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
# Returns the x coordinate.
|
92
|
-
#
|
93
|
-
# @return [Fixnum]
|
94
|
-
def x
|
95
|
-
if @x < 1 || @x.nil?
|
96
|
-
1
|
97
|
-
|
98
|
-
else
|
99
|
-
@x
|
100
|
-
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
83
|
end # Position
|
105
84
|
|
106
85
|
end # Vedeu
|
data/lib/vedeu/support/read.rb
CHANGED
@@ -3,6 +3,7 @@ module Vedeu
|
|
3
3
|
# Refreshes the terminal.
|
4
4
|
#
|
5
5
|
# @api private
|
6
|
+
#
|
6
7
|
module Refresh
|
7
8
|
|
8
9
|
extend self
|
@@ -27,7 +28,7 @@ module Vedeu
|
|
27
28
|
# @return [Array|ModelNotFound] A collection of the names of interfaces
|
28
29
|
# refreshed, or an exception if the group was not found.
|
29
30
|
def by_group(group_name)
|
30
|
-
Vedeu.log("Refreshing group: '#{group_name}'")
|
31
|
+
Vedeu.log(type: :info, message: "Refreshing group: '#{group_name}'")
|
31
32
|
|
32
33
|
Vedeu.groups.find(group_name).members.each { |name| by_name(name) }
|
33
34
|
end
|
@@ -38,7 +39,7 @@ module Vedeu
|
|
38
39
|
# named buffer.
|
39
40
|
# @return [Array|ModelNotFound]
|
40
41
|
def by_name(name)
|
41
|
-
Vedeu.log("Refreshing interface: '#{name}'")
|
42
|
+
Vedeu.log(type: :info, message: "Refreshing interface: '#{name}'")
|
42
43
|
|
43
44
|
Vedeu::Compositor.compose(name)
|
44
45
|
end
|
@@ -8,6 +8,7 @@ module Vedeu
|
|
8
8
|
# console, via Ruby's IO core library.
|
9
9
|
#
|
10
10
|
# @api private
|
11
|
+
#
|
11
12
|
module Terminal
|
12
13
|
|
13
14
|
extend self
|
@@ -22,12 +23,12 @@ module Vedeu
|
|
22
23
|
fail InvalidSyntax, 'block not given' unless block_given?
|
23
24
|
|
24
25
|
if raw_mode?
|
25
|
-
Vedeu.log("Terminal entering 'raw' mode")
|
26
|
+
Vedeu.log(type: :info, message: "Terminal entering 'raw' mode")
|
26
27
|
|
27
28
|
console.raw { initialize_screen { yield } }
|
28
29
|
|
29
30
|
else
|
30
|
-
Vedeu.log("Terminal entering 'cooked' mode")
|
31
|
+
Vedeu.log(type: :info, message: "Terminal entering 'cooked' mode")
|
31
32
|
|
32
33
|
console.cooked { initialize_screen { yield } }
|
33
34
|
|
@@ -88,7 +89,7 @@ module Vedeu
|
|
88
89
|
end
|
89
90
|
|
90
91
|
# @param block [Proc]
|
91
|
-
# @return []
|
92
|
+
# @return [void]
|
92
93
|
def initialize_screen(&block)
|
93
94
|
output(Esc.string('screen_init'))
|
94
95
|
|
@@ -132,7 +133,7 @@ module Vedeu
|
|
132
133
|
#
|
133
134
|
# @return [Symbol]
|
134
135
|
def cooked_mode!
|
135
|
-
Vedeu.log("Terminal switching to 'cooked' mode")
|
136
|
+
Vedeu.log(type: :info, message: "Terminal switching to 'cooked' mode")
|
136
137
|
|
137
138
|
@_mode = :cooked
|
138
139
|
end
|
@@ -149,7 +150,7 @@ module Vedeu
|
|
149
150
|
#
|
150
151
|
# @return [Symbol]
|
151
152
|
def raw_mode!
|
152
|
-
Vedeu.log("Terminal switching to 'raw' mode")
|
153
|
+
Vedeu.log(type: :info, message: "Terminal switching to 'raw' mode")
|
153
154
|
|
154
155
|
@_mode = :raw
|
155
156
|
end
|
@@ -258,6 +259,11 @@ module Vedeu
|
|
258
259
|
IO.console
|
259
260
|
end
|
260
261
|
|
262
|
+
# @return [VirtualTerminal]
|
263
|
+
def virtual
|
264
|
+
@virtual ||= VirtualTerminal.new(height, width)
|
265
|
+
end
|
266
|
+
|
261
267
|
end # Terminal
|
262
268
|
|
263
269
|
end # Vedeu
|
data/lib/vedeu/support/trace.rb
CHANGED
@@ -10,10 +10,25 @@ module Vedeu
|
|
10
10
|
# excruciatingly slow to run.
|
11
11
|
#
|
12
12
|
# @api private
|
13
|
+
#
|
13
14
|
class Trace
|
14
15
|
|
16
|
+
# @todo
|
17
|
+
# Replace this class with this:
|
18
|
+
#
|
19
|
+
# def self.trace
|
20
|
+
# trace = TracePoint.new(:call) do |tp|
|
21
|
+
# if tp.defined_class.to_s.match(/Troo/)
|
22
|
+
# Vedeu.log(type: :debug, message: [tp.defined_class.to_s, tp.method_id.to_s].join(' '))
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
# trace.enable
|
26
|
+
# end
|
27
|
+
|
15
28
|
# @param options [Hash]
|
16
|
-
# @
|
29
|
+
# @option option event [Symbol]
|
30
|
+
# @option option trace [Boolean]
|
31
|
+
# @return [void]
|
17
32
|
def self.call(options = {})
|
18
33
|
new(options).trace
|
19
34
|
end
|
data/lib/vedeu/support/write.rb
CHANGED
data/lib/vedeu/traps.rb
CHANGED
data/lib/vedeu.rb
CHANGED
@@ -2,13 +2,15 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
describe 'Running a distributed app' do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
it 'runs a simple app and exits' do
|
6
|
+
skip
|
7
|
+
app = Vedeu::TestApplication.build
|
8
|
+
server = Vedeu::Subprocess.execute!(app)
|
9
|
+
|
10
|
+
client = Vedeu::Distributed::Client.connect("druby://localhost:21420")
|
11
|
+
client.input('q')
|
12
|
+
client.output.must_equal('')
|
13
|
+
client.shutdown
|
14
|
+
end
|
13
15
|
|
14
16
|
end
|
data/test/lib/vedeu/api_test.rb
CHANGED
@@ -4,10 +4,6 @@ module Vedeu
|
|
4
4
|
|
5
5
|
describe API do
|
6
6
|
|
7
|
-
let(:event) { mock('Event') }
|
8
|
-
|
9
|
-
before { Event.stubs(:new).returns(event) }
|
10
|
-
|
11
7
|
# describe '.focus' do
|
12
8
|
# it 'sets the named interface to be focussed' do
|
13
9
|
# Interface.build({ name: 'plutonium' }).store
|
@@ -68,20 +64,20 @@ module Vedeu
|
|
68
64
|
describe '.log' do
|
69
65
|
it 'writes the message to the log file when debugging is enabled' do
|
70
66
|
Configuration.stub(:debug?, true) do
|
71
|
-
Vedeu.log('Testing debugging to log').must_equal(true)
|
67
|
+
Vedeu.log(type: :test, message: 'Testing debugging to log').must_equal(true)
|
72
68
|
end
|
73
69
|
end
|
74
70
|
|
75
71
|
it 'returns nil when debugging is disabled' do
|
76
72
|
Configuration.stub(:debug?, false) do
|
77
|
-
Vedeu.log('some message not logged...').must_equal(nil)
|
73
|
+
Vedeu.log(type: :test, message: 'some message not logged...').must_equal(nil)
|
78
74
|
end
|
79
75
|
end
|
80
76
|
|
81
77
|
it 'write the message to the log file when the `force` argument ' \
|
82
78
|
'evaluates to true' do
|
83
79
|
Configuration.stub(:debug?, false) do
|
84
|
-
Vedeu.log('Testing forced debugging to log', true).must_equal(true)
|
80
|
+
Vedeu.log(type: :test, message: 'Testing forced debugging to log', force: true).must_equal(true)
|
85
81
|
end
|
86
82
|
end
|
87
83
|
end
|
@@ -6,7 +6,7 @@ module Vedeu
|
|
6
6
|
|
7
7
|
let(:described) { Vedeu::Application }
|
8
8
|
let(:instance) { described.new(configuration) }
|
9
|
-
let(:configuration) {
|
9
|
+
let(:configuration) { test_configuration }
|
10
10
|
|
11
11
|
before do
|
12
12
|
configuration.stubs(:drb?).returns(false)
|
@@ -23,15 +23,12 @@ module Vedeu
|
|
23
23
|
|
24
24
|
it { subject.must_be_instance_of(Array) }
|
25
25
|
|
26
|
-
|
27
|
-
it { subject.must_be_instance_of(Array) }
|
28
|
-
end
|
26
|
+
it { described.must_respond_to(:restart) }
|
29
27
|
end
|
30
28
|
|
31
29
|
describe '.stop' do
|
32
30
|
subject { described.stop }
|
33
31
|
|
34
|
-
it { proc { subject }.must_raise(StopIteration) }
|
35
32
|
end
|
36
33
|
|
37
34
|
describe '#start' do
|
@@ -37,6 +37,8 @@ module Vedeu
|
|
37
37
|
configuration = Vedeu.configure { interactive }
|
38
38
|
configuration.interactive?.must_equal(true)
|
39
39
|
end
|
40
|
+
|
41
|
+
# it { configuration.must_respond_to(:interactive) }
|
40
42
|
end
|
41
43
|
|
42
44
|
describe '#standalone!' do
|
@@ -59,6 +61,8 @@ module Vedeu
|
|
59
61
|
configuration = Vedeu.configure { standalone }
|
60
62
|
configuration.interactive?.must_equal(false)
|
61
63
|
end
|
64
|
+
|
65
|
+
# it { configuration.must_respond_to(:standalone) }
|
62
66
|
end
|
63
67
|
|
64
68
|
describe '#run_once!' do
|
@@ -81,6 +85,8 @@ module Vedeu
|
|
81
85
|
configuration = Vedeu.configure { run_once }
|
82
86
|
configuration.once.must_equal(true)
|
83
87
|
end
|
88
|
+
|
89
|
+
# it { configuration.must_respond_to(:run_once) }
|
84
90
|
end
|
85
91
|
|
86
92
|
describe '#drb!' do
|
@@ -103,6 +109,8 @@ module Vedeu
|
|
103
109
|
configuration = Vedeu.configure { drb }
|
104
110
|
configuration.drb.must_equal(true)
|
105
111
|
end
|
112
|
+
|
113
|
+
# it { configuration.must_respond_to(:drb) }
|
106
114
|
end
|
107
115
|
|
108
116
|
describe '#drb_host' do
|
@@ -138,6 +146,8 @@ module Vedeu
|
|
138
146
|
configuration = Vedeu.configure { cooked! }
|
139
147
|
configuration.terminal_mode.must_equal(:cooked)
|
140
148
|
end
|
149
|
+
|
150
|
+
# it { configuration.must_respond_to(:cooked) }
|
141
151
|
end
|
142
152
|
|
143
153
|
describe '#raw!' do
|
@@ -145,6 +155,8 @@ module Vedeu
|
|
145
155
|
configuration = Vedeu.configure { raw! }
|
146
156
|
configuration.terminal_mode.must_equal(:raw)
|
147
157
|
end
|
158
|
+
|
159
|
+
# it { configuration.must_respond_to(:raw) }
|
148
160
|
end
|
149
161
|
|
150
162
|
describe '#debug!' do
|
@@ -37,6 +37,8 @@ module Vedeu
|
|
37
37
|
it { instance.instance_variable_get('@state').must_be_instance_of(Vedeu::Visible) }
|
38
38
|
it { instance.instance_variable_get('@x').must_equal(19) }
|
39
39
|
it { instance.instance_variable_get('@y').must_equal(8) }
|
40
|
+
|
41
|
+
it { instance.instance_variable_get('@position').must_be_instance_of(Vedeu::Position) }
|
40
42
|
end
|
41
43
|
|
42
44
|
describe '#inspect' do
|
@@ -8,25 +8,35 @@ module Vedeu
|
|
8
8
|
|
9
9
|
let(:described) { Vedeu::Distributed::Client }
|
10
10
|
let(:instance) { described.new(uri) }
|
11
|
-
let(:uri) {}
|
11
|
+
let(:uri) { 'druby://localhost:21420' }
|
12
12
|
|
13
13
|
describe '#initialize' do
|
14
|
-
|
14
|
+
it { instance.must_be_instance_of(described) }
|
15
|
+
it { instance.instance_variable_get('@uri').must_equal('druby://localhost:21420') }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.connect' do
|
19
|
+
subject { described.connect(uri) }
|
15
20
|
|
16
|
-
it { subject.must_be_instance_of(
|
17
|
-
it { subject.instance_variable_get('@uri').must_equal('') }
|
21
|
+
# it { subject.must_be_instance_of(Symbol) }
|
18
22
|
end
|
19
23
|
|
20
24
|
describe '#input' do
|
25
|
+
let(:data) {}
|
26
|
+
|
27
|
+
subject { instance.input(data) }
|
28
|
+
|
29
|
+
it { instance.must_respond_to(:read) }
|
21
30
|
end
|
22
31
|
|
23
32
|
describe '#output' do
|
24
|
-
|
33
|
+
subject { instance.output }
|
25
34
|
|
26
|
-
|
35
|
+
it { instance.must_respond_to(:write) }
|
27
36
|
end
|
28
37
|
|
29
|
-
describe '#
|
38
|
+
describe '#shutdown' do
|
39
|
+
subject { instance.shutdown }
|
30
40
|
end
|
31
41
|
|
32
42
|
end # Client
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Distributed
|
6
|
+
|
7
|
+
describe Server do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Distributed::Server }
|
10
|
+
let(:instance) { described.instance }
|
11
|
+
let(:configuration) {}
|
12
|
+
|
13
|
+
describe '.input' do
|
14
|
+
let(:data) {}
|
15
|
+
|
16
|
+
subject { described.input(data) }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '.output' do
|
20
|
+
subject { described.output }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#pid' do
|
24
|
+
before { Process.stubs(:pid).returns(9876) }
|
25
|
+
|
26
|
+
subject { instance.pid }
|
27
|
+
|
28
|
+
it { subject.must_be_instance_of(Fixnum) }
|
29
|
+
it { subject.must_equal(9876) }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '.restart' do
|
33
|
+
subject { described.restart }
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '.shutdown' do
|
37
|
+
subject { described.shutdown }
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '.start' do
|
41
|
+
subject { described.start }
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '.status' do
|
45
|
+
subject { described.status }
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '.stop' do
|
49
|
+
subject { described.stop }
|
50
|
+
end
|
51
|
+
|
52
|
+
end # Server
|
53
|
+
|
54
|
+
end # Distributed
|
55
|
+
|
56
|
+
end # Vedeu
|
@@ -9,12 +9,16 @@ module Vedeu
|
|
9
9
|
let(:attributes) { {} }
|
10
10
|
|
11
11
|
describe '#initialize' do
|
12
|
-
|
13
|
-
|
14
|
-
it { subject.must_be_instance_of(Vedeu::TestApplication) }
|
12
|
+
it { instance.must_be_instance_of(Vedeu::TestApplication) }
|
15
13
|
# it { subject.instance_variable_get('@attributes').must_equal(attributes) }
|
16
14
|
end
|
17
15
|
|
16
|
+
describe '.build' do
|
17
|
+
subject { described.build(attributes) { } }
|
18
|
+
|
19
|
+
it { subject.must_be_instance_of(String) }
|
20
|
+
end
|
21
|
+
|
18
22
|
describe '#lib_dir' do
|
19
23
|
subject { instance.lib_dir }
|
20
24
|
|
@@ -179,6 +179,8 @@ module Vedeu
|
|
179
179
|
)
|
180
180
|
end
|
181
181
|
end
|
182
|
+
|
183
|
+
it { instance.must_respond_to(:bottom) }
|
182
184
|
end
|
183
185
|
|
184
186
|
describe '#hide_bottom!' do
|
@@ -198,6 +200,8 @@ module Vedeu
|
|
198
200
|
|
199
201
|
it { subject.must_be_instance_of(TrueClass) }
|
200
202
|
|
203
|
+
it { instance.must_respond_to(:left) }
|
204
|
+
|
201
205
|
context 'when false' do
|
202
206
|
let(:boolean) { false }
|
203
207
|
|
@@ -208,7 +212,7 @@ module Vedeu
|
|
208
212
|
subject {
|
209
213
|
Vedeu.interface 'borders' do
|
210
214
|
border do
|
211
|
-
show_left
|
215
|
+
show_left!
|
212
216
|
end
|
213
217
|
geometry do
|
214
218
|
height 3
|
@@ -249,6 +253,8 @@ module Vedeu
|
|
249
253
|
|
250
254
|
it { subject.must_be_instance_of(TrueClass) }
|
251
255
|
|
256
|
+
it { instance.must_respond_to(:right) }
|
257
|
+
|
252
258
|
context 'when false' do
|
253
259
|
let(:boolean) { false }
|
254
260
|
|
@@ -259,7 +265,7 @@ module Vedeu
|
|
259
265
|
subject {
|
260
266
|
Vedeu.interface 'borders' do
|
261
267
|
border do
|
262
|
-
show_right
|
268
|
+
show_right!
|
263
269
|
end
|
264
270
|
geometry do
|
265
271
|
height 3
|
@@ -300,6 +306,8 @@ module Vedeu
|
|
300
306
|
|
301
307
|
it { subject.must_be_instance_of(TrueClass) }
|
302
308
|
|
309
|
+
it { instance.must_respond_to(:top) }
|
310
|
+
|
303
311
|
context 'when false' do
|
304
312
|
let(:boolean) { false }
|
305
313
|
|
@@ -40,6 +40,23 @@ module Vedeu
|
|
40
40
|
|
41
41
|
it { subject.must_be_instance_of(Vedeu::Lines) }
|
42
42
|
it { subject.first.must_be_instance_of(Vedeu::Line) }
|
43
|
+
|
44
|
+
context 'when the block is given' do
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'when the block is not given' do
|
48
|
+
context 'when the value is given' do
|
49
|
+
subject { instance.line(value) }
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when the value is not given' do
|
53
|
+
let(:value) {}
|
54
|
+
|
55
|
+
subject { instance.line(value) }
|
56
|
+
|
57
|
+
it { proc { subject }.must_raise(InvalidSyntax) }
|
58
|
+
end
|
59
|
+
end
|
43
60
|
end
|
44
61
|
|
45
62
|
describe '#streams' do
|
@@ -57,6 +74,8 @@ module Vedeu
|
|
57
74
|
context 'when the block is not given' do
|
58
75
|
it { proc { instance.streams }.must_raise(InvalidSyntax) }
|
59
76
|
end
|
77
|
+
|
78
|
+
it { instance.must_respond_to(:stream) }
|
60
79
|
end
|
61
80
|
|
62
81
|
end # Line
|
@@ -24,19 +24,8 @@ module Vedeu
|
|
24
24
|
)
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
it { subject.attributes.
|
31
|
-
must_equal({ background: '#00ff00', foreground: '' }) }
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'alias method #bgcolor' do
|
35
|
-
subject { dsl_klass.bgcolor(background) }
|
36
|
-
|
37
|
-
it { subject.attributes.
|
38
|
-
must_equal({ background: '#00ff00', foreground: '' }) }
|
39
|
-
end
|
27
|
+
it { dsl_klass.must_respond_to(:bg) }
|
28
|
+
it { dsl_klass.must_respond_to(:bgcolor) }
|
40
29
|
end
|
41
30
|
|
42
31
|
describe '#foreground' do
|
@@ -50,19 +39,8 @@ module Vedeu
|
|
50
39
|
)
|
51
40
|
end
|
52
41
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
it { subject.attributes.
|
57
|
-
must_equal({ background: '', foreground: '#ff00ff' }) }
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'alias method #fgcolor' do
|
61
|
-
subject { dsl_klass.fgcolor(foreground) }
|
62
|
-
|
63
|
-
it { subject.attributes.
|
64
|
-
must_equal({ background: '', foreground: '#ff00ff' }) }
|
65
|
-
end
|
42
|
+
it { dsl_klass.must_respond_to(:fg) }
|
43
|
+
it { dsl_klass.must_respond_to(:fgcolor) }
|
66
44
|
end
|
67
45
|
|
68
46
|
describe '#colour' do
|