vedeu 0.4.57 → 0.4.58

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/bin/vedeu_drb_server +1 -0
  3. data/examples/drb_app.rb +1 -0
  4. data/lib/vedeu/all.rb +95 -65
  5. data/lib/vedeu/api.rb +0 -45
  6. data/lib/vedeu/application.rb +1 -0
  7. data/lib/vedeu/{bindings/all.rb → bindings.rb} +0 -6
  8. data/lib/vedeu/bindings/system.rb +1 -1
  9. data/lib/vedeu/cli/generator/templates/application/config/configuration.erb +1 -0
  10. data/lib/vedeu/configuration/api.rb +47 -3
  11. data/lib/vedeu/configuration/configuration.rb +6 -7
  12. data/lib/vedeu/distributed/templates/default_configuration.vedeu +1 -0
  13. data/lib/vedeu/{dsl/all.rb → dsl.rb} +0 -16
  14. data/lib/vedeu/dsl/composition.rb +4 -4
  15. data/lib/vedeu/events/event_collection.rb +9 -0
  16. data/lib/vedeu/input/keys.rb +9 -0
  17. data/lib/vedeu/main_loop.rb +2 -2
  18. data/lib/vedeu/models/chars.rb +9 -0
  19. data/lib/vedeu/models/interface_collection.rb +9 -0
  20. data/lib/vedeu/models/lines.rb +9 -0
  21. data/lib/vedeu/models/streams.rb +9 -0
  22. data/lib/vedeu/{null/all.rb → null.rb} +2 -8
  23. data/lib/vedeu/output/{renderers/all.rb → renderers.rb} +0 -0
  24. data/lib/vedeu/{repositories/all.rb → repositories.rb} +9 -0
  25. data/lib/vedeu/repositories/collection.rb +0 -36
  26. data/lib/vedeu/terminal.rb +1 -54
  27. data/lib/vedeu/terminal_mode.rb +57 -0
  28. data/lib/vedeu/version.rb +1 -1
  29. data/test/lib/vedeu/configuration/api_test.rb +24 -0
  30. data/test/lib/vedeu/events/event_collection_test.rb +18 -0
  31. data/test/lib/vedeu/input/keys_test.rb +18 -0
  32. data/test/lib/vedeu/models/chars_test.rb +18 -0
  33. data/test/lib/vedeu/models/interface_collection_test.rb +18 -0
  34. data/test/lib/vedeu/models/lines_test.rb +18 -0
  35. data/test/lib/vedeu/models/streams_test.rb +18 -0
  36. data/test/lib/vedeu/repositories/collection_test.rb +0 -78
  37. data/test/lib/vedeu/terminal_mode_test.rb +72 -0
  38. data/test/lib/vedeu/terminal_test.rb +6 -67
  39. data/test/support/stats.sh +3 -0
  40. metadata +27 -9
  41. data/lib/vedeu/input/all.rb +0 -18
  42. data/test/support/colour_test.sh +0 -100
@@ -1,19 +1,3 @@
1
- require 'vedeu/common'
2
-
3
- require 'vedeu/dsl/use'
4
- require 'vedeu/dsl/presentation'
5
- require 'vedeu/dsl/border'
6
- require 'vedeu/dsl/composition'
7
- require 'vedeu/dsl/geometry'
8
- require 'vedeu/dsl/group'
9
- require 'vedeu/dsl/keymap'
10
- require 'vedeu/dsl/text'
11
- require 'vedeu/dsl/interface'
12
- require 'vedeu/dsl/line'
13
- require 'vedeu/dsl/menu'
14
- require 'vedeu/dsl/stream'
15
- require 'vedeu/dsl/view'
16
-
17
1
  module Vedeu
18
2
 
19
3
  # Provides a mechanism to help configure and use Vedeu.
@@ -100,10 +100,10 @@ module Vedeu
100
100
  # @param options [Hash] See {Vedeu::Wordwrap}
101
101
  # @return [Vedeu::InterfaceCollection<Vedeu::Interface>]
