vedeu 0.8.7 → 0.8.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/TODO.md +8 -0
  3. data/docs/dsl/by_method/buffer_update.md +3 -1
  4. data/docs/dsl/by_method/buffer_write.md +3 -1
  5. data/docs/dsl/by_method/cursor.md +3 -1
  6. data/docs/dsl/by_method/cursors.md +3 -1
  7. data/docs/dsl/by_method/direct_write.md +3 -1
  8. data/docs/dsl/by_method/log_stderr.md +4 -1
  9. data/docs/dsl/by_method/log_stdout.md +4 -1
  10. data/docs/dsl/by_method/log_timestamp.md +7 -1
  11. data/docs/dsl/by_method/render_output.md +3 -1
  12. data/docs/events/by_name/{geometry_down.md → aliases/geometry_down.md} +0 -0
  13. data/docs/events/by_name/{geometry_left.md → aliases/geometry_left.md} +0 -0
  14. data/docs/events/by_name/{geometry_right.md → aliases/geometry_right.md} +0 -0
  15. data/docs/events/by_name/{geometry_up.md → aliases/geometry_up.md} +0 -0
  16. data/docs/events/by_name/cursor_down.md +5 -0
  17. data/docs/events/by_name/cursor_left.md +3 -0
  18. data/docs/events/by_name/cursor_origin.md +3 -0
  19. data/docs/events/by_name/cursor_right.md +5 -0
  20. data/docs/events/by_name/cursor_top.md +3 -0
  21. data/docs/events/by_name/cursor_up.md +3 -0
  22. data/docs/events/by_name/hide_cursor.md +6 -1
  23. data/docs/events/by_name/maximise.md +2 -3
  24. data/docs/events/by_name/show_cursor.md +6 -1
  25. data/docs/events/by_name/unmaximise.md +5 -3
  26. data/docs/events/by_name/view_down.md +8 -0
  27. data/docs/events/by_name/view_left.md +8 -0
  28. data/docs/events/by_name/view_right.md +8 -0
  29. data/docs/events/by_name/view_up.md +8 -0
  30. data/docs/events/document.md +2 -1
  31. data/docs/events/focus.md +2 -1
  32. data/docs/events/menu.md +2 -1
  33. data/docs/events/movement.md +2 -1
  34. data/docs/events/refresh.md +2 -1
  35. data/docs/events/view.md +2 -1
  36. data/docs/events/visibility.md +2 -1
  37. data/examples/dsl_horizontal_alignment.rb +1 -1
  38. data/examples/dsl_vertical_alignment.rb +1 -1
  39. data/integrations/dsl_app_border_001.rb +63 -0
  40. data/integrations/dsl_app_border_002.rb +63 -0
  41. data/integrations/dsl_app_border_003.rb +63 -0
  42. data/integrations/dsl_app_border_004.rb +63 -0
  43. data/integrations/dsl_app_border_005.rb +63 -0
  44. data/integrations/expected/dsl_app_border_001.out +1 -0
  45. data/integrations/expected/dsl_app_border_002.out +1 -0
  46. data/integrations/expected/dsl_app_border_003.out +1 -0
  47. data/integrations/expected/dsl_app_border_004.out +1 -0
  48. data/integrations/expected/dsl_app_border_005.out +1 -0
  49. data/integrations/test_runner.sh +7 -0
  50. data/lib/vedeu.rb +2 -1
  51. data/lib/vedeu/borders/repository.rb +1 -5
  52. data/lib/vedeu/cursors/cursor.rb +29 -70
  53. data/lib/vedeu/cursors/move.rb +11 -4
  54. data/lib/vedeu/cursors/reposition.rb +2 -2
  55. data/lib/vedeu/cursors/repository.rb +7 -12
  56. data/lib/vedeu/dsl/elements.rb +0 -1
  57. data/lib/vedeu/error.rb +17 -5
  58. data/lib/vedeu/geometries/dsl/dsl.rb +2 -28
  59. data/lib/vedeu/geometries/dsl/grid.rb +2 -0
  60. data/lib/vedeu/geometries/geometry.rb +2 -22
  61. data/lib/vedeu/geometries/move.rb +45 -10
  62. data/lib/vedeu/geometries/repository.rb +0 -20
  63. data/lib/vedeu/input/capture.rb +2 -1
  64. data/lib/vedeu/logging/log.rb +25 -25
  65. data/lib/vedeu/renderers/file.rb +0 -5
  66. data/lib/vedeu/renderers/json.rb +1 -1
  67. data/lib/vedeu/renderers/options.rb +3 -1
  68. data/lib/vedeu/renderers/text.rb +0 -7
  69. data/lib/vedeu/runtime/bootstrap.rb +1 -1
  70. data/lib/vedeu/runtime/launcher.rb +8 -5
  71. data/lib/vedeu/version.rb +1 -1
  72. data/test/lib/vedeu/application/application_controller_test.rb +2 -4
  73. data/test/lib/vedeu/cursors/cursor_test.rb +9 -12
  74. data/test/lib/vedeu/cursors/move_test.rb +7 -3
  75. data/test/lib/vedeu/geometries/move_test.rb +22 -9
  76. data/test/lib/vedeu/interfaces/interface_test.rb +71 -73
  77. data/test/lib/vedeu/logging/log_test.rb +1 -1
  78. data/test/lib/vedeu/runtime/launcher_test.rb +5 -4
  79. data/test/support/examples/material_colours_app.rb +59 -8
  80. data/test/test_helper.rb +1 -0
  81. metadata +16 -6
