vedeu 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/dsl.md +3 -3
- data/examples/borders_app.rb +2 -0
- data/examples/colours_app.rb +2 -0
- data/examples/configuration_app.rb +2 -0
- data/examples/drb_app.rb +2 -0
- data/examples/focus_app.rb +2 -0
- data/examples/hello_world.rb +2 -0
- data/examples/material_colours_app.rb +2 -0
- data/lib/vedeu.rb +2 -0
- data/lib/vedeu/all.rb +4 -13
- data/lib/vedeu/api.rb +7 -6
- data/lib/vedeu/borders/border.rb +1 -1
- data/lib/vedeu/borders/render_border.rb +18 -18
- data/lib/vedeu/buffers/buffer.rb +18 -28
- data/lib/vedeu/colours/colour.rb +1 -1
- data/lib/vedeu/colours/colour_translator.rb +1 -1
- data/lib/vedeu/cursor/cursor.rb +9 -6
- data/lib/vedeu/dsl/border.rb +1 -1
- data/lib/vedeu/dsl/composition.rb +5 -5
- data/lib/vedeu/dsl/geometry.rb +1 -1
- data/lib/vedeu/dsl/group.rb +1 -1
- data/lib/vedeu/dsl/interface.rb +69 -93
- data/lib/vedeu/dsl/keymap.rb +1 -1
- data/lib/vedeu/dsl/line.rb +11 -11
- data/lib/vedeu/dsl/shared.rb +81 -0
- data/lib/vedeu/dsl/stream.rb +3 -3
- data/lib/vedeu/dsl/view.rb +76 -64
- data/lib/vedeu/models/escape.rb +1 -1
- data/lib/vedeu/models/interface.rb +3 -57
- data/lib/vedeu/models/menu.rb +1 -1
- data/lib/vedeu/models/views/all.rb +22 -0
- data/lib/vedeu/models/views/char.rb +175 -0
- data/lib/vedeu/models/views/chars.rb +13 -0
- data/lib/vedeu/models/views/composition.rb +73 -0
- data/lib/vedeu/models/views/line.rb +111 -0
- data/lib/vedeu/models/views/lines.rb +13 -0
- data/lib/vedeu/models/views/stream.rb +122 -0
- data/lib/vedeu/models/views/streams.rb +13 -0
- data/lib/vedeu/models/views/view.rb +157 -0
- data/lib/vedeu/models/views/view_collection.rb +13 -0
- data/lib/vedeu/null/view.rb +67 -0
- data/lib/vedeu/output/clear/named_interface.rb +4 -4
- data/lib/vedeu/output/compressor.rb +6 -6
- data/lib/vedeu/output/html_char.rb +6 -6
- data/lib/vedeu/output/output.rb +3 -3
- data/lib/vedeu/output/presentation.rb +1 -1
- data/lib/vedeu/output/renderers/escape_sequence.rb +1 -1
- data/lib/vedeu/output/renderers/file.rb +1 -1
- data/lib/vedeu/output/renderers/html.rb +3 -3
- data/lib/vedeu/output/renderers/json.rb +4 -4
- data/lib/vedeu/output/renderers/null.rb +1 -1
- data/lib/vedeu/output/renderers/terminal.rb +5 -5
- data/lib/vedeu/output/renderers/text.rb +3 -3
- data/lib/vedeu/output/style.rb +1 -1
- data/lib/vedeu/output/text.rb +20 -15
- data/lib/vedeu/output/viewport.rb +16 -23
- data/lib/vedeu/output/virtual_buffer.rb +9 -8
- data/lib/vedeu/output/virtual_terminal.rb +11 -11
- data/lib/vedeu/output/wordwrap.rb +5 -5
- data/lib/vedeu/runtime/application.rb +1 -1
- data/lib/vedeu/runtime/main_loop.rb +1 -1
- data/lib/vedeu/templating/helpers.rb +11 -10
- data/lib/vedeu/templating/template.rb +1 -1
- data/lib/vedeu/templating/view_template.rb +6 -6
- data/lib/vedeu/version.rb +1 -2
- data/test/lib/vedeu/api_test.rb +30 -30
- data/test/lib/vedeu/buffers/buffer_test.rb +5 -139
- data/test/lib/vedeu/colours/colour_translator_test.rb +3 -3
- data/test/lib/vedeu/configuration/api_test.rb +3 -3
- data/test/lib/vedeu/cursor/refresh_cursor_test.rb +1 -1
- data/test/lib/vedeu/dsl/composition_test.rb +7 -7
- data/test/lib/vedeu/dsl/group_test.rb +2 -2
- data/test/lib/vedeu/dsl/interface_test.rb +31 -21
- data/test/lib/vedeu/dsl/keymap_test.rb +4 -4
- data/test/lib/vedeu/dsl/line_test.rb +8 -8
- data/test/lib/vedeu/dsl/stream_test.rb +4 -4
- data/test/lib/vedeu/dsl/text_test.rb +11 -11
- data/test/lib/vedeu/dsl/view_test.rb +24 -29
- data/test/lib/vedeu/geometry/grid_test.rb +4 -4
- data/test/lib/vedeu/input/key_test.rb +1 -1
- data/test/lib/vedeu/internal_api_test.rb +18 -18
- data/test/lib/vedeu/models/focus_test.rb +54 -54
- data/test/lib/vedeu/models/interface_test.rb +11 -105
- data/test/lib/vedeu/models/menu_test.rb +1 -1
- data/test/lib/vedeu/models/views/char_test.rb +257 -0
- data/test/lib/vedeu/models/views/chars_test.rb +22 -0
- data/test/lib/vedeu/models/views/composition_test.rb +61 -0
- data/test/lib/vedeu/models/views/line_test.rb +189 -0
- data/test/lib/vedeu/models/views/lines_test.rb +22 -0
- data/test/lib/vedeu/models/views/stream_test.rb +138 -0
- data/test/lib/vedeu/models/views/streams_test.rb +22 -0
- data/test/lib/vedeu/models/views/view_test.rb +40 -0
- data/test/lib/vedeu/null/view_test.rb +12 -0
- data/test/lib/vedeu/output/clear/named_interface_test.rb +4 -4
- data/test/lib/vedeu/output/compressor_test.rb +28 -28
- data/test/lib/vedeu/output/html_char_test.rb +2 -2
- data/test/lib/vedeu/output/presentation_test.rb +10 -14
- data/test/lib/vedeu/output/renderers/escape_sequence_test.rb +20 -4
- data/test/lib/vedeu/output/renderers/html_test.rb +4 -4
- data/test/lib/vedeu/output/renderers/json_test.rb +3 -3
- data/test/lib/vedeu/output/text_test.rb +10 -10
- data/test/lib/vedeu/output/viewport_test.rb +21 -23
- data/test/lib/vedeu/output/virtual_buffer_test.rb +1 -1
- data/test/lib/vedeu/output/virtual_terminal_test.rb +1 -1
- data/test/lib/vedeu/output/wordwrap_test.rb +9 -9
- data/test/lib/vedeu/repositories/repository_test.rb +2 -2
- data/test/lib/vedeu/templating/helpers_test.rb +6 -39
- data/test/lib/vedeu/templating/template_test.rb +2 -2
- data/test/lib/vedeu/templating/view_template_test.rb +91 -91
- data/test/lib/vedeu/terminal_test.rb +1 -1
- metadata +33 -27
- data/lib/vedeu/buffers/display_buffer.rb +0 -39
- data/lib/vedeu/models/char.rb +0 -170
- data/lib/vedeu/models/chars.rb +0 -9
- data/lib/vedeu/models/composition.rb +0 -66
- data/lib/vedeu/models/line.rb +0 -112
- data/lib/vedeu/models/lines.rb +0 -9
- data/lib/vedeu/models/stream.rb +0 -122
- data/lib/vedeu/models/streams.rb +0 -9
- data/test/lib/vedeu/buffers/display_buffer_test.rb +0 -61
- data/test/lib/vedeu/models/char_test.rb +0 -253
- data/test/lib/vedeu/models/chars_test.rb +0 -18
- data/test/lib/vedeu/models/composition_test.rb +0 -57
- data/test/lib/vedeu/models/line_test.rb +0 -189
- data/test/lib/vedeu/models/lines_test.rb +0 -18
- data/test/lib/vedeu/models/stream_test.rb +0 -141
- data/test/lib/vedeu/models/streams_test.rb +0 -18
data/lib/vedeu/models/line.rb
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
|
3
|
-
# A Line represents a single row of the terminal. It is a container for
|
4
|
-
# {Vedeu::Stream} objects. A line's width is determined by the
|
5
|
-
# {Vedeu::Interface} it belongs to.
|
6
|
-
#
|
7
|
-
class Line
|
8
|
-
|
9
|
-
include Vedeu::Model
|
10
|
-
include Vedeu::Presentation
|
11
|
-
|
12
|
-
collection Vedeu::Streams
|
13
|
-
member Vedeu::Stream
|
14
|
-
|
15
|
-
# @!attribute [rw] parent
|
16
|
-
# @return [Vedeu::Interface]
|
17
|
-
attr_accessor :parent
|
18
|
-
|
19
|
-
# @!attribute [r] attributes
|
20
|
-
# @return [Hash]
|
21
|
-
attr_reader :attributes
|
22
|
-
|
23
|
-
# Returns a new instance of Vedeu::Line.
|
24
|
-
#
|
25
|
-
# @param attributes [Hash]
|
26
|
-
# @option attributes streams [Vedeu::Streams]
|
27
|
-
# @option attributes parent [Vedeu::Interface]
|
28
|
-
# @option attributes colour [Vedeu::Colour]
|
29
|
-
# @option attributes style [Vedeu::Style]
|
30
|
-
# @return [Vedeu::Line]
|
31
|
-
def initialize(attributes = {})
|
32
|
-
@attributes = defaults.merge!(attributes)
|
33
|
-
|
34
|
-
@attributes.each { |key, value| instance_variable_set("@#{key}", value) }
|
35
|
-
end
|
36
|
-
|
37
|
-
# @param child [void]
|
38
|
-
# @return [void]
|
39
|
-
def add(child)
|
40
|
-
@_streams = @streams = collection.coerce(streams, self).add(child)
|
41
|
-
end
|
42
|
-
alias_method :<<, :add
|
43
|
-
|
44
|
-
# Returns an array of all the characters with formatting for this line.
|
45
|
-
#
|
46
|
-
# @return [Array]
|
47
|
-
# @see Vedeu::Stream
|
48
|
-
def chars
|
49
|
-
return [] if empty?
|
50
|
-
|
51
|
-
@chars ||= streams.flat_map(&:chars)
|
52
|
-
end
|
53
|
-
|
54
|
-
# Returns a boolean indicating whether the line has content.
|
55
|
-
#
|
56
|
-
# @return [Boolean]
|
57
|
-
def empty?
|
58
|
-
streams.empty?
|
59
|
-
end
|
60
|
-
|
61
|
-
# An object is equal when its values are the same.
|
62
|
-
#
|
63
|
-
# @param other [Vedeu::Collection]
|
64
|
-
# @return [Boolean]
|
65
|
-
def eql?(other)
|
66
|
-
self.class == other.class && streams == other.streams
|
67
|
-
end
|
68
|
-
alias_method :==, :eql?
|
69
|
-
|
70
|
-
# @return [NilClass|String]
|
71
|
-
def name
|
72
|
-
parent.name if parent
|
73
|
-
end
|
74
|
-
|
75
|
-
# Returns the size of the content in characters without formatting.
|
76
|
-
#
|
77
|
-
# @return [Fixnum]
|
78
|
-
def size
|
79
|
-
streams.map(&:size).inject(0, :+)
|
80
|
-
end
|
81
|
-
|
82
|
-
# @return [Vedeu::Streams]
|
83
|
-
def streams
|
84
|
-
@_streams ||= collection.coerce(@streams, self)
|
85
|
-
end
|
86
|
-
alias_method :value, :streams
|
87
|
-
|
88
|
-
# Delegate to Vedeu::Interface#width when available.
|
89
|
-
#
|
90
|
-
# @return [Fixnum]
|
91
|
-
def width
|
92
|
-
parent.width if parent
|
93
|
-
end
|
94
|
-
|
95
|
-
private
|
96
|
-
|
97
|
-
# The default values for a new instance of this class.
|
98
|
-
#
|
99
|
-
# @return [Hash]
|
100
|
-
def defaults
|
101
|
-
{
|
102
|
-
client: nil,
|
103
|
-
colour: nil,
|
104
|
-
parent: nil,
|
105
|
-
streams: [],
|
106
|
-
style: nil,
|
107
|
-
}
|
108
|
-
end
|
109
|
-
|
110
|
-
end # Line
|
111
|
-
|
112
|
-
end # Vedeu
|
data/lib/vedeu/models/lines.rb
DELETED
data/lib/vedeu/models/stream.rb
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
|
3
|
-
# A Stream can represent a character or collection of characters as part of a
|
4
|
-
# {Vedeu::Line} which you wish to colour and style independently of the other
|
5
|
-
# characters in that line.
|
6
|
-
#
|
7
|
-
class Stream
|
8
|
-
|
9
|
-
include Vedeu::Model
|
10
|
-
include Vedeu::Presentation
|
11
|
-
|
12
|
-
collection Vedeu::Chars
|
13
|
-
member Vedeu::Char
|
14
|
-
|
15
|
-
# @!attribute [rw] parent
|
16
|
-
# @return [Vedeu::Line]
|
17
|
-
attr_accessor :parent
|
18
|
-
|
19
|
-
# @!attribute [rw] value
|
20
|
-
# @return [String]
|
21
|
-
attr_accessor :value
|
22
|
-
alias_method :content, :value
|
23
|
-
alias_method :data, :value
|
24
|
-
alias_method :text, :value
|
25
|
-
|
26
|
-
# @!attribute [r] attributes
|
27
|
-
# @return [Hash]
|
28
|
-
attr_reader :attributes
|
29
|
-
|
30
|
-
# Returns a new instance of Vedeu::Stream.
|
31
|
-
#
|
32
|
-
# @param attributes [Hash]
|
33
|
-
# @option attributes value [String]
|
34
|
-
# @option attributes parent [Vedeu::Line]
|
35
|
-
# @option attributes colour [Vedeu::Colour]
|
36
|
-
# @option attributes style [Vedeu::Style]
|
37
|
-
# @return [Vedeu::Stream]
|
38
|
-
def initialize(attributes = {})
|
39
|
-
@attributes = defaults.merge!(attributes)
|
40
|
-
|
41
|
-
@attributes.each { |key, value| instance_variable_set("@#{key}", value) }
|
42
|
-
end
|
43
|
-
|
44
|
-
# @param child [Vedeu::Stream]
|
45
|
-
# @return [Vedeu::Streams]
|
46
|
-
def add(child)
|
47
|
-
parent.add(child)
|
48
|
-
end
|
49
|
-
alias_method :<<, :add
|
50
|
-
|
51
|
-
# Returns an array of characters, each element is the escape sequences of
|
52
|
-
# colours and styles for this stream, the character itself, and the escape
|
53
|
-
# sequences of colours and styles for the parent of the stream
|
54
|
-
# ({Vedeu::Line}).
|
55
|
-
#
|
56
|
-
# @return [Array]
|
57
|
-
def chars
|
58
|
-
return [] if empty?
|
59
|
-
|
60
|
-
@chars ||= value.chars.map do |char|
|
61
|
-
member.new(value: char,
|
62
|
-
parent: parent,
|
63
|
-
colour: colour,
|
64
|
-
style: style,
|
65
|
-
position: nil)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
# Returns a boolean indicating whether the stream has content.
|
70
|
-
#
|
71
|
-
# @return [Boolean]
|
72
|
-
def empty?
|
73
|
-
value.empty?
|
74
|
-
end
|
75
|
-
|
76
|
-
# An object is equal when its values are the same.
|
77
|
-
#
|
78
|
-
# @param other [Vedeu::Char]
|
79
|
-
# @return [Boolean]
|
80
|
-
def eql?(other)
|
81
|
-
self.class == other.class && value == other.value &&
|
82
|
-
colour == other.colour && style == other.style && parent == other.parent
|
83
|
-
end
|
84
|
-
alias_method :==, :eql?
|
85
|
-
|
86
|
-
# @return [NilClass|String]
|
87
|
-
def name
|
88
|
-
parent.name if parent
|
89
|
-
end
|
90
|
-
|
91
|
-
# Returns the size of the content in characters without formatting.
|
92
|
-
#
|
93
|
-
# @return [Fixnum]
|
94
|
-
def size
|
95
|
-
value.size
|
96
|
-
end
|
97
|
-
|
98
|
-
# Delegate to Vedeu::Line#width when available.
|
99
|
-
#
|
100
|
-
# @return [Fixnum]
|
101
|
-
def width
|
102
|
-
parent.width if parent
|
103
|
-
end
|
104
|
-
|
105
|
-
private
|
106
|
-
|
107
|
-
# The default values for a new instance of this class.
|
108
|
-
#
|
109
|
-
# @return [Hash]
|
110
|
-
def defaults
|
111
|
-
{
|
112
|
-
client: nil,
|
113
|
-
colour: nil,
|
114
|
-
parent: nil,
|
115
|
-
style: nil,
|
116
|
-
value: '',
|
117
|
-
}
|
118
|
-
end
|
119
|
-
|
120
|
-
end # Stream
|
121
|
-
|
122
|
-
end # Vedeu
|
data/lib/vedeu/models/streams.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
class TestInterfaceModel
|
6
|
-
include Vedeu::Model
|
7
|
-
include Vedeu::DisplayBuffer
|
8
|
-
|
9
|
-
def colour
|
10
|
-
Vedeu::Colour.new(background: '#000000', foreground: '#ffffff')
|
11
|
-
end
|
12
|
-
|
13
|
-
def name
|
14
|
-
'test_interface_model'
|
15
|
-
end
|
16
|
-
|
17
|
-
def style
|
18
|
-
Vedeu::Style.new(:normal)
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def repository
|
24
|
-
Vedeu.interfaces
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe DisplayBuffer do
|
29
|
-
|
30
|
-
let(:described) { Vedeu::DisplayBuffer }
|
31
|
-
let(:example_model) { Vedeu::TestInterfaceModel }
|
32
|
-
let(:example_instance) { example_model.new }
|
33
|
-
|
34
|
-
before {
|
35
|
-
example_instance.store
|
36
|
-
|
37
|
-
Vedeu::Refresh.stubs(:by_name)
|
38
|
-
}
|
39
|
-
after { Vedeu.interfaces.reset }
|
40
|
-
|
41
|
-
describe '#store_immediate' do
|
42
|
-
subject { example_instance.store_immediate }
|
43
|
-
|
44
|
-
it { subject.must_be_instance_of(example_model) }
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '#store_deferred' do
|
48
|
-
subject { example_instance.store_deferred }
|
49
|
-
|
50
|
-
it { subject.must_be_instance_of(example_model) }
|
51
|
-
|
52
|
-
context 'when the name is not defined' do
|
53
|
-
before { example_instance.stubs(:name) }
|
54
|
-
|
55
|
-
it { proc { subject }.must_raise(InvalidSyntax) }
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
end # DisplayBuffer
|
60
|
-
|
61
|
-
end # Vedeu
|
@@ -1,253 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe Char do
|
6
|
-
|
7
|
-
let(:described) { Vedeu::Char }
|
8
|
-
let(:instance) { described.new(attributes) }
|
9
|
-
let(:attributes) {
|
10
|
-
{
|
11
|
-
border: border,
|
12
|
-
colour: colour,
|
13
|
-
parent: parent,
|
14
|
-
position: position,
|
15
|
-
style: style,
|
16
|
-
value: _value,
|
17
|
-
}
|
18
|
-
}
|
19
|
-
let(:_value) { 'a' }
|
20
|
-
let(:parent) { Vedeu::Line.new(parent_attributes) }
|
21
|
-
let(:parent_attributes) {
|
22
|
-
{
|
23
|
-
streams: [],
|
24
|
-
parent: nil,
|
25
|
-
colour: parent_colour,
|
26
|
-
style: parent_style,
|
27
|
-
}
|
28
|
-
}
|
29
|
-
let(:border) { nil }
|
30
|
-
let(:colour) { nil }
|
31
|
-
let(:style) { nil }
|
32
|
-
let(:position) { nil }
|
33
|
-
let(:parent_colour) { nil }
|
34
|
-
let(:parent_style) { nil }
|
35
|
-
|
36
|
-
describe '#initialize' do
|
37
|
-
it { instance.must_be_instance_of(described) }
|
38
|
-
it { instance.instance_variable_get('@border').must_equal(border) }
|
39
|
-
it { instance.instance_variable_get('@parent').must_equal(parent) }
|
40
|
-
it { instance.instance_variable_get('@value').must_equal(_value) }
|
41
|
-
|
42
|
-
it { instance.must_respond_to(:value) }
|
43
|
-
end
|
44
|
-
|
45
|
-
describe 'accessors' do
|
46
|
-
it { instance.must_respond_to(:border) }
|
47
|
-
it { instance.must_respond_to(:border=) }
|
48
|
-
it { instance.must_respond_to(:parent) }
|
49
|
-
it { instance.must_respond_to(:parent=) }
|
50
|
-
it { instance.must_respond_to(:attributes) }
|
51
|
-
it { instance.must_respond_to(:value=) }
|
52
|
-
end
|
53
|
-
|
54
|
-
describe '#chars' do
|
55
|
-
subject { instance.chars }
|
56
|
-
|
57
|
-
it { subject.must_be_instance_of(Array) }
|
58
|
-
end
|
59
|
-
|
60
|
-
describe '#eql?' do
|
61
|
-
let(:other) { instance }
|
62
|
-
|
63
|
-
subject { instance.eql?(other) }
|
64
|
-
|
65
|
-
it { subject.must_equal(true) }
|
66
|
-
|
67
|
-
context 'when different to other' do
|
68
|
-
let(:other) { described.new(value: 'b') }
|
69
|
-
|
70
|
-
it { subject.must_equal(false) }
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe '#inspect' do
|
75
|
-
let(:colour) { Vedeu::Colour.new(foreground: '#00ff00',
|
76
|
-
background: '#005500') }
|
77
|
-
let(:position) { Vedeu::Position[17, 2] }
|
78
|
-
let(:style) { Vedeu::Style.new('underline') }
|
79
|
-
|
80
|
-
|
81
|
-
subject { instance.inspect }
|
82
|
-
|
83
|
-
it { subject.must_equal(
|
84
|
-
"<Vedeu::Char '" \
|
85
|
-
"\\e[17;2H" \
|
86
|
-
"\\e[38;2;0;255;0m" \
|
87
|
-
"\\e[48;2;0;85;0m" \
|
88
|
-
"\\e[4ma" \
|
89
|
-
"'>"
|
90
|
-
) }
|
91
|
-
end
|
92
|
-
|
93
|
-
describe '#position' do
|
94
|
-
subject { instance.position }
|
95
|
-
end
|
96
|
-
|
97
|
-
describe '#position=' do
|
98
|
-
subject { instance.position=(value) }
|
99
|
-
end
|
100
|
-
|
101
|
-
describe '#to_hash' do
|
102
|
-
subject { instance.to_hash }
|
103
|
-
|
104
|
-
it { subject.must_be_instance_of(Hash) }
|
105
|
-
|
106
|
-
it { subject.must_equal(
|
107
|
-
border: '',
|
108
|
-
colour: {
|
109
|
-
background: '',
|
110
|
-
foreground: '',
|
111
|
-
},
|
112
|
-
parent: {
|
113
|
-
background: '',
|
114
|
-
foreground: '',
|
115
|
-
style: '',
|
116
|
-
},
|
117
|
-
position: {
|
118
|
-
y: nil,
|
119
|
-
x: nil
|
120
|
-
},
|
121
|
-
style: '',
|
122
|
-
value: 'a')
|
123
|
-
}
|
124
|
-
end
|
125
|
-
|
126
|
-
describe '#to_html' do
|
127
|
-
subject { instance.to_html }
|
128
|
-
|
129
|
-
it { subject.must_be_instance_of(String) }
|
130
|
-
end
|
131
|
-
|
132
|
-
describe '#to_s' do
|
133
|
-
subject { instance.to_s }
|
134
|
-
|
135
|
-
it { subject.must_be_instance_of(String) }
|
136
|
-
|
137
|
-
context 'when a position is specified' do
|
138
|
-
let(:position) { Vedeu::Position[17, 2] }
|
139
|
-
|
140
|
-
it { subject.must_equal("\e[17;2Ha") }
|
141
|
-
end
|
142
|
-
|
143
|
-
context 'when a position is not specified' do
|
144
|
-
let(:position) {}
|
145
|
-
|
146
|
-
it { subject.must_equal('a') }
|
147
|
-
end
|
148
|
-
|
149
|
-
context 'when a colour is specified' do
|
150
|
-
let(:colour) { Vedeu::Colour.new(foreground: '#00ff00',
|
151
|
-
background: '#005500') }
|
152
|
-
|
153
|
-
context 'and a parent colour is specified' do
|
154
|
-
let(:parent_colour) { Vedeu::Colour.new(foreground: '#ff0000',
|
155
|
-
background: '#550000') }
|
156
|
-
|
157
|
-
it { subject.must_equal("\e[38;2;0;255;0m\e[48;2;0;85;0ma") }
|
158
|
-
end
|
159
|
-
|
160
|
-
context 'and a parent colour is not specified' do
|
161
|
-
let(:parent_colour) {}
|
162
|
-
|
163
|
-
it { subject.must_equal("\e[38;2;0;255;0m\e[48;2;0;85;0ma") }
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
context 'when a colour is not specified' do
|
168
|
-
let(:colour) {}
|
169
|
-
|
170
|
-
it { subject.must_equal('a') }
|
171
|
-
end
|
172
|
-
|
173
|
-
context 'when a style is specified' do
|
174
|
-
let(:style) { Vedeu::Style.new('underline') }
|
175
|
-
|
176
|
-
context 'when a parent style is specified' do
|
177
|
-
let(:parent_style) { Vedeu::Style.new('bold') }
|
178
|
-
|
179
|
-
it { subject.must_equal("\e[4ma") }
|
180
|
-
end
|
181
|
-
|
182
|
-
context 'when a parent style is not specified' do
|
183
|
-
let(:parent_style) {}
|
184
|
-
|
185
|
-
it { subject.must_equal("\e[4ma") }
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
context 'when a style is not specified' do
|
190
|
-
let(:style) {}
|
191
|
-
|
192
|
-
it { subject.must_equal('a') }
|
193
|
-
end
|
194
|
-
|
195
|
-
context 'when the value is nil' do
|
196
|
-
let(:_value) {}
|
197
|
-
|
198
|
-
it { subject.must_equal('') }
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
describe '#value' do
|
203
|
-
subject { instance.value }
|
204
|
-
|
205
|
-
it { subject.must_be_instance_of(String) }
|
206
|
-
|
207
|
-
context 'when the border attribute is defined' do
|
208
|
-
let(:border) { :top_left }
|
209
|
-
let(:_value) { "\x6C" }
|
210
|
-
|
211
|
-
it { subject.must_equal("\e(0l\e(B") }
|
212
|
-
end
|
213
|
-
|
214
|
-
context 'when the border attributes is not defined' do
|
215
|
-
it { subject.must_equal('a') }
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
describe '#x' do
|
220
|
-
let(:position) { Vedeu::Position[17, 2] }
|
221
|
-
|
222
|
-
subject { instance.x }
|
223
|
-
|
224
|
-
context 'when a position is set' do
|
225
|
-
it { subject.must_equal(2) }
|
226
|
-
end
|
227
|
-
|
228
|
-
context 'when a position is not set' do
|
229
|
-
let(:position) {}
|
230
|
-
|
231
|
-
it { subject.must_equal(nil) }
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
describe '#y' do
|
236
|
-
let(:position) { Vedeu::Position[17, 2] }
|
237
|
-
|
238
|
-
subject { instance.y }
|
239
|
-
|
240
|
-
context 'when a position is set' do
|
241
|
-
it { subject.must_equal(17) }
|
242
|
-
end
|
243
|
-
|
244
|
-
context 'when a position is not set' do
|
245
|
-
let(:position) {}
|
246
|
-
|
247
|
-
it { subject.must_equal(nil) }
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
|
-
end # Char
|
252
|
-
|
253
|
-
end # Vedeu
|