vedeu 0.4.17 → 0.4.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/docs/dsl.md +54 -0
  3. data/docs/views.md +25 -25
  4. data/examples/cursor_app.rb +1 -1
  5. data/examples/material_colours_app.rb +1 -1
  6. data/lib/vedeu/all.rb +1 -0
  7. data/lib/vedeu/bindings.rb +2 -15
  8. data/lib/vedeu/buffers/buffer.rb +30 -7
  9. data/lib/vedeu/buffers/display_buffer.rb +1 -1
  10. data/lib/vedeu/configuration/configuration.rb +1 -1
  11. data/lib/vedeu/cursor/refresh_cursor.rb +4 -0
  12. data/lib/vedeu/dsl/components/border.rb +6 -1
  13. data/lib/vedeu/geometry/all.rb +0 -1
  14. data/lib/vedeu/geometry/area.rb +0 -20
  15. data/lib/vedeu/geometry/coordinate.rb +0 -50
  16. data/lib/vedeu/geometry/geometry.rb +1 -5
  17. data/lib/vedeu/geometry/position.rb +9 -0
  18. data/lib/vedeu/geometry/position_index.rb +19 -14
  19. data/lib/vedeu/geometry/position_validator.rb +3 -0
  20. data/lib/vedeu/models/all.rb +0 -3
  21. data/lib/vedeu/models/interface.rb +2 -4
  22. data/lib/vedeu/null/all.rb +5 -0
  23. data/lib/vedeu/null/border.rb +79 -0
  24. data/lib/vedeu/null/buffer.rb +44 -0
  25. data/lib/vedeu/null/generic.rb +52 -0
  26. data/lib/vedeu/null/geometry.rb +70 -0
  27. data/lib/vedeu/null/interface.rb +23 -0
  28. data/lib/vedeu/output/all.rb +0 -1
  29. data/lib/vedeu/output/border.rb +9 -9
  30. data/lib/vedeu/output/clear.rb +2 -1
  31. data/lib/vedeu/output/output.rb +1 -1
  32. data/lib/vedeu/output/refresh.rb +1 -1
  33. data/lib/vedeu/output/renderers/all.rb +7 -7
  34. data/lib/vedeu/output/renderers/escape_sequence.rb +47 -0
  35. data/lib/vedeu/output/renderers/{file_renderer.rb → file.rb} +11 -6
  36. data/lib/vedeu/output/renderers/{html_renderer.rb → html.rb} +4 -4
  37. data/lib/vedeu/output/renderers/{json_renderer.rb → json.rb} +4 -4
  38. data/lib/vedeu/output/renderers/{null_renderer.rb → null.rb} +2 -2
  39. data/lib/vedeu/output/renderers/{terminal_renderer.rb → terminal.rb} +4 -4
  40. data/lib/vedeu/output/renderers/{text_renderer.rb → text.rb} +4 -4
  41. data/lib/vedeu/output/text.rb +2 -2
  42. data/lib/vedeu/output/virtual_terminal.rb +2 -2
  43. data/lib/vedeu/repositories/all.rb +2 -0
  44. data/lib/vedeu/repositories/repositories/borders.rb +4 -2
  45. data/lib/vedeu/repositories/repositories/buffers.rb +11 -9
  46. data/lib/vedeu/repositories/repositories/cursors.rb +2 -0
  47. data/lib/vedeu/repositories/repositories/events_repository.rb +2 -0
  48. data/lib/vedeu/repositories/repositories/geometries.rb +4 -2
  49. data/lib/vedeu/repositories/repositories/groups.rb +2 -0
  50. data/lib/vedeu/repositories/repositories/interfaces_repository.rb +4 -2
  51. data/lib/vedeu/repositories/repositories/keymaps.rb +2 -0
  52. data/lib/vedeu/repositories/repositories/menus.rb +2 -0
  53. data/test/lib/vedeu/cursor/cursor_test.rb +1 -1
  54. data/test/lib/vedeu/cursor/move_test.rb +21 -33
  55. data/test/lib/vedeu/cursor/refresh_cursor_test.rb +16 -1
  56. data/test/lib/vedeu/distributed/test_application_test.rb +1 -1
  57. data/test/lib/vedeu/dsl/components/border_test.rb +1 -1
  58. data/test/lib/vedeu/dsl/components/geometry_test.rb +5 -5
  59. data/test/lib/vedeu/dsl/components/menu_test.rb +1 -1
  60. data/test/lib/vedeu/dsl/composition_test.rb +1 -1
  61. data/test/lib/vedeu/dsl/group_test.rb +1 -1
  62. data/test/lib/vedeu/dsl/interface_test.rb +1 -1
  63. data/test/lib/vedeu/dsl/stream_test.rb +1 -1
  64. data/test/lib/vedeu/events/event_test.rb +8 -8
  65. data/test/lib/vedeu/events/trigger_test.rb +1 -1
  66. data/test/lib/vedeu/geometry/area_test.rb +4 -36
  67. data/test/lib/vedeu/geometry/canvas_test.rb +2 -2
  68. data/test/lib/vedeu/geometry/coordinate_test.rb +0 -56
  69. data/test/lib/vedeu/geometry/dimension_test.rb +1 -1
  70. data/test/lib/vedeu/geometry/geometry_test.rb +1 -1
  71. data/test/lib/vedeu/geometry/grid_test.rb +1 -1
  72. data/test/lib/vedeu/geometry/position_index_test.rb +21 -23
  73. data/test/lib/vedeu/geometry/position_validator_test.rb +121 -3
  74. data/test/lib/vedeu/input/input_test.rb +1 -1
  75. data/test/lib/vedeu/input/key_test.rb +1 -1
  76. data/test/lib/vedeu/input/keymap_test.rb +1 -1
  77. data/test/lib/vedeu/models/interface_test.rb +14 -0
  78. data/test/lib/vedeu/null/border_test.rb +76 -0
  79. data/test/lib/vedeu/null/generic_test.rb +69 -0
  80. data/test/lib/vedeu/null/geometry_test.rb +63 -0
  81. data/test/lib/vedeu/null/interface_test.rb +13 -0
  82. data/test/lib/vedeu/output/clear_test.rb +1 -1
  83. data/test/lib/vedeu/output/compressor_test.rb +1 -1
  84. data/test/lib/vedeu/output/html_char_test.rb +1 -1
  85. data/test/lib/vedeu/output/output_test.rb +1 -1
  86. data/test/lib/vedeu/output/refresh_test.rb +17 -5
  87. data/test/lib/vedeu/output/renderers/escape_sequence_renderer_test.rb +4 -4
  88. data/test/lib/vedeu/output/renderers/{file_renderer_test.rb → file_test.rb} +4 -4
  89. data/test/lib/vedeu/output/renderers/{html_renderer_test.rb → html_test.rb} +4 -4
  90. data/test/lib/vedeu/output/renderers/{json_renderer_test.rb → json_test.rb} +4 -4
  91. data/test/lib/vedeu/output/renderers/{null_renderer_test.rb → null_test.rb} +3 -3
  92. data/test/lib/vedeu/output/renderers/{terminal_renderer_test.rb → terminal_test.rb} +4 -4
  93. data/test/lib/vedeu/output/renderers/{text_renderer_test.rb → text_test.rb} +4 -4
  94. data/test/lib/vedeu/output/style_test.rb +1 -1
  95. data/test/lib/vedeu/output/translator_test.rb +1 -1
  96. data/test/lib/vedeu/output/viewport_test.rb +1 -1
  97. data/test/lib/vedeu/output/virtual_terminal_test.rb +3 -3
  98. data/test/lib/vedeu/repositories/collection_test.rb +2 -2
  99. data/test/lib/vedeu/repositories/collections/chars_test.rb +1 -1
  100. data/test/lib/vedeu/repositories/collections/events_test.rb +1 -1
  101. data/test/lib/vedeu/repositories/collections/interfaces_test.rb +1 -1
  102. data/test/lib/vedeu/repositories/collections/keys_test.rb +1 -1
  103. data/test/lib/vedeu/repositories/collections/lines_test.rb +1 -1
  104. data/test/lib/vedeu/repositories/collections/streams_test.rb +1 -1
  105. data/test/lib/vedeu/repositories/repositories/borders_test.rb +1 -1
  106. data/test/lib/vedeu/repositories/repositories/buffers_test.rb +11 -23
  107. data/test/lib/vedeu/repositories/repositories/colours_test.rb +1 -1
  108. data/test/lib/vedeu/repositories/repositories/geometries_test.rb +1 -1
  109. data/test/lib/vedeu/repositories/repository_test.rb +1 -1
  110. data/test/lib/vedeu/storage/associative_store_test.rb +1 -1
  111. data/test/lib/vedeu/storage/conveyor_store_test.rb +1 -1
  112. data/test/lib/vedeu/storage/fifo_store_test.rb +1 -1
  113. data/test/lib/vedeu/support/template_test.rb +1 -1
  114. data/test/lib/vedeu/support/trace_test.rb +1 -1
  115. data/test/lib/vedeu/support/visibility_test.rb +2 -2
  116. data/test/test_helper.rb +1 -1
  117. data/vedeu.gemspec +1 -1
  118. metadata +36 -33
  119. data/lib/vedeu/geometry/null_geometry.rb +0 -70
  120. data/lib/vedeu/models/null.rb +0 -48
  121. data/lib/vedeu/models/null_interface.rb +0 -20
  122. data/lib/vedeu/output/null_border.rb +0 -75
  123. data/lib/vedeu/output/renderers/escape_sequence_renderer.rb +0 -43
  124. data/test/lib/vedeu/geometry/null_geometry_test.rb +0 -59
  125. data/test/lib/vedeu/models/null_interface_test.rb +0 -9
  126. data/test/lib/vedeu/models/null_test.rb +0 -66
  127. data/test/lib/vedeu/output/null_border_test.rb +0 -72
