vedeu 0.4.7 → 0.4.8
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/lib/vedeu/all.rb +1 -2
- data/lib/vedeu/api.rb +1 -0
- data/lib/vedeu/application.rb +2 -4
- data/lib/vedeu/bindings.rb +13 -13
- data/lib/vedeu/configuration/api.rb +6 -9
- data/lib/vedeu/configuration/cli.rb +4 -7
- data/lib/vedeu/cursor/all.rb +2 -2
- data/lib/vedeu/cursor/{move_cursor.rb → move.rb} +6 -6
- data/lib/vedeu/cursor/refresh_cursor.rb +7 -4
- data/lib/vedeu/cursor/{toggle_cursor.rb → toggle.rb} +6 -8
- data/lib/vedeu/debug.rb +2 -0
- data/lib/vedeu/distributed/client.rb +1 -2
- data/lib/vedeu/distributed/server.rb +1 -1
- data/lib/vedeu/distributed/subprocess.rb +3 -2
- data/lib/vedeu/distributed/test_application.rb +2 -4
- data/lib/vedeu/dsl/all.rb +2 -0
- data/lib/vedeu/dsl/components/geometry.rb +45 -10
- data/lib/vedeu/dsl/interface.rb +1 -1
- data/lib/vedeu/events/event.rb +22 -14
- data/lib/vedeu/events/trigger.rb +6 -3
- data/lib/vedeu/geometry/all.rb +6 -1
- data/lib/vedeu/geometry/area.rb +151 -0
- data/lib/vedeu/geometry/canvas.rb +79 -0
- data/lib/vedeu/geometry/centre.rb +83 -0
- data/lib/vedeu/geometry/{content_geometry.rb → content.rb} +3 -3
- data/lib/vedeu/geometry/dimension.rb +81 -0
- data/lib/vedeu/{models → geometry}/geometry.rb +32 -0
- data/lib/vedeu/geometry/grid.rb +1 -2
- data/lib/vedeu/geometry/index_position.rb +3 -11
- data/lib/vedeu/geometry/limit.rb +1 -1
- data/lib/vedeu/geometry/position.rb +5 -0
- data/lib/vedeu/geometry/position_index.rb +3 -5
- data/lib/vedeu/geometry/position_validator.rb +1 -4
- data/lib/vedeu/input/input.rb +1 -2
- data/lib/vedeu/input/mapper.rb +2 -4
- data/lib/vedeu/launcher.rb +1 -1
- data/lib/vedeu/main_loop.rb +2 -0
- data/lib/vedeu/models/all.rb +1 -1
- data/lib/vedeu/models/cell.rb +68 -0
- data/lib/vedeu/models/interface.rb +4 -2
- data/lib/vedeu/output/all.rb +0 -1
- data/lib/vedeu/output/border.rb +6 -6
- data/lib/vedeu/output/clear.rb +6 -5
- data/lib/vedeu/output/colour.rb +1 -1
- data/lib/vedeu/output/esc.rb +2 -2
- data/lib/vedeu/output/output.rb +1 -3
- data/lib/vedeu/output/style.rb +2 -2
- data/lib/vedeu/output/text.rb +17 -1
- data/lib/vedeu/output/translator.rb +1 -8
- data/lib/vedeu/output/virtual_terminal.rb +3 -3
- data/lib/vedeu/output/wordwrap.rb +1 -1
- data/lib/vedeu/repositories/model.rb +1 -1
- data/lib/vedeu/repositories/repository.rb +1 -1
- data/lib/vedeu/support/log.rb +1 -1
- data/lib/vedeu/support/trace.rb +5 -3
- data/test/lib/vedeu/cursor/{move_cursor_test.rb → move_test.rb} +22 -22
- data/test/lib/vedeu/cursor/{toggle_cursor_test.rb → toggle_test.rb} +6 -6
- data/test/lib/vedeu/dsl/components/geometry_test.rb +14 -2
- data/test/lib/vedeu/geometry/area_test.rb +99 -0
- data/test/lib/vedeu/geometry/canvas_test.rb +66 -0
- data/test/lib/vedeu/geometry/centre_test.rb +58 -0
- data/test/lib/vedeu/geometry/{content_geometry_test.rb → content_test.rb} +3 -3
- data/test/lib/vedeu/geometry/dimension_test.rb +99 -0
- data/test/lib/vedeu/{models → geometry}/geometry_test.rb +0 -0
- data/test/lib/vedeu/geometry/index_position_test.rb +3 -9
- data/test/lib/vedeu/geometry/position_index_test.rb +2 -2
- data/test/lib/vedeu/geometry/position_test.rb +6 -0
- data/test/lib/vedeu/models/cell_test.rb +66 -0
- data/test/lib/vedeu/output/virtual_terminal_test.rb +25 -25
- data/vedeu.gemspec +3 -3
- metadata +34 -22
- data/lib/vedeu/output/char_builder.rb +0 -36
- data/test/lib/vedeu/output/char_builder_test.rb +0 -50
@@ -0,0 +1,68 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# A Cell represents a single square of the terminal.
|
4
|
+
#
|
5
|
+
class Cell
|
6
|
+
|
7
|
+
# @!attribute [r] background
|
8
|
+
# @return [NilClass|String]
|
9
|
+
attr_reader :background
|
10
|
+
|
11
|
+
# @!attribute [r] foreground
|
12
|
+
# @return [NilClass|String]
|
13
|
+
attr_reader :foreground
|
14
|
+
|
15
|
+
# @!attribute [r] style
|
16
|
+
# @return [NilClass|Array<Symbol|String>|Symbol|String]
|
17
|
+
attr_reader :style
|
18
|
+
|
19
|
+
# @!attribute [r] value
|
20
|
+
# @return [NilClass|String]
|
21
|
+
attr_reader :value
|
22
|
+
|
23
|
+
# @!attribute [r] x
|
24
|
+
# @return [NilClass|Fixnum]
|
25
|
+
attr_reader :x
|
26
|
+
|
27
|
+
# @!attribute [r] y
|
28
|
+
# @return [NilClass|Fixnum]
|
29
|
+
attr_reader :y
|
30
|
+
|
31
|
+
# @param attributes [Hash<Symbol => Array<Symbol|String>, Fixnum, String, Symbol]
|
32
|
+
# @option attributes background [NilClass|String]
|
33
|
+
# @option attributes foreground [NilClass|String]
|
34
|
+
# @option attributes style [NilClass|Array<Symbol|String>|Symbol|String]
|
35
|
+
# @option attributes value [NilClass|String]
|
36
|
+
# @option attributes x [NilClass|Fixnum]
|
37
|
+
# @option attributes y [NilClass|Fixnum]
|
38
|
+
# @return [Vedeu::Cell]
|
39
|
+
def initialize(attributes = {})
|
40
|
+
@background = attributes[:background]
|
41
|
+
@foreground = attributes[:foreground]
|
42
|
+
@style = attributes[:style]
|
43
|
+
@value = attributes[:value]
|
44
|
+
@x = attributes[:x]
|
45
|
+
@y = attributes[:y]
|
46
|
+
end
|
47
|
+
|
48
|
+
# @param other [Vedeu::Cell]
|
49
|
+
# @return [Boolean]
|
50
|
+
def ==(other)
|
51
|
+
eql?(other)
|
52
|
+
end
|
53
|
+
|
54
|
+
# @param other [Vedeu::Cell]
|
55
|
+
# @return [Boolean]
|
56
|
+
def eql?(other)
|
57
|
+
self.class == other.class &&
|
58
|
+
background == other.background &&
|
59
|
+
foreground == other.foreground &&
|
60
|
+
style == other.style &&
|
61
|
+
value == other.value &&
|
62
|
+
x == other.x &&
|
63
|
+
y == other.y
|
64
|
+
end
|
65
|
+
|
66
|
+
end # Cell
|
67
|
+
|
68
|
+
end # Vedeu
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'vedeu/geometry/
|
1
|
+
require 'vedeu/geometry/content'
|
2
2
|
require 'vedeu/models/all'
|
3
3
|
require 'vedeu/output/presentation'
|
4
4
|
require 'vedeu/buffers/display_buffer'
|
@@ -132,7 +132,7 @@ module Vedeu
|
|
132
132
|
|
133
133
|
# @return [Vedeu::Geometry]
|
134
134
|
def geometry
|
135
|
-
Vedeu.geometries.find(name)
|
135
|
+
@geometry ||= Vedeu.geometries.find(name)
|
136
136
|
end
|
137
137
|
|
138
138
|
# @return [Vedeu::Lines]
|
@@ -148,6 +148,8 @@ module Vedeu
|
|
148
148
|
def lines?
|
149
149
|
lines.any?
|
150
150
|
end
|
151
|
+
alias_method :content?, :lines?
|
152
|
+
alias_method :value?, :lines?
|
151
153
|
|
152
154
|
# @return [Interface]
|
153
155
|
def store
|
data/lib/vedeu/output/all.rb
CHANGED
data/lib/vedeu/output/border.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'vedeu/repositories/all'
|
1
2
|
require 'vedeu/dsl/components/all'
|
2
3
|
|
3
4
|
module Vedeu
|
@@ -33,18 +34,22 @@ module Vedeu
|
|
33
34
|
# @!attribute [rw] show_bottom
|
34
35
|
# @return [Boolean]
|
35
36
|
attr_accessor :show_bottom
|
37
|
+
alias_method :bottom?, :show_bottom
|
36
38
|
|
37
39
|
# @!attribute [rw] show_left
|
38
40
|
# @return [Boolean]
|
39
41
|
attr_accessor :show_left
|
42
|
+
alias_method :left?, :show_left
|
40
43
|
|
41
44
|
# @!attribute [rw] show_right
|
42
45
|
# @return [Boolean]
|
43
46
|
attr_accessor :show_right
|
47
|
+
alias_method :right?, :show_right
|
44
48
|
|
45
49
|
# @!attribute [rw] show_top
|
46
50
|
# @return [Boolean]
|
47
51
|
attr_accessor :show_top
|
52
|
+
alias_method :top?, :show_top
|
48
53
|
|
49
54
|
# @!attribute [rw] top_left
|
50
55
|
# @return [String]
|
@@ -69,17 +74,12 @@ module Vedeu
|
|
69
74
|
# @!attribute [r] enabled
|
70
75
|
# @return [Boolean]
|
71
76
|
attr_reader :enabled
|
77
|
+
alias_method :enabled?, :enabled
|
72
78
|
|
73
79
|
# @!attribute [r] style
|
74
80
|
# @return [Style]
|
75
81
|
attr_reader :style
|
76
82
|
|
77
|
-
alias_method :enabled?, :enabled
|
78
|
-
alias_method :bottom?, :show_bottom
|
79
|
-
alias_method :left?, :show_left
|
80
|
-
alias_method :right?, :show_right
|
81
|
-
alias_method :top?, :show_top
|
82
|
-
|
83
83
|
# Returns a new instance of Border.
|
84
84
|
#
|
85
85
|
# @param attributes [Hash]
|
data/lib/vedeu/output/clear.rb
CHANGED
@@ -4,8 +4,6 @@ module Vedeu
|
|
4
4
|
#
|
5
5
|
class Clear
|
6
6
|
|
7
|
-
include Vedeu::CharBuilder
|
8
|
-
|
9
7
|
# Clears the area defined by the interface.
|
10
8
|
#
|
11
9
|
# @return [Array|String]
|
@@ -28,9 +26,12 @@ module Vedeu
|
|
28
26
|
#
|
29
27
|
# @return [Array<Array<Vedeu::Char>>]
|
30
28
|
def clear
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
Array.new(interface.height) do |iy|
|
30
|
+
Array.new(interface.width) do |ix|
|
31
|
+
Vedeu::Char.new({ value: ' ',
|
32
|
+
colour: interface.colour,
|
33
|
+
style: interface.style,
|
34
|
+
position: Vedeu::IndexPosition[iy, ix, interface.top, interface.left] })
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
data/lib/vedeu/output/colour.rb
CHANGED
data/lib/vedeu/output/esc.rb
CHANGED
@@ -40,7 +40,7 @@ module Vedeu
|
|
40
40
|
# :light_cyan
|
41
41
|
# :white
|
42
42
|
#
|
43
|
-
# @return [Hash]
|
43
|
+
# @return [Hash<Symbol => Fixnum>]
|
44
44
|
def codes
|
45
45
|
{
|
46
46
|
black: 30,
|
@@ -67,7 +67,7 @@ module Vedeu
|
|
67
67
|
# Produces the background named colour escape sequence hash from the
|
68
68
|
# foreground escape sequence hash.
|
69
69
|
#
|
70
|
-
# @return [Hash]
|
70
|
+
# @return [Hash<Symbol => Fixnum>]
|
71
71
|
def background_codes
|
72
72
|
Vedeu::Esc.codes.inject({}) { |h, (k, v)| h.merge!(k => v + 10) }
|
73
73
|
end
|
data/lib/vedeu/output/output.rb
CHANGED
@@ -11,8 +11,6 @@ module Vedeu
|
|
11
11
|
#
|
12
12
|
class Output
|
13
13
|
|
14
|
-
include Vedeu::CharBuilder
|
15
|
-
|
16
14
|
# Writes content (the provided interface object with associated lines,
|
17
15
|
# streams, colours and styles) to the area defined by the interface.
|
18
16
|
#
|
@@ -65,7 +63,7 @@ module Vedeu
|
|
65
63
|
row = []
|
66
64
|
line.each_with_index do |char, ix|
|
67
65
|
row << if char.x != ix || char.y != iy
|
68
|
-
char.position =
|
66
|
+
char.position = Vedeu::IndexPosition[iy, ix, interface.top, interface.left]
|
69
67
|
char
|
70
68
|
|
71
69
|
else
|
data/lib/vedeu/output/style.rb
CHANGED
@@ -17,7 +17,7 @@ module Vedeu
|
|
17
17
|
|
18
18
|
# Return a new instance of Vedeu::Style.
|
19
19
|
#
|
20
|
-
# @param value [Array
|
20
|
+
# @param value [Array<String|Symbol>|String|Symbol]
|
21
21
|
# The style value or a collection of values.
|
22
22
|
# @return [Style]
|
23
23
|
def initialize(value = nil)
|
@@ -26,7 +26,7 @@ module Vedeu
|
|
26
26
|
|
27
27
|
# Return an attributes hash for this class.
|
28
28
|
#
|
29
|
-
# @return [
|
29
|
+
# @return [Array<String|Symbol>|String|Symbol]
|
30
30
|
def attributes
|
31
31
|
{
|
32
32
|
style: value
|
data/lib/vedeu/output/text.rb
CHANGED
@@ -54,6 +54,8 @@ module Vedeu
|
|
54
54
|
options[:anchor]
|
55
55
|
end
|
56
56
|
|
57
|
+
# The string padded to width, centralized.
|
58
|
+
#
|
57
59
|
# @return [String]
|
58
60
|
def centre
|
59
61
|
string.center(width, pad)
|
@@ -61,7 +63,7 @@ module Vedeu
|
|
61
63
|
|
62
64
|
# The default values for a new instance of this class.
|
63
65
|
#
|
64
|
-
# @return [Hash]
|
66
|
+
# @return [Hash<Symbol => NilClass, String, Symbol>]
|
65
67
|
def defaults
|
66
68
|
{
|
67
69
|
anchor: :left,
|
@@ -70,36 +72,50 @@ module Vedeu
|
|
70
72
|
}
|
71
73
|
end
|
72
74
|
|
75
|
+
# The string padded to width, left justified.
|
76
|
+
#
|
73
77
|
# @return [String]
|
74
78
|
def left
|
75
79
|
string.ljust(width, pad)
|
76
80
|
end
|
77
81
|
|
82
|
+
# The character to use for padding the string.
|
83
|
+
#
|
78
84
|
# @return [String]
|
79
85
|
def pad
|
80
86
|
options[:pad]
|
81
87
|
end
|
82
88
|
|
89
|
+
# The string padded to width, right justified.
|
90
|
+
#
|
83
91
|
# @return [String]
|
84
92
|
def right
|
85
93
|
string.rjust(width, pad)
|
86
94
|
end
|
87
95
|
|
96
|
+
# The string, coerced.
|
97
|
+
#
|
88
98
|
# @return [String]
|
89
99
|
def string
|
90
100
|
value.to_s
|
91
101
|
end
|
92
102
|
|
103
|
+
# Return a boolean indicating that the string is greater than the width.
|
104
|
+
#
|
93
105
|
# @return [Boolean]
|
94
106
|
def truncate?
|
95
107
|
string.size > width
|
96
108
|
end
|
97
109
|
|
110
|
+
# Return the string truncated to the width.
|
111
|
+
#
|
98
112
|
# @return [String]
|
99
113
|
def truncated
|
100
114
|
string.slice(0, width)
|
101
115
|
end
|
102
116
|
|
117
|
+
# Return the width.
|
118
|
+
#
|
103
119
|
# @return [Fixnum]
|
104
120
|
def width
|
105
121
|
options[:width]
|
@@ -124,17 +124,10 @@ module Vedeu
|
|
124
124
|
[numbered_prefix, css_to_numbered, 'm'].join
|
125
125
|
end
|
126
126
|
|
127
|
-
# Returns a boolean indicated whether the colour is an HTML/CSS colour.
|
128
|
-
#
|
129
|
-
# @return [Boolean]
|
130
|
-
def rgb?
|
131
|
-
colour.is_a?(String) && valid_rgb?
|
132
|
-
end
|
133
|
-
|
134
127
|
# Returns a boolean indicated whether the colour is a valid HTML/CSS colour.
|
135
128
|
#
|
136
129
|
# @return [Boolean]
|
137
|
-
def
|
130
|
+
def rgb?
|
138
131
|
!!(colour =~ /^#([A-Fa-f0-9]{6})$/)
|
139
132
|
end
|
140
133
|
|
@@ -91,7 +91,7 @@ module Vedeu
|
|
91
91
|
# @param data [Vedeu::Char]
|
92
92
|
# @return [Vedeu::Char]
|
93
93
|
def write(y, x, data)
|
94
|
-
return false unless read(y, x).is_a?(Vedeu::
|
94
|
+
return false unless read(y, x).is_a?(Vedeu::Cell)
|
95
95
|
|
96
96
|
cy, cx = Vedeu::PositionIndex[y, x]
|
97
97
|
cells[cy][cx] = data
|
@@ -109,10 +109,10 @@ module Vedeu
|
|
109
109
|
from[which] || []
|
110
110
|
end
|
111
111
|
|
112
|
-
# @return [Array<Array<Vedeu::
|
112
|
+
# @return [Array<Array<Vedeu::Cell>>]
|
113
113
|
# @see {Vedeu::VirtualTerminal#cells}
|
114
114
|
def new_virtual_terminal
|
115
|
-
Array.new(height) { Array.new(width) { Vedeu::
|
115
|
+
Array.new(height) { Array.new(width) { Vedeu::Cell.new } }
|
116
116
|
end
|
117
117
|
|
118
118
|
end # VirtualTerminal
|
@@ -62,7 +62,7 @@ module Vedeu
|
|
62
62
|
#
|
63
63
|
# @param name [String]
|
64
64
|
# @raise [ModelNotFound] When the model cannot be found with this name.
|
65
|
-
# @return [Hash]
|
65
|
+
# @return [Hash<String => Object>]
|
66
66
|
def find(name)
|
67
67
|
storage.fetch(name) do
|
68
68
|
fail ModelNotFound, "Cannot find model by name: '#{name}'"
|
data/lib/vedeu/support/log.rb
CHANGED
data/lib/vedeu/support/trace.rb
CHANGED
@@ -4,6 +4,7 @@ require 'vedeu/support/log'
|
|
4
4
|
|
5
5
|
module Vedeu
|
6
6
|
|
7
|
+
# :nocov:
|
7
8
|
# This class currently provides the means to trace each method call which
|
8
9
|
# occurs inside Vedeu. This is very useful (to me!) for debugging. Running
|
9
10
|
# this will make your application less responsive, and the tests
|
@@ -194,7 +195,7 @@ module Vedeu
|
|
194
195
|
# 'Vedeu::Config::CLI',
|
195
196
|
'Vedeu::Configuration',
|
196
197
|
# 'Vedeu::Console',
|
197
|
-
# 'Vedeu::
|
198
|
+
# 'Vedeu::Content',
|
198
199
|
# 'Vedeu::Coordinate',
|
199
200
|
# 'Vedeu::Cursor',
|
200
201
|
# 'Vedeu::DisplayBuffer',
|
@@ -233,7 +234,7 @@ module Vedeu
|
|
233
234
|
# 'Vedeu::Menus',
|
234
235
|
# 'Vedeu::Model',
|
235
236
|
# 'Vedeu::Collection',
|
236
|
-
# 'Vedeu::
|
237
|
+
# 'Vedeu::Move',
|
237
238
|
# 'Vedeu::Node',
|
238
239
|
# 'Vedeu::Output',
|
239
240
|
'Vedeu::Position',
|
@@ -249,7 +250,7 @@ module Vedeu
|
|
249
250
|
'Vedeu::Style',
|
250
251
|
'Vedeu::Terminal',
|
251
252
|
# 'Vedeu::Text',
|
252
|
-
# 'Vedeu::
|
253
|
+
# 'Vedeu::Toggle',
|
253
254
|
'Vedeu::Trace',
|
254
255
|
'Vedeu::Translator',
|
255
256
|
# 'Vedeu::Traps',
|
@@ -263,5 +264,6 @@ module Vedeu
|
|
263
264
|
end
|
264
265
|
|
265
266
|
end # Trace
|
267
|
+
# :nocov:
|
266
268
|
|
267
269
|
end # Vedeu
|
@@ -2,12 +2,12 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe Move do
|
6
6
|
|
7
|
-
let(:described) { Vedeu::
|
7
|
+
let(:described) { Vedeu::Move }
|
8
8
|
let(:instance) { described.new(cursor, interface, dy, dx) }
|
9
9
|
let(:cursor) {
|
10
|
-
Cursor.new({ name: '
|
10
|
+
Cursor.new({ name: 'Move',
|
11
11
|
ox: ox,
|
12
12
|
oy: oy,
|
13
13
|
state: :show,
|
@@ -59,7 +59,7 @@ module Vedeu
|
|
59
59
|
end
|
60
60
|
|
61
61
|
describe '#initialize' do
|
62
|
-
it { instance.must_be_instance_of(Vedeu::
|
62
|
+
it { instance.must_be_instance_of(Vedeu::Move) }
|
63
63
|
it { instance.instance_variable_get('@cursor').must_equal(cursor) }
|
64
64
|
it { instance.instance_variable_get('@interface').must_equal(interface) }
|
65
65
|
it { instance.instance_variable_get('@dy').must_equal(dy) }
|
@@ -78,7 +78,7 @@ module Vedeu
|
|
78
78
|
Vedeu::Cursor.new({ name: 'manganese', oy: 2, ox: 3, x: 8, y: 7 }).store
|
79
79
|
end
|
80
80
|
|
81
|
-
subject {
|
81
|
+
subject { Move.by_name(direction, _name) }
|
82
82
|
|
83
83
|
it { subject.must_be_instance_of(Vedeu::Cursor) }
|
84
84
|
|
@@ -119,7 +119,7 @@ module Vedeu
|
|
119
119
|
end
|
120
120
|
|
121
121
|
describe '.down' do
|
122
|
-
subject {
|
122
|
+
subject { Move.down(cursor, interface) }
|
123
123
|
|
124
124
|
it { subject.must_be_instance_of(Vedeu::Cursor) }
|
125
125
|
|
@@ -127,7 +127,7 @@ module Vedeu
|
|
127
127
|
|
128
128
|
context 'when moving, the cursor must be within the boundary of the ' \
|
129
129
|
'interface' do
|
130
|
-
subject {
|
130
|
+
subject { Move.down(cursor, interface_without_border) }
|
131
131
|
let(:y) { 15 }
|
132
132
|
|
133
133
|
it 'does not move past the bottom of the interface' do
|
@@ -137,7 +137,7 @@ module Vedeu
|
|
137
137
|
|
138
138
|
context 'when moving, the cursor must be within the border of the ' \
|
139
139
|
'interface' do
|
140
|
-
subject {
|
140
|
+
subject { Move.down(cursor, interface_with_border) }
|
141
141
|
let(:y) { 15 }
|
142
142
|
|
143
143
|
it 'does not move past the bottom border' do
|
@@ -147,7 +147,7 @@ module Vedeu
|
|
147
147
|
end
|
148
148
|
|
149
149
|
describe '.left' do
|
150
|
-
subject {
|
150
|
+
subject { Move.left(cursor, interface) }
|
151
151
|
|
152
152
|
it { subject.must_be_instance_of(Vedeu::Cursor) }
|
153
153
|
|
@@ -155,7 +155,7 @@ module Vedeu
|
|
155
155
|
|
156
156
|
context 'when moving, the cursor must be within the boundary of the ' \
|
157
157
|
'interface' do
|
158
|
-
subject {
|
158
|
+
subject { Move.left(cursor, interface_without_border) }
|
159
159
|
let(:x) { 3 }
|
160
160
|
|
161
161
|
it 'does not move past the left of the interface' do
|
@@ -165,7 +165,7 @@ module Vedeu
|
|
165
165
|
|
166
166
|
context 'when moving, the cursor must be within the border of the ' \
|
167
167
|
'interface' do
|
168
|
-
subject {
|
168
|
+
subject { Move.left(cursor, interface_with_border) }
|
169
169
|
let(:x) { 4 }
|
170
170
|
|
171
171
|
it 'does not move past the left border' do
|
@@ -175,7 +175,7 @@ module Vedeu
|
|
175
175
|
end
|
176
176
|
|
177
177
|
describe '.right' do
|
178
|
-
subject {
|
178
|
+
subject { Move.right(cursor, interface) }
|
179
179
|
|
180
180
|
it { subject.must_be_instance_of(Vedeu::Cursor) }
|
181
181
|
|
@@ -183,7 +183,7 @@ module Vedeu
|
|
183
183
|
|
184
184
|
context 'when moving, the cursor must be within the boundary of the ' \
|
185
185
|
'interface' do
|
186
|
-
subject {
|
186
|
+
subject { Move.right(cursor, interface_without_border) }
|
187
187
|
let(:x) { 14 }
|
188
188
|
|
189
189
|
it 'does not move past the right of the interface' do
|
@@ -193,7 +193,7 @@ module Vedeu
|
|
193
193
|
|
194
194
|
context 'when moving, the cursor must be within the border of the ' \
|
195
195
|
'interface' do
|
196
|
-
subject {
|
196
|
+
subject { Move.right(cursor, interface_with_border) }
|
197
197
|
|
198
198
|
let(:x) { 14 }
|
199
199
|
|
@@ -204,7 +204,7 @@ module Vedeu
|
|
204
204
|
end
|
205
205
|
|
206
206
|
describe '.up' do
|
207
|
-
subject {
|
207
|
+
subject { Move.up(cursor, interface) }
|
208
208
|
|
209
209
|
it { subject.must_be_instance_of(Vedeu::Cursor) }
|
210
210
|
|
@@ -212,7 +212,7 @@ module Vedeu
|
|
212
212
|
|
213
213
|
context 'when moving, the cursor must be within the boundary of the ' \
|
214
214
|
'interface' do
|
215
|
-
subject {
|
215
|
+
subject { Move.up(cursor, interface_without_border) }
|
216
216
|
|
217
217
|
let(:y) { 3 }
|
218
218
|
|
@@ -223,7 +223,7 @@ module Vedeu
|
|
223
223
|
|
224
224
|
context 'when moving, the cursor must be within the border of the ' \
|
225
225
|
'interface' do
|
226
|
-
subject {
|
226
|
+
subject { Move.up(cursor, interface_with_border) }
|
227
227
|
|
228
228
|
let(:y) { 3 }
|
229
229
|
|
@@ -234,7 +234,7 @@ module Vedeu
|
|
234
234
|
end
|
235
235
|
|
236
236
|
describe '#origin' do
|
237
|
-
subject {
|
237
|
+
subject { Move.origin(cursor, interface) }
|
238
238
|
|
239
239
|
it { subject.must_be_instance_of(Vedeu::Cursor) }
|
240
240
|
|
@@ -244,14 +244,14 @@ module Vedeu
|
|
244
244
|
end
|
245
245
|
|
246
246
|
context 'within the boundary of the interface' do
|
247
|
-
subject {
|
247
|
+
subject { Move.origin(cursor, interface_without_border) }
|
248
248
|
|
249
249
|
it { subject.x.must_equal(5) }
|
250
250
|
it { subject.y.must_equal(5) }
|
251
251
|
end
|
252
252
|
|
253
253
|
context 'within the border of the interface' do
|
254
|
-
subject {
|
254
|
+
subject { Move.origin(cursor, interface_with_border) }
|
255
255
|
|
256
256
|
it { subject.x.must_equal(6) }
|
257
257
|
it { subject.y.must_equal(6) }
|
@@ -259,11 +259,11 @@ module Vedeu
|
|
259
259
|
end
|
260
260
|
|
261
261
|
describe '#move' do
|
262
|
-
subject {
|
262
|
+
subject { Move.new(cursor, interface, dy, dx).move }
|
263
263
|
|
264
264
|
it { subject.must_be_instance_of(Vedeu::Cursor) }
|
265
265
|
end
|
266
266
|
|
267
|
-
end #
|
267
|
+
end # Move
|
268
268
|
|
269
269
|
end # Vedeu
|
@@ -2,9 +2,9 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe Toggle do
|
6
6
|
|
7
|
-
let(:described) {
|
7
|
+
let(:described) { Toggle.new(cursor) }
|
8
8
|
let(:cursor) { Cursor.new({ name: 'vanadium',
|
9
9
|
ox: 1,
|
10
10
|
oy: 1,
|
@@ -14,12 +14,12 @@ module Vedeu
|
|
14
14
|
let(:state) { true }
|
15
15
|
|
16
16
|
describe '#initialize' do
|
17
|
-
it { described.must_be_instance_of(
|
17
|
+
it { described.must_be_instance_of(Toggle) }
|
18
18
|
it { described.instance_variable_get('@cursor').must_equal(cursor) }
|
19
19
|
end
|
20
20
|
|
21
21
|
describe '.hide' do
|
22
|
-
subject {
|
22
|
+
subject { Toggle.hide(cursor) }
|
23
23
|
|
24
24
|
it { subject.must_be_instance_of(Cursor) }
|
25
25
|
|
@@ -39,7 +39,7 @@ module Vedeu
|
|
39
39
|
end
|
40
40
|
|
41
41
|
describe '.show' do
|
42
|
-
subject {
|
42
|
+
subject { Toggle.show(cursor) }
|
43
43
|
|
44
44
|
it { subject.must_be_instance_of(Cursor) }
|
45
45
|
|
@@ -58,6 +58,6 @@ module Vedeu
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
end #
|
61
|
+
end # Toggle
|
62
62
|
|
63
63
|
end # Vedeu
|
@@ -146,7 +146,7 @@ module Vedeu
|
|
146
146
|
end
|
147
147
|
}
|
148
148
|
|
149
|
-
it { subject.geometry.x.must_equal(
|
149
|
+
it { subject.geometry.x.must_equal(1) }
|
150
150
|
end
|
151
151
|
|
152
152
|
context 'when a block is given' do
|
@@ -197,7 +197,7 @@ module Vedeu
|
|
197
197
|
end
|
198
198
|
}
|
199
199
|
|
200
|
-
it { subject.geometry.y.must_equal(
|
200
|
+
it { subject.geometry.y.must_equal(1) }
|
201
201
|
end
|
202
202
|
|
203
203
|
context 'when a block is given' do
|
@@ -205,6 +205,18 @@ module Vedeu
|
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
208
|
+
describe '#xn' do
|
209
|
+
subject { Vedeu::Geometry.build({}) { xn 15 } }
|
210
|
+
|
211
|
+
it { subject.xn.must_equal(15) }
|
212
|
+
end
|
213
|
+
|
214
|
+
describe '#yn' do
|
215
|
+
subject { Vedeu::Geometry.build({}) { yn 8 } }
|
216
|
+
|
217
|
+
it { subject.yn.must_equal(8) }
|
218
|
+
end
|
219
|
+
|
208
220
|
end # Geometry
|
209
221
|
|
210
222
|
end # DSL
|