vedeu 0.6.25 → 0.6.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu/application/application_view.rb +2 -2
  3. data/lib/vedeu/bindings/drb.rb +1 -1
  4. data/lib/vedeu/bindings/movement.rb +4 -4
  5. data/lib/vedeu/borders/border.rb +5 -13
  6. data/lib/vedeu/borders/refresh.rb +4 -1
  7. data/lib/vedeu/buffers/buffer.rb +1 -1
  8. data/lib/vedeu/colours/background.rb +2 -2
  9. data/lib/vedeu/colours/foreground.rb +2 -2
  10. data/lib/vedeu/colours/translator.rb +4 -4
  11. data/lib/vedeu/configuration/api.rb +1 -1
  12. data/lib/vedeu/configuration/configuration.rb +1 -1
  13. data/lib/vedeu/cursors/cursor.rb +2 -2
  14. data/lib/vedeu/distributed/client.rb +3 -3
  15. data/lib/vedeu/distributed/server.rb +16 -15
  16. data/lib/vedeu/distributed/subprocess.rb +2 -2
  17. data/lib/vedeu/distributed/uri.rb +1 -1
  18. data/lib/vedeu/dsl/composition.rb +3 -2
  19. data/lib/vedeu/dsl/dsl.rb +2 -1
  20. data/lib/vedeu/dsl/interface.rb +1 -1
  21. data/lib/vedeu/dsl/keymap.rb +3 -3
  22. data/lib/vedeu/editor/cropper.rb +1 -1
  23. data/lib/vedeu/editor/cursor.rb +1 -1
  24. data/lib/vedeu/editor/line.rb +1 -1
  25. data/lib/vedeu/error.rb +2 -2
  26. data/lib/vedeu/esc/actions.rb +15 -15
  27. data/lib/vedeu/esc/borders.rb +12 -12
  28. data/lib/vedeu/esc/colours.rb +10 -8
  29. data/lib/vedeu/esc/esc.rb +10 -9
  30. data/lib/vedeu/events/aliases.rb +1 -4
  31. data/lib/vedeu/events/event.rb +5 -4
  32. data/lib/vedeu/geometry/generic_coordinate.rb +1 -1
  33. data/lib/vedeu/geometry/geometry.rb +2 -4
  34. data/lib/vedeu/geometry/position.rb +2 -2
  35. data/lib/vedeu/groups/refresh.rb +2 -2
  36. data/lib/vedeu/input/keymap.rb +3 -2
  37. data/lib/vedeu/input/mapper.rb +1 -1
  38. data/lib/vedeu/logging/lockless_log_device.rb +1 -1
  39. data/lib/vedeu/logging/log.rb +2 -2
  40. data/lib/vedeu/logging/mono_logger.rb +1 -1
  41. data/lib/vedeu/logging/timer.rb +2 -1
  42. data/lib/vedeu/models/escape.rb +2 -2
  43. data/lib/vedeu/models/focus.rb +5 -3
  44. data/lib/vedeu/models/page.rb +2 -2
  45. data/lib/vedeu/models/views/html_char.rb +15 -14
  46. data/lib/vedeu/models/views/view.rb +2 -1
  47. data/lib/vedeu/output/clear/interface.rb +4 -4
  48. data/lib/vedeu/output/compressor.rb +3 -3
  49. data/lib/vedeu/output/presentation/presentation.rb +2 -2
  50. data/lib/vedeu/output/presentation/style.rb +1 -1
  51. data/lib/vedeu/output/refresh/refresh.rb +1 -1
  52. data/lib/vedeu/output/renderers/all.rb +2 -0
  53. data/lib/vedeu/output/renderers/file.rb +1 -1
  54. data/lib/vedeu/output/viewport.rb +1 -1
  55. data/lib/vedeu/output/wordwrap.rb +4 -4
  56. data/lib/vedeu/plugins/plugin.rb +3 -3
  57. data/lib/vedeu/plugins/plugins.rb +4 -3
  58. data/lib/vedeu/repositories/model.rb +6 -6
  59. data/lib/vedeu/repositories/repositories.rb +1 -1
  60. data/lib/vedeu/repositories/repository.rb +11 -10
  61. data/lib/vedeu/repositories/store.rb +1 -1
  62. data/lib/vedeu/runtime/bootstrap.rb +8 -8
  63. data/lib/vedeu/runtime/launcher.rb +1 -1
  64. data/lib/vedeu/runtime/main_loop.rb +1 -1
  65. data/lib/vedeu/runtime/router.rb +10 -8
  66. data/lib/vedeu/templating/template.rb +2 -2
  67. data/lib/vedeu/terminal/buffer.rb +10 -11
  68. data/lib/vedeu/terminal/terminal.rb +2 -2
  69. data/lib/vedeu/version.rb +1 -1
  70. data/test/lib/vedeu/borders/border_test.rb +1 -11
  71. data/test/lib/vedeu/colours/repository_test.rb +2 -1
  72. data/test/lib/vedeu/esc/colours_test.rb +50 -0
  73. data/test/lib/vedeu/repositories/repository_test.rb +0 -2
  74. data/test/lib/vedeu/terminal/buffer_test.rb +0 -209
  75. metadata +2 -2
