vedeu 0.5.11 → 0.5.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/README.md +1 -0
  4. data/docs/configuration.md +94 -0
  5. data/lib/vedeu/application/application_view.rb +4 -0
  6. data/lib/vedeu/bindings/system.rb +1 -0
  7. data/lib/vedeu/configuration/api.rb +17 -32
  8. data/lib/vedeu/configuration/cli.rb +61 -1
  9. data/lib/vedeu/configuration/configuration.rb +1 -1
  10. data/lib/vedeu/dsl/view.rb +2 -2
  11. data/lib/vedeu/events/event.rb +4 -1
  12. data/lib/vedeu/log/log.rb +5 -1
  13. data/lib/vedeu/runtime/bootstrap.rb +19 -17
  14. data/lib/vedeu/runtime/router.rb +2 -2
  15. data/lib/vedeu/version.rb +1 -1
  16. data/test/lib/vedeu/application/application_view_test.rb +24 -0
  17. data/test/lib/vedeu/bindings/application_test.rb +2 -2
  18. data/test/lib/vedeu/bindings_test.rb +2 -2
  19. data/test/lib/vedeu/configuration/api_test.rb +17 -17
  20. data/test/lib/vedeu/cursor/move_test.rb +30 -11
  21. data/test/lib/vedeu/dsl/interface_test.rb +8 -2
  22. data/test/lib/vedeu/esc/actions_test.rb +2 -2
  23. data/test/lib/vedeu/esc/borders_test.rb +2 -2
  24. data/test/lib/vedeu/events/event_aliases_test.rb +2 -2
  25. data/test/lib/vedeu/events/event_collection_test.rb +1 -1
  26. data/test/lib/vedeu/internal_api_test.rb +2 -2
  27. data/test/lib/vedeu/models/views/collections/chars_test.rb +1 -1
  28. data/test/lib/vedeu/models/views/collections/view_collection_test.rb +2 -2
  29. data/test/lib/vedeu/models/views/view_test.rb +2 -2
  30. data/test/lib/vedeu/null/menu_test.rb +2 -2
  31. data/test/lib/vedeu/null/view_test.rb +2 -2
  32. data/test/lib/vedeu/plugins/plugin_test.rb +2 -2
  33. data/test/lib/vedeu/plugins_test.rb +2 -2
  34. data/test/lib/vedeu/repositories_test.rb +2 -2
  35. data/test/lib/vedeu/runtime/bootstrap_test.rb +7 -16
  36. data/test/lib/vedeu/runtime/flags_test.rb +2 -2
  37. data/test/lib/vedeu/runtime/main_loop_test.rb +4 -1
  38. data/test/lib/vedeu/runtime/router_test.rb +2 -2
  39. data/test/lib/vedeu/runtime/traps_test.rb +2 -2
  40. data/test/lib/vedeu/templating/decoder_test.rb +2 -2
  41. data/test/lib/vedeu/templating/encoder_test.rb +2 -2
  42. data/test/lib/vedeu/templating/view_template_test.rb +2 -2
  43. data/test/lib/vedeu/terminal_mode_test.rb +2 -2
  44. data/vedeu.gemspec +1 -1
  45. metadata +5 -4
@@ -55,7 +55,7 @@ module Vedeu
55
55
  # with the arguments provided.
56
56
  #
57
57
  # @example
58
- # Vedeu.configure
58
+ # Vedeu.configure do
59
59
  # # ...
60
60
  # end
61
61
  #
@@ -128,12 +128,12 @@ module Vedeu
128
128
  # Typically includes `view` with associated sub-directives.
129
129
  # @raise [Vedeu::InvalidSyntax] The required block was not given.
130
130
  # @return [Array<View>]
131
- def render(&block)
131
+ def renders(&block)
132
132
  fail Vedeu::InvalidSyntax, 'block not given' unless block_given?
133
133
 
134
134
  store(:store_immediate, &block)
135
135
  end
136
- alias_method :renders, :render
136
+ alias_method :render, :renders
137
137
 
138
138
  # Define a view (content) for an interface.
139
139
  #
@@ -183,7 +183,10 @@ module Vedeu
183
183
  @executed_at = @now # set execution time to now
184
184
  @now = 0 # reset now
185
185
 
186
- Vedeu.log(type: :event, message: "Triggering: '#{name.inspect}'")
186
+ message = "Triggering: '#{name.inspect}'"
187
+ message << " with '#{args.inspect}'" if args.any?
188
+
189
+ Vedeu.log(type: :event, message: message)
187
190
 
