vedeu 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +26 -23
  3. data/deps.md +15 -19
  4. data/lib/vedeu.rb +8 -54
  5. data/lib/vedeu/api/base.rb +5 -3
  6. data/lib/vedeu/api/events.rb +75 -0
  7. data/lib/vedeu/api/interface.rb +12 -2
  8. data/lib/vedeu/api/store.rb +37 -0
  9. data/lib/vedeu/api/view.rb +12 -4
  10. data/lib/vedeu/application.rb +7 -3
  11. data/lib/vedeu/configuration.rb +4 -0
  12. data/lib/vedeu/instrumentation.rb +1 -9
  13. data/lib/vedeu/launcher.rb +5 -3
  14. data/lib/vedeu/models/attributes/background.rb +11 -0
  15. data/lib/vedeu/models/attributes/collection.rb +1 -7
  16. data/lib/vedeu/{output → models/attributes}/colour_translator.rb +19 -3
  17. data/lib/vedeu/models/attributes/foreground.rb +11 -0
  18. data/lib/vedeu/models/attributes/interface_collection.rb +5 -5
  19. data/lib/vedeu/models/colour.rb +2 -18
  20. data/lib/vedeu/models/interface.rb +22 -13
  21. data/lib/vedeu/models/line.rb +1 -2
  22. data/lib/vedeu/models/stream.rb +21 -13
  23. data/lib/vedeu/output/{clear_interface.rb → clear.rb} +5 -5
  24. data/lib/vedeu/output/{render_interface.rb → render.rb} +4 -4
  25. data/lib/vedeu/support/esc.rb +3 -0
  26. data/lib/vedeu/support/menu.rb +1 -1
  27. data/lib/vedeu/support/terminal.rb +4 -10
  28. data/test/lib/vedeu/api/base_test.rb +1 -1
  29. data/test/lib/vedeu/api/events_test.rb +37 -0
  30. data/test/lib/vedeu/api/grid_test.rb +11 -9
  31. data/test/lib/vedeu/api/interface_test.rb +10 -13
  32. data/test/lib/vedeu/api/line_test.rb +0 -2
  33. data/test/lib/vedeu/api/store_test.rb +49 -0
  34. data/test/lib/vedeu/api/stream_test.rb +1 -1
  35. data/test/lib/vedeu/api/view_test.rb +1 -1
  36. data/test/lib/vedeu/models/attributes/background_test.rb +8 -0
  37. data/test/lib/vedeu/models/attributes/colour_translator_test.rb +78 -0
  38. data/test/lib/vedeu/models/attributes/foreground_test.rb +8 -0
  39. data/test/lib/vedeu/models/attributes/interface_collection_test.rb +22 -6
  40. data/test/lib/vedeu/models/attributes/line_collection_test.rb +1 -6
  41. data/test/lib/vedeu/models/attributes/stream_collection_test.rb +1 -1
  42. data/test/lib/vedeu/models/composition_test.rb +108 -62
  43. data/test/lib/vedeu/models/geometry_test.rb +48 -0
  44. data/test/lib/vedeu/models/interface_test.rb +26 -10
  45. data/test/lib/vedeu/models/line_test.rb +0 -5
  46. data/test/lib/vedeu/output/{clear_interface_test.rb → clear_test.rb} +8 -8
  47. data/test/lib/vedeu/output/{render_interface_test.rb → render_test.rb} +7 -7
  48. data/test/lib/vedeu/support/esc_test.rb +12 -0
  49. data/test/lib/vedeu/support/terminal_test.rb +2 -1
  50. data/test/lib/vedeu_test.rb +0 -38
  51. data/test/support/colours.rb +1 -1
  52. data/vedeu.gemspec +1 -1
  53. metadata +23 -23
  54. data/lib/vedeu/output/text_adaptor.rb +0 -35
  55. data/lib/vedeu/support/events.rb +0 -51
  56. data/lib/vedeu/support/interface_store.rb +0 -43
  57. data/lib/vedeu/support/queue.rb +0 -31
  58. data/test/lib/vedeu/output/colour_translator_test.rb +0 -42
  59. data/test/lib/vedeu/output/text_adaptor_test.rb +0 -73
  60. data/test/lib/vedeu/support/events_test.rb +0 -35
  61. data/test/lib/vedeu/support/interface_store_test.rb +0 -51
  62. data/test/lib/vedeu/support/queue_test.rb +0 -44
