vedeu 0.4.35 → 0.4.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/Dockerfile +56 -35
  4. data/bin/vedeu +54 -13
  5. data/docs/applications.md +92 -0
  6. data/features/cli_vedeu.feature +5 -0
  7. data/features/start_stop.feature +1 -1
  8. data/features/step_definitions/vedeu_steps.rb +0 -0
  9. data/features/support/env.rb +3 -2
  10. data/lib/vedeu.rb +1 -0
  11. data/lib/vedeu/all.rb +6 -0
  12. data/lib/vedeu/application/all.rb +2 -0
  13. data/lib/vedeu/application/application_controller.rb +7 -0
  14. data/lib/vedeu/application/application_helper.rb +7 -0
  15. data/lib/vedeu/bootstrap.rb +73 -0
  16. data/lib/vedeu/distributed/templates/default_configuration.vedeu +7 -14
  17. data/lib/vedeu/generator/all.rb +13 -0
  18. data/lib/vedeu/generator/application.rb +108 -0
  19. data/lib/vedeu/generator/helpers.rb +55 -0
  20. data/lib/vedeu/generator/templates/application/Gemfile +3 -0
  21. data/lib/vedeu/generator/templates/application/app/controllers/application_controller.erb +7 -0
  22. data/lib/vedeu/generator/templates/application/app/controllers/name.erb +10 -0
  23. data/lib/vedeu/generator/templates/application/app/helpers/application_helper.erb +9 -0
  24. data/lib/vedeu/generator/templates/application/app/helpers/name.erb +9 -0
  25. data/lib/vedeu/generator/templates/application/app/models/keymaps/_global_.rb +2 -0
  26. data/lib/vedeu/generator/templates/application/app/models/keymaps/_system_.rb +2 -0
  27. data/lib/vedeu/generator/templates/application/app/views/interfaces/name.erb +44 -0
  28. data/lib/vedeu/generator/templates/application/app/views/name.erb +0 -0
  29. data/lib/vedeu/generator/templates/application/app/views/templates/name.erb +0 -0
  30. data/lib/vedeu/generator/templates/application/application.rb +9 -0
  31. data/lib/vedeu/generator/templates/application/bin/name +7 -0
  32. data/lib/vedeu/generator/templates/application/config/app_name.erb +1 -0
  33. data/lib/vedeu/generator/templates/application/config/configuration.rb +22 -0
  34. data/lib/vedeu/generator/templates/application/lib/.gitkeep +0 -0
  35. data/lib/vedeu/generator/templates/application/test/.gitkeep +0 -0
  36. data/lib/vedeu/generator/templates/application/vendor/.gitkeep +0 -0
  37. data/lib/vedeu/generator/view.rb +71 -0
  38. data/lib/vedeu/geometry/area.rb +21 -21
  39. data/lib/vedeu/main_loop.rb +0 -1
  40. data/lib/vedeu/output/esc.rb +5 -4
  41. data/lib/vedeu/output/refresh.rb +9 -3
  42. data/lib/vedeu/output/view_helpers/all.rb +0 -2
  43. data/lib/vedeu/support/log.rb +1 -1
  44. data/lib/vedeu/support/template.rb +1 -1
  45. data/lib/vedeu/support/terminal.rb +10 -2
  46. data/lib/vedeu/tasks/application.rake +28 -0
  47. data/lib/vedeu/tasks/vedeu.rake +3 -0
  48. data/lib/vedeu/templating/directive.rb +1 -8
  49. data/lib/vedeu/traps.rb +2 -2
  50. data/lib/vedeu/version.rb +1 -1
  51. data/test/lib/vedeu/application/application_controller_test.rb +12 -0
  52. data/test/lib/vedeu/application/application_helper_test.rb +18 -0
  53. data/test/lib/vedeu/bootstrap_test.rb +30 -0
  54. data/test/lib/vedeu/buffers/buffer_test.rb +7 -0
  55. data/test/lib/vedeu/buffers/display_buffer_test.rb +2 -0
  56. data/test/lib/vedeu/configuration/api_test.rb +6 -0
  57. data/test/lib/vedeu/cursor/move_test.rb +7 -0
  58. data/test/lib/vedeu/distributed/client_test.rb +4 -0
  59. data/test/lib/vedeu/distributed/server_test.rb +9 -0
  60. data/test/lib/vedeu/dsl/use_test.rb +4 -0
  61. data/test/lib/vedeu/generator/application_test.rb +55 -0
  62. data/test/lib/vedeu/generator/helpers_test.rb +80 -0
  63. data/test/lib/vedeu/generator/view_test.rb +35 -0
  64. data/test/lib/vedeu/geometry/area_test.rb +8 -0
  65. data/test/lib/vedeu/launcher_test.rb +2 -0
  66. data/test/lib/vedeu/main_loop_test.rb +2 -0
  67. data/test/lib/vedeu/null/interface_test.rb +1 -0
  68. data/test/lib/vedeu/output/clear_test.rb +3 -0
  69. data/test/lib/vedeu/output/refresh_test.rb +1 -0
  70. data/test/lib/vedeu/output/renderers/file_test.rb +1 -0
  71. data/test/lib/vedeu/repositories/repositories/events_repository_test.rb +2 -0
  72. data/test/lib/vedeu/repositories/repositories/interfaces_repository_test.rb +3 -0
  73. data/test/lib/vedeu/repositories/repositories/keymaps_test.rb +2 -0
  74. data/test/lib/vedeu/repositories/repositories/menus_test.rb +2 -0
  75. data/test/lib/vedeu/repositories/repository_test.rb +1 -0
  76. data/test/lib/vedeu/support/log_test.rb +5 -0
  77. data/test/lib/vedeu/support/terminal_test.rb +1 -0
  78. data/test/lib/vedeu/traps_test.rb +1 -1
  79. data/test/lib/vedeu_test.rb +1 -0
  80. data/vedeu.gemspec +7 -4
  81. metadata +97 -25
