vedeu 0.0.32 → 0.0.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu/application.rb +2 -0
- data/lib/vedeu/launcher.rb +1 -1
- data/lib/vedeu/models/colour.rb +7 -7
- data/lib/vedeu/models/command.rb +2 -0
- data/lib/vedeu/models/composition.rb +2 -2
- data/lib/vedeu/models/interface.rb +15 -6
- data/lib/vedeu/models/line.rb +5 -3
- data/lib/vedeu/models/presentation.rb +3 -3
- data/lib/vedeu/models/stream.rb +6 -3
- data/lib/vedeu/models/style.rb +31 -0
- data/lib/vedeu/output/interface_renderer.rb +1 -3
- data/lib/vedeu/support/coordinate.rb +21 -7
- data/lib/vedeu/support/parsing/json_parser.rb +3 -3
- data/test/lib/vedeu/application_test.rb +0 -11
- data/test/lib/vedeu/launcher_test.rb +0 -8
- data/test/lib/vedeu/models/collection_test.rb +3 -3
- data/test/lib/vedeu/models/colour_test.rb +7 -2
- data/test/lib/vedeu/models/command_test.rb +0 -6
- data/test/lib/vedeu/models/composition_test.rb +127 -37
- data/test/lib/vedeu/models/interface_collection_test.rb +8 -9
- data/test/lib/vedeu/models/interface_test.rb +64 -18
- data/test/lib/vedeu/models/line_test.rb +3 -7
- data/test/lib/vedeu/models/presentation_test.rb +7 -5
- data/test/lib/vedeu/models/stream_test.rb +21 -11
- data/test/lib/vedeu/models/style_test.rb +86 -0
- data/test/lib/vedeu/output/interface_renderer_test.rb +32 -5
- data/test/lib/vedeu/output/output_test.rb +8 -1
- data/test/lib/vedeu/repository/command_repository_test.rb +14 -10
- data/test/lib/vedeu/repository/interface_repository_test.rb +9 -9
- data/test/lib/vedeu/support/coordinate_test.rb +72 -19
- data/test/lib/vedeu/support/menu_test.rb +16 -16
- data/test/lib/vedeu/support/parsing/hash_parser_test.rb +7 -7
- data/test/lib/vedeu/support/parsing/json_parser_test.rb +1 -1
- data/test/lib/vedeu/support/terminal_test.rb +0 -7
- data/test/lib/vedeu_test.rb +0 -5
- data/test/test_helper.rb +1 -0
- data/vedeu.gemspec +2 -3
- metadata +7 -25
- data/lib/vedeu/models/style_collection.rb +0 -19
- data/lib/vedeu/support/geometry.rb +0 -62
- data/test/lib/vedeu/models/style_collection_test.rb +0 -13
- data/test/lib/vedeu/support/geometry_test.rb +0 -107
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73c1296c50c2e542fe744337b953c07e2a14ee03
|
4
|
+
data.tar.gz: 55e5fa60d09ce7c65382a2ff664b79e717cb0228
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8816692395970fdb8a2b9003a625348cef3255c23c9340b56bfdb0297efbedbdc63d53f903caba320f7d94eb0f9f7f1834f4a4a721785a7b0e7142b377124952
|
7
|
+
data.tar.gz: 7f321725fa3838de38dfcfd1091dbbd66ee5bc6439d47322fc3075ebd249c6ca52218f21c83fa7edb091ad5562783083998df9b1d05d6e6ec45c8b64deec0183
|
data/lib/vedeu/application.rb
CHANGED
data/lib/vedeu/launcher.rb
CHANGED
@@ -3,6 +3,7 @@ require_relative 'configuration'
|
|
3
3
|
|
4
4
|
module Vedeu
|
5
5
|
class Launcher
|
6
|
+
# :nocov:
|
6
7
|
def initialize(argv, stdin = STDIN,
|
7
8
|
stdout = STDOUT,
|
8
9
|
stderr = STDERR,
|
@@ -15,7 +16,6 @@ module Vedeu
|
|
15
16
|
@exit_code = 1
|
16
17
|
end
|
17
18
|
|
18
|
-
# :nocov:
|
19
19
|
def execute!
|
20
20
|
$stdin, $stdout, $stderr = @stdin, @stdout, @stderr
|
21
21
|
|
data/lib/vedeu/models/colour.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'json'
|
2
2
|
require 'virtus'
|
3
3
|
|
4
4
|
require_relative '../support/esc'
|
@@ -7,8 +7,8 @@ module Vedeu
|
|
7
7
|
class Colour
|
8
8
|
include Virtus.model
|
9
9
|
|
10
|
-
attribute :foreground, String
|
11
|
-
attribute :background, String
|
10
|
+
attribute :foreground, String, default: ''
|
11
|
+
attribute :background, String, default: ''
|
12
12
|
|
13
13
|
def foreground
|
14
14
|
@fg ||= Esc.foreground_colour(css_foreground)
|
@@ -19,15 +19,15 @@ module Vedeu
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def css_foreground
|
22
|
-
@foreground
|
22
|
+
@foreground
|
23
23
|
end
|
24
24
|
|
25
25
|
def css_background
|
26
|
-
@background
|
26
|
+
@background
|
27
27
|
end
|
28
28
|
|
29
|
-
def to_json
|
30
|
-
|
29
|
+
def to_json(*args)
|
30
|
+
as_hash.to_json
|
31
31
|
end
|
32
32
|
|
33
33
|
def to_s
|
data/lib/vedeu/models/command.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
+
require 'json'
|
1
2
|
require 'virtus'
|
2
3
|
|
3
4
|
require_relative 'presentation'
|
4
5
|
require_relative 'line_collection'
|
6
|
+
require_relative 'style'
|
5
7
|
require_relative '../output/interface_renderer'
|
8
|
+
require_relative '../support/coordinate'
|
6
9
|
require_relative '../support/esc'
|
7
10
|
require_relative '../support/queue'
|
8
11
|
require_relative '../support/terminal'
|
@@ -11,6 +14,7 @@ module Vedeu
|
|
11
14
|
class Interface
|
12
15
|
include Virtus.model
|
13
16
|
include Presentation
|
17
|
+
include Style
|
14
18
|
include Vedeu::Queue
|
15
19
|
|
16
20
|
attribute :name, String
|
@@ -22,9 +26,10 @@ module Vedeu
|
|
22
26
|
attribute :height, Integer, default: Terminal.height
|
23
27
|
attribute :current, String, default: ''
|
24
28
|
attribute :cursor, Boolean, default: true
|
29
|
+
attribute :centred, Boolean, default: false
|
25
30
|
|
26
|
-
def
|
27
|
-
|
31
|
+
def origin(index = 0)
|
32
|
+
geometry.origin(index)
|
28
33
|
end
|
29
34
|
|
30
35
|
def refresh
|
@@ -40,8 +45,8 @@ module Vedeu
|
|
40
45
|
end
|
41
46
|
end
|
42
47
|
|
43
|
-
def to_json
|
44
|
-
|
48
|
+
def to_json(*args)
|
49
|
+
json_attributes.to_json
|
45
50
|
end
|
46
51
|
|
47
52
|
def to_s
|
@@ -64,8 +69,8 @@ module Vedeu
|
|
64
69
|
|
65
70
|
def json_attributes
|
66
71
|
{
|
67
|
-
colour: colour,
|
68
|
-
style:
|
72
|
+
colour: colour,
|
73
|
+
style: style_original,
|
69
74
|
name: name,
|
70
75
|
lines: lines,
|
71
76
|
y: y,
|
@@ -76,5 +81,9 @@ module Vedeu
|
|
76
81
|
cursor: cursor
|
77
82
|
}
|
78
83
|
end
|
84
|
+
|
85
|
+
def geometry
|
86
|
+
@_geometry ||= Coordinate.new(attributes)
|
87
|
+
end
|
79
88
|
end
|
80
89
|
end
|
data/lib/vedeu/models/line.rb
CHANGED
@@ -1,19 +1,21 @@
|
|
1
|
-
require '
|
1
|
+
require 'json'
|
2
2
|
require 'virtus'
|
3
3
|
|
4
4
|
require_relative 'presentation'
|
5
5
|
require_relative 'stream_collection'
|
6
|
+
require_relative 'style'
|
6
7
|
|
7
8
|
module Vedeu
|
8
9
|
class Line
|
9
10
|
include Virtus.model
|
10
11
|
include Presentation
|
12
|
+
include Style
|
11
13
|
|
12
14
|
attribute :model, Hash
|
13
15
|
attribute :streams, StreamCollection
|
14
16
|
|
15
17
|
def to_json
|
16
|
-
|
18
|
+
json_attributes.to_json
|
17
19
|
end
|
18
20
|
|
19
21
|
def to_s
|
@@ -25,7 +27,7 @@ module Vedeu
|
|
25
27
|
def json_attributes
|
26
28
|
{
|
27
29
|
colour: colour,
|
28
|
-
style:
|
30
|
+
style: style_original,
|
29
31
|
streams: streams
|
30
32
|
}
|
31
33
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'virtus'
|
2
2
|
|
3
3
|
require_relative 'colour'
|
4
|
-
require_relative '
|
4
|
+
require_relative '../support/esc'
|
5
5
|
|
6
6
|
module Vedeu
|
7
7
|
module Presentation
|
8
8
|
include Virtus.module
|
9
9
|
|
10
|
-
attribute :colour, Colour
|
11
|
-
attribute :style,
|
10
|
+
attribute :colour, Colour, default: Colour.new
|
11
|
+
attribute :style, Array[String]
|
12
12
|
end
|
13
13
|
end
|
data/lib/vedeu/models/stream.rb
CHANGED
@@ -1,17 +1,20 @@
|
|
1
|
+
require 'json'
|
1
2
|
require 'virtus'
|
2
3
|
|
3
4
|
require_relative 'presentation'
|
4
5
|
require_relative '../support/terminal'
|
6
|
+
require_relative 'style'
|
5
7
|
|
6
8
|
module Vedeu
|
7
9
|
class Stream
|
8
10
|
include Virtus.model
|
9
11
|
include Presentation
|
12
|
+
include Style
|
10
13
|
|
11
14
|
attribute :text, String, default: ''
|
12
15
|
|
13
16
|
def to_json
|
14
|
-
|
17
|
+
json_attributes.to_json
|
15
18
|
end
|
16
19
|
|
17
20
|
def to_s(options = {})
|
@@ -22,8 +25,8 @@ module Vedeu
|
|
22
25
|
|
23
26
|
def json_attributes
|
24
27
|
{
|
25
|
-
colour: colour
|
26
|
-
style:
|
28
|
+
colour: colour,
|
29
|
+
style: style_original,
|
27
30
|
text: text
|
28
31
|
}
|
29
32
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative '../support/esc'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
module Style
|
5
|
+
def style
|
6
|
+
@_style ||= if no_style?
|
7
|
+
''
|
8
|
+
|
9
|
+
else
|
10
|
+
@style.map { |s| Esc.string(s) }.join
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def style_original
|
16
|
+
@_original ||= if no_style?
|
17
|
+
''
|
18
|
+
|
19
|
+
else
|
20
|
+
@style
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def no_style?
|
28
|
+
@style.nil? || @style.empty?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require_relative '../support/geometry'
|
2
|
-
|
3
1
|
module Vedeu
|
4
2
|
class InterfaceRenderer
|
5
3
|
def self.clear(interface)
|
@@ -48,7 +46,7 @@ module Vedeu
|
|
48
46
|
end
|
49
47
|
|
50
48
|
def origin(index)
|
51
|
-
interface.
|
49
|
+
interface.origin(index)
|
52
50
|
end
|
53
51
|
|
54
52
|
def height
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require_relative 'esc'
|
1
2
|
require_relative 'terminal'
|
2
3
|
|
3
4
|
module Vedeu
|
@@ -15,6 +16,10 @@ module Vedeu
|
|
15
16
|
@centred = attrs.fetch(:centred, true)
|
16
17
|
end
|
17
18
|
|
19
|
+
def origin(index = 0)
|
20
|
+
Esc.set_position(virtual_y(index), virtual_x)
|
21
|
+
end
|
22
|
+
|
18
23
|
def terminal_height
|
19
24
|
fail OutOfBoundsError,
|
20
25
|
'Value must be greater than or equal to 1.' if @terminal_height < 1
|
@@ -45,10 +50,10 @@ module Vedeu
|
|
45
50
|
fail OutOfBoundsError,
|
46
51
|
'Value must be greater than or equal to 1.' if @y < 1
|
47
52
|
|
48
|
-
if @y >
|
53
|
+
if @y > terminal_height
|
49
54
|
fail OutOfBoundsError, 'Cannot set y position to be greater' \
|
50
|
-
' that the specified height
|
51
|
-
' actual terminal height.'
|
55
|
+
' that the specified terminal height' \
|
56
|
+
' or actual terminal height.'
|
52
57
|
else
|
53
58
|
@y
|
54
59
|
end
|
@@ -57,7 +62,6 @@ module Vedeu
|
|
57
62
|
def terminal_width
|
58
63
|
fail OutOfBoundsError,
|
59
64
|
'Value must be greater than or equal to 1.' if @terminal_width < 1
|
60
|
-
|
61
65
|
if @terminal_width > Terminal.width
|
62
66
|
fail OutOfBoundsError, 'Cannot set terminal_width to be ' \
|
63
67
|
'greater than the actual terminal ' \
|
@@ -84,10 +88,10 @@ module Vedeu
|
|
84
88
|
fail OutOfBoundsError,
|
85
89
|
'Value must be greater than or equal to 1.' if @x < 1
|
86
90
|
|
87
|
-
if @x >
|
91
|
+
if @x > terminal_width
|
88
92
|
fail OutOfBoundsError, 'Cannot set x position to be greater' \
|
89
|
-
' that the specified width
|
90
|
-
' actual terminal width.'
|
93
|
+
' that the specified terminal width' \
|
94
|
+
' or actual terminal width.'
|
91
95
|
else
|
92
96
|
@x
|
93
97
|
end
|
@@ -145,5 +149,15 @@ module Vedeu
|
|
145
149
|
}
|
146
150
|
end
|
147
151
|
|
152
|
+
private
|
153
|
+
|
154
|
+
def virtual_x
|
155
|
+
left
|
156
|
+
end
|
157
|
+
|
158
|
+
def virtual_y(index = 0)
|
159
|
+
((top..bottom).to_a)[index]
|
160
|
+
end
|
161
|
+
|
148
162
|
end
|
149
163
|
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require '
|
1
|
+
require 'json'
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
module JSONParser
|
5
5
|
extend self
|
6
6
|
|
7
7
|
def parse(output)
|
8
|
-
|
9
|
-
rescue
|
8
|
+
JSON.load(output, nil, symbolize_names: true)
|
9
|
+
rescue JSON::ParserError
|
10
10
|
{}
|
11
11
|
end
|
12
12
|
end
|
@@ -3,16 +3,5 @@ require_relative '../../../lib/vedeu/application'
|
|
3
3
|
|
4
4
|
module Vedeu
|
5
5
|
describe Application do
|
6
|
-
describe '.start' do
|
7
|
-
it 'returns a NilClass when the application should run interactively' do
|
8
|
-
skip
|
9
|
-
# Application.start({ interactive: true }).must_be_instance_of(NilClass)
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'returns a NilClass when the application should run once' do
|
13
|
-
skip
|
14
|
-
# Application.start({ interactive: false }).must_be_instance_of(NilClass)
|
15
|
-
end
|
16
|
-
end
|
17
6
|
end
|
18
7
|
end
|
@@ -3,13 +3,5 @@ require_relative '../../../lib/vedeu/launcher'
|
|
3
3
|
|
4
4
|
module Vedeu
|
5
5
|
describe Launcher do
|
6
|
-
describe '#execute!' do
|
7
|
-
it 'needs a spec, please write one.' do
|
8
|
-
skip
|
9
|
-
Application.stub :start, nil do
|
10
|
-
Launcher.new([]).execute!
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
6
|
end
|
15
7
|
end
|
@@ -15,15 +15,15 @@ module Vedeu
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'returns an empty collection when nil or empty' do
|
18
|
-
Collection.coercer('',
|
18
|
+
Collection.coercer('', TestClass, :key).must_equal([])
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'returns an empty collection when nil or empty' do
|
22
|
-
Collection.coercer([],
|
22
|
+
Collection.coercer([], TestClass, :key).must_equal([])
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'returns an empty collection when nil or empty' do
|
26
|
-
Collection.coercer({},
|
26
|
+
Collection.coercer({}, TestClass, :key).must_equal([])
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'returns a single model in a collection when a String' do
|
@@ -56,7 +56,9 @@ module Vedeu
|
|
56
56
|
Colour.new({
|
57
57
|
foreground: '#ff0000',
|
58
58
|
background: '#000000'
|
59
|
-
}).to_json.must_equal(
|
59
|
+
}).to_json.must_equal(
|
60
|
+
"{\"foreground\":\"#ff0000\",\"background\":\"#000000\"}"
|
61
|
+
)
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
@@ -90,7 +92,10 @@ module Vedeu
|
|
90
92
|
Colour.new({
|
91
93
|
foreground: '#ff0000',
|
92
94
|
background: '#000000'
|
93
|
-
}).as_hash.must_equal({
|
95
|
+
}).as_hash.must_equal({
|
96
|
+
foreground: '#ff0000',
|
97
|
+
background: '#000000'
|
98
|
+
})
|
94
99
|
end
|
95
100
|
end
|
96
101
|
end
|