vedeu 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -15
- data/deps.md +93 -96
- data/lib/vedeu.rb +1 -6
- data/lib/vedeu/api/line.rb +0 -4
- data/lib/vedeu/api/view.rb +0 -1
- data/lib/vedeu/application.rb +1 -3
- data/lib/vedeu/instrumentation.rb +1 -1
- data/lib/vedeu/models/colour.rb +3 -2
- data/lib/vedeu/models/geometry.rb +16 -0
- data/lib/vedeu/models/interface.rb +9 -1
- data/lib/vedeu/output/render_interface.rb +3 -0
- data/lib/vedeu/output/text_adaptor.rb +2 -0
- data/lib/vedeu/output/view.rb +17 -24
- data/lib/vedeu/support/esc.rb +1 -21
- data/test/lib/vedeu/api/base_test.rb +0 -11
- data/test/lib/vedeu/api/grid_test.rb +10 -0
- data/test/lib/vedeu/api/line_test.rb +0 -11
- data/test/lib/vedeu/api/stream_test.rb +0 -11
- data/test/lib/vedeu/api/view_test.rb +1 -4
- data/test/lib/vedeu/models/composition_test.rb +3 -0
- data/test/lib/vedeu/output/view_test.rb +0 -27
- data/test/lib/vedeu/support/esc_test.rb +1 -21
- data/vedeu.gemspec +1 -1
- metadata +2 -20
- data/lib/vedeu/output/dsl_parser.rb +0 -19
- data/lib/vedeu/output/erb_parser.rb +0 -59
- data/lib/vedeu/output/json_parser.rb +0 -23
- data/lib/vedeu/output/menu_parser.rb +0 -51
- data/lib/vedeu/output/raw_parser.rb +0 -42
- data/lib/vedeu/support/helpers.rb +0 -66
- data/test/lib/vedeu/output/dsl_parser_test.rb +0 -19
- data/test/lib/vedeu/output/erb_parser_test.rb +0 -242
- data/test/lib/vedeu/output/json_parser_test.rb +0 -17
- data/test/lib/vedeu/output/menu_parser_test.rb +0 -46
- data/test/lib/vedeu/output/raw_parser_test.rb +0 -74
- data/test/lib/vedeu/support/helpers_test.rb +0 -71
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'forwardable'
|
1
2
|
require 'virtus'
|
2
3
|
|
3
4
|
require 'vedeu'
|
@@ -14,10 +15,12 @@ require 'vedeu/support/terminal'
|
|
14
15
|
|
15
16
|
module Vedeu
|
16
17
|
class Interface
|
18
|
+
extend Forwardable
|
17
19
|
include Vedeu::Queue
|
18
20
|
include Virtus.model
|
19
21
|
|
20
22
|
attribute :name, String
|
23
|
+
attribute :group, String
|
21
24
|
attribute :lines, LineCollection
|
22
25
|
attribute :colour, Colour, default: Colour.new
|
23
26
|
attribute :style, Style, default: ''
|
@@ -26,10 +29,15 @@ module Vedeu
|
|
26
29
|
attribute :cursor, Boolean, default: true
|
27
30
|
attribute :delay, Float, default: 0
|
28
31
|
|
32
|
+
def_delegators :@geometry, :north, :east, :south, :west,
|
33
|
+
:top, :right, :bottom, :left
|
34
|
+
|
29
35
|
def initialize(attributes = {})
|
30
36
|
super
|
31
37
|
|
32
|
-
Vedeu.events.on(:
|
38
|
+
Vedeu.events.on(:_refresh_, self.delay) { refresh }
|
39
|
+
Vedeu.events.on("_refresh_group_#{group}_".to_sym, self.delay) { refresh } unless group.nil? || group.empty?
|
40
|
+
Vedeu.events.on("_refresh_#{name}_".to_sym, self.delay) { refresh }
|
33
41
|
|
34
42
|
self
|
35
43
|
end
|
data/lib/vedeu/output/view.rb
CHANGED
@@ -1,42 +1,35 @@
|
|
1
1
|
require 'vedeu/models/composition'
|
2
|
-
require 'vedeu/output/dsl_parser'
|
3
|
-
require 'vedeu/output/erb_parser'
|
4
|
-
require 'vedeu/output/raw_parser'
|
5
|
-
require 'vedeu/output/json_parser'
|
6
|
-
require 'vedeu/output/menu_parser'
|
7
|
-
require 'vedeu/output/raw_parser'
|
8
2
|
|
9
3
|
module Vedeu
|
4
|
+
NotImplemented = Class.new(StandardError)
|
5
|
+
|
10
6
|
class View
|
11
|
-
|
12
|
-
|
7
|
+
include Vedeu::API
|
8
|
+
|
9
|
+
def self.render(object = nil)
|
10
|
+
new(object).render
|
13
11
|
end
|
14
12
|
|
15
|
-
def initialize(
|
16
|
-
@
|
13
|
+
def initialize(object = nil)
|
14
|
+
@object = object
|
17
15
|
end
|
18
16
|
|
19
17
|
def render
|
20
|
-
Composition.enqueue(
|
18
|
+
Composition.enqueue(interfaces)
|
21
19
|
end
|
22
20
|
|
23
|
-
|
21
|
+
def output
|
22
|
+
fail NotImplemented, 'Implement #output on your subclass of Vedeu::View.'
|
23
|
+
end
|
24
24
|
|
25
|
-
|
25
|
+
private
|
26
26
|
|
27
|
-
|
28
|
-
@parsed ||= parser.parse(output)
|
29
|
-
end
|
27
|
+
attr_reader :object
|
30
28
|
|
31
|
-
def
|
29
|
+
def interfaces
|
32
30
|
{
|
33
|
-
|
34
|
-
|
35
|
-
json: JSONParser,
|
36
|
-
hash: RawParser,
|
37
|
-
menu: MenuParser,
|
38
|
-
raw: RawParser,
|
39
|
-
}.fetch(type)
|
31
|
+
interfaces: [ output ]
|
32
|
+
}
|
40
33
|
end
|
41
34
|
end
|
42
35
|
end
|
data/lib/vedeu/support/esc.rb
CHANGED
@@ -1,21 +1,7 @@
|
|
1
|
-
require 'vedeu/output/colour_translator'
|
2
|
-
|
3
1
|
module Vedeu
|
4
2
|
module Esc
|
5
3
|
extend self
|
6
4
|
|
7
|
-
def background_colour(value = '')
|
8
|
-
return '' if value.nil? || value.empty?
|
9
|
-
|
10
|
-
["\e[48;5;", colour_translator(value), 'm'].join
|
11
|
-
end
|
12
|
-
|
13
|
-
def foreground_colour(value = '')
|
14
|
-
return '' if value.nil? || value.empty?
|
15
|
-
|
16
|
-
["\e[38;5;", colour_translator(value), 'm'].join
|
17
|
-
end
|
18
|
-
|
19
5
|
def set_position(y = 1, x = 1)
|
20
6
|
row = (y == 0 || y == nil) ? 1 : y
|
21
7
|
column = (x == 0 || x == nil) ? 1 : x
|
@@ -30,7 +16,7 @@ module Vedeu
|
|
30
16
|
when 'blink_off' then "\e[25m"
|
31
17
|
when 'bold' then "\e[1m"
|
32
18
|
when 'bold_off' then "\e[21m"
|
33
|
-
when 'clear' then "\e[2J"
|
19
|
+
when 'clear' then "\e[38;2;39m\e[48;2;49m\e[2J"
|
34
20
|
when 'colour_reset' then "\e[38;2;39m\e[48;2;49m"
|
35
21
|
when 'fg_reset' then "\e[38;2;39m"
|
36
22
|
when 'hide_cursor' then "\e[?25l"
|
@@ -46,11 +32,5 @@ module Vedeu
|
|
46
32
|
''
|
47
33
|
end
|
48
34
|
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def colour_translator(value)
|
53
|
-
ColourTranslator.translate(value)
|
54
|
-
end
|
55
35
|
end
|
56
36
|
end
|
@@ -7,17 +7,6 @@ require 'vedeu/support/interface_store'
|
|
7
7
|
module Vedeu
|
8
8
|
module API
|
9
9
|
describe Base do
|
10
|
-
before do
|
11
|
-
InterfaceStore.reset
|
12
|
-
Interface.save('testing_view') do
|
13
|
-
width 80
|
14
|
-
height 25
|
15
|
-
x 1
|
16
|
-
y 1
|
17
|
-
colour foreground: '#ffffff', background: '#000000'
|
18
|
-
centred false
|
19
|
-
end
|
20
|
-
end
|
21
10
|
end
|
22
11
|
end
|
23
12
|
end
|
@@ -2,6 +2,16 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
require 'vedeu/api/grid'
|
4
4
|
|
5
|
+
describe Fixnum do
|
6
|
+
describe '#columns' do
|
7
|
+
it 'returns the width if the value is in range' do
|
8
|
+
IO.console.stub :winsize, [25, 60] do
|
9
|
+
1.columns.must_equal(5)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
5
15
|
module Vedeu
|
6
16
|
module API
|
7
17
|
describe Grid do
|
@@ -7,17 +7,6 @@ require 'vedeu/support/interface_store'
|
|
7
7
|
module Vedeu
|
8
8
|
module API
|
9
9
|
describe Line do
|
10
|
-
before do
|
11
|
-
InterfaceStore.reset
|
12
|
-
Interface.save('testing_view') do
|
13
|
-
width 80
|
14
|
-
height 25
|
15
|
-
x 1
|
16
|
-
y 1
|
17
|
-
colour foreground: '#ffffff', background: '#000000'
|
18
|
-
centred false
|
19
|
-
end
|
20
|
-
end
|
21
10
|
end
|
22
11
|
end
|
23
12
|
end
|
@@ -7,17 +7,6 @@ require 'vedeu/support/interface_store'
|
|
7
7
|
module Vedeu
|
8
8
|
module API
|
9
9
|
describe Stream do
|
10
|
-
before do
|
11
|
-
InterfaceStore.reset
|
12
|
-
Interface.save('testing_view') do
|
13
|
-
width 80
|
14
|
-
height 25
|
15
|
-
x 1
|
16
|
-
y 1
|
17
|
-
colour foreground: '#ffffff', background: '#000000'
|
18
|
-
centred false
|
19
|
-
end
|
20
|
-
end
|
21
10
|
end
|
22
11
|
end
|
23
12
|
end
|
@@ -410,7 +410,6 @@ module Vedeu
|
|
410
410
|
end
|
411
411
|
|
412
412
|
it 'handles alignment' do
|
413
|
-
skip
|
414
413
|
Vedeu.view 'testing_view' do
|
415
414
|
line do
|
416
415
|
stream do
|
@@ -438,7 +437,6 @@ module Vedeu
|
|
438
437
|
end
|
439
438
|
|
440
439
|
it 'handles alignment' do
|
441
|
-
skip
|
442
440
|
Vedeu.view 'testing_view' do
|
443
441
|
line do
|
444
442
|
stream do
|
@@ -458,7 +456,7 @@ module Vedeu
|
|
458
456
|
style: [],
|
459
457
|
width: 80,
|
460
458
|
align: :centre,
|
461
|
-
text: 'This is aligned
|
459
|
+
text: 'This is aligned centrally, and padded with spaces.'
|
462
460
|
}]
|
463
461
|
}]
|
464
462
|
}
|
@@ -466,7 +464,6 @@ module Vedeu
|
|
466
464
|
end
|
467
465
|
|
468
466
|
it 'handles alignment' do
|
469
|
-
skip
|
470
467
|
Vedeu.view 'testing_view' do
|
471
468
|
line do
|
472
469
|
stream do
|
@@ -4,33 +4,6 @@ require 'vedeu/output/view'
|
|
4
4
|
module Vedeu
|
5
5
|
describe View do
|
6
6
|
describe '.render' do
|
7
|
-
it 'returns when the type is :erb' do
|
8
|
-
skip
|
9
|
-
View.render(:erb, '').must_equal('')
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'returns when the type is :json' do
|
13
|
-
skip
|
14
|
-
View.render(:json, '').must_equal('')
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'returns when the type is :raw' do
|
18
|
-
skip
|
19
|
-
View.render(:raw, '').must_equal('')
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'returns when the type is :menu' do
|
23
|
-
skip
|
24
|
-
View.render(:menu, '').must_equal('')
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'returns when the type is not set' do
|
28
|
-
proc { View.render(nil, '') }.must_raise(KeyError)
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'returns when the type is not recognised' do
|
32
|
-
proc { View.render(:unknown, '') }.must_raise(KeyError)
|
33
|
-
end
|
34
7
|
end
|
35
8
|
end
|
36
9
|
end
|
@@ -3,26 +3,6 @@ require 'vedeu/support/esc'
|
|
3
3
|
|
4
4
|
module Vedeu
|
5
5
|
describe Esc do
|
6
|
-
describe '.background_colour' do
|
7
|
-
it 'returns an escape sequence' do
|
8
|
-
Esc.background_colour('#000000').must_equal("\e[48;5;16m")
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'returns an empty string when the value is empty' do
|
12
|
-
Esc.background_colour('').must_equal('')
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '.foreground_colour' do
|
17
|
-
it 'returns an escape sequence' do
|
18
|
-
Esc.foreground_colour('#ffffff').must_equal("\e[38;5;231m")
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'returns an empty string when the value is empty' do
|
22
|
-
Esc.foreground_colour('').must_equal('')
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
6
|
describe '.set_position' do
|
27
7
|
it 'returns a position escape sequence when no coordinates are provided' do
|
28
8
|
Esc.set_position.must_equal("\e[1;1H")
|
@@ -59,7 +39,7 @@ module Vedeu
|
|
59
39
|
end
|
60
40
|
|
61
41
|
it 'returns an escape sequence when the style is clear' do
|
62
|
-
Esc.string('clear').must_equal("\e[2J")
|
42
|
+
Esc.string('clear').must_equal("\e[38;2;39m\e[48;2;49m\e[2J")
|
63
43
|
end
|
64
44
|
|
65
45
|
it 'returns an escape sequence when the style is colour_reset' do
|
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.
|
7
|
+
spec.version = '0.1.7'
|
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.
|
4
|
+
version: 0.1.7
|
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-
|
11
|
+
date: 2014-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -208,17 +208,11 @@ files:
|
|
208
208
|
- lib/vedeu/models/style.rb
|
209
209
|
- lib/vedeu/output/clear_interface.rb
|
210
210
|
- lib/vedeu/output/colour_translator.rb
|
211
|
-
- lib/vedeu/output/dsl_parser.rb
|
212
|
-
- lib/vedeu/output/erb_parser.rb
|
213
|
-
- lib/vedeu/output/json_parser.rb
|
214
|
-
- lib/vedeu/output/menu_parser.rb
|
215
|
-
- lib/vedeu/output/raw_parser.rb
|
216
211
|
- lib/vedeu/output/render_interface.rb
|
217
212
|
- lib/vedeu/output/text_adaptor.rb
|
218
213
|
- lib/vedeu/output/view.rb
|
219
214
|
- lib/vedeu/support/esc.rb
|
220
215
|
- lib/vedeu/support/events.rb
|
221
|
-
- lib/vedeu/support/helpers.rb
|
222
216
|
- lib/vedeu/support/input.rb
|
223
217
|
- lib/vedeu/support/interface_store.rb
|
224
218
|
- lib/vedeu/support/menu.rb
|
@@ -248,17 +242,11 @@ files:
|
|
248
242
|
- test/lib/vedeu/models/style_test.rb
|
249
243
|
- test/lib/vedeu/output/clear_interface_test.rb
|
250
244
|
- test/lib/vedeu/output/colour_translator_test.rb
|
251
|
-
- test/lib/vedeu/output/dsl_parser_test.rb
|
252
|
-
- test/lib/vedeu/output/erb_parser_test.rb
|
253
|
-
- test/lib/vedeu/output/json_parser_test.rb
|
254
|
-
- test/lib/vedeu/output/menu_parser_test.rb
|
255
|
-
- test/lib/vedeu/output/raw_parser_test.rb
|
256
245
|
- test/lib/vedeu/output/render_interface_test.rb
|
257
246
|
- test/lib/vedeu/output/text_adaptor_test.rb
|
258
247
|
- test/lib/vedeu/output/view_test.rb
|
259
248
|
- test/lib/vedeu/support/esc_test.rb
|
260
249
|
- test/lib/vedeu/support/events_test.rb
|
261
|
-
- test/lib/vedeu/support/helpers_test.rb
|
262
250
|
- test/lib/vedeu/support/input_test.rb
|
263
251
|
- test/lib/vedeu/support/interface_store_test.rb
|
264
252
|
- test/lib/vedeu/support/menu_test.rb
|
@@ -337,17 +325,11 @@ test_files:
|
|
337
325
|
- test/lib/vedeu/models/style_test.rb
|
338
326
|
- test/lib/vedeu/output/clear_interface_test.rb
|
339
327
|
- test/lib/vedeu/output/colour_translator_test.rb
|
340
|
-
- test/lib/vedeu/output/dsl_parser_test.rb
|
341
|
-
- test/lib/vedeu/output/erb_parser_test.rb
|
342
|
-
- test/lib/vedeu/output/json_parser_test.rb
|
343
|
-
- test/lib/vedeu/output/menu_parser_test.rb
|
344
|
-
- test/lib/vedeu/output/raw_parser_test.rb
|
345
328
|
- test/lib/vedeu/output/render_interface_test.rb
|
346
329
|
- test/lib/vedeu/output/text_adaptor_test.rb
|
347
330
|
- test/lib/vedeu/output/view_test.rb
|
348
331
|
- test/lib/vedeu/support/esc_test.rb
|
349
332
|
- test/lib/vedeu/support/events_test.rb
|
350
|
-
- test/lib/vedeu/support/helpers_test.rb
|
351
333
|
- test/lib/vedeu/support/input_test.rb
|
352
334
|
- test/lib/vedeu/support/interface_store_test.rb
|
353
335
|
- test/lib/vedeu/support/menu_test.rb
|