@@ -25,28 +25,28 @@ module Vedeu
25
25
  attr_reader :xn
26
26
  alias_method :right, :xn
27
27
 
28
- # @param y [Fixnum]
29
- # @param yn [Fixnum]
30
- # @param y_yn [Fixnum]
31
- # @param y_default [Fixnum]
32
- # @param x [Fixnum]
33
- # @param xn [Fixnum]
34
- # @param x_xn [Fixnum]
35
- # @param x_default [Fixnum]
36
- # @param options [Hash<Symbol => Boolean>]
28
+ # @param attributes [Hash]
29
+ # @option attributes y [Fixnum]
30
+ # @option attributes yn [Fixnum]
31
+ # @option attributes y_yn [Fixnum]
32
+ # @option attributes y_default [Fixnum]
33
+ # @option attributes x [Fixnum]
34
+ # @option attributes xn [Fixnum]
35
+ # @option attributes x_xn [Fixnum]
36
+ # @option attributes x_default [Fixnum]
37
+ # @option attributes options [Hash<Symbol => Boolean>]
37
38
  # @return [Vedeu::Area]
38
- def self.from_attributes(y:, yn:, y_yn:, y_default:,
39
- x:, xn:, x_xn:, x_default:, options:)
40
- y_yn = Vedeu::Dimension.pair(d: y,
41
- dn: yn,
42
- d_dn: y_yn,
43
- default: y_default,
44
- options: options)
45
- x_xn = Vedeu::Dimension.pair(d: x,
46
- dn: xn,
47
- d_dn: x_xn,
48
- default: x_default,
49
- options: options)
39
+ def self.from_attributes(attributes = {})
40
+ y_yn = Vedeu::Dimension.pair(d: attributes[:y],
41
+ dn: attributes[:yn],
42
+ d_dn: attributes[:y_yn],
43
+ default: attributes[:y_default],
44
+ options: attributes[:options])
45
+ x_xn = Vedeu::Dimension.pair(d: attributes[:x],
46
+ dn: attributes[:xn],
47
+ d_dn: attributes[:x_xn],
48
+ default: attributes[:x_default],
49
+ options: attributes[:options])
50
50
 
51
51
  from_dimensions(y_yn: y_yn, x_xn: x_xn)
52
52
  end
@@ -28,7 +28,6 @@ module Vedeu
28
28
  rescue VedeuInterrupt