@@ -1,31 +0,0 @@
1
- # Todo: mutation (queue)
2
-
3
- module Vedeu
4
- module Queue
5
- extend self
6
-
7
- def dequeue
8
- store.pop
9
- end
10
-
11
- def enqueue(result)
12
- store.unshift(result)
13
-
14
- self
15
- end
16
-
17
- def enqueued?
18
- store.any?
19
- end
20
-
21
- def reset
22
- store.clear
23
- end
24
-
25
- private
26
-
27
- def store
28
- @store ||= []
29
- end
30
- end
31
- end
@@ -1,42 +0,0 @@
1
- require 'test_helper'
2
- require 'vedeu/output/colour_translator'
3
-
4
- module Vedeu
5
- describe ColourTranslator do
6
- describe '#translate' do
7
- {
8
- '#ff0000' => 196, # red
9
- '#00ff00' => 46, # green
10
- '#0000ff' => 21, # blue
11
- '#ffffff' => 231, # white
12
- '#aadd00' => 148, # lime green
13
- '#b94f1c' => 130, # sunset orange
14
- }.map do |html_colour, terminal_colour|
15
- it 'translation is performed' do
16
- ColourTranslator.translate(html_colour)
17
- .must_equal(terminal_colour)
18
- end
19
- end
20
-
21
- it 'returns empty string when not present' do
22
- ColourTranslator.translate.must_equal('')
23
- end
24
-
25
- it 'returns empty string when the wrong type!' do
26
- ColourTranslator.translate(:wrong_type).must_equal('')
27
- end
28
-
29
- it 'returns empty string when invalid format' do
30
- ColourTranslator.translate('345678').must_equal('')
31
- end
32
-
33
- it 'returns empty string when invalid format' do
34
- ColourTranslator.translate('#h11111').must_equal('')
35
- end
36
-
37
- it 'returns empty string when invalid format' do
38
- ColourTranslator.translate('#1111').must_equal('')
39
- end
40
- end
41
- end
42
- end
@@ -1,73 +0,0 @@
1
- require 'test_helper'
2
- require 'vedeu/output/text_adaptor'
3
-
4
- module Vedeu
5
- describe TextAdaptor do
6
- describe '.adapt' do
7
- it 'returns an empty collection for an empty string' do
8
- TextAdaptor.adapt('').must_be_empty
9
-
10
- TextAdaptor.adapt('').must_equal([])
11
- end
12
-
13
- it 'returns a single line' do
14
- text = "This is a single line of text.\n"
15
- TextAdaptor.adapt(text).size.must_equal(1)
16
-
17
- TextAdaptor.adapt(text).must_equal(
18
- [
19
- {
20
- streams: { text: 'This is a single line of text.' }
21
- }
22
- ]
23
- )
24
- end
25
-
26
- it 'returns multiple lines' do
27
- text = "Lorem ipm olor sit aet,\nConsctetur adipiscing.\n" \
28
- "Curitur aiquet, trpis id dui.\n\nCondum elemum.\n"
29
- TextAdaptor.adapt(text).size.must_equal(5)
30
-
31
- TextAdaptor.adapt(text).must_equal(
32
- [
33
- {
34
- streams: { text: 'Lorem ipm olor sit aet,' }
35
- }, {
36
- streams: { text: 'Consctetur adipiscing.' }
37
- }, {
38
- streams: { text: 'Curitur aiquet, trpis id dui.' }
39
- }, {
40
- streams: { text: '' }
41
- }, {
42
- streams: { text: 'Condum elemum.' }
43
- }
44
- ]
45
- )
46
- end
47
-
48
- it 'handles collections of lines' do
49
- text = ["Lorm ipsum door sit amet, consecteur ",
50
- "adipscing elit. Curbitur gravda nisl ",
51
- "sit amet sagitis digisim. Nibh, eget."]
52
- TextAdaptor.adapt(text).size.must_equal(3)
53
- TextAdaptor.adapt(text).must_equal(
54
- [
55
- {
56
- streams: {
57
- text: "Lorm ipsum door sit amet, consecteur "
58
- }
59
- }, {
60
- streams: {
61
- text: "adipscing elit. Curbitur gravda nisl "
62
- }
63
- }, {
64
- streams: {
65
- text: "sit amet sagitis digisim. Nibh, eget."
66
- }
67
- }
68
- ]
69
- )
70
- end
71
- end
72
- end
73
- end
@@ -1,35 +0,0 @@
1
- require 'test_helper'
2
- require 'vedeu/support/events'
3
-
4
- module Vedeu
5
- describe Events do
6
- describe '#on' do
7
- it 'adds the event block to the handlers' do
8
- skip
9
- events = Events.new
10
- events.on(:some_event) { proc { |x| x } }
11
- end
12
-
13
- it 'adds the specified throttle to the throttles' do
14
- skip
15
- events = Events.new
16
- events.on(:some_event, 250) { proc { |x| x } }
17
- end
18
- end
19
-
20
- describe '#trigger' do
21
- it 'returns a collection containing the event when the event is ' \
22
- 'pre-registered' do
23
- events = Events.new do
24
- on(:_exit_) { fail StopIteration }
25
- end
26
- proc { events.trigger(:_exit_) }.must_raise(StopIteration)
27
- end
28
-
29
- it 'returns an empty collection when the event has not been registered' do
30
- events = Events.new
31
- events.trigger(:_not_found_).must_be_empty
32
- end
33
- end
34
- end
35
- end
@@ -1,51 +0,0 @@
1
- require 'test_helper'
2
- require 'vedeu/support/interface_store'
3
-
4
- module Vedeu
5
- describe InterfaceStore do
6
- before { InterfaceStore.reset }
7
-
8
- describe '.update' do
9
- it 'returns an Interface' do
10
- InterfaceStore.update('dummy', { name: 'dumber' })
11
- .must_be_instance_of(Interface)
12
- end
13
-
14
- it 'updates and returns the existing interface when the interface exists' do
15
- InterfaceStore.update('dummy', { name: 'dumber' }).name
16
- .must_equal('dumber')
17
- end
18
-
19
- it 'returns a new interface when the interface does not exist' do
20
- InterfaceStore.update('dummy', { name: 'dumber' }).name
21
- .must_equal('dumber')
22
- end
23
- end
24
-
25
- describe '#create' do
26
- it 'creates and returns the stored record' do
27
- InterfaceStore.create({ name: 'dummy' })
28
- .must_be_instance_of(Interface)
29
- end
30
- end
31
-
32
- describe '#query' do
33
- it 'returns the record when found' do
34
- InterfaceStore.create({ name: 'hydrogen' })
35
-
36
- InterfaceStore.query('hydrogen').name.must_equal('hydrogen')
37
- end
38
-
39
- it 'raises an exception when the record cannot be found' do
40
- proc { InterfaceStore.query('dummy') }.must_raise(EntityNotFound)
41
- end
42
- end
43
-
44
- describe '#reset' do
45
- it 'deletes all records stored' do
46
- InterfaceStore.create({ name: 'dumb' })
47
- InterfaceStore.reset.must_equal({})
48
- end
49
- end
50
- end
51
- end
@@ -1,44 +0,0 @@
1
- require 'test_helper'
2
- require 'vedeu/support/queue'
3
-
4
- module Vedeu
5
- describe Queue do
6
- before { Queue.reset }
7
-
8
- describe '.dequeue' do
9
- it 'returns a NilClass when the queue is empty' do
10
- Queue.dequeue.must_be_instance_of(NilClass)
11
- end
12
-
13
- it 'returns the first entry added when the queue is not empty' do
14
- Queue.enqueue(:result)
15
- Queue.dequeue.must_be_instance_of(Symbol)
16
- end
17
- end
18
-
19
- describe '.enqueue' do
20
- it 'stores an item on the queue' do
21
- Queue.enqueue(:result)
22
- Queue.enqueued?.must_equal(true)
23
- end
24
- end
25
-
26
- describe '.enqueued?' do
27
- it 'returns true when the queue is not empty' do
28
- Queue.enqueue(:result)
29
- Queue.enqueued?.must_be_instance_of(TrueClass)
30
- end
31
-
32
- it 'returns false when the queue is empty' do
33
- Queue.enqueued?.must_be_instance_of(FalseClass)
34
- end
35
- end
36
-
37
- describe '.clear' do
38
- it 'returns an empty array' do
39
- Queue.enqueue(:result)
40
- Queue.reset.must_be_empty
41
- end
42
- end
43
- end
44
- end