188
191
  closure.call(*args)
189
192
  end
data/lib/vedeu/log/log.rb CHANGED
@@ -192,7 +192,11 @@ module Vedeu
192
192
  #
193
193
  # The 'type' will be shown as the first colour defined in the value
194
194
  # array, whilst the 'message' will be shown using the last colour.
195
- # Valid types are available by viewing the source for this method.
195
+ #
196
+ # Valid types available:
197
+ #
198
+ # :config, :create, :debug, :error, :drb, :event, :info, :input,
199
+ # :output, :reset, :store, :test, :timer, :update
196
200
  #
197
201
  # @return [Hash<Symbol => Array<Symbol>>]
198
202
  def message_types
@@ -8,25 +8,21 @@ module Vedeu
8
8
  class Bootstrap
9
9
 
10
10
  # @param argv [Array<String>]
11
- # @param entry_point [void]
12
11
  # @return [void]
13
- def self.start(argv = ARGV, entry_point = nil)
14
- new(argv, entry_point).start
12
+ def self.start(argv = ARGV)
13
+ new(argv).start
15
14
  end
16
15
 
17
16
  # Returns a new instance of Vedeu::Bootstrap.
18
17
  #
19
18
  # @param argv [Array<String>]
20
- # @param entry_point [void]
21
19
  # @return [Vedeu::Bootstrap]
22
- def initialize(argv, entry_point = nil)
23
- @argv = argv
24
- @entry_point = entry_point
20
+ def initialize(argv)
21
+ @argv = argv
25
22
  end
26
23
 
27
24
  # Loads all of the client application files so that Vedeu has access to
28
- # them, calls the 'entry_point' controller, ready to start the application,
29
- # then launches the client application.
25
+ # them, then launches the client application.
30
26
  #
31
27
  # @return [void]
32
28
  def start
@@ -44,10 +40,6 @@ module Vedeu
44
40
  # @return [Array<String>]
45
41
  attr_reader :argv
46
42
 
47
- # @!attribute [r] entry_point
48
- # @return [void]
49
- attr_reader :entry_point
50
-
51
43
  private
52
44
 
53
45
  # @return [String]
@@ -80,7 +72,13 @@ module Vedeu
80
72
 
81
73
  # @return [void]
82
74
  def client_initialize!
83
- entry_point || root
75
+ if Vedeu::Configuration.root
76
+ Vedeu.trigger(:_goto_, *Vedeu::Configuration.root)
77
+
78
+ else
79
+ Vedeu.log_stderr(type: :debug, message: client_initialize_error)
80
+
81
+ end
84
82
  end
85
83
 
86
84
  # Load each of the loadable files.
@@ -111,9 +109,13 @@ module Vedeu
111
109
  end unless Vedeu::Configuration.log?
112
110
  end
113
111
 
114
- # @return [Class]
115
- def root
116
- Vedeu::Configuration.root if Vedeu::Configuration.root
112
+ # @return [String]
113
+ def client_initialize_error
114
+ "Please update the 'root' setting in 'config/configuration.rb' to " \
115
+ "start Vedeu using this controller and action: (args are optional)\n\n" \
116
+ "Vedeu.configure do\n" \
117
+ " root :some_controller, :show, *args\n" \
118
+ "end\n\n"
117
119
  end
118
120
 
119
121
  end # Bootstrap
@@ -22,7 +22,7 @@ module Vedeu
22
22
  end
23
23
 
24
24
  Vedeu.log(type: :create,
25
- message: "Adding ':#{controller}'")
25
+ message: "Controller: ':#{controller}'")
26
26
 
27
27
  if registered?(controller)
28
28
  storage[controller].merge!(klass: klass)
@@ -46,7 +46,7 @@ module Vedeu
46
46
  def add_action(controller, action)
47
47
  if present?(controller) && present?(action)
48
48
  Vedeu.log(type: :create,
49
- message: "Adding ':#{action}' for ':#{controller}'")
49
+ message: "Action: ':#{action}' (for ':#{controller}')")
50
50
 
51
51
  if registered?(controller)
52
52
  storage[controller][:actions] << action
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.5.11'
4
+ VERSION = '0.5.12'
5
5
 
6
6
  end
@@ -11,6 +11,28 @@ module Vedeu
11
11
  describe '#initialize' do
12
12
  it { instance.must_be_instance_of(described) }