@@ -51,7 +51,7 @@ module Vedeu
51
51
  # @return [Array|Hash|Set]
52
52
  def reset
53
53
  Vedeu.log(type: :reset,
54
- message: "(#{self.class.name}) #{registered.inspect}")
54
+ message: "(#{self.class.name}) #{registered.inspect}".freeze)
55
55
 
56
56
  @storage = in_memory
57
57
  end
@@ -65,12 +65,12 @@ module Vedeu
65
65
  # @return [void]
66
66
  def client_application!
67
67
  [
68
- 'app/views/templates/**/*',
69
- 'app/views/interfaces/**/*',
70
- 'app/controllers/**/*',
71
- 'app/helpers/**/*',
72
- 'app/views/**/*',
73
- 'app/models/keymaps/**/*',
68
+ 'app/views/templates/**/*'.freeze,
69
+ 'app/views/interfaces/**/*'.freeze,
70
+ 'app/controllers/**/*'.freeze,
71
+ 'app/helpers/**/*'.freeze,
72
+ 'app/views/**/*'.freeze,
73
+ 'app/models/keymaps/**/*'.freeze,
74
74
  ].each { |path| load(File.join(base_path, path)) }
75
75
  end
76
76
 
@@ -103,7 +103,7 @@ module Vedeu
103
103
  # @return [Array<String>]
104
104
  def loadables(path)
105
105
  Dir.glob(path).select do |file|
106
- File.file?(file) && File.extname(file) == '.rb'
106
+ File.file?(file) && File.extname(file) == '.rb'.freeze
107
107
  end
108
108
  end
109
109
 
@@ -121,7 +121,7 @@ module Vedeu
121
121
  "controller and action: (args are optional)\n\n" \
122
122
  "Vedeu.configure do\n" \
123
123
  " root :some_controller, :show, *args\n" \
124
- "end\n\n"
124
+ "end\n\n".freeze
125
125
  end
126
126
 
127
127
  end # Bootstrap
@@ -102,7 +102,7 @@ module Vedeu
102
102
  #
103
103
  # @return [void]
104
104
  def terminate!
105
- Vedeu.log(type: :info, message: 'Exiting gracefully.')
105
+ Vedeu.log(type: :info, message: 'Exiting gracefully.'.freeze)
106
106
 
107
107
  $stdin = STDIN
108
108
  $stdout = STDOUT
@@ -31,7 +31,7 @@ module Vedeu
31
31
  end
32
32
  rescue Vedeu::Error::Interrupt
33
33
  Vedeu.log(type: :info,
34
- message: 'Vedeu execution interrupted, exiting.')
34
+ message: 'Vedeu execution interrupted, exiting.'.freeze)
35
35
  end
36
36
 
37
37
  # :nocov:
@@ -22,11 +22,11 @@ module Vedeu
22
22
  def add_controller(controller, klass)
23
23
  unless present?(controller)
24
24
  fail Vedeu::Error::MissingRequired,
25
- 'Cannot store controller without a name attribute.'
25
+ 'Cannot store controller without a name attribute.'.freeze
26
26
  end
