vedeu 0.4.15 → 0.4.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/examples/borders_app.rb +0 -2
  4. data/examples/colours_app.rb +0 -2
  5. data/examples/cursor_app.rb +0 -2
  6. data/examples/drb_app.rb +0 -2
  7. data/examples/focus_app.rb +0 -2
  8. data/examples/geometry_app.rb +0 -2
  9. data/examples/hello_world.rb +0 -2
  10. data/examples/lines_app.rb +0 -2
  11. data/examples/material_colours_app.rb +0 -2
  12. data/lib/vedeu/bindings.rb +2 -1
  13. data/lib/vedeu/buffers/buffer.rb +18 -10
  14. data/lib/vedeu/debug.rb +2 -1
  15. data/lib/vedeu/distributed/server.rb +14 -8
  16. data/lib/vedeu/dsl/composition.rb +3 -10
  17. data/lib/vedeu/dsl/line.rb +14 -11
  18. data/lib/vedeu/dsl/shared/colour.rb +2 -3
  19. data/lib/vedeu/geometry/coordinate.rb +0 -4
  20. data/lib/vedeu/geometry/position.rb +2 -1
  21. data/lib/vedeu/main_loop.rb +1 -1
  22. data/lib/vedeu/models/all.rb +2 -0
  23. data/lib/vedeu/models/char.rb +4 -6
  24. data/lib/vedeu/models/composition.rb +4 -2
  25. data/lib/vedeu/models/interface.rb +4 -18
  26. data/lib/vedeu/models/line.rb +4 -3
  27. data/lib/vedeu/models/null_interface.rb +15 -0
  28. data/lib/vedeu/models/stream.rb +4 -3
  29. data/lib/vedeu/output/border.rb +9 -12
  30. data/lib/vedeu/output/clear.rb +2 -2
  31. data/lib/vedeu/output/colour.rb +30 -8
  32. data/lib/vedeu/output/esc.rb +2 -1
  33. data/lib/vedeu/output/presentation.rb +37 -20
  34. data/lib/vedeu/output/renderers/all.rb +1 -0
  35. data/lib/vedeu/output/renderers/escape_sequence_renderer.rb +40 -0
  36. data/lib/vedeu/output/renderers/file_renderer.rb +9 -5
  37. data/lib/vedeu/output/renderers/html_renderer.rb +1 -1
  38. data/lib/vedeu/output/text.rb +1 -15
  39. data/lib/vedeu/output/viewport.rb +1 -1
  40. data/lib/vedeu/repositories/repositories/borders.rb +11 -11
  41. data/lib/vedeu/repositories/repositories/buffers.rb +11 -11
  42. data/lib/vedeu/repositories/repositories/cursors.rb +15 -15
  43. data/lib/vedeu/repositories/repositories/events_repository.rb +11 -11
  44. data/lib/vedeu/repositories/repositories/geometries.rb +11 -11
  45. data/lib/vedeu/repositories/repositories/groups.rb +11 -11
  46. data/lib/vedeu/repositories/repositories/interfaces_repository.rb +23 -10
  47. data/lib/vedeu/repositories/repositories/keymaps.rb +11 -11
  48. data/lib/vedeu/repositories/repositories/menus.rb +11 -11
  49. data/test/lib/vedeu/buffers/buffer_test.rb +4 -6
  50. data/test/lib/vedeu/distributed/server_test.rb +101 -3
  51. data/test/lib/vedeu/dsl/view_test.rb +6 -0
  52. data/test/lib/vedeu/input/input_test.rb +1 -1
  53. data/test/lib/vedeu/models/char_test.rb +18 -2
  54. data/test/lib/vedeu/models/composition_test.rb +0 -2
  55. data/test/lib/vedeu/models/interface_test.rb +12 -17
  56. data/test/lib/vedeu/models/line_test.rb +0 -2
  57. data/test/lib/vedeu/models/null_interface_test.rb +9 -0
  58. data/test/lib/vedeu/models/stream_test.rb +0 -2
  59. data/test/lib/vedeu/output/border_test.rb +2 -4
  60. data/test/lib/vedeu/output/clear_test.rb +17 -0
  61. data/test/lib/vedeu/output/colour_test.rb +139 -0
  62. data/test/lib/vedeu/output/output_test.rb +15 -13
  63. data/test/lib/vedeu/output/renderers/escape_sequence_renderer_test.rb +46 -0
  64. data/test/lib/vedeu/output/renderers/file_renderer_test.rb +27 -4
  65. data/test/lib/vedeu/output/renderers/html_renderer_test.rb +14 -3
  66. data/test/lib/vedeu/repositories/repositories/interfaces_repository_test.rb +8 -0
  67. data/test/test_helper.rb +3 -2
  68. data/vedeu.gemspec +4 -4
  69. metadata +18 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c8865f24cef3c2543a91eb50d836dbc561e25d4