102
102
  def template_for(name, filename, object = nil, options = {})
103
- fail MissingRequired, 'Cannot render template without the name of ' \
104
- 'the view.' unless name
105
- fail MissingRequired, "Cannot render template for '#{name}', without " \
106
- 'a filename.' unless filename
103
+ fail Vedeu::MissingRequired,
104
+ 'Cannot render template without the name of the view.' unless name
105
+ fail Vedeu::MissingRequired,
106
+ "Cannot render template without a filename." unless filename
107
107
 
108
108
  content = Vedeu::Templating::Template.parse(object, filename)
109
109
  lines = Vedeu::Wordwrap.for(content, options)
@@ -0,0 +1,9 @@
1
+ module Vedeu
2
+
3
+ # A collection of {Vedeu::Event} instances.
4
+ #
5
+ class EventCollection < Vedeu::Collection
6
+
7
+ end # EventCollection
8
+
9
+ end # Vedeu
@@ -0,0 +1,9 @@
1
+ module Vedeu
2
+
3
+ # A collection of {Vedeu::Key} instances.
4
+ #
5
+ class Keys < Vedeu::Collection
6
+
7
+ end # Keys
8
+
9
+ end # Vedeu
@@ -24,7 +24,7 @@ module Vedeu
24
24
 
25
25
  safe_exit_point!
26
26
  end
27
- rescue VedeuInterrupt
27
+ rescue Vedeu::VedeuInterrupt
28
28
  Vedeu.log(type: :debug,
29
29
  message: 'Vedeu execution interrupted, exiting.')
30
30
  end
@@ -44,7 +44,7 @@ module Vedeu
44
44
  # application.
45
45
  # @return [void]
46
46
  def safe_exit_point!
47
- fail VedeuInterrupt if @started && !@loop
47
+ fail Vedeu::VedeuInterrupt if @started && !@loop
48
48
  end
49
49
  # :nocov:
50
50
 
@@ -0,0 +1,9 @@
1
+ module Vedeu
2
+
3
+ # A collection of {Vedeu::Char} instances.
4
+ #
5
+ class Chars < Vedeu::Collection
6
+
7
+ end # Chars
8
+
9
+ end # Vedeu
@@ -0,0 +1,9 @@
1
+ module Vedeu
2
+
3
+ # A collection of {Vedeu::Interface} instances.
4
+ #
5
+ class InterfaceCollection < Vedeu::Collection
6
+
7
+ end # InterfaceCollection
8
+
9
+ end # Vedeu
@@ -0,0 +1,9 @@
1
+ module Vedeu
2
+
3
+ # A collection of {Vedeu::Line} instances.
4
+ #
5
+ class Lines < Vedeu::Collection
6
+
7
+ end # Lines
8
+
9
+ end # Vedeu
@@ -0,0 +1,9 @@
1
+ module Vedeu
2
+
3
+ # A collection of {Vedeu::Stream} instances.
4
+ #
5
+ class Streams < Vedeu::Collection
6
+
7
+ end # Streams
8
+
9
+ end # Vedeu
@@ -6,12 +6,6 @@ module Vedeu
6
6
  #
7
7
  module Null
8
8
 
9
- end
9
+ end # Null
10
10
 
11
- end
12
-
13
- require 'vedeu/null/border'
14
- require 'vedeu/null/buffer'
15
- require 'vedeu/null/generic'
16
- require 'vedeu/null/geometry'
17
- require 'vedeu/null/interface'
11
+ end # Vedeu
File without changes
@@ -59,5 +59,14 @@ end # Vedeu
59
59
  require 'vedeu/repositories/store'
60
60
  require 'vedeu/repositories/registerable'
61
61
  require 'vedeu/repositories/collection'
62
+
63
+ require 'vedeu/events/event_collection'
64
+ require 'vedeu/input/keys'
65
+
66
+ require 'vedeu/models/chars'
67
+ require 'vedeu/models/interface_collection'
68
+ require 'vedeu/models/lines'
69
+ require 'vedeu/models/streams'
70
+
62
71
  require 'vedeu/repositories/model'
