vedeu 0.1.12 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -0
  3. data/lib/vedeu.rb +12 -12
  4. data/lib/vedeu/api/api.rb +23 -18
  5. data/lib/vedeu/api/events.rb +1 -1
  6. data/lib/vedeu/api/interface.rb +29 -19
  7. data/lib/vedeu/api/line.rb +1 -34
  8. data/lib/vedeu/api/stream.rb +1 -34
  9. data/lib/vedeu/models/attributes/attributes.rb +7 -7
  10. data/lib/vedeu/models/attributes/colour_translator.rb +45 -7
  11. data/lib/vedeu/models/colour.rb +4 -2
  12. data/lib/vedeu/models/composition.rb +9 -9
  13. data/lib/vedeu/models/interface.rb +1 -1
  14. data/lib/vedeu/models/line.rb +17 -3
  15. data/lib/vedeu/{api → models}/store.rb +0 -2
  16. data/lib/vedeu/models/stream.rb +17 -3
  17. data/lib/vedeu/output/buffers.rb +14 -8
  18. data/lib/vedeu/output/view.rb +7 -3
  19. data/lib/vedeu/support/esc.rb +1 -14
  20. data/lib/vedeu/support/position.rb +31 -0
  21. data/lib/vedeu/support/terminal.rb +4 -0
  22. data/test/lib/vedeu/api/api_test.rb +21 -0
  23. data/test/lib/vedeu/api/interface_test.rb +765 -51
  24. data/test/lib/vedeu/configuration_test.rb +5 -0
  25. data/test/lib/vedeu/models/composition_test.rb +1 -1
  26. data/test/lib/vedeu/models/interface_test.rb +59 -17
  27. data/test/lib/vedeu/{api → models}/store_test.rb +12 -3
  28. data/test/lib/vedeu/output/clear_test.rb +1 -1
  29. data/test/lib/vedeu/output/render_test.rb +1 -1
  30. data/test/lib/vedeu/output/view_test.rb +17 -0
  31. data/test/lib/vedeu/support/esc_test.rb +0 -10
  32. data/test/lib/vedeu/support/position_test.rb +19 -0
  33. data/test/support/colour_test.sh +100 -0
  34. data/test/{stats.sh → support/stats.sh} +0 -0
  35. data/vedeu.gemspec +1 -1
  36. metadata +16 -10
  37. data/lib/vedeu/api/view.rb +0 -45
  38. data/test/lib/vedeu/api/view_test.rb +0 -565
@@ -21,6 +21,11 @@ module Vedeu
21
21
  Configuration.configure(['--raw'])
22
22
  .must_equal({ mode: :raw })
23
23
  end
24
+
25
+ it 'returns the options which instructs Vedeu to run with debugging on' do
26
+ Configuration.configure(['--debug'])
27
+ .must_equal({ debug: true })
28
+ end
24
29
  end
25
30
  end
26
31
  end
@@ -7,7 +7,7 @@ module Vedeu
7
7
  let(:json) { File.read('test/support/model_test_data.json') }
8
8
  let(:attributes) { JSON.load(json, nil, symbolize_names: true) }
9
9
 
10
- before { API::Store.reset }
10
+ before { Store.reset }
11
11
 
12
12
  describe '#interfaces' do
13
13
  it 'returns a collection of interfaces' do
@@ -21,37 +21,79 @@ module Vedeu
21
21
  })
22
22
  }
23
23
 
24
- it 'has a name attribute' do
25
- interface.name.must_equal('#initialize')
24
+ describe '#attributes' do
25
+ it 'returns the value' do
26
+ interface.attributes.must_equal(
27
+ {
28
+ name: '#initialize',
29
+ group: 'my_group',
30
+ lines: [],
31
+ colour: {
32
+ foreground: '#ff0000',
33
+ background: '#000000'
34
+ },
35
+ style: '',
36
+ geometry: {
37
+ y: 3,
38
+ x: 5,
39
+ width: 10,
40
+ height: 15
41
+ },
42
+ cursor: true,
43
+ delay: 0.0,
44
+ current: "\e[1;1H#initialize"
45
+ }
46
+ )
47
+ end
26
48
  end
27
49
 
28
- it 'has a name attribute' do
29
- interface.group.must_equal('my_group')
50
+ describe '#name' do
51
+ it 'returns the value' do
52
+ interface.name.must_equal('#initialize')
53
+ end
30
54
  end
31
55
 