@@ -1,75 +0,0 @@
1
- module Vedeu
2
-
3
- # Provides a non-existent Vedeu::Border that acts like the real thing, but
4
- # does nothing.
5
- #
6
- class NullBorder
7
-
8
- # @!attribute [r] name
9
- # @return [String|NilClass]
10
- attr_reader :name
11
-
12
- # Returns a new instance of Vedeu::NullBorder.
13
- #
14
- # @param name [String|NilClass]
15
- # @return [Vedeu::NullBorder]S
16
- def initialize(name = nil)
17
- @name = name
18
- end
19
-
20
- # @return [Fixnum]
21
- def bx
22
- geometry.x
23
- end
24
- alias_method :x, :bx
25
-
26
- # @return [Fixnum]
27
- def bxn
28
- geometry.xn
29
- end
30
- alias_method :xn, :bxn
31
-
32
- # @return [Fixnum]
33
- def by
34
- geometry.y
35
- end
36
- alias_method :y, :by
37
-
38
- # @return [Fixnum]
39
- def byn
40
- geometry.yn
41
- end
42
- alias_method :yn, :byn
43
-
44
- # @return [FalseClass]
45
- def enabled?
46
- false
47
- end
48
-
49
- # @return [Fixnum]
50
- def height
51
- (by..byn).size
52
- end
53
-
54
- # @return [Array]
55
- def render
56
- []
57
- end
58
-
59
- # @return [Fixnum]
60
- def width
61
- (bx..bxn).size
62
- end
63
-
64
- private
65
-
66
- # Returns the geometry for the interface.
67
- #
68
- # @return (see Vedeu::Geometries#by_name)
69
- def geometry
70
- @geometry ||= Vedeu.geometries.by_name(name)
71
- end
72
-
73
- end # NullBorder
74
-
75
- end # Vedeu
@@ -1,43 +0,0 @@
1
- module Vedeu
2
-
3
- # A renderer which returns the escape sequence for each character.
4
- #
5
- class EscapeSequenceRenderer
6
-
7
- # @param output [Array<Array<Vedeu::Char>>]
8
- # @return [String]
9
- def self.render(output)
10
- new(output).render
11
- end
12
-
13
- # @param output [Array<Array<Vedeu::Char>>]
14
- def initialize(output)
15
- @output = output
16
- end
17
-
18
- # @return [String]
19
- def render
20
- Vedeu.log(type: :debug,
21
- message: "Vedeu::EscapeSequenceRenderer:\n#{parsed}")
22
-
23
- parsed
24
- end
25
-
26
- private
27
-
28
- # @!attribute [r] output
29
- # @return [Array<Array<Vedeu::Char>>]
30
- attr_reader :output
31
-
32
- # Escapes the escape sequences.
33
- #
34
- # @return [String]
35
- def parsed
36
- @parsed ||= Array(output).flatten.map do |char|
37
- Esc.escape(char.to_s) + "\n"
38
- end.join
39
- end
40
-
41
- end # EscapeSequenceRenderer
42
-
43
- end # Vedeu
@@ -1,59 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe NullGeometry do
6
-
7
- let(:described) { Vedeu::NullGeometry }
8
- let(:instance) { described.new(_name) }
9
- let(:_name) { 'null_geometry' }
10
-
11
- before do
12
- Vedeu::Terminal.stubs(:height).returns(25)
13
- Vedeu::Terminal.stubs(:width).returns(40)
14
- end
15
-
16
- describe '#initialize' do
17
- it { instance.must_be_instance_of(described) }
18
- it { instance.instance_variable_get('@name').must_equal(_name) }
19
- end
20
-
21
- describe '#centred' do
22
- subject { instance.centred }
23
-
24
- it { subject.must_equal(false) }
25
- end
26
-
27
- describe '#store' do
28
- subject { instance.store }
29
-
30
- it { subject.must_be_instance_of(described) }
31
- end
32
-
33
- describe '#height' do
34
- it { instance.height.must_equal(25) }
35
- end
36
-
37
- describe '#width' do
38
- it { instance.width.must_equal(40) }
39
- end
40
-
41
- describe '#x' do
42
- it { instance.x.must_equal(1) }
43
- end
44
-
45
- describe '#xn' do
46
- it { instance.xn.must_equal(40) }
47
- end
48
-
49
- describe '#y' do
50
- it { instance.y.must_equal(1) }
51
- end
52
-
53
- describe '#yn' do
54
- it { instance.yn.must_equal(25) }
55
- end
56
-
57
- end # NullGeometry
58
-
59
- end # Vedeu
@@ -1,9 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe NullInterface do
6
-
7
- end # NullInterface
8
-
9
- end # Vedeu
@@ -1,66 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe Null do
6
-
7
- let(:described) { Vedeu::Null }
8
- let(:instance) { described.new }
9
-
10
- describe 'alias methods' do
11
- it { instance.must_respond_to(:visible?) }
12
- end
13
-
14
- describe '#initialize' do
15
- it { instance.must_be_instance_of(Vedeu::Null) }
16
- end
17
-
18
- describe '#add' do
19
- subject { instance.add }
20
-
21
- it { subject.must_be_instance_of(NilClass) }
22
- end
23
-
24
- describe '#colour' do
25
- subject { instance.colour }
26
-
27
- it { subject.must_be_instance_of(NilClass) }
28
- end
29
-
30
- describe '#parent' do
31
- subject { instance.parent }
32
-
33
- it { subject.must_be_instance_of(NilClass) }
34
- end
35
-
36
- describe '#store' do
37
- subject { instance.store }
38
-
39
- it { subject.must_be_instance_of(Vedeu::Null) }
40
- end
41
-
42
- describe '#style' do
43
- subject { instance.style }
44
-
45
- it { subject.must_be_instance_of(NilClass) }
46
- end
47
-
48
- describe '#visible' do
49
- subject { instance.visible }
50
-
51
- it { subject.must_be_instance_of(FalseClass) }
52
- end
53
-
54
- describe '#visible=' do
55
- let(:_value) { :ignored }
56
-
57
- subject { instance.visible = (_value) }
58
-
59
- # This should be FalseClass, I'm explicitly returning false in the method.
60
- it { subject.must_be_instance_of(Symbol) }
61
- end
62
-
63
-
64
- end # Null
65
-
66
- end # Vedeu
@@ -1,72 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe NullBorder do
6
-
7
- let(:described) { Vedeu::NullBorder }
8
- let(:instance) { described.new(_name) }
9
- let(:_name) { 'null_border' }
10
-
11
- before do
12
- Vedeu::Geometry.new(name: _name, x: 4, y: 6, xn: 10, yn: 12).store
13
- end
14
- after { Vedeu.geometries.reset }
15
-
16
- describe '#initialize' do
17
- it { instance.must_be_instance_of(Vedeu::NullBorder) }
18
- it { instance.instance_variable_get('@name').must_equal(_name) }
19
- end
20
-
21
- describe '#bx' do
22
- subject { instance.bx }
23
-
24
- it { subject.must_be_instance_of(Fixnum) }
25
- it { subject.must_equal(4) }
26
- end
27
-
28
- describe '#by' do
29
- subject { instance.by }
30
-
31
- it { subject.must_be_instance_of(Fixnum) }
32
- it { subject.must_equal(6) }
33
- end
34
-
35
- describe '#bxn' do
36
- subject { instance.bxn }
37
-
38
- it { subject.must_be_instance_of(Fixnum) }
39
- it { subject.must_equal(10) }
40
- end
41
-
42
- describe '#byn' do
43
- subject { instance.byn }
44
-
45
- it { subject.must_be_instance_of(Fixnum) }
46
- it { subject.must_equal(12) }
47
- end
48
-
49
- describe '#height' do
50
- subject { instance.height }
51
-
52
- it { subject.must_be_instance_of(Fixnum) }
53
- it { subject.must_equal(7) }
54
- end
55
-
56
- describe '#render' do
57
- subject { instance.render }
58
-
59
- it { subject.must_be_instance_of(Array) }
60
- it { subject.must_equal([]) }
61
- end
62
-
63
- describe '#width' do
64
- subject { instance.width }
65
-
66
- it { subject.must_be_instance_of(Fixnum) }
67
- it { subject.must_equal(7) }
68
- end
69
-
70
- end # NullBorder
71
-
72
- end # Vedeu