4
- data.tar.gz: 36c470985cca56b3ce4971da527483b67371121b
3
+ metadata.gz: 4a9751fe9473165039b61060cd75848373362b2e
4
+ data.tar.gz: f26036519a3f79b436bbe48dc6ff56c0be95ee5e
5
5
  SHA512:
6
- metadata.gz: 6fd140c4261e97199d0ac05f7d1cd45bbbd6132b4fb34db4359786c35d5f2a2fdbb4957946647cded9fcc5eecf18b7eab4a57ade8aabfb47957661e04f6d7f09
7
- data.tar.gz: 5b123a4c23bc9600064f974c2326c0b699747c689388ff096eb3e9cfd6417fb88d04168d392ea4c76717bc6beefb4508f0606f68fdf69b1138a6f80f97eb6630
6
+ metadata.gz: a6cf213571c0d78127d30f13d5b7371e6f35ed841e5df29943082c43ecf2be8e6254a0959acfeddf119f1f4807a30540948d420399d727c8e3b365da2628c80c
7
+ data.tar.gz: 65f8b8ab0fe4bfec7074ac7d1c54294b04a764f9e9303fc2da3c27fec296c6c87897ee402f5d04e3289bd46efdc34de635eb6210ed06e1865516f78ddee3e7dd
data/.gitignore CHANGED
@@ -16,6 +16,7 @@ spec/reports
16
16
  test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
+ vendor/bundle
19
20
  .gemtags
20
21
  .tags
21
22
  .tags_sorted_by_file
@@ -16,8 +16,6 @@ class VedeuBordersApp
16
16
  log '/tmp/vedeu_borders_app.log'
17
17
  end
18
18
 
19
- bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
20
-
21
19
  interface 'default_border' do
22
20
  geometry do
23
21
  x 2
@@ -16,8 +16,6 @@ class VedeuColoursApp
16
16
  log '/tmp/vedeu_colours_app.log'
17
17
  end
18
18
 
19
- bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
20
-
21
19
  interface 'colours_256' do
22
20
  geometry do
23
21
  centred!
@@ -17,8 +17,6 @@ class VedeuCursorApp
17
17
  log '/tmp/vedeu_cursor_app.log'
18
18
  end
19
19
 
20
- bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
21
-
22
20
  interface 'main_interface' do
23
21
  colour foreground: '#ff0000', background: '#000000'
24
22
  cursor!
data/examples/drb_app.rb CHANGED
@@ -40,8 +40,6 @@ class VedeuTestApplication
40
40
  # stderr File.open("/tmp/vedeu_error.log", "w+")
41
41
  end
42
42
 
43
- Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
44
-
45
43
  Vedeu.border 'test_interface' do
46
44
  # Define colour and style of border
47
45
  colour foreground: '#ffff00', background: '#0000ff'
@@ -20,8 +20,6 @@ class VedeuFocusApp
20
20
  log '/tmp/vedeu_focus_app.log'
21
21
  end
22
22
 
23
- Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
24
-
25
23
  update = proc do
26
24
  Vedeu.focus_next
27
25
 
@@ -16,8 +16,6 @@ class VedeuGeometryApp
16
16
  log '/tmp/vedeu_geometry_app.log'
17
17
  end
18
18
 
19
- bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
20
-
21
19
  interface 'main_interface' do
22
20
  colour foreground: '#ff0000', background: '#000000'
23
21
  cursor!
@@ -19,8 +19,6 @@ class HelloWorldApp
19
19
  log '/tmp/vedeu_hello_world.log'
20
20
  end
