vedeu 0.6.8 → 0.6.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +9 -0
- data/README.md +1 -1
- data/docs/api.md +60 -67
- data/docs/configuration.md +8 -5
- data/docs/events.md +31 -15
- data/docs/events/application.md +12 -0
- data/docs/events/document.md +57 -0
- data/docs/events/drb.md +43 -0
- data/docs/events/focus.md +24 -0
- data/docs/events/menu.md +57 -0
- data/docs/events/movement.md +57 -0
- data/docs/events/refresh.md +25 -0
- data/docs/events/system.md +90 -0
- data/docs/events/visibility.md +68 -0
- data/lib/vedeu.rb +2 -2
- data/lib/vedeu/all.rb +3 -2
- data/lib/vedeu/api.rb +18 -18
- data/lib/vedeu/application/controller.rb +1 -1
- data/lib/vedeu/application/helper.rb +1 -1
- data/lib/vedeu/application/view.rb +1 -1
- data/lib/vedeu/bindings/application.rb +1 -12
- data/lib/vedeu/bindings/bindings.rb +3 -1
- data/lib/vedeu/bindings/document.rb +9 -62
- data/lib/vedeu/bindings/drb.rb +12 -56
- data/lib/vedeu/bindings/focus.rb +3 -28
- data/lib/vedeu/bindings/menus.rb +10 -66
- data/lib/vedeu/bindings/movement.rb +4 -69
- data/lib/vedeu/bindings/refresh.rb +3 -33
- data/lib/vedeu/bindings/system.rb +14 -100
- data/lib/vedeu/bindings/visibility.rb +20 -71
- data/lib/vedeu/borders/all.rb +4 -3
- data/lib/vedeu/borders/border.rb +39 -33
- data/lib/vedeu/borders/dsl.rb +40 -33
- data/lib/vedeu/borders/null.rb +2 -2
- data/lib/vedeu/borders/render.rb +29 -24
- data/lib/vedeu/borders/repository.rb +2 -2
- data/lib/vedeu/buffers/all.rb +8 -7
- data/lib/vedeu/buffers/buffer.rb +47 -39
- data/lib/vedeu/buffers/null.rb +2 -2
- data/lib/vedeu/buffers/refresh.rb +4 -3
- data/lib/vedeu/buffers/virtual_buffer.rb +122 -118
- data/lib/vedeu/buffers/virtual_buffers.rb +62 -56
- data/lib/vedeu/colours/background.rb +2 -1
- data/lib/vedeu/colours/colour.rb +21 -19
- data/lib/vedeu/colours/foreground.rb +2 -1
- data/lib/vedeu/colours/repository.rb +6 -5
- data/lib/vedeu/colours/translator.rb +39 -35
- data/lib/vedeu/configuration/api.rb +59 -51
- data/lib/vedeu/configuration/cli.rb +9 -7
- data/lib/vedeu/configuration/configuration.rb +41 -32
- data/lib/vedeu/cursors/cursor.rb +1 -1
- data/lib/vedeu/cursors/refresh.rb +20 -16
- data/lib/vedeu/distributed/server.rb +8 -6
- data/lib/vedeu/distributed/subprocess.rb +90 -86
- data/lib/vedeu/distributed/uri.rb +4 -3
- data/lib/vedeu/dsl/composition.rb +2 -2
- data/lib/vedeu/dsl/group.rb +4 -4
- data/lib/vedeu/dsl/interface.rb +5 -5
- data/lib/vedeu/dsl/presentation.rb +2 -2
- data/lib/vedeu/dsl/text.rb +1 -1
- data/lib/vedeu/editor/cropper.rb +4 -4
- data/lib/vedeu/editor/cursor.rb +6 -4
- data/lib/vedeu/editor/document.rb +20 -18
- data/lib/vedeu/editor/editor.rb +2 -2
- data/lib/vedeu/editor/line.rb +10 -5
- data/lib/vedeu/editor/lines.rb +2 -2
- data/lib/vedeu/internal_api.rb +4 -4
- data/lib/vedeu/models/focus.rb +197 -191
- data/lib/vedeu/models/group.rb +171 -159
- data/lib/vedeu/models/groups.rb +14 -10
- data/lib/vedeu/models/interface.rb +116 -110
- data/lib/vedeu/models/interfaces.rb +24 -20
- data/lib/vedeu/models/toggleable.rb +4 -4
- data/lib/vedeu/models/views/char.rb +1 -1
- data/lib/vedeu/models/views/composition.rb +1 -1
- data/lib/vedeu/models/views/line.rb +1 -1
- data/lib/vedeu/models/views/stream.rb +1 -1
- data/lib/vedeu/models/views/view.rb +1 -1
- data/lib/vedeu/null/interface.rb +1 -1
- data/lib/vedeu/null/view.rb +1 -1
- data/lib/vedeu/output/clear/named_interface.rb +1 -1
- data/lib/vedeu/output/compressor.rb +78 -73
- data/lib/vedeu/output/direct.rb +61 -57
- data/lib/vedeu/output/output.rb +34 -29
- data/lib/vedeu/output/{presentation.rb → presentation/presentation.rb} +2 -1
- data/lib/vedeu/output/presentation/style.rb +64 -18
- data/lib/vedeu/output/presentation/styles.rb +39 -0
- data/lib/vedeu/output/renderers/html.rb +2 -2
- data/lib/vedeu/output/renderers/json.rb +2 -1
- data/lib/vedeu/output/renderers/terminal.rb +3 -3
- data/lib/vedeu/output/renderers/text.rb +3 -3
- data/lib/vedeu/output/text.rb +186 -180
- data/lib/vedeu/output/wordwrap.rb +142 -138
- data/lib/vedeu/refresh/refresh.rb +2 -2
- data/lib/vedeu/templating/helpers.rb +11 -6
- data/lib/vedeu/templating/view_template.rb +1 -1
- data/lib/vedeu/terminal/terminal.rb +2 -2
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/borders/render_test.rb +1 -1
- data/test/lib/vedeu/buffers/buffer_test.rb +16 -14
- data/test/lib/vedeu/buffers/virtual_buffer_test.rb +105 -101
- data/test/lib/vedeu/buffers/virtual_buffers_test.rb +43 -39
- data/test/lib/vedeu/colours/colour_test.rb +4 -4
- data/test/lib/vedeu/cursors/cursor_test.rb +2 -2
- data/test/lib/vedeu/cursors/repository_test.rb +3 -3
- data/test/lib/vedeu/distributed/subprocess_test.rb +33 -29
- data/test/lib/vedeu/dsl/group_test.rb +3 -3
- data/test/lib/vedeu/dsl/interface_test.rb +6 -5
- data/test/lib/vedeu/dsl/line_test.rb +4 -2
- data/test/lib/vedeu/dsl/presentation_test.rb +2 -2
- data/test/lib/vedeu/dsl/text_test.rb +8 -8
- data/test/lib/vedeu/editor/document_test.rb +10 -6
- data/test/lib/vedeu/input/keymap_test.rb +1 -10
- data/test/lib/vedeu/models/focus_test.rb +177 -170
- data/test/lib/vedeu/models/group_test.rb +99 -95
- data/test/lib/vedeu/models/groups_test.rb +13 -9
- data/test/lib/vedeu/models/interface_test.rb +93 -87
- data/test/lib/vedeu/models/interfaces_test.rb +24 -20
- data/test/lib/vedeu/models/views/char_test.rb +2 -2
- data/test/lib/vedeu/models/views/line_test.rb +11 -7
- data/test/lib/vedeu/models/views/stream_test.rb +1 -1
- data/test/lib/vedeu/models/views/view_test.rb +1 -1
- data/test/lib/vedeu/output/clear/named_group_test.rb +1 -1
- data/test/lib/vedeu/output/clear/named_interface_test.rb +3 -1
- data/test/lib/vedeu/output/compressor_test.rb +126 -122
- data/test/lib/vedeu/output/direct_test.rb +49 -43
- data/test/lib/vedeu/output/output_test.rb +35 -31
- data/test/lib/vedeu/output/{presentation_test.rb → presentation/presentation_test.rb} +11 -7
- data/test/lib/vedeu/output/presentation/style_test.rb +88 -48
- data/test/lib/vedeu/output/presentation/styles_test.rb +84 -0
- data/test/lib/vedeu/output/text_test.rb +109 -105
- data/test/lib/vedeu/output/viewport_test.rb +3 -1
- data/test/lib/vedeu/output/wordwrap_test.rb +209 -205
- data/test/lib/vedeu/refresh/refresh_test.rb +3 -1
- data/test/lib/vedeu/templating/helpers_test.rb +6 -6
- data/test/lib/vedeu/templating/view_template_test.rb +1 -1
- metadata +17 -8
- data/lib/vedeu/output/style.rb +0 -76
- data/test/lib/vedeu/output/style_test.rb +0 -120
@@ -21,7 +21,9 @@ module Vedeu
|
|
21
21
|
end
|
22
22
|
|
23
23
|
context 'when there are registered interfaces' do
|
24
|
-
let(:interface) {
|
24
|
+
let(:interface) {
|
25
|
+
Vedeu::Models::Interface.new(name: 'Vedeu::Refresh')
|
26
|
+
}
|
25
27
|
let(:interfaces) { [interface] }
|
26
28
|
|
27
29
|
before { Vedeu.interfaces.stubs(:zindexed).returns(interfaces) }
|
@@ -17,7 +17,7 @@ module Vedeu
|
|
17
17
|
|
18
18
|
describe '#background' do
|
19
19
|
let(:expected) {
|
20
|
-
"{{
|
20
|
+
"{{eJx1UE1rAjEQ7UGiNbEI7aX0oKx/wPPsZVAs7E1QvMfdaVlcNyWZtEr/fLPRdUHoXDLDm/eR6Q0MvO6oIA+wK+nHAWzYkj4qGKNmtuXeM7lfCTKvSqp5HhpTGW8NvF15yzi7tukH5l7nh09rfF0YmNyvLW6gAIUXtSxRs3ksAWK1DRIfxtK/Eu83UKQqSx5EOtqC/NI2Jhw6PlfU0daWXAA0l6Zu/hdAARK/deUpbMc3S1660FOmE0fNx1ofqTUIYS83SBX2w9T6SYyGqNJnHMEQGw4+/QF64W6r}}"
|
21
21
|
}
|
22
22
|
|
23
23
|
subject { instance.background('#000000') { 'background text' } }
|
@@ -43,7 +43,7 @@ module Vedeu
|
|
43
43
|
}
|
44
44
|
}
|
45
45
|
let(:expected) {
|
46
|
-
"{{
|
46
|
+
"{{eJx1j09rAjEQxXso0ZooQk/Sg2X9AsHj7GVoqbC3guI96lQW140kk/7BL2/MdhUETzPDm/ebN49dC6MlbSgALEv68QBzdmT2CoZomF25Ckz+KEGuq5Jq1rGxlQ3Owsu/7z3Nvm060bky693W2VBvLIxv194uogCFDa3I1ETr6VRrAeJjERFf1tFdxOwiilwV2YPI+wuQB+NSwp7nv4qutk9HPgqGS1uf/4uiAInfpgoUt1MtsmGT5JXplxPvqTZ7auExaPN/rrATp/aWxHQMVf6Mfejh2YODE6SObR8=}}"
|
47
47
|
}
|
48
48
|
|
49
49
|
it { subject.must_equal(expected) }
|
@@ -56,7 +56,7 @@ module Vedeu
|
|
56
56
|
}
|
57
57
|
}
|
58
58
|
let(:expected) {
|
59
|
-
"{{
|
59
|
+
"{{eJx1j09rAjEQxXuQaE0UoSfpoWX7BTzPXgaLhb0VFO9RZ8vSdVOSSVX65Tub9Q8Umkvm8eY386Y3cDBd044iwLqiQwBYsie7NzBBy+yrTWQKPxr0tq6o4ZkUrnbRO3g8c69Jh0vRF3Jjt58f3sVm5+Dpb9v8aiow2E0rsjsFarEStnSe/mXfrqbKTZGZl7KcyVP5aAX6y/qUcBj4VNONfvcUxLBcuaa9T0wFGr9tHUm6019kky7JM9OR07z7xu6pDdYKCdrdnxvsi7rs0piWockfcARDbBkc/wISY22H}}"
|
60
60
|
}
|
61
61
|
|
62
62
|
it { subject.must_equal(expected) }
|
@@ -70,7 +70,7 @@ module Vedeu
|
|
70
70
|
}
|
71
71
|
}
|
72
72
|
let(:expected) {
|
73
|
-
"{{
|
73
|
+
"{{eJx1UMFqAjEQ7aFEa6IIPUkPFf2BxYswexlaWvBWqHiPOiuL66Ykk2rpz3c2WxUKzSXz5s1785LbroPRirYUAVYlHQPAO3uyBwNDtMy+XEem8K1Bb6qSas6kcJWL3sHDr+454XAuOqJc281+512stw4e/449XUgFBlu3xcRMMzmzmQL1shSLwnn61+L1QqrcNNqimM+zTOX9JegP61PQXuCviq7qN09BCMulq5tnCqlA46etIsl0uheTYRtozHTi5HdX24P0bxKQvO035AY7gs67NKZlaPJ77EMPGw0OfgB4C27o}}"
|
74
74
|
}
|
75
75
|
|
76
76
|
it { subject.must_equal(expected) }
|
@@ -79,7 +79,7 @@ module Vedeu
|
|
79
79
|
|
80
80
|
describe '#foreground' do
|
81
81
|
let(:expected) {
|
82
|
-
"{{
|
82
|
+
"{{eJx1kMuKAjEQRV1IfCSK4GxkFkr7A66rN4XiQO8ExX3UmqGx7UhS8cH8/KTjC4TJJnW5depWUm8aGKxpRx5gndPZASzZkj4o6KFmtvnGM7lfCXJb5FTyJBSmMN4a+Lxzs6jdo2gEcqO3+x9rfLkzMHxvmz5NAQpv07KkJkDMV4H9Npb+Zb+epkhVlqjxJB6RdlYgj9rGDduOrwW96IUlFwzNuSmr9wVTgMSTLjyF7nhnyccreMR04TizVeoDVctVIix7+4NUYSOoR57EGIgq7WMH2lgx2P0DtPJuxg==}}"
|
83
83
|
}
|
84
84
|
|
85
85
|
subject { instance.foreground('#000000') { 'foreground text' } }
|
@@ -91,7 +91,7 @@ module Vedeu
|
|
91
91
|
|
92
92
|
describe '#style' do
|
93
93
|
let(:expected) {
|
94
|
-
"{{
|
94
|
+
"{{eJx1j0FLAzEQhT1IajepFTyJB0t/Qc+zl0Gp0Jtg6T3bnZal6U5JJrbinzebuhUEb/N48715c33D8LCimiLAqqFjAHgXT3Zv4A6tiG+qKBS+NOi1a6iVWRrYcfQMjz/cS9ahHwaJrOx6t/Uc25rh6e/a88VUYPCctpheKVDzZWI37Olf9vViqtJ0UDlagj5Yn6sVQT4d/WJvnkIyrDTcdo8lU4HGD+siwbBiV0ORxWI6zuhE6CQ5c9jaPfUHUsvz86XBQVL9PY2ZQlPe4wgK7Bi8/QYTK20c}}"
|
95
95
|
}
|
96
96
|
|
97
97
|
subject { instance.style(:bold) { 'style text' } }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vedeu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
@@ -239,6 +239,15 @@ files:
|
|
239
239
|
- docs/configuration.md
|
240
240
|
- docs/dsl.md
|
241
241
|
- docs/events.md
|
242
|
+
- docs/events/application.md
|
243
|
+
- docs/events/document.md
|
244
|
+
- docs/events/drb.md
|
245
|
+
- docs/events/focus.md
|
246
|
+
- docs/events/menu.md
|
247
|
+
- docs/events/movement.md
|
248
|
+
- docs/events/refresh.md
|
249
|
+
- docs/events/system.md
|
250
|
+
- docs/events/visibility.md
|
242
251
|
- docs/getting_started.md
|
243
252
|
- docs/object_graph.md
|
244
253
|
- lib/vedeu.rb
|
@@ -398,9 +407,10 @@ files:
|
|
398
407
|
- lib/vedeu/output/compressor.rb
|
399
408
|
- lib/vedeu/output/direct.rb
|
400
409
|
- lib/vedeu/output/output.rb
|
401
|
-
- lib/vedeu/output/presentation.rb
|
402
410
|
- lib/vedeu/output/presentation/colour.rb
|
411
|
+
- lib/vedeu/output/presentation/presentation.rb
|
403
412
|
- lib/vedeu/output/presentation/style.rb
|
413
|
+
- lib/vedeu/output/presentation/styles.rb
|
404
414
|
- lib/vedeu/output/renderers.rb
|
405
415
|
- lib/vedeu/output/renderers/escape_sequence.rb
|
406
416
|
- lib/vedeu/output/renderers/file.rb
|
@@ -410,7 +420,6 @@ files:
|
|
410
420
|
- lib/vedeu/output/renderers/renderer_options.rb
|
411
421
|
- lib/vedeu/output/renderers/terminal.rb
|
412
422
|
- lib/vedeu/output/renderers/text.rb
|
413
|
-
- lib/vedeu/output/style.rb
|
414
423
|
- lib/vedeu/output/templates/html_renderer.vedeu
|
415
424
|
- lib/vedeu/output/text.rb
|
416
425
|
- lib/vedeu/output/viewport.rb
|
@@ -578,8 +587,9 @@ files:
|
|
578
587
|
- test/lib/vedeu/output/direct_test.rb
|
579
588
|
- test/lib/vedeu/output/output_test.rb
|
580
589
|
- test/lib/vedeu/output/presentation/colour_test.rb
|
590
|
+
- test/lib/vedeu/output/presentation/presentation_test.rb
|
581
591
|
- test/lib/vedeu/output/presentation/style_test.rb
|
582
|
-
- test/lib/vedeu/output/
|
592
|
+
- test/lib/vedeu/output/presentation/styles_test.rb
|
583
593
|
- test/lib/vedeu/output/renderers/escape_sequence_test.rb
|
584
594
|
- test/lib/vedeu/output/renderers/file_test.rb
|
585
595
|
- test/lib/vedeu/output/renderers/html_test.rb
|
@@ -589,7 +599,6 @@ files:
|
|
589
599
|
- test/lib/vedeu/output/renderers/terminal_test.rb
|
590
600
|
- test/lib/vedeu/output/renderers/text_test.rb
|
591
601
|
- test/lib/vedeu/output/renderers_test.rb
|
592
|
-
- test/lib/vedeu/output/style_test.rb
|
593
602
|
- test/lib/vedeu/output/text_test.rb
|
594
603
|
- test/lib/vedeu/output/viewport_test.rb
|
595
604
|
- test/lib/vedeu/output/wordwrap_test.rb
|
@@ -804,8 +813,9 @@ test_files:
|
|
804
813
|
- test/lib/vedeu/output/direct_test.rb
|
805
814
|
- test/lib/vedeu/output/output_test.rb
|
806
815
|
- test/lib/vedeu/output/presentation/colour_test.rb
|
816
|
+
- test/lib/vedeu/output/presentation/presentation_test.rb
|
807
817
|
- test/lib/vedeu/output/presentation/style_test.rb
|
808
|
-
- test/lib/vedeu/output/
|
818
|
+
- test/lib/vedeu/output/presentation/styles_test.rb
|
809
819
|
- test/lib/vedeu/output/renderers/escape_sequence_test.rb
|
810
820
|
- test/lib/vedeu/output/renderers/file_test.rb
|
811
821
|
- test/lib/vedeu/output/renderers/html_test.rb
|
@@ -815,7 +825,6 @@ test_files:
|
|
815
825
|
- test/lib/vedeu/output/renderers/terminal_test.rb
|
816
826
|
- test/lib/vedeu/output/renderers/text_test.rb
|
817
827
|
- test/lib/vedeu/output/renderers_test.rb
|
818
|
-
- test/lib/vedeu/output/style_test.rb
|
819
828
|
- test/lib/vedeu/output/text_test.rb
|
820
829
|
- test/lib/vedeu/output/viewport_test.rb
|
821
830
|
- test/lib/vedeu/output/wordwrap_test.rb
|
data/lib/vedeu/output/style.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
|
3
|
-
# Converts the style value or value collection into a terminal escape
|
4
|
-
# sequence. Unrecognised values are discarded- an empty string is returned.
|
5
|
-
#
|
6
|
-
# Vedeu has a range of symbol styles which are compatible with most terminals
|
7
|
-
# which are ANSI compatible. Like colours, they can be defined in either
|
8
|
-
# interfaces, for specific lines or within streams.
|
9
|
-
# Styles are applied as encountered.
|
10
|
-
#
|
11
|
-
# @see Vedeu::Esc
|
12
|
-
#
|
13
|
-
class Style
|
14
|
-
|
15
|
-
include Vedeu::Common
|
16
|
-
|
17
|
-
# @!attribute [rw] value
|
18
|
-
# @return [String|Symbol]
|
19
|
-
attr_accessor :value
|
20
|
-
|
21
|
-
# Produces new objects of the correct class from the value, ignores objects
|
22
|
-
# that have already been coerced.
|
23
|
-
#
|
24
|
-
# @param value [Object|NilClass]
|
25
|
-
# @return [Object]
|
26
|
-
def self.coerce(value)
|
27
|
-
if value.is_a?(self)
|
28
|
-
value
|
29
|
-
|
30
|
-
else
|
31
|
-
new(value)
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# Return a new instance of Vedeu::Style.
|
37
|
-
#
|
38
|
-
# @param value [Array<String|Symbol>|String|Symbol]
|
39
|
-
# The style value or a collection of values.
|
40
|
-
# @return [Vedeu::Style]
|
41
|
-
def initialize(value = nil)
|
42
|
-
@value = value
|
43
|
-
end
|
44
|
-
|
45
|
-
# Return an attributes hash for this class.
|
46
|
-
#
|
47
|
-
# @return [Hash<Symbol => Array<String|Symbol>|String|Symbol>]
|
48
|
-
def attributes
|
49
|
-
{
|
50
|
-
style: value,
|
51
|
-
}
|
52
|
-
end
|
53
|
-
|
54
|
-
# An object is equal when its values are the same.
|
55
|
-
#
|
56
|
-
# @param other [Vedeu::Views::Char]
|
57
|
-
# @return [Boolean]
|
58
|
-
def eql?(other)
|
59
|
-
self.class == other.class && value == other.value
|
60
|
-
end
|
61
|
-
alias_method :==, :eql?
|
62
|
-
|
63
|
-
# Return the terminal escape sequences after converting the style or styles.
|
64
|
-
#
|
65
|
-
# @return [String]
|
66
|
-
def to_s
|
67
|
-
return '' unless present?(value)
|
68
|
-
|
69
|
-
@sequences ||= Array(value).flatten.map { |v| Vedeu::Esc.string(v) }.join
|
70
|
-
end
|
71
|
-
alias_method :escape_sequences, :to_s
|
72
|
-
alias_method :to_str, :to_s
|
73
|
-
|
74
|
-
end # Style
|
75
|
-
|
76
|
-
end # Vedeu
|
@@ -1,120 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe Style do
|
6
|
-
|
7
|
-
let(:described) { Vedeu::Style }
|
8
|
-
let(:instance) { described.new(_value) }
|
9
|
-
let(:_value) { 'bold' }
|
10
|
-
|
11
|
-
describe 'alias methods' do
|
12
|
-
it { instance.must_respond_to(:escape_sequences) }
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '#initialize' do
|
16
|
-
it { instance.must_be_instance_of(described) }
|
17
|
-
it { instance.instance_variable_get('@value').must_equal('bold') }
|
18
|
-
end
|
19
|
-
|
20
|
-
describe 'accessors' do
|
21
|
-
it { instance.must_respond_to(:value) }
|
22
|
-
it { instance.must_respond_to(:value=) }
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '.coerce' do
|
26
|
-
let(:_value) { 'bold' }
|
27
|
-
|
28
|
-
subject { described.coerce(_value) }
|
29
|
-
|
30
|
-
it { subject.must_be_instance_of(described) }
|
31
|
-
|
32
|
-
context 'when the value is nil' do
|
33
|
-
let(:_value) { nil }
|
34
|
-
|
35
|
-
it { subject.must_be_instance_of(described) }
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'when the value is a Style already' do
|
39
|
-
let(:_value) { Vedeu::Style.new('bold') }
|
40
|
-
|
41
|
-
it 'returns the value' do
|
42
|
-
subject.must_equal(_value)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'when the value is an Array' do
|
47
|
-
let(:_value) { [:bold, :blink] }
|
48
|
-
|
49
|
-
it { subject.value.must_equal([:bold, :blink]) }
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe '#attributes' do
|
54
|
-
subject { instance.attributes }
|
55
|
-
|
56
|
-
it { subject.must_be_instance_of(Hash) }
|
57
|
-
|
58
|
-
it 'returns an attributes hash for this instance' do
|
59
|
-
subject.must_equal(style: 'bold')
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe '#eql?' do
|
64
|
-
let(:other) { instance }
|
65
|
-
|
66
|
-
subject { instance.eql?(other) }
|
67
|
-
|
68
|
-
it { subject.must_equal(true) }
|
69
|
-
|
70
|
-
context 'when different to other' do
|
71
|
-
let(:other) { described.new('underline') }
|
72
|
-
|
73
|
-
it { subject.must_equal(false) }
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe '#to_s' do
|
78
|
-
let(:_value) {}
|
79
|
-
|
80
|
-
subject { instance.to_s }
|
81
|
-
|
82
|
-
it { subject.must_be_instance_of(String) }
|
83
|
-
it { subject.must_equal('') }
|
84
|
-
|
85
|
-
describe 'for a single style' do
|
86
|
-
let(:_value) { 'normal' }
|
87
|
-
|
88
|
-
it 'returns an escape sequence' do
|
89
|
-
subject.must_equal("\e[24m\e[22m\e[27m")
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe 'for multiple styles' do
|
94
|
-
let(:_value) { ['normal', 'underline'] }
|
95
|
-
|
96
|
-
it 'returns an escape sequence for multiple styles' do
|
97
|
-
subject.must_equal("\e[24m\e[22m\e[27m\e[4m")
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
describe 'for an unknown style' do
|
102
|
-
let(:_value) { 'unknown' }
|
103
|
-
|
104
|
-
it 'returns an empty string for an unknown style' do
|
105
|
-
subject.must_equal('')
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe 'for an empty or nil' do
|
110
|
-
let(:_value) { '' }
|
111
|
-
|
112
|
-
it 'returns an empty string for empty or nil' do
|
113
|
-
subject.must_equal('')
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
end # Style
|
119
|
-
|
120
|
-
end # Vedeu
|