vedeu 0.6.40 → 0.6.41

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/.yardopts +7 -0
  4. data/README.md +10 -0
  5. data/benchmarks/array_vs_range.rb +41 -0
  6. data/docs/api.md +7 -0
  7. data/docs/colours_styles.md +4 -0
  8. data/docs/debugging.md +19 -0
  9. data/docs/template.md +1 -0
  10. data/examples/284_slow_rendering.rb +105 -0
  11. data/lib/vedeu/borders/dsl.rb +2 -1
  12. data/lib/vedeu/borders/repository.rb +2 -1
  13. data/lib/vedeu/buffers/repository.rb +2 -1
  14. data/lib/vedeu/colours/backgrounds.rb +2 -1
  15. data/lib/vedeu/colours/foregrounds.rb +2 -1
  16. data/lib/vedeu/configuration/configuration.rb +3 -1
  17. data/lib/vedeu/cursors/cursor.rb +3 -1
  18. data/lib/vedeu/cursors/repository.rb +4 -2
  19. data/lib/vedeu/distributed/server.rb +5 -2
  20. data/lib/vedeu/dsl/view.rb +4 -1
  21. data/lib/vedeu/editor/document.rb +13 -12
  22. data/lib/vedeu/editor/repository.rb +2 -1
  23. data/lib/vedeu/events/aliases.rb +3 -1
  24. data/lib/vedeu/events/event.rb +6 -2
  25. data/lib/vedeu/events/repository.rb +2 -1
  26. data/lib/vedeu/events/trigger.rb +2 -1
  27. data/lib/vedeu/geometry/dsl.rb +2 -1
  28. data/lib/vedeu/geometry/repository.rb +2 -1
  29. data/lib/vedeu/groups/clear.rb +2 -1
  30. data/lib/vedeu/groups/dsl.rb +2 -1
  31. data/lib/vedeu/groups/group.rb +4 -1
  32. data/lib/vedeu/groups/repository.rb +2 -1
  33. data/lib/vedeu/input/dsl.rb +2 -1
  34. data/lib/vedeu/input/keymaps.rb +2 -1
  35. data/lib/vedeu/input/mapper.rb +2 -1
  36. data/lib/vedeu/interfaces/dsl.rb +2 -1
  37. data/lib/vedeu/interfaces/interface.rb +3 -1
  38. data/lib/vedeu/interfaces/repository.rb +2 -1
  39. data/lib/vedeu/logging/all.rb +1 -0
  40. data/lib/vedeu/logging/debug.rb +2 -1
  41. data/lib/vedeu/logging/ips.rb +57 -0
  42. data/lib/vedeu/logging/log.rb +4 -1
  43. data/lib/vedeu/logging/timer.rb +2 -1
  44. data/lib/vedeu/menus/menu.rb +2 -1
  45. data/lib/vedeu/menus/repository.rb +2 -1
  46. data/lib/vedeu/models/focus.rb +6 -2
  47. data/lib/vedeu/output/clear/interface.rb +46 -4
  48. data/lib/vedeu/output/compressor.rb +1 -1
  49. data/lib/vedeu/output/output.rb +36 -3
  50. data/lib/vedeu/output/renderers/all.rb +3 -1
  51. data/lib/vedeu/runtime/application.rb +2 -1
  52. data/lib/vedeu/runtime/flags.rb +3 -1
  53. data/lib/vedeu/runtime/main_loop.rb +2 -2
  54. data/lib/vedeu/runtime/router.rb +2 -1
  55. data/lib/vedeu/terminal/buffer.rb +27 -8
  56. data/lib/vedeu/terminal/terminal.rb +4 -1
  57. data/lib/vedeu/version.rb +1 -1
  58. data/test/lib/vedeu/editor/document_test.rb +1 -0
  59. data/test/lib/vedeu/output/clear/interface_test.rb +1 -0
  60. data/test/lib/vedeu/output/output_test.rb +45 -1
  61. data/test/lib/vedeu/terminal/buffer_test.rb +11 -0
  62. data/test/lib/vedeu_test.rb +2 -0
  63. data/test/test_helper.rb +21 -0
  64. data/vedeu.gemspec +1 -0
  65. metadata +20 -2