63
72
  require 'vedeu/repositories/repository'
@@ -95,40 +95,4 @@ module Vedeu
95
95
 
96
96
  end # Collection
97
97
 
98
- # A collection of {Vedeu::Char} instances.
99
- #
100
- class Chars < Vedeu::Collection
101
-
102
- end # Chars
103
-
104
- # A collection of {Vedeu::Event} instances.
105
- #
106
- class EventCollection < Vedeu::Collection
107
-
108
- end # EventCollection
109
-
110
- # A collection of {Vedeu::Interface} instances.
111
- #
112
- class InterfaceCollection < Vedeu::Collection
113
-
114
- end # InterfaceCollection
115
-
116
- # A collection of {Vedeu::Key} instances.
117
- #
118
- class Keys < Vedeu::Collection
119
-
120
- end # Keys
121
-
122
- # A collection of {Vedeu::Line} instances.
123
- #
124
- class Lines < Vedeu::Collection
125
-
126
- end # Lines
127
-
128
- # A collection of {Vedeu::Stream} instances.
129
- #
130
- class Streams < Vedeu::Collection
131
-
132
- end # Streams
133
-
134
98
  end # Vedeu
@@ -8,6 +8,7 @@ module Vedeu
8
8
  # @api public
9
9
  module Terminal
10
10
 
11
+ include Vedeu::TerminalMode
11
12
  extend self
12
13
 
13
14
  # Opens a terminal screen in either `raw` or `cooked` mode. On exit,
@@ -124,60 +125,6 @@ module Vedeu
124
125
  output(Esc.string('show_cursor')) unless raw_mode?
125
126
  end
126
127
 
127
- # Returns a boolean indicating whether the terminal is currently in `cooked`
128
- # mode.
129
- #
130
- # @return [Boolean]
131
- def cooked_mode?
132
- mode == :cooked
133
- end
134
-
135
- # Sets the terminal in to `cooked` mode.
136
- #
137
- # @return [Symbol]
138
- def cooked_mode!
139
- @mode = :cooked
140
- end
141
-
142
- # Returns a boolean indicating whether the terminal is currently in `raw`
143
- # mode.
144
- #
145
- # @return [Boolean]
146
- def raw_mode?
147
- mode == :raw
148
- end
149
-
150
- # Sets the terminal in to `raw` mode.
151
- #
152
- # @return [Symbol]
153
- def raw_mode!
154
- @mode = :raw
155
- end
156
-
157
- # Toggles the terminal's mode between `cooked` and `raw`, depending on its
158
- # current mode.
159
- #
160
- # @return [Symbol]
161
- def switch_mode!
162
- return cooked_mode! if raw_mode?
163
-
164
- raw_mode!
165
- end
166
-
167
- # Returns the mode of the terminal, either `:raw` or `:cooked`
168
- #
169
- # @return [Symbol]
170
- def mode
171
- @mode ||= Vedeu::Configuration.terminal_mode
172
- end
173
-
174
- # Returns the position of the cursor.
175
- #
176
- # @return [Vedeu::Position]
177
- def cursor
178
- # Vedeu.trigger(:_cursor_position_)
179
- end
180
-
181
128
  # Returns a coordinate tuple of the format [y, x], where `y` is the row/line
182
129
  # and `x` is the column/character.
183
130
  #