27
27
 
28
28
  Vedeu.log(type: :create,
29
- message: "Controller: ':#{controller}'")
29
+ message: "Controller: ':#{controller}'.freeze")
30
30
 
31
31
  if registered?(controller)
32
32
  storage[controller].merge!(klass: klass)
@@ -50,7 +50,8 @@ module Vedeu
50
50
  def add_action(controller, action)
51
51
  if present?(controller) && present?(action)
52
52
  Vedeu.log(type: :create,
53
- message: "Action: ':#{action}' (for ':#{controller}')")
53
+ message: "Action: ':#{action}' " \
54
+ "(for ':#{controller}')".freeze)
54
55
 
55
56
  if registered?(controller)
56
57
  storage[controller][:actions] << action
@@ -65,7 +66,8 @@ module Vedeu
65
66
 
66
67
  else
67
68
  fail Vedeu::Error::MissingRequired,
68
- 'Cannot store action without a controller or name attribute.'
69
+ 'Cannot store action without a controller or name ' \
70
+ 'attribute.'.freeze
69
71
 
70
72
  end
71
73
  end
@@ -84,7 +86,7 @@ module Vedeu
84
86
  # @return [void]
85
87
  def goto(controller, action, **args)
86
88
  Vedeu.log(type: :debug,
87
- message: "Routing: #{controller} #{action}")
89
+ message: "Routing: #{controller} #{action}".freeze)
88
90
 
89
91
  route(controller, action, args) if action_defined?(action, controller)
90
92
  end
@@ -120,11 +122,11 @@ module Vedeu
120
122
  return true if storage[controller][:actions].include?(action)
121
123
 
122
124
  fail Vedeu::Error::ActionNotFound,
123
- "#{action} is not registered for #{controller}."
125
+ "#{action} is not registered for #{controller}.".freeze
124
126
 
125
127
  else
126
128
  fail Vedeu::Error::ControllerNotFound,
127
- "#{controller} is not registered."
129
+ "#{controller} is not registered.".freeze
128
130
 
129
131
  end
130
132
  end
@@ -153,7 +155,7 @@ module Vedeu
153
155
 
154
156
  else
155
157
  fail Vedeu::Error::MissingRequired,
156
- "Cannot route to #{controller} as no class defined."
158
+ "Cannot route to #{controller} as no class defined.".freeze
157
159
 
158
160
  end
159
161
  end
@@ -52,11 +52,11 @@ module Vedeu
52
52
  # @return [String]
53
53
  def path
54
54
  fail Vedeu::Error::MissingRequired,
55
- 'No path to template specified.' if @path.empty?
55
+ 'No path to template specified.'.freeze if @path.empty?
56
56
 
57
57
  unless File.exist?(@path)
58
58
  fail Vedeu::Error::MissingRequired,
59
- "Template file cannot be found. (#{@path})"
59
+ "Template file cannot be found. (#{@path})".freeze
60
60
  end
61
61
 
62
62
  @path
@@ -20,7 +20,11 @@ module Vedeu
20
20
  #
21
21
  # @return [Array<Array<Vedeu::Models::Cell>>]
22
22
  def buffer
23
- @output ||= empty_buffer.dup
23
+ @output ||= Array.new(Vedeu.height) do |y|
24
+ Array.new(Vedeu.width) do |x|
25
+ Vedeu::Models::Cell.new(position: [y + 1, x + 1])
26
+ end
27
+ end
24
28
  end
25
29
  alias_method :cells, :buffer
26
30
 
@@ -36,15 +40,6 @@ module Vedeu
36
40
  Vedeu.renderers.clear if Vedeu.ready?
37
41
  end
38
42
 
39
- # @return [Array<Array<Vedeu::Models::Cell>>]
40
- def empty_buffer
41
- @empty_buffer ||= Array.new(Vedeu.height) do |y|
42
- Array.new(Vedeu.width) do |x|
43
- Vedeu::Models::Cell.new(position: [y + 1, x + 1])
44
- end
45
- end
46
- end
47
-
48
43
  # @return [Vedeu::Models::Page]