@@ -120,7 +120,9 @@ module Vedeu
120
120
  # @see Vedeu::Renderers#renderer
121
121
  # @!method renderers
122
122
  # @see Vedeu::Renderers#renderers
123
- def_delegators Vedeu::Renderers, :renderer, :renderers
123
+ def_delegators Vedeu::Renderers,
124
+ :renderer,
125
+ :renderers
124
126
 
125
127
  end # Vedeu
126
128
 
@@ -135,7 +135,8 @@ module Vedeu
135
135
 
136
136
  # @!method exit
137
137
  # @see Vedeu::Runtime::Application.stop
138
- def_delegators Vedeu::Runtime::Application, :exit
138
+ def_delegators Vedeu::Runtime::Application,
139
+ :exit
139
140
 
140
141
  # :nocov:
141
142
 
@@ -63,7 +63,9 @@ module Vedeu
63
63
  # @!method ready?
64
64
  # @!method ready!
65
65
  # @return [Boolean]
66
- def_delegators Vedeu::Runtime::Flags, :ready?, :ready!
66
+ def_delegators Vedeu::Runtime::Flags,
67
+ :ready?,
68
+ :ready!
67
69
 
68
70
  # :nocov:
69
71
 
@@ -24,9 +24,9 @@ module Vedeu
24
24
 
25
25
  Vedeu.trigger(:_refresh_cursor_, Vedeu.focus)
26
26
 
27
- while @loop
28
- Vedeu.refresh
27
+ Vedeu.trigger(:_refresh_)
29
28
 
29
+ while @loop
30
30
  yield
31
31
 
32
32
  safe_exit_point!
@@ -191,7 +191,8 @@ module Vedeu
191
191
 
192
192
  # @!method goto
193
193
  # @see Vedeu::Runtime::Router#goto
194
- def_delegators Vedeu::Runtime::Router, :goto
194
+ def_delegators Vedeu::Runtime::Router,
195
+ :goto
195
196
 
196
197
  # :nocov:
197
198
 
@@ -84,22 +84,30 @@ module Vedeu
84
84
  end
85
85
  end
86
86
 
87
- # Write a collection of cells to the virtual terminal.
87
+ # Write a collection of cells to the virtual terminal, will
88
+ # then send written content to be rendered by a renderer.
88
89
  #
89
90
  # @param value [Array<Array<Vedeu::Views::Char>>]
90
91
  # @return [Array<Array<Vedeu::Views::Char>>]
91
92
  def write(value)
92
- values = Array(value).flatten
93
-
94
- values.each do |v|
95
- buffer[v.position.y][v.position.x] = v if valid_position?(v)
96
- end
93
+ update_buffer(value)
97
94
 
98
95
  render
99
96
 
100
97
  self
101
98
  end
102
99
 
100
+ # Write a collection of cells to the virtual terminal, but do
101
+ # not send to a renderer.
102
+ #
103
+ # @param value [Array<Array<Vedeu::Views::Char>>]
104
+ # @return [Array<Array<Vedeu::Views::Char>>]
105
+ def update(value)
106
+ update_buffer(value)
107
+
108
+ self
109
+ end
110
+
103
111
  private
104
112
 
105
113
  # @param from [Array] An Array of rows, or an Array of cells.
@@ -120,6 +128,16 @@ module Vedeu
120
128
  value.position.is_a?(Vedeu::Geometry::Position)
121
129
  end
122
130
 
131
+ # @param value [Array<Array<Vedeu::Views::Char>>]
132
+ # @return [Array<Array<Vedeu::Views::Char>>]
133
+ def update_buffer(value)
134
+ values = Array(value).flatten
135
+
136
+ values.each do |v|
137
+ buffer[v.position.y][v.position.x] = v if valid_position?(v)
138
+ end
139
+ end
140
+
123
141
  # Returns a boolean indicating the value has a position
124
142
  # attribute and is within the terminal boundary.
125
143
  #
@@ -144,8 +162,9 @@ module Vedeu
144
162
 
145
163
  # @!method clear
146
164
  # @see Vedeu::Terminal::Buffer#clear