32
- it 'has a lines attribute' do
33
- interface.lines.must_equal([])
56
+ describe '#group' do
57
+ it 'returns the value' do
58
+ interface.group.must_equal('my_group')
59
+ end
34
60
  end
35
61
 
36
- it 'has a colour attribute' do
37
- interface.colour.must_be_instance_of(Colour)
62
+ describe '#lines' do
63
+ it 'returns the value' do
64
+ interface.lines.must_equal([])
65
+ end
38
66
  end
39
67
 
40
- it 'has a style attribute' do
41
- interface.style.must_equal('')
68
+ describe '#colour' do
69
+ it 'returns the value' do
70
+ interface.colour.must_be_instance_of(Colour)
71
+ end
42
72
  end
43
73
 
44
- it 'has a geometry attribute' do
45
- interface.geometry.must_be_instance_of(Geometry)
74
+ describe '#style' do
75
+ it 'returns the value' do
76
+ interface.style.must_equal('')
77
+ end
78
+ end
79
+
80
+ describe '#geometry' do
81
+ it 'returns the value' do
82
+ interface.geometry.must_be_instance_of(Geometry)
83
+ end
46
84
  end
47
85
 
48
- it 'has a cursor attribute' do
49
- interface.cursor.must_equal(true)
50
- Interface.new({ cursor: false }).cursor.must_equal(false)
86
+ describe '#cursor' do
87
+ it 'returns the value' do
88
+ interface.cursor.must_equal(true)
89
+ Interface.new({ cursor: false }).cursor.must_equal(false)
90
+ end
51
91
  end
52
92
 
53
- it 'has a delay attribute' do
54
- interface.delay.must_equal(0.0)
93
+ describe '#delay' do
94
+ it 'returns the value' do
95
+ interface.delay.must_equal(0.0)
96
+ end
55
97
  end
56
98
 
57
99
  describe '#to_s' do
@@ -1,7 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
3
  module Vedeu
4
- module API
5
4
  describe Store do
6
5
  before { Store.reset }
7
6
 
@@ -20,7 +19,18 @@ module Vedeu
20
19
  end
21
20
 
22
21
  it 'returns the record when found' do
23
- Store.query('chlorine').must_equal({ name: 'chlorine', geometry: {} })
22
+ Store.query('chlorine').must_equal(
23
+ {
24
+ name: 'chlorine',
25
+ group: '',
26
+ lines: [],
27
+ colour: {},
28
+ style: '',
29
+ geometry: {},
30
+ cursor: true,
31
+ delay: 0.0
32
+ }
33
+ )
24
34
  end
25
35
 
26
36
  it 'raises an exception when name is empty' do
@@ -44,5 +54,4 @@ module Vedeu
44
54
  end
45
55
  end
46
56
  end
47
- end
48
57
  end
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
  describe Clear do
5
- before { API::Store.reset }
5
+ before { Store.reset }
6
6
 
7
7
  describe '.call' do
8
8
  it 'returns the escape sequence to clear the whole interface' do
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
  describe Render do
5
- before { API::Store.reset }
5
+ before { Store.reset }
6
6
 
7
7
  describe '.call' do
8
8
  it 'returns the content for the interface' do
@@ -0,0 +1,17 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+ class ViewTest < View
5
+ def output
6
+ []
7
+ end
8
+ end
9
+
10
+ describe View do
11
+ describe '.render' do
12
+ it 'returns' do
13
+ ViewTest.render.must_equal([])
14
+ end
15
+ end
16
+ end
17
+ end
@@ -2,16 +2,6 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
  describe Esc do
5
- describe '.set_position' do
6
- it 'returns a position escape sequence when no coordinates are provided' do
7
- Esc.set_position.must_equal("\e[1;1H")
8
- end
9
-
10
- it 'returns a position escape sequence when coordinates are provided' do
11
- Esc.set_position(12, 19).must_equal("\e[12;19H")
12
- end
13
- end
14
-
15
5
  describe '.string' do
16
6
  it 'returns an empty string when the style is not provided' do
17
7
  Esc.string.must_equal('')