@@ -10,11 +10,6 @@ module Vedeu
10
10
 
11
11
  include Vedeu::Renderers::Options
12
12
 
13
- # @return [String]
14
- def clear
15
- render('')
16
- end
17
-
18
13
  # Render the output (either content or clearing) to a file.
19
14
  #
20
15
  # @return [String]
@@ -12,7 +12,7 @@ module Vedeu
12
12
 
13
13
  # Render a cleared output.
14
14
  #
15
- # @return [void]
15
+ # @return [Hash]
16
16
  def clear
17
17
  render({})
18
18
  end
@@ -36,7 +36,9 @@ module Vedeu
36
36
  @options = defaults.merge!(opts || {})
37
37
  end
38
38
 
39
- # @return [void]
39
+ # Render a cleared output.
40
+ #
41
+ # @return [String]
40
42
  def clear
41
43
  render('')
42
44
  end
@@ -12,13 +12,6 @@ module Vedeu
12
12
 
13
13
  include Vedeu::Renderers::Options
14
14
 
15
- # Render a cleared output.
16
- #
17
- # @return [String]
18
- def clear
19
- render('')
20
- end
21
-
22
15
  private
23
16
 
24
17
  # Combine all characters in a row to produce a line, then all
@@ -82,7 +82,7 @@ module Vedeu
82
82
  Vedeu.trigger(:_goto_, *Vedeu.config.root)
83
83
 
84
84
  else
85
- Vedeu.log_stderr(type: :debug, message: client_initialize_error)
85
+ Vedeu.log_stderr(message: client_initialize_error)
86
86
 
87
87
  end
88
88
  end
@@ -69,15 +69,18 @@ module Vedeu
69
69
  terminate!
70
70
 
71
71
  rescue StandardError => uncaught_exception
72
+ message = uncaught_exception.message + "\n"
73
+ trace = uncaught_exception.backtrace.join("\n")
74
+
72
75
  output = if Vedeu.config.debug?
73
- uncaught_exception.message + "\n" +
74
- uncaught_exception.backtrace.join("\n")
76
+ message + Vedeu.esc.screen_colour_reset + trace
77
+
75
78
  else
76
- uncaught_exception.message
79
+ message
80
+
77
81
  end
78
82
 