21
21
 
22
- bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
23
-
24
22
  interface 'messages' do
25
23
  background '#000000'
26
24
  foreground '#00ff00'
@@ -16,8 +16,6 @@ class VedeuLinesApp
16
16
  log '/tmp/vedeu_lines_app.log'
17
17
  end
18
18
 
19
- bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
20
-
21
19
  interface 'ruthenium' do
22
20
  geometry do
23
21
  centred true
@@ -17,8 +17,6 @@ class VedeuMaterialColoursApp
17
17
  renderers Vedeu::FileRenderer
18
18
  end
19
19
 
20
- # bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
21
-
22
20
  interface 'main_interface' do
23
21
  border 'main_interface' do
24
22
  colour foreground: '#ffffff', background: '#000000'
@@ -176,7 +176,8 @@ module Vedeu
176
176
  # if given.
177
177
  Vedeu.bind(:_clear_) do |name|
178
178
  if name && Vedeu.interfaces.registered?(name)
179
- Vedeu::Clear.clear(Vedeu.interfaces.find(name))
179
+ Vedeu::Clear.clear(Vedeu.interfaces.find(name), clear_border: true,
180
+ use_terminal_colours: true)
180
181
 
181
182
  else
182
183
  Vedeu::Terminal.virtual.clear if Vedeu::Configuration.drb?
@@ -110,21 +110,18 @@ module Vedeu
110
110
  #
111
111
  # @return [void]
112
112
  def clear
113
- buffer = if content_for?(:front)
114
- front.clear.clear
113
+ Vedeu::Output.render(clear_buffer) unless clear_buffer.empty?
115
114
 
116
- else
117
- interface.clear.clear
118
-
119
- end
120
-
121
- Vedeu::Output.render(buffer) unless buffer.empty?
122
-
123
- buffer
115
+ clear_buffer
124
116
  end
125
117
 
126
118
  private
127
119
 
120
+ # @return [void]
121
+ def clear_buffer
122
+ @clear_buffer ||= Vedeu::Clear.new(view).clear
123
+ end
124
+
128
125
  # @return [Hash<Symbol => NilClass, String>]
129
126
  def defaults