@@ -0,0 +1,57 @@
1
+ module Vedeu
2
+
3
+ module TerminalMode
4
+
5
+ extend self
6
+
7
+ # Returns a boolean indicating whether the terminal is currently in `cooked`
8
+ # mode.
9
+ #
10
+ # @return [Boolean]
11
+ def cooked_mode?
12
+ mode == :cooked
13
+ end
14
+
15
+ # Sets the terminal in to `cooked` mode.
16
+ #
17
+ # @return [Symbol]
18
+ def cooked_mode!
19
+ @mode = :cooked
20
+ end
21
+
22
+ # Returns a boolean indicating whether the terminal is currently in `raw`
23
+ # mode.
24
+ #
25
+ # @return [Boolean]
26
+ def raw_mode?
27
+ mode == :raw
28
+ end
29
+
30
+ # Sets the terminal in to `raw` mode.
31
+ #
32
+ # @return [Symbol]
33
+ def raw_mode!
34
+ @mode = :raw
35
+ end
36
+
37
+ # Toggles the terminal's mode between `cooked` and `raw`, depending on its
38
+ # current mode.
39
+ #
40
+ # @return [Symbol]
41
+ def switch_mode!
42
+ return cooked_mode! if raw_mode?
43
+
44
+ raw_mode!
45
+ end
46
+
47
+ # Returns the mode of the terminal, either `:raw` or `:cooked`. Can change
48
+ # throughout the lifespan of the client application.
49
+ #
50
+ # @return [Symbol]
51
+ def mode
52
+ @mode ||= Vedeu::Configuration.terminal_mode
53
+ end
54
+
55
+ end # TerminalMode
56
+
57
+ end # Vedeu
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.57'
4
+ VERSION = '0.4.58'
5
5
 
6
6
  end
@@ -271,6 +271,30 @@ module Vedeu
271
271
  end
272
272
  end
273
273
 
274
+ describe '#terminal_mode' do
275
+ context 'when setting to :raw mode' do
276
+ it {
277
+ configuration = Vedeu.configure { terminal_mode(:raw) }
278
+ configuration.terminal_mode.must_equal(:raw)
279
+ }
280
+ end
281
+
282
+ context 'when setting to :cooked mode' do
283
+ it {
284
+ configuration = Vedeu.configure { terminal_mode(:raw) }
285
+ configuration.terminal_mode.must_equal(:raw)
286
+ }
287
+ end
288
+
289
+ context 'when setting to an invalid mode' do
290
+ it {
291
+ proc {
292
+ Vedeu.configure { terminal_mode(:invalid) }
293
+ }.must_raise(Vedeu::InvalidSyntax)
294
+ }
295
+ end
296
+ end
297
+
274
298
  end # API
275
299
 
276
300
  end # Config
@@ -0,0 +1,18 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe EventCollection do
6
+
7
+ let(:described) { Vedeu::EventCollection }
8
+ let(:instance) { described.new }
9
+
10
+ it { described.superclass.must_equal(Vedeu::Collection) }
11
+
12
+ describe '#initialize' do
13
+ it { instance.must_be_instance_of(described) }
14
+ end
15
+
16
+ end # EventCollection
17
+
18
+ end # Vedeu
@@ -0,0 +1,18 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe Keys do
6
+
7
+ let(:described) { Vedeu::Keys }
8
+ let(:instance) { described.new }
9
+
10
+ it { described.superclass.must_equal(Vedeu::Collection) }
11
+
12
+ describe '#initialize' do
13
+ it { instance.must_be_instance_of(described) }
14
+ end
15
+
16
+ end # Keys
17
+
18
+ end # Vedeu
@@ -0,0 +1,18 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe Chars do
6
+
7
+ let(:described) { Vedeu::Chars }
8
+ let(:instance) { described.new }
9
+
10
+ it { described.superclass.must_equal(Vedeu::Collection) }
11
+
12
+ describe '#initialize' do
13
+ it { instance.must_be_instance_of(described) }
14
+ end
15
+
16
+ end # Chars
17
+
18
+ end # Vedeu
@@ -0,0 +1,18 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ describe InterfaceCollection do
6
+
7
+ let(:described) { Vedeu::InterfaceCollection }
8
+ let(:instance) { described.new }
9
+
10
+ it { described.superclass.must_equal(Vedeu::Collection) }
11
+
12
+ describe '#initialize' do
13
+ it { instance.must_be_instance_of(described) }
14
+ end
15
+
16
+ end # InterfaceCollection
17
+
18
+ end # Vedeu