147
- def_delegators Vedeu::Terminal::Buffer, :clear
148
- def_delegators Vedeu::Terminal::Buffer, :refresh
165
+ def_delegators Vedeu::Terminal::Buffer,
166
+ :clear,
167
+ :refresh
149
168
 
150
169
  # :nocov:
151
170
 
@@ -222,7 +222,10 @@ module Vedeu
222
222
  # @see Vedeu::Terminal#resize
223
223
  # @!method width
224
224
  # @see Vedeu::Terminal#width
225
- def_delegators Vedeu::Terminal, :height, :resize, :width
225
+ def_delegators Vedeu::Terminal,
226
+ :height,
227
+ :resize,
228
+ :width
226
229
 
227
230
  # :nocov:
228
231
 
data/lib/vedeu/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # The current version of Vedeu.
4
- VERSION = '0.6.40'.freeze
4
+ VERSION = '0.6.41'.freeze
5
5
 
6
6
  end
@@ -35,6 +35,7 @@ module Vedeu
35
35
  Vedeu.geometries.stubs(:by_name).with(_name).returns(geometry)
36
36
  Vedeu.interfaces.stubs(:by_name).with(_name).returns(interface)
37
37
 
38
+ Vedeu.stubs(:direct_write)
38
39
  Vedeu.stubs(:render_output)
39
40
  }
40
41
 
@@ -16,6 +16,7 @@ module Vedeu
16
16
  let(:options) {
17
17
  {
18
18
  content_only: false,
19
+ direct: false,
19
20
  }
20
21
  }
21
22
  let(:_name) { 'Vedeu::Clear::Interface' }
@@ -16,6 +16,42 @@ module Vedeu
16
16
  it { instance.instance_variable_get('@output').must_equal(output) }
17
17
  end
18
18
 
19
+ describe '.buffer_write' do
20
+ subject { described.buffer_write(output) }
21
+
22
+ context 'when the output is empty' do
23
+ it { subject.must_be_instance_of(NilClass) }
24
+ end
25
+
26
+ context 'when the output is not empty' do
27
+ let(:output) { Vedeu::Models::Page.new }
28
+
29
+ it {
30
+ Vedeu::Terminal::Buffer.expects(:write).with(output)
31
+ subject
32
+ }
33
+ end
34
+ end
35
+
36
+ describe '.direct_write' do
37
+ subject { described.direct_write(output) }
38
+
39
+ context 'when the output is empty' do
40
+ it { subject.must_be_instance_of(NilClass) }
41
+ end
42
+
43
+ context 'when the output is not empty' do
44
+ let(:output) {
45
+ Vedeu::Models::Escape.new(value: "\e[?25h", position: [1, 1])
46
+ }
47
+
48
+ it {
49
+ Vedeu::Terminal.expects(:output).with(output.to_s)
50
+ subject
51
+ }
52
+ end
53
+ end
54
+
19
55
  describe '.render_output' do
20
56
  subject { described.render_output(output) }
21
57
 
@@ -30,7 +66,7 @@ module Vedeu
30
66
  }
31
67
 
32
68
  it {
33
- Vedeu::Terminal.expects(:output)
69
+ Vedeu::Terminal.expects(:output).with(output.to_s)
34
70
  subject
35
71
  }
36
72
  end
@@ -46,6 +82,14 @@ module Vedeu
46
82
  end
47
83
  end
48
84
 
85
+ describe '#buffer_write' do
86
+ it { instance.must_respond_to(:buffer_write) }
87
+ end
88
+
89
+ describe '#direct_write' do
90
+ it { instance.must_respond_to(:direct_write) }
91
+ end
92
+
49
93
  describe '#render_output' do
50
94
  it { instance.must_respond_to(:render_output) }
51
95
  end
@@ -49,6 +49,7 @@ module Vedeu
49
49
  end
50
50
 
51
51
  context 'when Vedeu is not ready' do
52
+ # @todo Add more tests.
52
53
  end
53
54
  end
54
55
 
@@ -86,6 +87,16 @@ module Vedeu
86
87
  let(:_value) {}
87
88
 
88
89
  subject { described.write(_value) }