79
- Vedeu.log(type: :error, message: output)
80
- Vedeu.log_stdout(type: :error, message: output)
83
+ Vedeu.log_stderr(message: output)
81
84
  end
82
85
 
83
86
  protected
@@ -3,6 +3,6 @@
3
3
  module Vedeu
4
4
 
5
5
  # The current version of Vedeu.
6
- VERSION = '0.8.7'.freeze
6
+ VERSION = '0.8.8'.freeze
7
7
 
8
8
  end
@@ -11,10 +11,8 @@ module Vedeu
11
11
  let(:params) { {} }
12
12
 
13
13
  describe '#initialize' do
14
- subject { instance }
15
-
16
- it { subject.must_be_instance_of(described) }
17
- it { subject.instance_variable_get('@params').must_equal(params) }
14
+ it { instance.must_be_instance_of(described) }
15
+ it { instance.instance_variable_get('@params').must_equal(params) }
18
16
  end
19
17
 
20
18
  describe '#redirect_to' do
@@ -61,18 +61,16 @@ module Vedeu
61
61
  end
62
62
 
63
63
  describe '#initialize' do
64
- subject { instance }
65
-
66
- it { subject.must_be_instance_of(described) }
67
- it { subject.instance_variable_get('@name').must_equal( _name) }
68
- it { subject.instance_variable_get('@ox').must_equal(ox) }
69
- it { subject.instance_variable_get('@oy').must_equal(oy) }
64
+ it { instance.must_be_instance_of(described) }
65
+ it { instance.instance_variable_get('@name').must_equal( _name) }
66
+ it { instance.instance_variable_get('@ox').must_equal(ox) }
67
+ it { instance.instance_variable_get('@oy').must_equal(oy) }
70
68
  it do
71
- subject.instance_variable_get('@repository').must_equal(repository)
69
+ instance.instance_variable_get('@repository').must_equal(repository)
72
70
  end
73
- it { subject.instance_variable_get('@visible').must_equal(true) }
74
- it { subject.instance_variable_get('@x').must_equal(x) }
75
- it { subject.instance_variable_get('@y').must_equal(y) }
71
+ it { instance.instance_variable_get('@visible').must_equal(true) }
72
+ it { instance.instance_variable_get('@x').must_equal(x) }
73
+ it { instance.instance_variable_get('@y').must_equal(y) }
76
74
  end
77
75
 
78
76
  describe '#attributes' do
@@ -147,8 +145,7 @@ module Vedeu
147
145
 
148
146
  describe '#inspect' do
149
147
  let(:expected) {
150
- "<Vedeu::Cursors::Cursor name:'vedeu_cursors_cursor', x:19, y:8, ox:3, oy:2, " \
151
- "visible:true>"
148
+ "name:'vedeu_cursors_cursor' x:19 y:8 ox:3 oy:2 visible:true"
152
149
  }
153
150
 
154
151
  subject { instance.inspect }
@@ -9,15 +9,19 @@ module Vedeu
9
9
  describe Move do
10
10
 
11
11
  let(:described) { Vedeu::Cursors::Move }
12
- let(:instance) { described.new(_name, direction) }
12
+ let(:instance) { described.new(_name, direction, offset) }
13
13
  let(:_name) {}
14
14
  let(:direction) {}
15
+ let(:offset) { 1 }
15
16
  let(:visible) { true }
16
17
 
17
18
  describe '#initialize' do
18
19
  it { instance.must_be_instance_of(described) }
19
20
  it { instance.instance_variable_get('@name').must_equal(_name) }
20
- it { instance.instance_variable_get('@direction').must_equal(direction) }
21
+ it do
22
+ instance.instance_variable_get('@direction').must_equal(direction)
23
+ end
24
+ it { instance.instance_variable_get('@offset').must_equal(offset) }
21
25
  end
22
26
 
23
27
  describe '.move' do
@@ -29,7 +33,7 @@ module Vedeu
29
33
  Vedeu.stubs(:trigger).with(:_refresh_cursor_, _name)