13
13
  it { instance.instance_variable_get('@params').must_equal(params) }
14
+
15
+ context 'defined methods' do
16
+ let(:params) {
17
+ {
18
+ elements: [:hydrogen, :helium]
19
+ }
20
+ }
21
+
22
+ it { instance.must_respond_to(:elements) }
23
+ it { instance.elements.must_equal(params[:elements]) }
24
+
25
+ context 'but the params contain a key already defined as a method' do
26
+ let(:params) {
27
+ {
28
+ render: [:some_value]
29
+ }
30
+ }
31
+
32
+ it { instance.must_respond_to(:render) }
33
+ it { proc { instance.render }.wont_equal(params[:render]) }
34
+ end
35
+ end
14
36
  end
15
37
 
16
38
  # describe 'accessors' do
@@ -28,6 +50,8 @@ module Vedeu
28
50
  it { instance.must_respond_to(:render) }
29
51
  end
30
52
 
53
+
54
+
31
55
  end # ApplicationView
32
56
 
33
57
  end # Vedeu
@@ -4,7 +4,7 @@ module Vedeu
4
4
 
5
5
  module Bindings
6
6
 
7
- describe Application do
7
+ describe Application do
8
8
 
9
9
  context 'the application specific events are defined' do
10
10
  it { Vedeu.bound?(:_goto_).must_equal(true) }
@@ -31,7 +31,7 @@ module Vedeu
31
31
  }
32
32
  end
33
33
 
34
- end # Application
34
+ end # Application
35
35
 
36
36
  end # Bindings
37
37
 
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
- describe Bindings do
5
+ describe Bindings do
6
6
 
7
7
  let(:described) { Vedeu::Bindings }
8
8
 
@@ -51,6 +51,6 @@ module Vedeu
51
51
  it { subject.must_equal(true) }
52
52
  end
53
53
 
54
- end # Bindings
54
+ end # Bindings
55
55
 
56
56
  end # Vedeu
@@ -240,36 +240,36 @@ module Vedeu
240
240
 
241
241
  describe '#root' do
242
242
  it 'sets the options to the desired value' do
243
- configuration = Vedeu.configure { root(::YourApp::SomeController.new) }
244
- configuration.root.must_be_instance_of(YourApp::SomeController)
243
+ configuration = Vedeu.configure { root(:controller, :action, :args) }
244
+ configuration.root.must_equal([:controller, :action, :args])
245
245
  end
246
246
  end
247
247
 
248
248
  describe '#stdin' do
249
- let(:io) {}
249
+ let(:io) { IO.console }
250
250
 
251
- subject { instance.stdin(io) }
252
-
253
- # @todo Add more tests.
254
- # it { skip }
251
+ it 'sets the option to the desired value' do
252
+ configuration = Vedeu.configure { stdin(IO.console) }
253
+ configuration.stdin.must_equal(io)
254
+ end
255
255
  end
256
256
 
257
257
  describe '#stdout' do
258
- let(:io) {}
258
+ let(:io) { IO.console }
259
259
 
260
- subject { instance.stdout(io) }
261
-
262
- # @todo Add more tests.
263
- # it { skip }
260
+ it 'sets the option to the desired value' do
261
+ configuration = Vedeu.configure { stdout(IO.console) }
262
+ configuration.stdout.must_equal(io)
263
+ end
264
264
  end
265
265
 
266
266
  describe '#stderr' do
267
- let(:io) {}
268
-
269
- subject { instance.stderr(io) }
267
+ let(:io) { IO.console }
270
268
 
271
- # @todo Add more tests.
272
- # it { skip }
269
+ it 'sets the option to the desired value' do
270
+ configuration = Vedeu.configure { stderr(IO.console) }
271
+ configuration.stderr.must_equal(io)
272
+ end
273
273
  end
274
274
 
275
275
  describe '#compression!' do
@@ -232,13 +232,14 @@ module Vedeu
232
232
  describe '#move' do
233
233
  let(:_name) { 'move_move' }
234
234
 
235
+ before { Vedeu.stubs(:trigger) }
236
+
235
237
  subject { instance.move }
236
238
 
237
239
  context 'when the entity is a Vedeu::Geometry' do
238
240
  let(:entity) { Vedeu::Geometry }
239
241
 
240
- # @todo Add more tests.
241
- # it { skip }
242
+ it { subject.must_be_instance_of(Vedeu::Geometry) }
242
243
  end
243
244
 
