vedeu 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Gemfile +0 -1
  4. data/Guardfile +0 -8
  5. data/README.md +33 -1
  6. data/Rakefile +0 -8
  7. data/bin/vedeu +9 -0
  8. data/lib/vedeu.rb +23 -6
  9. data/lib/vedeu/application.rb +47 -0
  10. data/lib/vedeu/interface/interface.rb +37 -0
  11. data/lib/vedeu/interface/interfaces.rb +49 -0
  12. data/lib/vedeu/output/background.rb +23 -0
  13. data/lib/vedeu/output/base.rb +49 -0
  14. data/lib/vedeu/output/colour.rb +30 -0
  15. data/lib/vedeu/output/compositor.rb +60 -0
  16. data/lib/vedeu/output/directive.rb +34 -0
  17. data/lib/vedeu/output/esc.rb +37 -0
  18. data/lib/vedeu/output/foreground.rb +23 -0
  19. data/lib/vedeu/output/position.rb +22 -0
  20. data/lib/vedeu/output/style.rb +32 -0
  21. data/lib/vedeu/output/translator.rb +62 -0
  22. data/lib/vedeu/process/command.rb +51 -0
  23. data/lib/vedeu/process/commands.rb +58 -0
  24. data/lib/vedeu/process/process.rb +31 -0
  25. data/lib/vedeu/support/terminal.rb +139 -0
  26. data/lib/vedeu/version.rb +1 -1
  27. data/test/lib/vedeu/application_test.rb +18 -0
  28. data/test/lib/vedeu/interface/interface_test.rb +76 -0
  29. data/test/lib/vedeu/interface/interfaces_test.rb +63 -0
  30. data/test/lib/vedeu/output/background_test.rb +10 -0
  31. data/test/lib/vedeu/output/base_test.rb +10 -0
  32. data/test/lib/vedeu/output/colour_test.rb +67 -0
  33. data/test/lib/vedeu/output/compositor_test.rb +106 -0
  34. data/test/lib/vedeu/output/directive_test.rb +55 -0
  35. data/test/lib/vedeu/output/esc_test.rb +71 -0
  36. data/test/lib/vedeu/output/foreground_test.rb +10 -0
  37. data/test/lib/vedeu/output/position_test.rb +33 -0
  38. data/test/lib/vedeu/output/style_test.rb +59 -0
  39. data/test/lib/vedeu/output/translator_test.rb +52 -0
  40. data/test/lib/vedeu/process/command_test.rb +54 -0
  41. data/test/lib/vedeu/process/commands_test.rb +62 -0
  42. data/test/lib/vedeu/process/process_test.rb +11 -0
  43. data/test/lib/vedeu/support/terminal_test.rb +140 -0
  44. data/test/lib/vedeu/version_test.rb +9 -0
  45. data/test/support/test_app/bin/testapp +32 -0
  46. data/test/test_helper.rb +4 -0
  47. data/vedeu.gemspec +0 -6
  48. metadata +60 -99
  49. data/.rubocop.yml +0 -2
  50. data/features/.gitkeep +0 -0
  51. data/lib/vedeu/buffer.rb +0 -106
  52. data/lib/vedeu/colour.rb +0 -98
  53. data/lib/vedeu/terminal.rb +0 -25
  54. data/test/lib/vedeu/buffer_test.rb +0 -114
  55. data/test/lib/vedeu/colour_test.rb +0 -57
  56. data/test/lib/vedeu/terminal_test.rb +0 -30