90
+
91
+ # @todo Add more tests.
92
+ end
93
+
94
+ describe '#update' do
95
+ let(:_value) {}
96
+
97
+ subject { described.update(_value) }
98
+
99
+ # @todo Add more tests.
89
100
  end
90
101
 
91
102
  end # Buffer
@@ -13,6 +13,7 @@ describe Vedeu do
13
13
  it { Vedeu.must_respond_to(:borders) }
14
14
  it { Vedeu.must_respond_to(:bound?) }
15
15
  it { Vedeu.must_respond_to(:buffers) }
16
+ it { Vedeu.must_respond_to(:buffer_write) }
16
17
  it { Vedeu.must_respond_to(:clear) }
17
18
  it { Vedeu.must_respond_to(:clear_by_group) }
18
19
  it { Vedeu.must_respond_to(:clear_by_name) }
@@ -21,6 +22,7 @@ describe Vedeu do
21
22
  it { Vedeu.must_respond_to(:configure) }
22
23
  it { Vedeu.must_respond_to(:cursor) }
23
24
  it { Vedeu.must_respond_to(:cursors) }
25
+ it { Vedeu.must_respond_to(:direct_write) }
24
26
  it { Vedeu.must_respond_to(:documents) }
25
27
  it { Vedeu.must_respond_to(:drb_restart) }
26
28
  it { Vedeu.must_respond_to(:drb_start) }
data/test/test_helper.rb CHANGED
@@ -123,3 +123,24 @@ def test_configuration
123
123
  end
124
124
 
125
125
  test_configuration
126
+
127
+ # require "benchmark/ips"
128
+
129
+ # def fast
130
+ # end
131
+
132
+ # def slow
133
+ # end
134
+
135
+ # Benchmark.ips do |x|
136
+ # x.report("describe") { fast }
137
+ # x.report("describe") { slow }
138
+ # x.compare!
139
+ # end
140
+
141
+ # ips = Vedeu::Logging::Debug::IPS.new
142
+ # ips.add_item('original') do
143
+ # end
144
+ # ips.add_item('newimproved') do
145
+ # end
146
+ # ips.execute!
data/vedeu.gemspec CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
21
  spec.require_paths = ['lib']
22
22
 
23
+ spec.add_development_dependency 'benchmark-ips', '2.3.0'
23
24
  spec.add_development_dependency 'guard', '2.13.0'
24
25
  spec.add_development_dependency 'guard-minitest', '2.4.4'
25
26
  spec.add_development_dependency 'guard-rubocop', '1.2.0'
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vedeu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.40
4
+ version: 0.6.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-26 00:00:00.000000000 Z
11
+ date: 2015-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: benchmark-ips
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 2.3.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 2.3.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: guard
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -257,6 +271,7 @@ files:
257
271
  - LICENSE.txt
258
272
  - README.md
259
273
  - Rakefile
274
+ - benchmarks/array_vs_range.rb
260
275
  - bin/vedeu
261
276
  - bin/vedeu_drb_client
262
277
  - bin/vedeu_drb_server
@@ -270,6 +285,7 @@ files:
270
285
  - docs/colours_styles.md
271
286
  - docs/configuration.md
272
287
  - docs/cursors.md
288
+ - docs/debugging.md
273
289
  - docs/dsl.md
274
290
  - docs/events.md
275
291
  - docs/events/application.md
@@ -294,6 +310,7 @@ files:
294
310
  - docs/streams.md
295
311
  - docs/template.md
296
312
  - docs/view.md
313
+ - examples/284_slow_rendering.rb
297
314
  - examples/dsl_alignment.rb
298
315
  - examples/dsl_demo_groups.rb
299
316
  - examples/dsl_editor.rb
@@ -419,6 +436,7 @@ files:
419
436
  - lib/vedeu/interfaces/repository.rb
420
437
  - lib/vedeu/logging/all.rb
421
438
  - lib/vedeu/logging/debug.rb
439
+ - lib/vedeu/logging/ips.rb
422
440
  - lib/vedeu/logging/lockless_log_device.rb
423
441
  - lib/vedeu/logging/log.rb
424
442
  - lib/vedeu/logging/mono_logger.rb