244
245
  context 'when the entity is a Vedeu::Cursor' do
@@ -247,33 +248,51 @@ module Vedeu
247
248
  end
248
249
 
249
250
  describe '#refresh' do
251
+ before { Vedeu.stubs(:trigger) }
252
+
250
253
  subject { instance.refresh }
251
254
 
252
255
  context 'when the entity is a Vedeu::Geometry' do
253
256
  let(:entity) { Vedeu::Geometry }
254
257
 
255
- # @todo Add more tests.
256
- # it { skip }
258
+ it {
259
+ Vedeu.expects(:trigger)
260
+ subject
261
+ }
257
262
  end
258
263
 
259
264
  context 'when the entity is a Vedeu::Cursor' do
260
- # @todo Add more tests.
261
- # it { skip }
265
+ it {
266
+ Vedeu.expects(:trigger)
267
+ subject
268
+ }
262
269
  end
263
270
  end
264
271
 
265
272
  describe '#merged_attributes' do
266
273
  subject { instance.merged_attributes }
267
274
 
268
- context 'when the entity is a Vedeu::Geometry' do
269
- let(:entity) { Vedeu::Geometry }
275
+ it { subject.must_be_instance_of(Hash) }
270
276
 
271
- it { subject.must_be_instance_of(Hash) }
277
+ context 'when the entity is a Vedeu::Geometry' do
278
+ let(:entity) { Vedeu::Geometry }
279
+ let(:expected) {
280
+ {
281
+ centred: false,
282
+ maximised: false,
283
+ name: '',
284
+ x: 5,
285
+ y: 5,
286
+ xn: 10,
287
+ yn: 10
288
+ }
289
+ }
290
+
291
+ it { subject.must_equal(expected) }
272
292
  end
273
293
 
274
294
  context 'when the entity is a Vedeu::Cursor' do
275
- # @todo Add more tests.
276
- # it { skip }
295
+ it { subject.must_be_instance_of(Hash) }
277
296
  end
278
297
  end
279
298
 
@@ -156,7 +156,10 @@ module Vedeu
156
156
  describe '#delay' do
157
157
  subject { instance.delay(0.25) }
158
158
 
159
- it { subject; model.delay.must_equal(0.25) }
159
+ it {
160
+ subject
161
+ model.delay.must_equal(0.25)
162
+ }
160
163
  end
161
164
 
162
165
  describe '#focus!' do
@@ -253,7 +256,10 @@ module Vedeu
253
256
  describe '#name' do
254
257
  subject { instance.name('nickel') }
255
258
 
256
- it { subject; model.name.must_equal('nickel') }
259
+ it {
260
+ subject
261
+ model.name.must_equal('nickel')
262
+ }
257
263
  end
258
264
 
259
265
  describe '#no_cursor!' do
@@ -4,7 +4,7 @@ module Vedeu
4
4
 
5
5
  module EscapeSequences
6
6
 
7
- describe Actions do
7
+ describe Actions do
8
8
 
9
9
  let(:described) { Vedeu::EscapeSequences::Actions }
10
10
 
@@ -32,7 +32,7 @@ module Vedeu
32
32
  it { described.characters.must_be_instance_of(Hash) }
33
33
  end
34
34
 
35
- end # Actions
35
+ end # Actions
36
36
 
37
37
  end # EscapeSequences
38
38
 
@@ -4,7 +4,7 @@ module Vedeu
4
4
 
5
5
  module EscapeSequences
6
6
 
7
- describe Borders do
7
+ describe Borders do
8
8
 
9
9
  let(:described) { Vedeu::EscapeSequences::Borders }
10
10
 
@@ -30,7 +30,7 @@ module Vedeu
30
30
  it { described.characters.must_be_instance_of(Hash) }
31
31
  end
32
32
 
33
- end # Borders
33
+ end # Borders
34
34
 
35
35
  end # EscapeSequences
36
36
 
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
- describe EventAliases do
5
+ describe EventAliases do
6
6
 
7
7
  let(:described) { Vedeu::EventAliases }
8
8
 
@@ -118,6 +118,6 @@ module Vedeu
118
118
  end
119
119
  end
120
120
 
121
- end # EventAliases
121
+ end # EventAliases
122
122
 
123
123
  end # Vedeu
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
- describe EventCollection do
5
+ describe EventCollection do
6
6
 
7
7
  let(:described) { Vedeu::EventCollection }
8
8
  let(:instance) { described.new }