@@ -0,0 +1,19 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+ describe Position do
5
+ describe '#to_s' do
6
+ it 'returns an escape sequence when no coordinates are provided' do
7
+ Position.new.to_s.must_equal("\e[1;1H")
8
+ end
9
+
10
+ it 'returns an escape sequence when coordinates are provided' do
11
+ Position.new(12, 19).to_s.must_equal("\e[12;19H")
12
+ end
13
+
14
+ it 'resets to starting position when a block is given' do
15
+ Position.new(4, 9).to_s { 'test' }.must_equal("\e[4;9Htest\e[4;9H")
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,100 @@
1
+ #!/bin/bash
2
+ #
3
+ # This file echoes four gradients with 24-bit color codes
4
+ # to the terminal to demonstrate their functionality.
5
+ # The foreground escape sequence is ^[38;2;<r>;<g>;<b>m
6
+ # The background escape sequence is ^[48;2;<r>;<g>;<b>m
7
+ # <r> <g> <b> range from 0 to 255 inclusive.
8
+ # The escape sequence ^[0m returns output to default
9
+
10
+ SEPARATOR=':'
11
+
12
+ setBackgroundColor()
13
+ {
14
+ echo -en "\x1b[48${SEPARATOR}2${SEPARATOR}$1${SEPARATOR}$2${SEPARATOR}$3""m"
15
+ }
16
+
17
+ resetOutput()
18
+ {
19
+ echo -en "\x1b[0m\n"
20
+ }
21
+
22
+ # Gives a color $1/255 % along HSV
23
+ # Who knows what happens when $1 is outside 0-255
24
+ # Echoes "$red $green $blue" where
25
+ # $red $green and $blue are integers
26
+ # ranging between 0 and 255 inclusive
27
+ rainbowColor()
28
+ {
29
+ let h=$1/43
30
+ let f=$1-43*$h
31
+ let t=$f*255/43
32
+ let q=255-t
33
+
34
+ if [ $h -eq 0 ]
35
+ then
36
+ echo "255 $t 0"
37
+ elif [ $h -eq 1 ]
38
+ then
39
+ echo "$q 255 0"
40
+ elif [ $h -eq 2 ]
41
+ then
42
+ echo "0 255 $t"
43
+ elif [ $h -eq 3 ]
44
+ then
45
+ echo "0 $q 255"
46
+ elif [ $h -eq 4 ]
47
+ then
48
+ echo "$t 0 255"
49
+ elif [ $h -eq 5 ]
50
+ then
51
+ echo "255 0 $q"
52
+ else
53
+ # execution should never reach here
54
+ echo "0 0 0"
55
+ fi
56
+ }
57
+
58
+ for i in `seq 0 127`; do
59
+ setBackgroundColor $i 0 0
60
+ echo -en " "
61
+ done
62
+ resetOutput
63
+ for i in `seq 255 128`; do
64
+ setBackgroundColor $i 0 0
65
+ echo -en " "
66
+ done
67
+ resetOutput
68
+
69
+ for i in `seq 0 127`; do
70
+ setBackgroundColor 0 $i 0
71
+ echo -n " "
72
+ done
73
+ resetOutput
74
+ for i in `seq 255 128`; do
75
+ setBackgroundColor 0 $i 0
76
+ echo -n " "
77
+ done
78
+ resetOutput
79
+
80
+ for i in `seq 0 127`; do
81
+ setBackgroundColor 0 0 $i
82
+ echo -n " "
83
+ done
84
+ resetOutput
85
+ for i in `seq 255 128`; do
86
+ setBackgroundColor 0 0 $i
87
+ echo -n " "
88
+ done
89
+ resetOutput
90
+
91
+ for i in `seq 0 127`; do
92
+ setBackgroundColor `rainbowColor $i`
93
+ echo -n " "
94
+ done
95
+ resetOutput
96
+ for i in `seq 255 128`; do
97
+ setBackgroundColor `rainbowColor $i`
98
+ echo -n " "
99
+ done
100
+ resetOutput
File without changes
data/vedeu.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'vedeu'
7
- spec.version = '0.1.12'
7
+ spec.version = '0.1.13'
8
8
  spec.authors = ['Gavin Laking']
9
9
  spec.email = ['gavinlaking@gmail.com']
10
10
  spec.summary = %q{A terminal case of wonderland.}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vedeu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-15 00:00:00.000000000 Z
11
+ date: 2014-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -177,9 +177,7 @@ files:
177
177
  - lib/vedeu/api/interface.rb
178
178
  - lib/vedeu/api/line.rb
179
179
  - lib/vedeu/api/log.rb
180
- - lib/vedeu/api/store.rb
181
180
  - lib/vedeu/api/stream.rb
182
- - lib/vedeu/api/view.rb
183
181
  - lib/vedeu/application.rb
184
182
  - lib/vedeu/configuration.rb
185
183
  - lib/vedeu/launcher.rb
@@ -190,6 +188,7 @@ files:
190
188
  - lib/vedeu/models/geometry.rb