@@ -1,25 +0,0 @@
1
- module Vedeu
2
- class Terminal
3
- def width
4
- size[1]
5
- end
6
-
7
- def height
8
- size[0]
9
- end
10
-
11
- private
12
-
13
- def size
14
- IO.console.winsize
15
- end
16
- end
17
-
18
- def self.test_Vedue__Terminal(klass = Vedeu::Terminal)
19
- terminal = klass.new
20
-
21
- puts "Width: #{terminal.width}"
22
- puts "Height: #{terminal.height}"
23
- puts
24
- end
25
- end
@@ -1,114 +0,0 @@
1
- require_relative '../../test_helper'
2
-
3
- module Vedeu
4
- describe Buffer do
5
- let(:klass) { Buffer }
6
- let(:options) { { width: 4, height: 3 } }
7
- let(:instance){ klass.new(options) }
8
-
9
- it 'returns an instance of self' do
10
- instance.must_be_instance_of(Vedeu::Buffer)
11
- end
12
-
13
- describe '#contents' do
14
- subject { capture_io { instance.contents }.join }
15
-
16
- it 'returns the contents of the buffer' do
17
- subject.must_equal("
18
- ' '' '' '' '
19
- ' '' '' '' '
20
- ' '' '' '' '
21
- ")
22
- end
23
- end
24
-
25
- describe '#cell' do
26
- let(:y) { 1 }
27
- let(:x) { 2 }
28
-
29
- subject { instance.cell(y, x) }
30
-
31
- context 'when the reference is in range' do
32
- it 'returns the value at that location' do
33
- subject.must_equal(' ')
34
- end
35
- end
36
-
37
- context 'when the reference is out of range' do
38
- let(:y) { 4 }
39
-
40
- it 'raises an exception' do
41
- proc { subject }.must_raise(OutOfRangeError)
42
- end
43
- end
44
- end
45
-
46
- describe '#set_cell' do
47
- let(:y) { 1 }
48
- let(:x) { 2 }
49
- let(:v) { '*' }
50
-
51
- subject { instance.set_cell(y, x, v) }
52
-
53
- context 'when the reference is in range' do
54
- it 'returns the value at that location' do
55
- subject.must_equal('*')
56
- end
57
-
58
- it 'updates just that cell' do
59
- subject
60
- capture_io { instance.contents }.join.must_equal("
61
- ' '' '' '' '
62
- ' '' ''*'' '
63
- ' '' '' '' '
64
- ")
65
- end
66
- end
67
-
68
- context 'when the reference is out of range' do
69
- end
70
- end
71
-
72
- describe '#set_row' do
73
- let(:y) { 1 }
74
- let(:v) { '****' }
75
- let(:instance) { klass.new(options) }
76
-
77
- subject { instance.set_row(y, v) }
78
-
79
- it 'sets the row' do
80
- subject.must_equal(['*', '*', '*', '*'])
81
- end
82
-
83
- it 'updates just that row' do
84
- subject
85
- capture_io { instance.contents }.join.must_equal("
86
- ' '' '' '' '
87
- '*''*''*''*'
88
- ' '' '' '' '
89
- ")
90
- end
91
- end
92
-
93
- describe '#set_column' do
94
- let(:x) { 2 }
95
- let(:v) { '***' }
96
- let(:instance) { klass.new(options) }
97
-
98
- subject { instance.set_column(x, v) }
99
-
100
- it 'sets the row' do
101
- subject.must_equal(['*', '*', '*'])
102
- end
103
-
104
- it 'updates just that column' do
105
- subject
106
- capture_io { instance.contents }.join.must_equal("
107
- ' '' ''*'' '
108
- ' '' ''*'' '
109
- ' '' ''*'' '
110
- ")
111
- end
112
- end
113
- end
114
- end
@@ -1,57 +0,0 @@
1
- require_relative '../../test_helper'
2
-
3
- module Vedeu
4
- describe Colour do
5
- let(:klass) { Colour }
6
- let(:instance) { klass.new }
7
- let(:pair) { [] }
8
-
9
- it 'returns an instance of self' do
10
- instance.must_be_instance_of(Vedeu::Colour)
11
- end
12
-
13
- describe '.set' do
14
- subject { klass.set(pair) }
15
-
16
- context 'when both the foreground and background is specified' do
17
- let(:pair) { [:red, :yellow] }
18
-
19
- it 'returns the code for red on yellow' do
20
- subject.must_equal("\e[31;43m")
21
- end
22
- end
23
-
24
- context 'when a foreground is specified' do
25
- let(:pair) { [:blue] }
26
-
27
- it 'returns the code for blue on default' do
28
- subject.must_equal("\e[34;49m")
29
- end
30
- end
31
-
32
- context 'when a background is specified' do
33
- let(:pair) { [nil, :cyan] }
34
-
35
- it 'returns the code for default with cyan background' do
36
- subject.must_equal("\e[39;46m")
37
- end
38
- end
39
-
40
- context 'when an invalid foreground/background is specified' do
41
- let(:pair) { [:melon, :raspberry] }
42
-
43
- it 'returns the default code' do
44
- subject.must_equal("\e[39;49m")
45
- end
46
- end
47
-
48
- context 'when no foreground/background is specified' do
49
- let(:pair) { [] }
50
-
51
- it 'returns the reset code' do
52
- subject.must_equal("\e[0m")
53
- end
54
- end
55
- end
56
- end
57
- end
@@ -1,30 +0,0 @@
1
- require_relative '../../test_helper'
2
-
3
- module Vedeu
4
- describe Terminal do
5
- let(:klass) { Terminal }
6
- let(:instance) { klass.new }
7
- let(:console) { stub }
8
-
9
- before do
10
- IO.stubs(:console).returns(console)
11
- console.stubs(:winsize).returns([25, 80])
12
- end
13
-
14
- it 'returns an instance of self' do
15
- instance.must_be_instance_of(Vedeu::Terminal)
16
- end
17
-
18
- describe '#width' do
19
- it 'returns the width of the terminal' do
20
- instance.width.must_equal(80)
21
- end
22
- end
23
-
24
- describe '#height' do
25
- it 'returns the height of the terminal' do
26
- instance.height.must_equal(25)
27
- end
28
- end
29
- end
30
- end