30
34
  end
31
35
 
32
- subject { described.move(_name, direction) }
36
+ subject { described.move(_name, direction, offset) }
33
37
 
34
38
  context 'when a name is given' do
35
39
  let(:_name) { :vedeu_cursors_move }
@@ -12,7 +12,7 @@ module Vedeu
12
12
  let(:instance) { described.new(attributes) }
13
13
  let(:direction) {}
14
14
  let(:_name) { :vedeu_geometries_move }
15
- let(:offset) {}
15
+ let(:offset) { 1 }
16
16
  let(:attributes) {
17
17
  {
18
18
  direction: direction,
@@ -24,14 +24,7 @@ module Vedeu
24
24
  Vedeu::Geometries::Geometry.new(name: _name, x: 2, xn: 8, y: 2, yn: 8)
25
25
  }
26
26
 
27
- before do
28
- Vedeu.stubs(:trigger).with(:_movement_refresh_, _name)
29
- Vedeu.stubs(:trigger).with(:_cursor_down_, _name)
30
- Vedeu.stubs(:trigger).with(:_cursor_left_, _name)
31
- Vedeu.stubs(:trigger).with(:_cursor_origin_, _name)
32
- Vedeu.stubs(:trigger).with(:_cursor_right_, _name)
33
- Vedeu.stubs(:trigger).with(:_cursor_up_, _name)
34
- end
27
+ before { Vedeu.stubs(:trigger).with(:_movement_refresh_, _name) }
35
28
 
36
29
  describe '#initialize' do
37
30
  it { instance.must_be_instance_of(described) }
@@ -81,6 +74,10 @@ module Vedeu
81
74
  context 'when the direction is :down' do
82
75
  let(:direction) { :down }
83
76
 
77
+ before do
78
+ Vedeu.stubs(:trigger).with(:_cursor_down_, _name, 0)
79
+ end
80
+
84
81
  context 'when y + offset > terminal height' do
85
82
  let(:offset) { 3 }
86
83
 
@@ -99,6 +96,10 @@ module Vedeu
99
96
  context 'when the direction is :left' do
100
97
  let(:direction) { :left }
101
98
 
99
+ before do
100
+ Vedeu.stubs(:trigger).with(:_cursor_left_, _name, 0)
101
+ end
102
+
102
103
  context 'when x - offset < 1' do
103
104
  let(:offset) { 3 }
104
105
 
@@ -124,6 +125,10 @@ module Vedeu
124
125
  context 'when the direction is :origin' do
125
126
  let(:direction) { :origin }
126
127
 
128
+ before do
129
+ Vedeu.stubs(:trigger).with(:_cursor_origin_, _name)
130
+ end
131
+
127
132
  it { subject.must_be_instance_of(Vedeu::Geometries::Geometry) }
128
133
  it { subject.x.must_equal(1) }
129
134
  it { subject.xn.must_equal(7) }
@@ -134,6 +139,10 @@ module Vedeu
134
139
  context 'when the direction is :right' do
135
140
  let(:direction) { :right }
136
141
 
142
+ before do
143
+ Vedeu.stubs(:trigger).with(:_cursor_right_, _name, 0)
144
+ end
145
+
137
146
  context 'when xn + offset > terminal width' do
138
147
  let(:offset) { 3 }
139
148
 
@@ -152,6 +161,10 @@ module Vedeu
152
161
  context 'when the direction is :up' do
153
162
  let(:direction) { :up }
154
163
 
164
+ before do
165
+ Vedeu.stubs(:trigger).with(:_cursor_up_, _name, 0)
166
+ end
167
+
155
168
  context 'when y - offset < 1' do
156
169
  let(:offset) { 3 }
157
170
 
@@ -39,105 +39,103 @@ module Vedeu
39
39
  let(:zindex) { 1 }
40
40
 
41
41
  describe '#initialize' do
42
- subject { instance }
43
-
44
- it { subject.must_be_instance_of(described) }
45
- it { subject.instance_variable_get('@client').must_equal(client) }
42
+ it { instance.must_be_instance_of(described) }
43
+ it { instance.instance_variable_get('@client').must_equal(client) }
46
44
  it do
47
- subject.instance_variable_get('@cursor_visible').
45
+ instance.instance_variable_get('@cursor_visible').
48
46
  must_equal(cursor_visible)
49
47
  end
50
- it { subject.instance_variable_get('@delay').must_equal(delay) }
51
- it { subject.instance_variable_get('@editable').must_equal(editable) }
52
- it { subject.instance_variable_get('@group').must_equal(group) }
53
- it { subject.instance_variable_get('@name').must_equal(_name) }
54
- it { subject.instance_variable_get('@parent').must_equal(parent) }
48
+ it { instance.instance_variable_get('@delay').must_equal(delay) }
49
+ it { instance.instance_variable_get('@editable').must_equal(editable) }
50
+ it { instance.instance_variable_get('@group').must_equal(group) }
51
+ it { instance.instance_variable_get('@name').must_equal(_name) }
52
+ it { instance.instance_variable_get('@parent').must_equal(parent) }
55
53
  it do
56
- subject.instance_variable_get('@repository').must_equal(repository)
54
+ instance.instance_variable_get('@repository').must_equal(repository)
57
55
  end
58
- it { subject.instance_variable_get('@visible').must_equal(visible) }
59
- it { subject.instance_variable_get('@zindex').must_equal(zindex) }
56
+ it { instance.instance_variable_get('@visible').must_equal(visible) }
57
+ it { instance.instance_variable_get('@zindex').must_equal(zindex) }
60
58
  end
61
59
 
62
- describe '#client' do
63
- it { instance.must_respond_to(:client) }
64
- end
60
+ describe '#client' do
61
+ it { instance.must_respond_to(:client) }
62
+ end
65
63
 
66
- describe '#client=' do
67
- it { instance.must_respond_to(:client=) }
68
- end
64
+ describe '#client=' do
65
+ it { instance.must_respond_to(:client=) }
66
+ end
69
67
 
70
- describe '#cursor_visible' do
71
- it { instance.must_respond_to(:cursor_visible) }
72
- end
68
+ describe '#cursor_visible' do
69
+ it { instance.must_respond_to(:cursor_visible) }
70
+ end
73
71
 
74
- describe '#cursor_visible=' do
75
- it { instance.must_respond_to(:cursor_visible=) }
76
- end
72
+ describe '#cursor_visible=' do
73
+ it { instance.must_respond_to(:cursor_visible=) }
74
+ end
77
75
 
78
- describe '#delay' do
79
- it { instance.must_respond_to(:delay) }
80
- end
76
+ describe '#delay' do
77
+ it { instance.must_respond_to(:delay) }
78
+ end
81
79
 
82
- describe '#delay=' do
83
- it { instance.must_respond_to(:delay=) }
84
- end
80
+ describe '#delay=' do
81
+ it { instance.must_respond_to(:delay=) }
82
+ end
85
83
 
86
- describe '#editable' do
87
- it { instance.must_respond_to(:editable) }
88
- end
84
+ describe '#editable' do
85
+ it { instance.must_respond_to(:editable) }
86
+ end
89
87
 
90
- describe '#editable=' do
91
- it { instance.must_respond_to(:editable=) }
92
- end
88
+ describe '#editable=' do
89
+ it { instance.must_respond_to(:editable=) }
90
+ end
93
91
 
94
- describe '#editable?' do
95
- it { instance.must_respond_to(:editable?) }
96
- end
92
+ describe '#editable?' do
93
+ it { instance.must_respond_to(:editable?) }
94
+ end
97
95
 
98
- describe '#group' do
99
- it { instance.must_respond_to(:group) }
100
- end
96
+ describe '#group' do
97
+ it { instance.must_respond_to(:group) }
98
+ end
101
99
 
102
- describe '#group=' do
103
- it { instance.must_respond_to(:group=) }
104
- end
100
+ describe '#group=' do
101
+ it { instance.must_respond_to(:group=) }
102
+ end
105
103
 
106
- describe '#name' do
107
- it { instance.must_respond_to(:name) }
108
- end
104
+ describe '#name' do
105
+ it { instance.must_respond_to(:name) }
106
+ end
109
107
 
110
- describe '#name=' do
111
- it { instance.must_respond_to(:name=) }
112
- end
108
+ describe '#name=' do
109
+ it { instance.must_respond_to(:name=) }
110
+ end
113
111
 
114
- describe '#parent' do
115
- it { instance.must_respond_to(:parent) }
116
- end
112
+ describe '#parent' do
113
+ it { instance.must_respond_to(:parent) }
114
+ end
117
115
 
118
- describe '#parent=' do
119
- it { instance.must_respond_to(:parent=) }
120
- end
116
+ describe '#parent=' do
117
+ it { instance.must_respond_to(:parent=) }
118
+ end
121
119
 
122
- describe '#zindex' do
123
- it { instance.must_respond_to(:zindex) }
124
- end
120
+ describe '#zindex' do
121
+ it { instance.must_respond_to(:zindex) }
122
+ end
125
123
 
126
- describe '#zindex=' do
127
- it { instance.must_respond_to(:zindex=) }
128
- end
124
+ describe '#zindex=' do
125
+ it { instance.must_respond_to(:zindex=) }
126
+ end
129
127
 
130
- describe '#visible' do
131
- it { instance.must_respond_to(:visible) }
132
- end
128
+ describe '#visible' do
129
+ it { instance.must_respond_to(:visible) }
130
+ end
133
131
 
134
- describe '#visible=' do
135
- it { instance.must_respond_to(:visible=) }
136
- end
132
+ describe '#visible=' do
133
+ it { instance.must_respond_to(:visible=) }
134
+ end
137
135
 
138
- describe '#visible?' do
139
- it { instance.must_respond_to(:visible?) }
140
- end
136
+ describe '#visible?' do
137
+ it { instance.must_respond_to(:visible?) }
138
+ end
141
139
 
142
140
  describe '#attributes' do
143
141
  subject { instance.attributes }
@@ -49,7 +49,7 @@ module Vedeu
49
49
  end
50
50
  end
51
51
 
52
- describe '.log_stdout' do
52
+ describe '.log_stderr' do
53
53
  let(:type) { :debug }
54
54
  let(:_message) { 'Logging to stderr...' }
55
55
 
@@ -39,7 +39,6 @@ module Vedeu
39
39
 
40
40
  describe '#execute!' do
41
41
  before do
42
- Vedeu.stubs(:log_stdout)
43
42
  Vedeu::Runtime::Application.stubs(:start)
44
43
  Kernel.stubs(:exit)
45
44
  Kernel.stubs(:puts)
@@ -63,8 +62,10 @@ module Vedeu
63
62
  context 'but debugging is disabled' do
64
63
  let(:debug) { false }
65
64
 
65
+ before { Vedeu.stubs(:log_stderr).with(message: "Oops!\n") }
66
+
66
67
  it do
67
- Vedeu.expects(:log_stdout).with(type: :error, message: 'Oops!')
68
+ Vedeu.expects(:log_stderr).with(message: "Oops!\n")
68
69
  subject
69
70
  end
70
71
  end
@@ -72,9 +73,9 @@ module Vedeu
72
73
  context 'and debugging is enabled' do
73
74
  let(:debug) { true }
74
75
 
75
- # Need to stub a backtrace.
76
+ # @todo Need to stub a backtrace.
76
77
  # it do
77
- # Vedeu.expects(:log_stdout).with(type: :error, message: 'Oops!')
78
+ # Vedeu.expects(:log_stderr).with(message: "Oops!\n")
78
79
  # subject
79
80
  # end
80
81
  end