49
44
  def output
50
45
  Vedeu::Models::Page.coerce(buffer)
@@ -81,7 +76,11 @@ module Vedeu
81
76
  #
82
77
  # @return [Array<Array<Vedeu::Models::Cell>>]
83
78
  def reset
84
- @output = empty_buffer
79
+ @output = Array.new(Vedeu.height) do |y|
80
+ Array.new(Vedeu.width) do |x|
81
+ Vedeu::Models::Cell.new(position: [y + 1, x + 1])
82
+ end
83
+ end
85
84
  end
86
85
 
87
86
  # Write a collection of cells to the virtual terminal.
@@ -34,7 +34,7 @@ module Vedeu
34
34
  #
35
35
  # @return [String]
36
36
  def input
37
- Vedeu.log(type: :input, message: 'Waiting for user input...')
37
+ Vedeu.log(type: :input, message: 'Waiting for user input...'.freeze)
38
38
 
39
39
  if raw_mode? || fake_mode?
40
40
  Vedeu::Editor::Capture.read(console)
@@ -75,7 +75,7 @@ module Vedeu
75
75
  # @param mode [Symbol]
76
76
  # @return [void]
77
77
  def initialize_screen(mode)
78
- Vedeu.log(type: :info, message: "Terminal entering '#{mode}' mode")
78
+ Vedeu.log(type: :info, message: "Terminal entering '#{mode}' mode".freeze)
79
79
 
80
80
  output(Vedeu::EscapeSequences::Esc.string('screen_init'))
81
81
 
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # The current version of Vedeu.
4
- VERSION = '0.6.25'
4
+ VERSION = '0.6.26'.freeze
5
5
 
6
6
  end
@@ -18,6 +18,7 @@ module Vedeu
18
18
  enabled: false,
19
19
  horizontal: 'q',
20
20
  name: _name,
21
+ parent: nil,
21
22
  repository: Vedeu.borders,
22
23
  show_bottom: true,
23
24
  show_left: true,
@@ -409,17 +410,6 @@ module Vedeu
409
410
  end
410
411
  end
411
412
 
412
- describe '#render' do
413
- before { Vedeu.stubs(:trigger).with(:_refresh_border_, _name) }
414
-
415
- subject { instance.render }
416
-
417
- it {
418
- Vedeu.expects(:trigger).with(:_refresh_border_, _name)
419
- subject
420
- }
421
- end
422
-
423
413
  end # Border
424
414
 
425
415
  end # Borders
@@ -8,10 +8,11 @@ module Vedeu
8
8
 
9
9
  let(:described) { Vedeu::Colours::Repository }
10
10
  let(:instance) { described.new }
11
+ let(:storage) { {} }
11
12
 
12
13
  describe '#initialize' do
13
14
  it { instance.must_be_instance_of(described) }
14
- it { instance.instance_variable_get('@storage').must_equal({}) }
15
+ it { instance.instance_variable_get('@storage').must_equal(storage) }
15
16
  end
16
17
 
17
18
  describe 'accessors' do
@@ -41,7 +41,57 @@ module Vedeu
41
41
  end
42
42
 
43
43
  describe '.background_codes' do
44
+ let(:expected) {
45
+ {
46
+ black: 40,
47
+ red: 41,
48
+ green: 42,
49
+ yellow: 43,
50
+ blue: 44,
51
+ magenta: 45,
52
+ cyan: 46,
53
+ light_grey: 47,
54
+ default: 49,
55
+ dark_grey: 100,
56
+ light_red: 101,
57
+ light_green: 102,
58
+ light_yellow: 103,
59
+ light_blue: 104,
60
+ light_magenta: 105,
61
+ light_cyan: 106,
62
+ white: 107,
63
+ }
64
+ }
65
+
44
66
  it { described.background_codes.must_be_instance_of(Hash) }