130
127
  {
@@ -164,6 +161,17 @@ module Vedeu
164
161
  @interface ||= Vedeu.interfaces.find(name)
165
162
  end
166
163
 
164
+ # @return [Vedeu::Interface]
165
+ def view
166
+ if content_for?(:front)
167
+ front
168
+
169
+ else
170
+ interface
171
+
172
+ end
173
+ end
174
+
167
175
  end # Buffer
168
176
 
169
177
  end # Vedeu
data/lib/vedeu/debug.rb CHANGED
@@ -5,7 +5,8 @@ module Vedeu
5
5
  # execution upon exiting.
6
6
  #
7
7
  # @param filename [String]
8
- # @param block [Proc]
8
+ # @return [void]
9
+ # @yieldreturn [void] The section of the application to debug.
9
10
  def self.debug(filename = 'profile.html')
10
11
  return nil unless block_given?
11
12
 
@@ -66,17 +66,23 @@ module Vedeu
66
66
 
67
67
  # @return [void]
68
68
  def restart
69
- Vedeu.log(type: :drb, message: 'Attempting to restart')
69
+ log('Attempting to restart')
70
70
 
71
71
  return not_enabled unless drb?
72
72
 
73
- log('Not running') unless drb_running?
73
+ if drb_running?
74
+ log('Restarting')
75
+
76
+ stop
74
77
 
75
- log('Restarting')
78
+ start
76
79
 
77
- stop
80
+ else
81
+ log('Not running')
78
82
 
79
- start
83
+ start
84
+
85
+ end
80
86
  end
81
87
 
82
88
  # When called will stop the DRb server and attempt to terminate the client
@@ -99,7 +105,7 @@ module Vedeu
99
105
 
100
106
  # @return [Vedeu::Distributed::Server]
101
107
  def start
102
- Vedeu.log(type: :drb, message: 'Attempting to start')
108
+ log('Attempting to start')
103
109
 
104
110
  return not_enabled unless drb?
105
111
 
@@ -117,7 +123,7 @@ module Vedeu
117
123
 
118
124
  # @return [Symbol]
119
125
  def status
120
- Vedeu.log(type: :drb, message: 'Fetching status')
126
+ log('Fetching status')
121
127
 
122
128
  return not_enabled unless drb?
123
129
 
@@ -136,7 +142,7 @@ module Vedeu
136
142
 
137
143
  # @return [void]
138
144
  def stop
139
- Vedeu.log(type: :drb, message: 'Attempting to stop')
145
+ log('Attempting to stop')
140
146
 
141
147
  return not_enabled unless drb?
142
148
 
@@ -94,20 +94,13 @@ module Vedeu
94
94
  # @param name [String] The name of the interface.
95
95
  # @return [Hash]
96
96
  def new_attributes(name)
97
- attributes.merge!(existing_interface_attributes(name))
97
+ attributes.merge!(existing_attributes(name))
98
98
  end
99
99
 
100
100
  # @param name [String] The name of the interface.
101
101
  # @return [Hash]
102
- def existing_interface_attributes(name)
103
- if model.repository.registered?(name)
104
- stored = model.repository.find(name)
105
- stored.attributes
106
-
107
- else
108
- { name: name }
109
-
110
- end
102
+ def existing_attributes(name)
103
+ Vedeu.interfaces.by_name(name).attributes
111
104
  end
112
105
 
113
106
  # @return [Hash]
@@ -66,22 +66,19 @@ module Vedeu
66
66
  # @raise [InvalidSyntax] When no block or value is provided.
67
67
  # @return [Vedeu::Lines]
68
68
  def line(value = '', &block)
69
- content = if block_given?
70
- Vedeu::Line.build({ client: client,
69
+ if block_given?
70
+ content = Vedeu::Line.build({ client: client,
71
71
  parent: model.parent }, &block)
72
72
 
73
- elsif value
74
- stream = Vedeu::Stream.build(client: client,
75
- parent: model,
76
- value: value)
77
- Vedeu::Line.build(client: client,
73
+ elsif value
74
+ content = Vedeu::Line.build(client: client,
78
75
  parent: model.parent,
79
- streams: [stream])
76
+ streams: [build_stream(value)])
80
77
 
81
- else
82
- fail InvalidSyntax, 'block not given'
78
+ else
79
+ fail InvalidSyntax, 'block not given'
83
80
 
84
- end
81
+ end
85
82
 
86
83
  model.parent.add(content)
87
84
  end
@@ -129,6 +126,12 @@ module Vedeu
129
126
  }
130
127
  end
131
128
 
129
+ # @param value [String]
130
+ # @return [Vedeu::Stream]
131
+ def build_stream(value)
132
+ Vedeu::Stream.build(client: client, parent: model, value: value)
133
+ end
134
+
132
135
  end # Line
133
136
 
134
137
  end # DSL
@@ -70,13 +70,12 @@ module Vedeu
70
70
  # colour background: '#000000', foreground: '#ffffff'
71
71
  # # ...
72
72
  #
73
- # @return [Hash]
73
+ # @return [Vedeu::Colour]
74
74
  def colour(attributes = {})
75
75
  attributes.delete_if do |k, v|
76
76
  [:background, :foreground].include?(k) == false || v.nil? || v.empty?
77
77
  end
78
-
79
- model.colour = Vedeu::Colour.new(attributes)
78
+ model.colour = Vedeu::Colour.coerce(attributes)
80
79
  end
81
80
 
82
81
  end # Colour
@@ -250,10 +250,6 @@ module Vedeu
250
250
  # @return [String]
251
251
  attr_reader :name
252
252
 
253
- def border
254
- @border ||= Vedeu.borders.by_name(name)
255
- end
256
-
257
253
  end # Coordinate
258
254
 
259
255
  end # Vedeu
@@ -56,8 +56,9 @@ module Vedeu
56
56
  # point on the screen. When passed a block, will do the aforementioned,
57
57
  # call the block and then reposition to this location.
58
58
  #
59
- # @param block [Proc]
60
59
  # @return [String]
60
+ # @yieldreturn [void] Returns the block wrapped in position escape
61
+ # sequences.
61
62
  def to_s
62
63
  if block_given?
63
64
  [sequence, yield, sequence].join
@@ -15,8 +15,8 @@ module Vedeu
15
15
  # :nocov:
16
16
  # Start the main loop.
17
17
  #
18
- # @param block [Proc]
19
18
  # @return [void]
19
+ # @yieldreturn [void] The client application.
20
20
  def self.start!
21
21
  @started = true
22
22
  @loop = true
@@ -1,6 +1,8 @@
1
1
  require 'vedeu/repositories/all'
2
2
 
3
3
  require_relative 'null'
4
+ require_relative 'null_interface'
5
+
4
6
  require_relative 'cell'
5
7
  require_relative 'char'
6
8
  require_relative 'stream'
@@ -23,6 +23,10 @@ module Vedeu
23
23
  # @return [Vedeu::Line]
24
24
  attr_accessor :parent
25
25
 
26
+ # @!attribute [r] attributes
27
+ # @return [Hash]
28
+ attr_reader :attributes
29
+
26
30
  # @!attribute [w] value
27
31
  # @return [String]
28
32
  attr_writer :value
@@ -42,9 +46,7 @@ module Vedeu
42
46
  @attributes = defaults.merge!(attributes)
43
47
 
44
48
  @border = @attributes[:border]
45
- @colour = @attributes[:colour]
46
49
  @parent = @attributes[:parent]
47
- @style = @attributes[:style]
48
50
  @value = @attributes[:value]
49
51
  end
50
52
 
@@ -139,10 +141,6 @@ module Vedeu
139
141
 
140
142
  private
141
143
 
142
- # @!attribute [r] attributes
143
- # @return [Hash]
144
- attr_reader :attributes
145
-
146
144
  # @return [Hash]
147
145
  def colour_to_hash
148
146
  {
@@ -15,6 +15,10 @@ module Vedeu
15
15
  collection Vedeu::Interfaces
16
16
  member Vedeu::Interface
17
17
 
18
+ # @!attribute [r] attributes
19
+ # @return [Hash]
20
+ attr_reader :attributes
21
+
18
22
  # Returns a new instance of Vedeu::Composition.
19
23
  #
20
24
  # @param attributes [Hash]
@@ -25,10 +29,8 @@ module Vedeu
25
29
  def initialize(attributes = {})
26
30
  @attributes = defaults.merge!(attributes)
27
31
 
28
- @colour = @attributes[:colour]
29
32
  @interfaces = @attributes[:interfaces]
30
33
  @repository = Vedeu.interfaces
31
- @style = @attributes[:style]
32
34
  end
33
35
 
34
36
  # @param child [Vedeu::Interface]
@@ -42,6 +42,10 @@ module Vedeu
42
42
  attr_accessor :visible
43
43
  alias_method :visible?, :visible
44
44
 
45
+ # @!attribute [r] attributes
46
+ # @return [Hash]
47
+ attr_reader :attributes
48
+
45
49
  # @!attribute [w] lines
46
50
  # @return [Array<Vedeu::Line>]
47
51
  attr_writer :lines
@@ -81,14 +85,12 @@ module Vedeu
81
85
  def initialize(attributes = {})
82
86
  @attributes = defaults.merge!(attributes)
83
87
 
84
- @colour = @attributes[:colour]
85
88
  @delay = @attributes[:delay]
86
89
  @group = @attributes[:group]
87
90
  @lines = @attributes[:lines]
88
91
  @name = @attributes[:name]
89
92
  @parent = @attributes[:parent]
90
93
  @repository = Vedeu.interfaces
91
- @style = @attributes[:style]
92
94
  @visible = @attributes[:visible]
93
95
  end
94
96
 
@@ -98,22 +100,6 @@ module Vedeu
98
100
  @lines = lines.add(child)
99
101
  end
100
102
 
101
- # @note
102
- # This may be unused. (GL 2015-02-20)
103
- #
104
- # @return [Hash]
105
- def attributes
106
- {
107
- colour: colour,
108
- delay: delay,
109
- group: group,
110
- name: name,
111
- parent: parent,
112
- style: style,
113
- visible: true,
114
- }
115
- end
116
-
117
103
  # Returns the border object belonging to the interface.
118
104
  #
119
105
  # @return [Vedeu::Border|NilClass]