191
189
  - lib/vedeu/models/interface.rb
192
190
  - lib/vedeu/models/line.rb
191
+ - lib/vedeu/models/store.rb
193
192
  - lib/vedeu/models/stream.rb
194
193
  - lib/vedeu/output/buffers.rb
195
194
  - lib/vedeu/output/clear.rb
@@ -198,13 +197,13 @@ files:
198
197
  - lib/vedeu/support/esc.rb
199
198
  - lib/vedeu/support/input.rb
200
199
  - lib/vedeu/support/menu.rb
200
+ - lib/vedeu/support/position.rb
201
201
  - lib/vedeu/support/terminal.rb
202
202
  - logs/.gitkeep
203
+ - test/lib/vedeu/api/api_test.rb
203
204
  - test/lib/vedeu/api/events_test.rb
204
205
  - test/lib/vedeu/api/grid_test.rb
205
206
  - test/lib/vedeu/api/interface_test.rb
206
- - test/lib/vedeu/api/store_test.rb
207
- - test/lib/vedeu/api/view_test.rb
208
207
  - test/lib/vedeu/configuration_test.rb
209
208
  - test/lib/vedeu/models/attributes/attributes_test.rb
210
209
  - test/lib/vedeu/models/attributes/colour_translator_test.rb
@@ -213,16 +212,20 @@ files:
213
212
  - test/lib/vedeu/models/geometry_test.rb
214
213
  - test/lib/vedeu/models/interface_test.rb
215
214
  - test/lib/vedeu/models/line_test.rb
215
+ - test/lib/vedeu/models/store_test.rb
216
216
  - test/lib/vedeu/models/stream_test.rb
217
217
  - test/lib/vedeu/output/buffers_test.rb
218
218
  - test/lib/vedeu/output/clear_test.rb
219
219
  - test/lib/vedeu/output/render_test.rb
220
+ - test/lib/vedeu/output/view_test.rb
220
221
  - test/lib/vedeu/support/esc_test.rb
221
222
  - test/lib/vedeu/support/input_test.rb
222
223
  - test/lib/vedeu/support/menu_test.rb
224
+ - test/lib/vedeu/support/position_test.rb
223
225
  - test/lib/vedeu/support/terminal_test.rb
224
- - test/stats.sh
226
+ - test/support/colour_test.sh
225
227
  - test/support/model_test_data.json
228
+ - test/support/stats.sh
226
229
  - test/test_helper.rb
227
230
  - vedeu.gemspec
228
231
  homepage: https://github.com/gavinlaking/vedeu
@@ -250,11 +253,10 @@ signing_key:
250
253
  specification_version: 4
251
254
  summary: A terminal case of wonderland.
252
255
  test_files:
256
+ - test/lib/vedeu/api/api_test.rb
253
257
  - test/lib/vedeu/api/events_test.rb
254
258
  - test/lib/vedeu/api/grid_test.rb
255
259
  - test/lib/vedeu/api/interface_test.rb
256
- - test/lib/vedeu/api/store_test.rb
257
- - test/lib/vedeu/api/view_test.rb
258
260
  - test/lib/vedeu/configuration_test.rb
259
261
  - test/lib/vedeu/models/attributes/attributes_test.rb
260
262
  - test/lib/vedeu/models/attributes/colour_translator_test.rb
@@ -263,14 +265,18 @@ test_files:
263
265
  - test/lib/vedeu/models/geometry_test.rb
264
266
  - test/lib/vedeu/models/interface_test.rb
265
267
  - test/lib/vedeu/models/line_test.rb
268
+ - test/lib/vedeu/models/store_test.rb
266
269
  - test/lib/vedeu/models/stream_test.rb
267
270
  - test/lib/vedeu/output/buffers_test.rb
268
271
  - test/lib/vedeu/output/clear_test.rb
269
272
  - test/lib/vedeu/output/render_test.rb
273
+ - test/lib/vedeu/output/view_test.rb
270
274
  - test/lib/vedeu/support/esc_test.rb
271
275
  - test/lib/vedeu/support/input_test.rb
272
276
  - test/lib/vedeu/support/menu_test.rb
277
+ - test/lib/vedeu/support/position_test.rb
273
278
  - test/lib/vedeu/support/terminal_test.rb
274
- - test/stats.sh
279
+ - test/support/colour_test.sh
275
280
  - test/support/model_test_data.json
281
+ - test/support/stats.sh
276
282
  - test/test_helper.rb