vedeu 0.2.1 → 0.2.2

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/.yardopts +1 -0
  3. data/README.md +1 -2
  4. data/Rakefile +5 -5
  5. data/bin/vedeu +8 -4
  6. data/docs/api.md +3 -1
  7. data/docs/events.md +43 -29
  8. data/docs/getting_started.md +2 -0
  9. data/examples/cursor_app/cursor_app.rb +85 -0
  10. data/examples/lines_app/lines_app.rb +60 -0
  11. data/lib/vedeu.rb +9 -3
  12. data/lib/vedeu/api/api.rb +28 -7
  13. data/lib/vedeu/api/composition.rb +2 -0
  14. data/lib/vedeu/api/helpers.rb +2 -0
  15. data/lib/vedeu/api/interface.rb +2 -20
  16. data/lib/vedeu/api/keymap.rb +2 -0
  17. data/lib/vedeu/api/line.rb +2 -0
  18. data/lib/vedeu/api/menu.rb +3 -1
  19. data/lib/vedeu/api/stream.rb +25 -2
  20. data/lib/vedeu/application.rb +4 -4
  21. data/lib/vedeu/configuration/api.rb +327 -0
  22. data/lib/vedeu/configuration/cli.rb +110 -0
  23. data/lib/vedeu/{configuration.rb → configuration/configuration.rb} +49 -99
  24. data/lib/vedeu/launcher.rb +0 -1
  25. data/lib/vedeu/models/attributes/colour_translator.rb +2 -2
  26. data/lib/vedeu/models/colour.rb +0 -1
  27. data/lib/vedeu/models/composition.rb +2 -8
  28. data/lib/vedeu/models/cursor.rb +261 -0
  29. data/lib/vedeu/models/geometry.rb +11 -19
  30. data/lib/vedeu/models/interface.rb +2 -12
  31. data/lib/vedeu/models/keymap.rb +2 -0
  32. data/lib/vedeu/models/line.rb +2 -0
  33. data/lib/vedeu/models/stream.rb +2 -0
  34. data/lib/vedeu/models/style.rb +2 -0
  35. data/lib/vedeu/output/clear.rb +0 -1
  36. data/lib/vedeu/output/compositor.rb +0 -1
  37. data/lib/vedeu/output/refresh.rb +3 -0
  38. data/lib/vedeu/output/render.rb +12 -6
  39. data/lib/vedeu/output/view.rb +1 -0
  40. data/lib/vedeu/repositories/cursors.rb +98 -0
  41. data/lib/vedeu/repositories/events.rb +0 -1
  42. data/lib/vedeu/repositories/focus.rb +18 -0
  43. data/lib/vedeu/repositories/menus.rb +4 -4
  44. data/lib/vedeu/support/common.rb +2 -1
  45. data/lib/vedeu/support/event.rb +1 -10
  46. data/lib/vedeu/support/grid.rb +1 -2
  47. data/lib/vedeu/{repositories → support}/keymap_validator.rb +5 -4
  48. data/lib/vedeu/support/log.rb +3 -0
  49. data/lib/vedeu/support/menu.rb +4 -1
  50. data/lib/vedeu/support/registrar.rb +2 -1
  51. data/test/integration/defining_interfaces_test.rb +0 -1
  52. data/test/integration/views/basic_view_test.rb +741 -739
  53. data/test/lib/vedeu/api/api_test.rb +14 -3
  54. data/test/lib/vedeu/api/helpers_test.rb +3 -3
  55. data/test/lib/vedeu/api/interface_test.rb +17 -70
  56. data/test/lib/vedeu/api/keymap_test.rb +2 -0
  57. data/test/lib/vedeu/api/line_test.rb +4 -4
  58. data/test/lib/vedeu/api/menu_test.rb +6 -5
  59. data/test/lib/vedeu/api/stream_test.rb +18 -0
  60. data/test/lib/vedeu/configuration/api_test.rb +248 -0
  61. data/test/lib/vedeu/configuration/cli_test.rb +88 -0
  62. data/test/lib/vedeu/configuration/configuration_test.rb +67 -0
  63. data/test/lib/vedeu/input/input_test.rb +2 -2
  64. data/test/lib/vedeu/models/attributes/background_test.rb +3 -3
  65. data/test/lib/vedeu/models/attributes/foreground_test.rb +3 -3
  66. data/test/lib/vedeu/models/composition_test.rb +0 -222
  67. data/test/lib/vedeu/models/cursor_test.rb +164 -0
  68. data/test/lib/vedeu/models/interface_test.rb +0 -11
  69. data/test/lib/vedeu/output/compositor_test.rb +2 -4
  70. data/test/lib/vedeu/output/render_test.rb +4 -41
  71. data/test/lib/vedeu/repositories/cursors_test.rb +13 -0
  72. data/test/lib/vedeu/repositories/focus_test.rb +14 -4
  73. data/test/lib/vedeu/repositories/menus_test.rb +36 -29
  74. data/test/lib/vedeu/{repositories → support}/keymap_validator_test.rb +0 -0
  75. data/test/lib/vedeu/support/menu_test.rb +3 -3
  76. data/test/lib/vedeu/support/registrar_test.rb +6 -0
  77. data/test/lib/vedeu/support/terminal_test.rb +2 -2
  78. data/test/test_helper.rb +1 -1
  79. data/vedeu.gemspec +1 -1
  80. metadata +23 -14
  81. data/elements.txt +0 -118
  82. data/lib/vedeu/support/cursor.rb +0 -96
  83. data/test/lib/vedeu/configuration_test.rb +0 -154
  84. data/test/lib/vedeu/support/cursor_test.rb +0 -79
  85. data/test/support/model_test_data.json +0 -437