67
+ it { described.background_codes.must_equal(expected) }
68
+ end
69
+
70
+ describe '.foreground_codes' do
71
+ let(:expected) {
72
+ {
73
+ black: 30,
74
+ red: 31,
75
+ green: 32,
76
+ yellow: 33,
77
+ blue: 34,
78
+ magenta: 35,
79
+ cyan: 36,
80
+ light_grey: 37,
81
+ default: 39,
82
+ dark_grey: 90,
83
+ light_red: 91,
84
+ light_green: 92,
85
+ light_yellow: 93,
86
+ light_blue: 94,
87
+ light_magenta: 95,
88
+ light_cyan: 96,
89
+ white: 97,
90
+ }
91
+ }
92
+
93
+ it { described.foreground_codes.must_be_instance_of(Hash) }
94
+ it { described.foreground_codes.must_equal(expected) }
45
95
  end
46
96
 
47
97
  describe 'background colour methods' do
@@ -218,9 +218,7 @@ module Vedeu
218
218
  describe '#remove' do
219
219
  subject { instance.remove('francium') }
220
220
 
221
- it { instance.must_respond_to(:destroy) }
222
221
  it { instance.must_respond_to(:delete) }
223
- it { instance.must_respond_to(:deregister) }
224
222
 
225
223
  context 'when the storage is empty' do
226
224
  before { instance.reset }
@@ -46,37 +46,6 @@ module Vedeu
46
46
  end
47
47
  end
48
48
 
49
- describe '#empty_buffer' do
50
- subject { described.empty_buffer }
51
-
52
- it { subject.must_be_instance_of(Array) }
53
- end
54
-
55
- # describe '#output' do
56
- # subject { described.output }
57
-
58
- # context 'when nothing has been written to the buffer' do
59
- # it {
60
- # described.instance_variable_get('@output').must_equal(empty_buffer)
61
- # }
62
- # end
63
-
64
- # context 'when something has been written to the buffer' do
65
- # let(:expected) {
66
- # exp = empty_buffer
67
- # exp[1][2] = Vedeu::Views::Char.new(value: 'a', position: [1, 2])
68
- # exp
69
- # }
70
-
71
- # before do
72
- # described.write(Vedeu::Views::Char.new(value: 'a',
73
- # position: [1, 2]))
74
- # end
75
-
76
- # it { described.instance_variable_get('@output').must_equal(expected) }
77
- # end
78
- # end
79
-
80
49
  describe '#render' do
81
50
  let(:ready) { false }
82
51
 
@@ -111,35 +80,6 @@ module Vedeu
111
80
  let(:_value) {}
112
81
 
113
82
  subject { described.write(_value) }
114
-
115
- # context 'when the value is nil' do
116
- # let(:expected) {
117
- # [
118
- # [
119
- # Vedeu::Models::Cell.new(position: [1, 1]),
120
- # Vedeu::Models::Cell.new(position: [1, 2]),
121
- # Vedeu::Models::Cell.new(position: [1, 3])
122
- # ], [
123
- # Vedeu::Models::Cell.new(position: [2, 1]),
124
- # Vedeu::Models::Cell.new(position: [2, 2]),
125
- # Vedeu::Models::Cell.new(position: [2, 3])
126
- # ]
127
- # ]
128
- # }
129
-
130
- # it { subject.must_equal(described) }
131
- # it { described.output.must_equal(expected) }
132
- # end
133
-
134
- # context 'when the value is not nil' do
135
- # let(:_value) { Vedeu::Views::Char.new(y: 2, x: 1, value: 'a') }
136
- # let(:expected) {
137
-
138
- # }
139
-
140
- # it { subject.must_equal(described) }
141
- # it { described.output.must_equal(expected) }
142
- # end
143
83
  end
144
84
 
145
85
  end # Buffer
@@ -147,152 +87,3 @@ module Vedeu
147
87
  end # Terminal
148
88
 
149
89
  end # Vedeu