29
29
  Vedeu.log(type: :debug,
30
30
  message: 'Vedeu execution interrupted, exiting.')
31
-
32
31
  end
33
32
  # :nocov:
34
33
 
@@ -56,7 +56,10 @@ module Vedeu
56
56
  #
57
57
  # @return [Hash<Symbol => Fixnum>]
58
58
  def background_codes
59
- Vedeu::Esc.codes.inject({}) { |h, (k, v)| h.merge!(k => v + 10) }
59
+ hash = {}
60
+ Vedeu::Esc.codes.inject(hash) do |h, (k, v)|
61
+ h.merge!(k => v + 10)
62
+ end
60
63
  end
61
64
 
62
65
  # Dynamically creates methods for each terminal named colour. When a block
@@ -98,9 +101,7 @@ module Vedeu
98
101
  }
99
102
  end
100
103
 
101
- actions.each do |key, code|
102
- define_method(key) { code }
103
- end
104
+ actions.each { |key, code| define_method(key) { code } }
104
105
 
105
106
  # Return the stream with the escape sequences escaped so that they can be
106
107
  # printed to the terminal instead of being interpreted by the terminal which
@@ -27,6 +27,11 @@ module Vedeu
27
27
 
28
28
  # Refresh an interface, or collection of interfaces belonging to a group.
29
29
  #
30
+ # @note
31
+ # The group of interfaces will be refreshed in z-index order, meaning that
32
+ # interfaces with a lower z-index will be draw first. This means
33
+ # overlapping interfaces will be drawn as specified.
34
+ #
30
35
  # @param group_name [String] The name of the group to be refreshed.
31
36
  # @return [Array|ModelNotFound] A collection of the names of interfaces
32
37
  # refreshed, or an exception if the group was not found.
@@ -34,9 +39,10 @@ module Vedeu
34
39
  message = "Refreshing group: '#{group_name}'"
35
40
 
36
41
  Vedeu.timer(message) do
37
- Vedeu.groups.find!(group_name).members.each { |name|
38
- Vedeu.interfaces.by_name(name)
39
- }.sort { |a, b| a.zindex <=> b.zindex }.each { |name| by_name(name) }
42
+ members = Vedeu.groups.find!(group_name).members
43
+ interfaces = members.each { |name| Vedeu.interfaces.by_name(name) }
44
+ by_zindex = interfaces.sort { |a, b| a.zindex <=> b.zindex }
45
+ by_zindex.each { |name| by_name(name) }
40
46
  end
41
47
  end
42
48
 
@@ -2,6 +2,4 @@ require 'vedeu/output/view_helpers/view_helpers'
2
2
 
3
3
  module Vedeu
4
4
 
5
-
6
-
7
5
  end # Vedeu
@@ -173,7 +173,7 @@ module Vedeu
173
173
  @last = @now
174
174
  end
175
175
 
176
- "[#{'%7.4f' % @time.to_s}] ".rjust(7)
176
+ "[#{format(@time.to_s, '%7.4f')}] ".rjust(7)
177
177
  end
178
178
 
179
179
  end # Log eigenclass
@@ -55,7 +55,7 @@ module Vedeu
55
55
  fail MissingRequired, 'No path to template specified.' if @path.empty?
56
56
 
57
57
  unless File.exist?(@path)
58
- fail MissingRequired, 'Template file cannot be found.'
58
+ fail MissingRequired, "Template file cannot be found. (#{@path})"
59
59
  end
60
60
 
61
61
  @path
@@ -40,8 +40,16 @@ module Vedeu
40
40
  keys = console.getch
41
41
 
42
42
  if keys.ord == 27
43
- keys << console.read_nonblock(3) rescue nil
44
- keys << console.read_nonblock(2) rescue nil
43
+ begin
44
+ keys << console.read_nonblock(3)
45
+ rescue
46
+ nil
47
+ end
48
+ begin
49
+ keys << console.read_nonblock(2)
50
+ rescue
51
+ nil
52
+ end
45
53
  end
46
54
  keys
47
55
 