@@ -1,118 +0,0 @@
1
- holmium
2
- neon
3
- mercury
4
- protactinium
5
- - calcium
6
- - fermium
7
- - nitrogen
8
- - palladium
9
- - silicon
10
- - oxygen
11
- - americium
12
- - bismuth
13
- ununpentium
14
- - chlorine
15
- neptunium
16
- plutonium
17
- - carbon
18
- - zinc
19
- polonium
20
- roentgenium
21
- darmstadtium
22
- mendelevium
23
- copernicium
24
- molybdenum
25
- aluminium
26
- iridium
27
- lanthanum
28
- neodymium
29
- ruthenium
30
- bohrium
31
- thorium
32
- indium
33
- uranium
34
- strontium
35
- rubidium
36
- helium
37
- berkelium
38
- gallium
39
- thallium
40
- livermorium
41
- lithium
42
- fluorine
43
- chromium
44
- europium
45
- selenium
46
- - cadmium
47
- xenon
48
- hassium
49
- tantalum
50
- radium
51
- scandium
52
- yttrium
53
- potassium
54
- promethium
55
- astatine
56
- niobium
57
- seaborgium
58
- cerium
59
- lead
60
- caesium
61
- gold
62
- phosphorus
63
- antimony
64
- sodium
65
- rhodium
66
- magnesium
67
- hafnium
68
- rhenium
69
- cobalt
70
- francium
71
- ununtrium
72
- rutherfordium
73
- manganese
74
- lutetium
75
- thulium
76
- samarium
77
- ytterbium
78
- argon
79
- technetium
80
- actinium
81
- iron
82
- sulfur
83
- tungsten
84
- tin
85
- hydrogen
86
- - vanadium
87
- germanium
88
- platinum
89
- - meitnerium
90
- erbium
91
- flerovium
92
- tellurium
93
- zirconium
94
- iodine
95
- titanium
96
- einsteinium
97
- dysprosium
98
- copper
99
- silver
100
- arsenic
101
- dubnium
102
- nobelium
103
- radon
104
- gadolinium
105
- terbium
106
- boron
107
- ununoctium
108
- nickel
109
- ununseptium
110
- bromine
111
- krypton
112
- lawrencium
113
- beryllium
114
- osmium
115
- praseodymium
116
- barium
117
- curium
118
- californium
@@ -1,96 +0,0 @@
1
- module Vedeu
2
-
3
- # Stores and manipulates the position of the current cursor.
4
- #
5
- # @api private
6
- class Cursor
7
-
8
- # @return [Hash]
9
- attr_reader :attributes
10
-
11
- # @return [Fixnum]
12
- attr_reader :top
13
-
14
- # @return [Fixnum]
15
- attr_reader :bottom
16
-
17
- # @return [Fixnum]
18
- attr_reader :left
19
-
20
- # @return [Fixnum]
21
- attr_reader :right
22
-
23
- # @return [Fixnum]
24
- attr_reader :cursor_x
25
-
26
- # @return [Fixnum]
27
- attr_reader :cursor_y
28
-
29
- # Provides a new instance of Cursor.
30
- #
31
- # @param attributes [Hash]
32
- # @return [Cursor]
33
- def initialize(attributes = {})
34
- @attributes = attributes
35
-
36
- @top = attributes.fetch(:top)
37
- @bottom = attributes.fetch(:bottom)
38
- @left = attributes.fetch(:left)
39
- @right = attributes.fetch(:right)
40
- @cursor_y = attributes.fetch(:cursor_y, @top)
41
- @cursor_x = attributes.fetch(:cursor_x, @left)
42
- end
43
-
44
- # Reports the position of the cursor.
45
- #
46
- # @return [Array]
47
- def position
48
- [ @cursor_y, @cursor_x ]
49
- end
50
-
51
- # Move the cursor up one row.
52
- #
53
- # @return [Cursor]
54
- def move_up
55
- unless @cursor_y == top || @cursor_y - 1 < top
56
- @cursor_y -= 1
57
- end
58
-
59
- self
60
- end
61
-
62
- # Move the cursor down one row.
63
- #
64
- # @return [Cursor]
65
- def move_down
66
- unless @cursor_y == bottom || @cursor_y + 1 > bottom
67
- @cursor_y += 1
68
- end
69
-
70
- self
71
- end
72
-
73
- # Move the cursor left one column.
74
- #
75
- # @return [Cursor]
76
- def move_left
77
- unless @cursor_x == left || @cursor_x - 1 < left
78
- @cursor_x -= 1
79
- end
80
-
81
- self
82
- end
83
-
84
- # Move the cursor right one column.
85
- #
86
- # @return [Cursor]
87
- def move_right
88
- unless @cursor_x == right || @cursor_x + 1 > right
89
- @cursor_x += 1
90
- end
91
-
92
- self
93
- end
94
-
95
- end
96
- end
@@ -1,154 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
- describe Configuration do
5
- before { Configuration.reset }
6
- after { Configuration.reset }
7
-
8
- describe '#colour_mode' do
9
- it 'returns the value of the colour_mode option' do
10
- ENV['VEDEU_TERM'] = 'xterm-truecolor'
11
- Configuration.colour_mode.must_equal(16777216)
12
- end
13
-
14
- it '--colour-mode' do
15
- Configuration.configure(['--colour-mode', '16777216'])
16
- Configuration.colour_mode.must_equal(16777216)
17
- end
18
-
19
- it '--colour-mode' do
20
- Configuration.configure(['--colour-mode', '256'])
21
- Configuration.colour_mode.must_equal(256)
22
- end
23
-
24
- it '--colour-mode' do
25
- Configuration.configure(['--colour-mode', '16'])
26
- Configuration.colour_mode.must_equal(16)
27
- end
28
-
29
- it '--colour-mode' do
30
- Configuration.configure(['--colour-mode', '348'])
31
- Configuration.colour_mode.must_equal(8)
32
- end
33
- end
34
-
35
- describe '#debug?' do
36
- it 'returns the value of the debug option' do
37
- Configuration.debug?.must_equal(false)
38
- end
39
-
40
- it '--debug' do
41
- Configuration.configure(['--debug'])
42
- Configuration.debug?.must_equal(true)
43
- end
44
- end
45
-
46
- describe '#interactive?' do
47
- it 'returns the value of the interactive option' do
48
- Configuration.interactive?.must_equal(true)
49
- end
50
-
51
- it '--interactive' do
52
- Configuration.configure(['--interactive'])
53
- Configuration.interactive?.must_equal(true)
54
- end
55
-
56
- it '--noninteractive' do
57
- Configuration.configure(['--noninteractive'])
58
- Configuration.interactive?.must_equal(false)
59
- end
60
-
61
- it '--standalone' do
62
- Configuration.configure(['--standalone'])
63
- Configuration.interactive?.must_equal(false)
64
- end
65
- end
66
-
67
- describe '#once?' do
68
- it 'returns the value of the once option' do
69
- Configuration.once?.must_equal(false)
70
- end
71
-
72
- it '--run-once' do
73
- Configuration.configure(['--run-once'])
74
- Configuration.once?.must_equal(true)
75
- end
76
-
77
- it '--run-many' do
78
- Configuration.configure(['--run-many'])
79
- Configuration.once?.must_equal(false)
80
- end
81
- end
82
-
83
- describe '#terminal_mode' do
84
- it 'returns the value of the mode option' do
85
- Configuration.terminal_mode.must_equal(:raw)
86
- end
87
-
88
- it '--cooked' do
89
- Configuration.configure(['--cooked'])
90
- Configuration.terminal_mode.must_equal(:cooked)
91
- end
92
-
93
- it '--raw' do
94
- Configuration.configure(['--raw'])
95
- Configuration.terminal_mode.must_equal(:raw)
96
- end
97
- end
98
-
99
- describe '#trace?' do
100
- it 'returns the value of the trace option' do
101
- Configuration.trace?.must_equal(false)
102
- end
103
-
104
- it '--trace' do
105
- Configuration.configure(['--trace'])
106
- Configuration.trace?.must_equal(true)
107
- end
108
- end
109
-
110
- describe '#options' do
111
- it 'returns the options configured' do
112
- Configuration.options.must_equal(
113
- {
114
- colour_mode: 16777216,
115
- debug: false,
116
- interactive: true,
117
- once: false,
118
- system_keys: {
119
- exit: "q",
120
- focus_next: :tab,
121
- focus_prev: :shift_tab,
122
- mode_switch: :escape
123
- },
124
- terminal_mode: :raw,
125
- trace: false
126
- }
127
- )
128
- end
129
- end
130
-
131
- describe 'exploring multiple options set' do
132
- it 'returns the options correctly configured' do
133
- Configuration.configure(['--standalone', '--run-once'])
134
- Configuration.options.must_equal(
135
- {
136
- interactive: false,
137
- once: true,
138
- colour_mode: 16777216,
139
- debug: false,
140
- system_keys: {
141
- exit: "q",
142
- focus_next: :tab,
143
- focus_prev: :shift_tab,
144
- mode_switch: :escape
145
- },
146
- terminal_mode: :raw,
147
- trace: false
148
- }
149
- )
150
- end
151
- end
152
-
153
- end
154
- end
@@ -1,79 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
- describe Cursor do
5
- let(:attributes) {
6
- {
7
- top: 3,
8
- bottom: 6,
9
- left: 3,
10
- right: 6
11
- }
12
- }
13
-
14
- describe '#position' do
15
- it 'returns the current cursor position' do
16
- cursor = Cursor.new(attributes)
17
- cursor.position.must_equal([3, 3])
18
- end
19
- end
20
-
21
- describe '#move_up' do
22
- it 'does not move up when already at the top' do
23
- cursor = Cursor.new(attributes)
24
- cursor.move_up
25
- cursor.position.must_equal([3, 3])
26
- end
27
-
28
- it 'moves the cursor up' do
29
- cursor = Cursor.new(attributes)
30
- 2.times { cursor.move_down }
31
- cursor.move_up
32
- cursor.position.must_equal([4, 3])
33
- end
34
- end
35
-
36
- describe '#move_down' do
37
- it 'moves the cursor down' do
38
- cursor = Cursor.new(attributes)
39
- cursor.move_down
40
- cursor.position.must_equal([4, 3])
41
- end
42
-
43
- it 'does not move down when already at the bottom' do
44
- cursor = Cursor.new(attributes)
45
- 4.times { cursor.move_down }
46
- cursor.position.must_equal([6, 3])
47
- end
48
- end
49
-
50
- describe '#move_left' do
51
- it 'does not move left when already at leftmost' do
52
- cursor = Cursor.new(attributes)
53
- cursor.move_left
54
- cursor.position.must_equal([3, 3])
55
- end
56
-
57
- it 'moves the cursor left' do
58
- cursor = Cursor.new(attributes)
59
- 2.times { cursor.move_right }
60
- cursor.move_left
61
- cursor.position.must_equal([3, 4])
62
- end
63
- end
64
-
65
- describe '#move_right' do
66
- it 'does not move right when already at rightmost' do
67
- cursor = Cursor.new(attributes)
68
- 4.times { cursor.move_right }
69
- cursor.position.must_equal([3, 6])
70
- end
71
-
72
- it 'moves the cursor right' do
73
- cursor = Cursor.new(attributes)
74
- cursor.move_right
75
- cursor.position.must_equal([3, 4])
76
- end
77
- end
78
- end
79
- end