150
-
151
- # require 'test_helper'
152
-
153
- # module Vedeu
154
-
155
- # module Buffers
156
-
157
- # describe VirtualBuffer do
158
-
159
- # let(:described) { Vedeu::Buffers::VirtualBuffer }
160
- # let(:instance) { described.new(height, width, renderer) }
161
- # let(:height) { 3 }
162
- # let(:width) { 3 }
163
- # let(:renderer) { Vedeu::Renderers::HTML.new }
164
-
165
- # describe '#initialize' do
166
- # it { instance.must_be_instance_of(described) }
167
- # it { instance.instance_variable_get('@height').must_equal(3) }
168
- # it { instance.instance_variable_get('@width').must_equal(3) }
169
- # it { instance.instance_variable_get('@renderer').must_equal(renderer) }
170
- # end
171
-
172
- # describe 'accessors' do
173
- # it { instance.must_respond_to(:renderer) }
174
- # it { instance.must_respond_to(:renderer=) }
175
- # it { instance.must_respond_to(:height) }
176
- # it { instance.must_respond_to(:width) }
177
- # end
178
-
179
- # describe '.output' do
180
- # let(:data) {}
181
-
182
- # before do
183
- # Vedeu.stubs(:width).returns(3)
184
- # Vedeu.stubs(:height).returns(3)
185
- # end
186
-
187
- # subject { described.output(data) }
188
-
189
- # it { subject.must_be_instance_of(Array) }
190
- # end
191
-
192
- # describe '#cells' do
193
- # before do
194
- # Vedeu.stubs(:width).returns(3)
195
- # Vedeu.stubs(:height).returns(3)
196
- # end
197
-
198
- # subject { instance.cells }
199
-
200
- # it { subject.must_be_instance_of(Array) }
201
- # it { subject.size.must_equal(3) }
202
- # it { subject.flatten.size.must_equal(9) }
203
- # end
204
-
205
- # describe '#read' do
206
- # subject { instance.read(y, x) }
207
-
208
- # context 'when x is out of bounds' do
209
- # let(:y) { 1 }
210
- # let(:x) { 5 }
211
-
212
- # it { subject.must_equal([]) }
213
- # end
214
-
215
- # context 'when y is out of bounds' do
216
- # let(:y) { 5 }
217
- # let(:x) { 1 }
218
-
219
- # it { subject.must_equal([]) }
220
- # end
221
-
222
- # context 'when both x and y are out of bounds' do
223
- # let(:y) { 5 }
224
- # let(:x) { 5 }
225
-
226
- # it { subject.must_equal([]) }
227
- # end
228
-
229
- # context 'when x and y are in bounds' do
230
- # let(:y) { 0 }
231
- # let(:x) { 2 }
232
-
233
- # it { subject.must_be_instance_of(Vedeu::Models::Cell) }
234
- # end
235
- # end
236
-
237
- # describe '#output' do
238
- # it { instance.must_respond_to(:output) }
239
- # end
240
-
241
- # describe '#render' do
242
- # before do
243
- # Vedeu.stubs(:width).returns(3)
244
- # Vedeu.stubs(:height).returns(3)
245
- # end
246
-
247
- # subject { instance.render }
248
-
249
- # it { subject.must_be_instance_of(String) }
250
- # end
251
-
252
- # describe '#reset' do
253
- # subject { instance.reset }
254
-
255
- # it { subject.must_be_instance_of(Array) }
256
-
257
- # it { instance.must_respond_to(:clear) }
258
- # end
259
-
260
- # describe '#write' do
261
- # let(:data) { Vedeu::Views::Char.new(value: 'a') }
262
-
263
- # subject { instance.write(y, x, data) }
264
-
265
- # context 'when x is out of bounds' do
266
- # let(:y) { 1 }
267
- # let(:x) { 5 }
268
-
269
- # it { subject.must_equal(false) }
270
- # end
271
-
272
- # context 'when y is out of bounds' do
273
- # let(:y) { 5 }
274
- # let(:x) { 1 }
275
-
276
- # it { subject.must_equal(false) }
277
- # end
278
-
279
- # context 'when both x and y are out of bounds' do
280
- # let(:y) { 5 }
281
- # let(:x) { 5 }
282
-
283
- # it { subject.must_equal(false) }
284
- # end
285
-
286
- # context 'when x and y are in bounds' do
287
- # let(:y) { 0 }
288
- # let(:x) { 2 }
289
-
290
- # it { subject.must_equal(true) }
291
- # end
292
- # end
293
-
294
- # end # VirtualBuffer
295
-
296
- # end # Buffers
297
-
298
- # end # Vedeu