@@ -0,0 +1,28 @@
1
+ desc 'Create a skeleton Vedeu client application.'
2
+ task :new do
3
+ app_name = ARGV[0]
4
+
5
+ if app_name
6
+ Vedeu::Generator::Application.generate(app_name)
7
+
8
+ else
9
+ print Vedeu::Esc.red { 'Error: ' }
10
+ print 'You did not specify a name for the new application.'
11
+
12
+ end
13
+ end
14
+
15
+ # 'Specify the interface name lowercase snakecase; e.g. main_interface'
16
+ desc 'Create a new interface within the client application.'
17
+ task :view do
18
+ view_name = ARGV[0]
19
+
20
+ if view_name
21
+ Vedeu::Generator::View.generate(view_name)
22
+
23
+ else
24
+ print Vedeu::Esc.red { 'Error: ' }
25
+ print 'You did not specify a name for the name view.'
26
+
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ Dir[File.expand_path('../*.rake', __FILE__)].delete_if do |task_file|
2
+ task_file =~ /vedeu\.rake$/
3
+ end.each { |task_file| load task_file }
@@ -23,7 +23,7 @@ module Vedeu
23
23
 
24
24
  # @return [Vedeu::Stream]
25
25
  def process
26
- eval(code, proc.binding)
26
+ eval(code, proc {}.binding)
27
27
  end
28
28
 
29
29
  protected
@@ -32,13 +32,6 @@ module Vedeu
32
32
  # @return [String]
33
33
  attr_reader :code
34
34
 
35
- private
36
-
37
- # @return [Proc]
38
- def proc
39
- @proc ||= Proc.new {}
40
- end
41
-
42
35
  end # Directive
43
36
 
44
37
  end # Templating
data/lib/vedeu/traps.rb CHANGED
@@ -5,9 +5,9 @@ module Vedeu
5
5
  # @api private
6
6
  module Traps
7
7
 
8
- Signal.trap('INT') { exit! }
8
+ Signal.trap('INT') { puts; exit(1) }
9
9
 
10
- Signal.trap('TERM') { exit! }
10
+ Signal.trap('TERM') { puts; exit(1) }
11
11
 
12
12
  Signal.trap('TTIN') {}
13
13
  Signal.trap('USR1') {}
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.4.35'
4
+ VERSION = '0.4.36'
5
5
 
6
6
  end
@@ -0,0 +1,12 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe ApplicationController do
6
+
7
+ let(:described) { Vedeu::ApplicationController }
8
+ let(:instance) { described.new }
9
+
10
+ end # ApplicationController
11
+
12
+ end # Vedeu
@@ -0,0 +1,18 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ class ApplicationHelperTestClass
6
+
7
+ include Vedeu::ApplicationHelper
8
+
9
+ end
10
+
11
+ describe ApplicationHelper do
12
+
13
+ let(:described) { Vedeu::ApplicationHelper }
14
+ let(:instance) { Vedeu::ApplicationHelperTestClass.new }
15
+
16
+ end # Application
17
+
18
+ end # Vedeu
@@ -0,0 +1,30 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe Bootstrap do
6
+
7
+ let(:described) { Vedeu::Bootstrap }
8
+ let(:instance) { described.new(argv) }
9
+ let(:argv) { [] }
10
+
11
+ describe '#initialize' do
12
+ subject { instance }
13
+
14
+ it { subject.must_be_instance_of(described) }
15
+ it { subject.instance_variable_get('@argv').must_equal(argv) }
16
+ end
17
+
18
+ describe '.start' do
19
+ it { described.must_respond_to(:start) }
20
+ end
21
+
22
+ describe '#start' do
23
+ subject { instance.start }
24
+
25
+
26
+ end
27
+
28
+ end # Bootstrap
29
+
30
+ end # Vedeu
@@ -99,6 +99,7 @@ module Vedeu
99
99
 
100
100
  context 'with content' do
101
101
  # it { subject.must_equal(true) }
102
+ # it { skip }
102
103
  end
103
104
 
104
105
  context 'without content' do
@@ -117,6 +118,7 @@ module Vedeu
117
118
 
118
119
  context 'with content' do
119
120
  # it { subject.must_equal(true) }
121
+ # it { skip }
120
122
  end
121
123
 
122
124
  context 'without content' do
@@ -129,6 +131,7 @@ module Vedeu
129
131
 
130
132
  context 'with content' do
