vedeu 0.8.8 → 0.8.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/docs/dsl/by_method/focus_by_name.md +6 -1
  3. data/docs/dsl/by_method/focus_next.md +7 -0
  4. data/docs/dsl/by_method/focus_previous.md +7 -0
  5. data/docs/events/by_name/mouse_event.md +8 -0
  6. data/lib/vedeu.rb +12 -0
  7. data/lib/vedeu/all.rb +2 -0
  8. data/lib/vedeu/application/controller.rb +2 -6
  9. data/lib/vedeu/buffers/empty.rb +2 -1
  10. data/lib/vedeu/cells/borders/vertices/bottom_left.rb +1 -1
  11. data/lib/vedeu/cells/borders/vertices/bottom_right.rb +1 -1
  12. data/lib/vedeu/cells/borders/vertices/top_left.rb +1 -1
  13. data/lib/vedeu/cells/borders/vertices/top_right.rb +1 -1
  14. data/lib/vedeu/cells/char.rb +2 -6
  15. data/lib/vedeu/cells/cursor.rb +1 -1
  16. data/lib/vedeu/cells/support/html.rb +6 -18
  17. data/lib/vedeu/coercers/all.rb +18 -1
  18. data/lib/vedeu/coercers/chars.rb +29 -0
  19. data/lib/vedeu/coercers/coercer.rb +59 -0
  20. data/lib/vedeu/coercers/colour.rb +15 -33
  21. data/lib/vedeu/coercers/colour_attributes.rb +8 -3
  22. data/lib/vedeu/coercers/editor_line.rb +36 -0
  23. data/lib/vedeu/coercers/editor_lines.rb +36 -0
  24. data/lib/vedeu/coercers/lines.rb +36 -0
  25. data/lib/vedeu/coercers/page.rb +52 -0
  26. data/lib/vedeu/coercers/position.rb +69 -0
  27. data/lib/vedeu/coercers/row.rb +43 -0
  28. data/lib/vedeu/coercers/streams.rb +29 -0
  29. data/lib/vedeu/coercers/style.rb +54 -0
  30. data/lib/vedeu/configuration/api.rb +10 -0
  31. data/lib/vedeu/configuration/configuration.rb +11 -0
  32. data/lib/vedeu/cursors/coordinate.rb +41 -66
  33. data/lib/vedeu/cursors/cursor.rb +4 -4
  34. data/lib/vedeu/cursors/reposition.rb +3 -3
  35. data/lib/vedeu/dsl/border.rb +2 -39
  36. data/lib/vedeu/dsl/elements.rb +5 -6
  37. data/lib/vedeu/dsl/geometry.rb +3 -12
  38. data/lib/vedeu/editor/cropper.rb +2 -1
  39. data/lib/vedeu/error.rb +4 -0
  40. data/lib/vedeu/geometries/position.rb +14 -27
  41. data/lib/vedeu/input/mouse.rb +14 -5
  42. data/lib/vedeu/input/read.rb +1 -11
  43. data/lib/vedeu/interfaces/clear.rb +2 -1
  44. data/lib/vedeu/logging/log.rb +1 -1
  45. data/lib/vedeu/models/page.rb +5 -23
  46. data/lib/vedeu/models/row.rb +5 -14
  47. data/lib/vedeu/models/toggleable.rb +2 -7
  48. data/lib/vedeu/plugins/plugin.rb +1 -0
  49. data/lib/vedeu/presentation/style.rb +4 -20
  50. data/lib/vedeu/renderers/all.rb +24 -10
  51. data/lib/vedeu/repositories/model.rb +2 -8
  52. data/lib/vedeu/repositories/registerable.rb +4 -9
  53. data/lib/vedeu/runtime/application.rb +2 -0
  54. data/lib/vedeu/runtime/flags.rb +2 -0
  55. data/lib/vedeu/runtime/router.rb +2 -0
  56. data/lib/vedeu/support/point.rb +9 -7
  57. data/lib/vedeu/support/x_coordinate.rb +57 -0
  58. data/lib/vedeu/support/y_coordinate.rb +57 -0
  59. data/lib/vedeu/terminal/terminal.rb +2 -0
  60. data/lib/vedeu/version.rb +1 -1
  61. data/lib/vedeu/views/value.rb +3 -12
  62. data/test/lib/vedeu/coercers/chars_test.rb +33 -0
  63. data/test/lib/vedeu/coercers/coercer_test.rb +34 -0
  64. data/test/lib/vedeu/coercers/colour_test.rb +9 -7
  65. data/test/lib/vedeu/coercers/editor_line_test.rb +40 -0
  66. data/test/lib/vedeu/coercers/editor_lines_test.rb +40 -0
  67. data/test/lib/vedeu/coercers/lines_test.rb +40 -0
  68. data/test/lib/vedeu/coercers/page_test.rb +150 -0
  69. data/test/lib/vedeu/coercers/position_test.rb +76 -0
  70. data/test/lib/vedeu/coercers/row_test.rb +64 -0
  71. data/test/lib/vedeu/coercers/streams_test.rb +33 -0
  72. data/test/lib/vedeu/coercers/style_test.rb +62 -0
  73. data/test/lib/vedeu/cursors/coordinate_test.rb +11 -12
  74. data/test/lib/vedeu/geometries/position_test.rb +10 -54
  75. data/test/lib/vedeu/input/capture_test.rb +1 -1
  76. data/test/lib/vedeu/models/page_test.rb +4 -116
  77. data/test/lib/vedeu/models/row_test.rb +1 -31
  78. data/test/lib/vedeu/presentation/style_test.rb +4 -38
  79. data/test/lib/vedeu/renderers/all_test.rb +6 -0
  80. data/test/lib/vedeu/support/point_test.rb +13 -1
  81. data/test/lib/vedeu/support/x_coordinate_test.rb +64 -0
  82. data/test/lib/vedeu/support/y_coordinate_test.rb +64 -0
  83. data/test/support/examples/material_colours_app.rb +1 -0
  84. data/vedeu.gemspec +1 -1
  85. metadata +41 -4
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ module Vedeu
6
+
7
+ module Coercers
8
+
9
+ describe EditorLine do
10
+
11
+ let(:described) { Vedeu::Coercers::EditorLine }
12
+ let(:instance) { described.new(_value) }
13
+ let(:_value) {}
14
+ let(:klass) { Vedeu::Editor::Line }
15
+
16
+ describe '#initialize' do
17
+ it { instance.must_be_instance_of(described) }
18
+ it { instance.instance_variable_get('@value').must_equal(_value) }
19
+ end
20
+
21
+ describe '.coerce' do
22
+ it { described.must_respond_to(:coerce) }
23
+ end
24
+
25
+ describe '#coerce' do
26
+ subject { instance.coerce }
27
+
28
+ context 'when the value is already the target class' do
29
+ let(:_value) { klass.new }
30
+
31
+ it { subject.must_be_instance_of(klass) }
32
+ it { subject.must_equal(_value) }
33
+ end
34
+ end
35
+
36
+ end # EditorLine
37
+
38
+ end # Coercers
39
+
40
+ end # Vedeu
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ module Vedeu
6
+
7
+ module Coercers
8
+
9
+ describe EditorLines do
10
+
11
+ let(:described) { Vedeu::Coercers::EditorLines }
12
+ let(:instance) { described.new(_value) }
13
+ let(:_value) {}
14
+ let(:klass) { Vedeu::Editor::Lines }
15
+
16
+ describe '#initialize' do
17
+ it { instance.must_be_instance_of(described) }
18
+ it { instance.instance_variable_get('@value').must_equal(_value) }
19
+ end
20
+
21
+ describe '.coerce' do
22
+ it { described.must_respond_to(:coerce) }
23
+ end
24
+
25
+ describe '#coerce' do
26
+ subject { instance.coerce }
27
+
28
+ context 'when the value is already the target class' do
29
+ let(:_value) { klass.new }
30
+
31
+ it { subject.must_be_instance_of(klass) }
32
+ it { subject.must_equal(_value) }
33
+ end
34
+ end
35
+
36
+ end # EditorLines
37
+
38
+ end # Coercers
39
+
40
+ end # Vedeu
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ module Vedeu
6
+
7
+ module Coercers
8
+
9
+ describe Lines do
10
+
11
+ let(:described) { Vedeu::Coercers::Lines }
12
+ let(:instance) { described.new(_value) }
13
+ let(:_value) {}
14
+ let(:klass) { Vedeu::Views::Lines }
15
+
16
+ describe '#initialize' do
17
+ it { instance.must_be_instance_of(described) }
18
+ it { instance.instance_variable_get('@value').must_equal(_value) }
19
+ end
20
+
21
+ describe '.coerce' do
22
+ it { described.must_respond_to(:coerce) }
23
+ end
24
+
25
+ describe '#coerce' do
26
+ subject { instance.coerce }
27
+
28
+ context 'when the value is already the target class' do
29
+ let(:_value) { klass.new }
30
+
31
+ it { subject.must_be_instance_of(klass) }
32
+ it { subject.must_equal(_value) }
33
+ end
34
+ end
35
+
36
+ end # Lines
37
+
38
+ end # Coercers
39
+
40
+ end # Vedeu
@@ -0,0 +1,150 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ module Vedeu
6
+
7
+ module Coercers
8
+
9
+ describe Page do
10
+
11
+ let(:described) { Vedeu::Coercers::Page }
12
+ let(:instance) { described.new(_value) }
13
+ let(:_value) {}
14
+ let(:klass) { Vedeu::Models::Page }
15
+
16
+ describe '#initialize' do
17
+ it { instance.must_be_instance_of(described) }
18
+ it { instance.instance_variable_get('@value').must_equal(_value) }
19
+ end
20
+
21
+ describe '.coerce' do
22
+ it { described.must_respond_to(:coerce) }
23
+ end
24
+
25
+ describe '#coerce' do
26
+ subject { instance.coerce }
27
+
28
+ context 'when the value is already the target class' do
29
+ let(:_value) { klass.new }
30
+
31
+ it { subject.must_be_instance_of(klass) }
32
+ it { subject.must_equal(_value) }
33
+ end
34
+ end
35
+
36
+ describe '.coerce' do
37
+ let(:_value) {}
38
+
39
+ subject { described.coerce(_value) }
40
+
41
+ it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
42
+
43
+ context 'when the value is a Vedeu::Models::Row' do
44
+ let(:_value) { Vedeu::Models::Row.new }
45
+ let(:expected) { klass.new([_value]) }
46
+
47
+ it { subject.must_equal(expected) }
48
+ end
49
+
50
+ context 'when the value is an Array' do
51
+ context 'and the value is empty' do
52
+ let(:_value) { [] }
53
+ let(:expected) {
54
+ klass.coerce(Vedeu::Models::Row.coerce(_value))
55
+ }
56
+
57
+ it { subject.must_be_instance_of(klass) }
58
+ it { subject.must_equal(expected) }
59
+ end
60
+
61
+ context 'and the value is not empty, the content is' do
62
+ context 'is an empty Array' do
63
+ let(:_value) { [[]] }
64
+ let(:expected) { klass.coerce(Vedeu::Models::Row.coerce([])) }
65
+
66
+ it { subject.must_be_instance_of(klass) }
67
+ it { subject.must_equal(expected) }
68
+ end
69
+
70
+ context 'an array of Vedeu::Models::Row objects' do
71
+ let(:_value) {
72
+ [
73
+ Vedeu::Models::Row.new([:hydrogen, :helium]),
74
+ Vedeu::Models::Row.new([:lithium, :beryllium]),
75
+ ]
76
+ }
77
+ let(:expected) { klass.new(_value) }
78
+
79
+ it { subject.must_equal(expected) }
80
+ end
81
+
82
+ context 'a mix of Vedeu::Models::Row objects and other objects' do
83
+ let(:_value) {
84
+ [
85
+ Vedeu::Models::Row.new([:hydrogen, :helium]),
86
+ [:lithium],
87
+ Vedeu::Models::Row.new([:beryllium, :boron]),
88
+ ]
89
+ }
90
+ let(:expected) {
91
+ klass.new([
92
+ Vedeu::Models::Row.new([:hydrogen, :helium]),
93
+ Vedeu::Models::Row.new([:lithium]),
94
+ Vedeu::Models::Row.new([:beryllium, :boron]),
95
+ ])
96
+ }
97
+
98
+ it { subject.must_equal(expected) }
99
+ end
100
+
101
+ context 'a mix of Vedeu::Models::Row objects, other objects and ' \
102
+ 'nils' do
103
+ let(:_value) {
104
+ [
105
+ Vedeu::Models::Row.new([:hydrogen, :helium]),
106
+ nil,
107
+ [:lithium],
108
+ Vedeu::Models::Row.new([:beryllium]),
109
+ [
110
+ Vedeu::Cells::Char.new(value: 'b'),
111
+ Vedeu::Cells::Char.new(value: 'o'),
112
+ Vedeu::Cells::Char.new(value: 'r'),
113
+ Vedeu::Cells::Char.new(value: 'o'),
114
+ Vedeu::Cells::Char.new(value: 'n'),
115
+ ],
116
+ [nil, :carbon],
117
+ :nitrogen,
118
+ ]
119
+ }
120
+ let(:expected) {
121
+ klass.new([
122
+ Vedeu::Models::Row.new([:hydrogen, :helium]),
123
+ Vedeu::Models::Row.new([]),
124
+ Vedeu::Models::Row.new([:lithium]),
125
+ Vedeu::Models::Row.new([:beryllium]),
126
+ Vedeu::Models::Row.new([
127
+ Vedeu::Cells::Char.new(value: 'b'),
128
+ Vedeu::Cells::Char.new(value: 'o'),
129
+ Vedeu::Cells::Char.new(value: 'r'),
130
+ Vedeu::Cells::Char.new(value: 'o'),
131
+ Vedeu::Cells::Char.new(value: 'n'),
132
+ ]),
133
+ Vedeu::Models::Row.new([:carbon]),
134
+ Vedeu::Models::Row.new([:nitrogen]),
135
+ ])
136
+ }
137
+
138
+ it { subject.must_equal(expected) }
139
+ end
140
+
141
+ end
142
+
143
+ end
144
+ end
145
+
146
+ end # Page
147
+
148
+ end # Coercers
149
+
150
+ end # Vedeu
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ module Vedeu
6
+
7
+ module Coercers
8
+
9
+ describe Position do
10
+
11
+ let(:described) { Vedeu::Coercers::Position }
12
+ let(:instance) { described.new(_value) }
13
+ let(:_value) {}
14
+ let(:klass) { Vedeu::Geometries::Position }
15
+
16
+ describe '#initialize' do
17
+ it { instance.must_be_instance_of(described) }
18
+ it { instance.instance_variable_get('@value').must_equal(_value) }
19
+ end
20
+
21
+ describe '.coerce' do
22
+ it { described.must_respond_to(:coerce) }
23
+ end
24
+
25
+ describe '#coerce' do
26
+ subject { instance.coerce }
27
+
28
+ context 'when the value is already the target class' do
29
+ let(:_value) { klass.new }
30
+
31
+ it { subject.must_be_instance_of(klass) }
32
+ it { subject.must_equal(_value) }
33
+ end
34
+
35
+ context 'when the value is an Array' do
36
+ let(:_value) { [2, 8] }
37
+
38
+ it { subject.must_be_instance_of(klass) }
39
+ it { subject.y.must_equal(2) }
40
+ it { subject.x.must_equal(8) }
41
+ end
42
+
43
+ context 'when the value is an Fixnum' do
44
+ let(:_value) { 2 }
45
+
46
+ it { subject.must_be_instance_of(klass) }
47
+ it { subject.y.must_equal(2) }
48
+ it { subject.x.must_equal(1) }
49
+ end
50
+
51
+ context 'when the value is a Hash' do
52
+ let(:_value) { { y: 3, x: 9 } }
53
+
54
+ it { subject.must_be_instance_of(klass) }
55
+ it { subject.y.must_equal(3) }
56
+ it { subject.x.must_equal(9) }
57
+ end
58
+
59
+ context 'when the value is a NilClass' do
60
+ let(:_value) {}
61
+
62
+ it { subject.must_be_instance_of(NilClass) }
63
+ end
64
+
65
+ context 'when the value is something unhandled' do
66
+ let(:_value) { :invalid }
67
+
68
+ it { proc { subject }.must_raise(Vedeu::Error::Fatal) }
69
+ end
70
+ end
71
+
72
+ end # Position
73
+
74
+ end # Coercers
75
+
76
+ end # Vedeu
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ module Vedeu
6
+
7
+ module Coercers
8
+
9
+ describe Row do
10
+
11
+ let(:described) { Vedeu::Coercers::Row }
12
+ let(:instance) { described.new(_value) }
13
+ let(:_value) {}
14
+ let(:klass) { Vedeu::Models::Row }
15
+
16
+ describe '#initialize' do
17
+ it { instance.must_be_instance_of(described) }
18
+ it { instance.instance_variable_get('@value').must_equal(_value) }
19
+ end
20
+
21
+ describe '.coerce' do
22
+ it { described.must_respond_to(:coerce) }
23
+ end
24
+
25
+ describe '#coerce' do
26
+ subject { instance.coerce }
27
+
28
+ context 'when the value is already the target class' do
29
+ let(:_value) { klass.new }
30
+
31
+ it { subject.must_be_instance_of(klass) }
32
+ it { subject.must_equal(_value) }
33
+ end
34
+
35
+ context 'when the value is an Array' do
36
+ let(:_value) { [:hydrogen, :helium, :lithium] }
37
+
38
+ it { subject.must_equal(klass.new(_value)) }
39
+ end
40
+
41
+ context 'when the value is an Array containing nil objects' do
42
+ let(:_value) { [:hydrogen, nil, :lithium] }
43
+
44
+ it { subject.must_equal(klass.new([:hydrogen, :lithium])) }
45
+ end
46
+
47
+ context 'when the value is nil' do
48
+ let(:_value) {}
49
+
50
+ it { subject.must_equal(klass.new) }
51
+ end
52
+
53
+ context 'when the value is anything else' do
54
+ let(:_value) { :beryllium }
55
+
56
+ it { subject.must_equal(klass.new([_value])) }
57
+ end
58
+ end
59
+
60
+ end # Row
61
+
62
+ end # Coercers
63
+
64
+ end # Vedeu
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ module Vedeu
6
+
7
+ module Coercers
8
+
9
+ describe Streams do
10
+
11
+ let(:described) { Vedeu::Coercers::Streams }
12
+ let(:instance) { described.new(_value) }
13
+ let(:_value) {}
14
+ let(:klass) { Vedeu::Views::Streams }
15
+
16
+ describe '#initialize' do
17
+ it { instance.must_be_instance_of(described) }
18
+ it { instance.instance_variable_get('@value').must_equal(_value) }
19
+ end
20
+
21
+ describe '.coerce' do
22
+ it { described.must_respond_to(:coerce) }
23
+ end
24
+
25
+ describe '#coerce' do
26
+ subject { instance.coerce }
27
+ end
28
+
29
+ end # Streams
30
+
31
+ end # Coercers
32
+
33
+ end # Vedeu