131
133
  # it { subject.must_equal(true) }
134
+ # it { skip }
132
135
  end
133
136
 
134
137
  context 'without content' do
@@ -140,6 +143,7 @@ module Vedeu
140
143
  subject { instance.hide }
141
144
 
142
145
  context 'when the interface is visible' do
146
+ # it { skip }
143
147
  end
144
148
 
145
149
  context 'when the interface is not visible' do
@@ -152,9 +156,11 @@ module Vedeu
152
156
 
153
157
  context 'when the interface is visible' do
154
158
  # it { subject.must_be_instance_of(NilClass) }
159
+ # it { skip }
155
160
  end
156
161
 
157
162
  context 'when the interface is not visible' do
163
+ # it { skip }
158
164
  end
159
165
  end
160
166
 
@@ -165,6 +171,7 @@ module Vedeu
165
171
 
166
172
  it { instance.must_respond_to(:content) }
167
173
 
174
+ # it { skip }
168
175
  # it { subject.must_be_instance_of(Array) }
169
176
 
170
177
  # context 'when there is content on the back buffer' do
@@ -56,9 +56,11 @@ module Vedeu
56
56
  end
57
57
 
58
58
  context 'when the buffer is not already registered' do
59
+ # it { skip }
59
60
  end
60
61
 
61
62
  context 'when the buffer is already registered' do
63
+ # it { skip }
62
64
  end
63
65
  end
64
66
 
@@ -222,18 +222,24 @@ module Vedeu
222
222
  let(:io) {}
223
223
 
224
224
  subject { instance.stdin(io) }
225
+
226
+ # it { skip }
225
227
  end
226
228
 
227
229
  describe '#stdout' do
228
230
  let(:io) {}
229
231
 
230
232
  subject { instance.stdout(io) }
233
+
234
+ # it { skip }
231
235
  end
232
236
 
233
237
  describe '#stderr' do
234
238
  let(:io) {}
235
239
 
236
240
  subject { instance.stderr(io) }
241
+
242
+ # it { skip }
237
243
  end
238
244
 
239
245
  describe 'redefining system keys' do
@@ -75,6 +75,7 @@ module Vedeu
75
75
  context 'when the name is not specified' do
76
76
  let(:_name) {}
77
77
 
78
+ # it { skip }
78
79
  end
79
80
 
80
81
  context 'when the name is specified' do
@@ -245,6 +246,8 @@ module Vedeu
245
246
 
246
247
  context 'when the entity is a Vedeu::Geometry' do
247
248
  let(:entity) { Vedeu::Geometry }
249
+
250
+ # it { skip }
248
251
  end
249
252
 
250
253
  context 'when the entity is a Vedeu::Cursor' do
@@ -257,9 +260,12 @@ module Vedeu
257
260
 
258
261
  context 'when the entity is a Vedeu::Geometry' do
259
262
  let(:entity) { Vedeu::Geometry }
263
+
264
+ # it { skip }
260
265
  end
261
266
 
262
267
  context 'when the entity is a Vedeu::Cursor' do
268
+ # it { skip }
263
269
  end
264
270
  end
265
271
 
@@ -273,6 +279,7 @@ module Vedeu
273
279
  end
274
280
 
275
281
  context 'when the entity is a Vedeu::Cursor' do
282
+ # it { skip }
276
283
  end
277
284
  end
278
285
 
@@ -37,6 +37,7 @@ module Vedeu
37
37
  end
38
38
 
39
39
  context 'when the DRb server is available' do
40
+ # it { skip }
40
41
  end
41
42
  end
42
43
 
@@ -53,6 +54,7 @@ module Vedeu
53
54
  end
54
55
 
55
56
  context 'when the DRb server is available' do
57
+ # it { skip }
56
58
  end
57
59
  end
58
60
 
@@ -68,6 +70,7 @@ module Vedeu
68
70
  end
69
71
 
70
72
  context 'when the DRb server is available' do
73
+ # it { skip }
71
74
  end
72
75
  end
73
76
 
@@ -81,6 +84,7 @@ module Vedeu
81
84
  end
82
85
 
83
86
  context 'when the DRb server is available' do
87
+ # it { skip }
84
88
  end
85
89
  end
86
90