vedeu 0.0.25 → 0.0.26
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 -9
- data/Rakefile +0 -10
- data/bin/composition +1 -1
- data/examples/single_interface_app.rb +7 -4
- data/lib/vedeu.rb +19 -48
- data/lib/vedeu/application.rb +8 -7
- data/lib/vedeu/configuration.rb +4 -4
- data/lib/vedeu/input/input.rb +3 -0
- data/lib/vedeu/launcher.rb +3 -0
- data/lib/vedeu/models/background.rb +13 -0
- data/lib/vedeu/models/coercions.rb +21 -0
- data/lib/vedeu/models/colour.rb +22 -0
- data/lib/vedeu/{repository → models}/command.rb +2 -0
- data/lib/vedeu/models/composition.rb +30 -0
- data/lib/vedeu/models/foreground.rb +13 -0
- data/lib/vedeu/models/interface.rb +62 -0
- data/lib/vedeu/models/interface_collection.rb +24 -0
- data/lib/vedeu/models/line.rb +22 -0
- data/lib/vedeu/models/line_collection.rb +27 -0
- data/lib/vedeu/models/presentation.rb +13 -0
- data/lib/vedeu/models/stream.rb +21 -0
- data/lib/vedeu/models/stream_collection.rb +27 -0
- data/lib/vedeu/models/style_collection.rb +23 -0
- data/lib/vedeu/output/interface_renderer.rb +62 -0
- data/lib/vedeu/output/output.rb +6 -5
- data/lib/vedeu/process/process.rb +15 -31
- data/lib/vedeu/repository/command_repository.rb +13 -14
- data/lib/vedeu/repository/interface_repository.rb +12 -13
- data/lib/vedeu/repository/repository.rb +2 -0
- data/lib/vedeu/{output → support}/cursor.rb +2 -0
- data/lib/vedeu/support/esc.rb +112 -0
- data/lib/vedeu/support/events.rb +21 -0
- data/lib/vedeu/support/geometry.rb +66 -0
- data/lib/vedeu/support/parser.rb +27 -0
- data/lib/vedeu/support/terminal.rb +31 -134
- data/lib/vedeu/{output → support}/translator.rb +12 -8
- data/lib/vedeu/{output → support}/wordwrap.rb +2 -4
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/application_test.rb +7 -2
- data/test/lib/vedeu/configuration_test.rb +13 -8
- data/test/lib/vedeu/input/input_test.rb +2 -1
- data/test/lib/vedeu/launcher_test.rb +7 -2
- data/test/lib/vedeu/models/background_test.rb +35 -0
- data/test/lib/vedeu/models/colour_test.rb +71 -0
- data/test/lib/vedeu/models/command_test.rb +109 -0
- data/test/lib/vedeu/models/composition_test.rb +187 -0
- data/test/lib/vedeu/models/foreground_test.rb +35 -0
- data/test/lib/vedeu/models/interface_collection_test.rb +57 -0
- data/test/lib/vedeu/models/interface_test.rb +220 -0
- data/test/lib/vedeu/models/line_collection_test.rb +69 -0
- data/test/lib/vedeu/models/line_test.rb +76 -0
- data/test/lib/vedeu/models/presentation_test.rb +8 -0
- data/test/lib/vedeu/models/stream_collection_test.rb +57 -0
- data/test/lib/vedeu/models/stream_test.rb +76 -0
- data/test/lib/vedeu/models/style_collection_test.rb +22 -0
- data/test/lib/vedeu/output/interface_renderer_test.rb +12 -0
- data/test/lib/vedeu/output/output_test.rb +15 -30
- data/test/lib/vedeu/process/process_test.rb +22 -44
- data/test/lib/vedeu/repository/command_repository_test.rb +22 -16
- data/test/lib/vedeu/repository/interface_repository_test.rb +62 -14
- data/test/lib/vedeu/repository/repository_test.rb +1 -0
- data/test/lib/vedeu/repository/storage_test.rb +13 -6
- data/test/lib/vedeu/{output → support}/cursor_test.rb +1 -0
- data/test/lib/vedeu/support/esc_test.rb +348 -0
- data/test/lib/vedeu/support/events_test.rb +37 -0
- data/test/lib/vedeu/support/exit_test.rb +1 -0
- data/test/lib/vedeu/support/geometry_test.rb +131 -0
- data/test/lib/vedeu/support/parser_test.rb +56 -0
- data/test/lib/vedeu/support/queue_test.rb +1 -0
- data/test/lib/vedeu/support/terminal_test.rb +1 -119
- data/test/lib/vedeu/{output → support}/translator_test.rb +17 -12
- data/test/lib/vedeu/{output → support}/wordwrap_test.rb +1 -0
- data/test/lib/vedeu/version_test.rb +1 -0
- data/test/lib/vedeu_test.rb +1 -0
- data/{lib/vedeu/repository → test/support}/dummy_command.rb +0 -0
- data/{lib/vedeu/repository → test/support}/dummy_interface.rb +0 -0
- data/test/support/json/int1_lin1_str1.json +10 -0
- data/test/support/json/int1_lin1_str3.json +18 -0
- data/test/support/json/int1_lin2_str1.json +17 -0
- data/test/support/json/int1_lin2_str3.json +33 -0
- data/test/support/json/int1_lin2_str3_styles.json +43 -0
- data/test/support/json/int2_lin1_str1.json +20 -0
- data/test/support/json/int2_lin1_str3.json +36 -0
- data/test/support/json/int2_lin2_str1.json +34 -0
- data/test/support/json/int2_lin2_str3.json +66 -0
- data/test/support/json/int2_lin2_str3_styles.json +158 -0
- data/test/support/output_1.json +9 -0
- data/test/support/output_1.rb +14 -0
- data/test/support/output_2.json +1 -0
- data/test/support/output_2.rb +19 -0
- data/test/test_helper.rb +0 -2
- data/vedeu.gemspec +0 -3
- metadata +98 -150
- data/config/cucumber.yml +0 -8
- data/documentation/composition.ebnf +0 -7
- data/documentation/diagram/ColourDirective.png +0 -0
- data/documentation/diagram/Directive.png +0 -0
- data/documentation/diagram/Interface.png +0 -0
- data/documentation/diagram/Output.png +0 -0
- data/documentation/diagram/PositionDirective.png +0 -0
- data/documentation/diagram/Stream.png +0 -0
- data/documentation/diagram/StyleDirective.png +0 -0
- data/documentation/diagram/rr-1.35.837.png +0 -0
- data/documentation/index.html +0 -325
- data/features/getting_started.feature +0 -10
- data/features/step_definitions/vedeu_steps.rb +0 -11
- data/features/support/env.rb +0 -12
- data/lib/vedeu/output/background.rb +0 -27
- data/lib/vedeu/output/base.rb +0 -57
- data/lib/vedeu/output/buffer/composition.rb +0 -24
- data/lib/vedeu/output/buffer/formatting.rb +0 -25
- data/lib/vedeu/output/buffer/interface.rb +0 -14
- data/lib/vedeu/output/buffer/line.rb +0 -14
- data/lib/vedeu/output/buffer/stream.rb +0 -14
- data/lib/vedeu/output/buffer/style.rb +0 -11
- data/lib/vedeu/output/colour.rb +0 -39
- data/lib/vedeu/output/compositor.rb +0 -72
- data/lib/vedeu/output/directive.rb +0 -63
- data/lib/vedeu/output/esc.rb +0 -61
- data/lib/vedeu/output/foreground.rb +0 -27
- data/lib/vedeu/output/geometry.rb +0 -71
- data/lib/vedeu/output/layer.rb +0 -9
- data/lib/vedeu/output/menu.rb +0 -26
- data/lib/vedeu/output/position.rb +0 -35
- data/lib/vedeu/output/style.rb +0 -38
- data/lib/vedeu/repository/interface.rb +0 -62
- data/lib/vedeu/support/json_parser.rb +0 -25
- data/lib/vedeu/support/options.rb +0 -4
- data/test/lib/vedeu/output/background_test.rb +0 -67
- data/test/lib/vedeu/output/base_test.rb +0 -8
- data/test/lib/vedeu/output/buffer/composition_test.rb +0 -57
- data/test/lib/vedeu/output/buffer/formatting_test.rb +0 -9
- data/test/lib/vedeu/output/buffer/interface_test.rb +0 -38
- data/test/lib/vedeu/output/buffer/line_test.rb +0 -64
- data/test/lib/vedeu/output/buffer/stream_test.rb +0 -61
- data/test/lib/vedeu/output/buffer/style_test.rb +0 -8
- data/test/lib/vedeu/output/colour_test.rb +0 -104
- data/test/lib/vedeu/output/compositor_test.rb +0 -247
- data/test/lib/vedeu/output/directive_test.rb +0 -82
- data/test/lib/vedeu/output/esc_test.rb +0 -175
- data/test/lib/vedeu/output/foreground_test.rb +0 -67
- data/test/lib/vedeu/output/geometry_test.rb +0 -190
- data/test/lib/vedeu/output/layer_test.rb +0 -35
- data/test/lib/vedeu/output/menu_test.rb +0 -13
- data/test/lib/vedeu/output/position_test.rb +0 -48
- data/test/lib/vedeu/output/style_test.rb +0 -132
- data/test/lib/vedeu/repository/command_test.rb +0 -73
- data/test/lib/vedeu/repository/dummy_command_test.rb +0 -27
- data/test/lib/vedeu/repository/dummy_interface_test.rb +0 -7
- data/test/lib/vedeu/repository/interface_test.rb +0 -79
- data/test/lib/vedeu/support/json_parser_test.rb +0 -45
- data/test/support/composition.json +0 -47
- data/test/support/composition.rb +0 -5
- data/test/support/composition.xml +0 -36
- data/test/support/multi_interface.json +0 -34
- data/test/support/single_interface.json +0 -19
@@ -1,11 +0,0 @@
|
|
1
|
-
Given(/^the interface "(.*?)" is defined$/) do |interface|
|
2
|
-
Vedeu::InterfaceRepository.create({ name: interface, entity: Vedeu::DummyInterface, options: {} })
|
3
|
-
end
|
4
|
-
|
5
|
-
Given(/^the command "(.*?)" is defined$/) do |command|
|
6
|
-
Vedeu::CommandRepository.create({ name: command, entity: Vedeu::DummyCommand, options: { keyword: command } })
|
7
|
-
end
|
8
|
-
|
9
|
-
When(/^the input "(.*?)" is entered$/) do |input|
|
10
|
-
pending
|
11
|
-
end
|
data/features/support/env.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
require 'aruba'
|
3
|
-
require 'aruba/cucumber'
|
4
|
-
require 'aruba/in_process'
|
5
|
-
require 'mocha/api'
|
6
|
-
|
7
|
-
require_relative '../../lib/vedeu.rb'
|
8
|
-
|
9
|
-
class CucumberError < StandardError; end
|
10
|
-
|
11
|
-
Aruba::InProcess.main_class = Vedeu::Launcher
|
12
|
-
Aruba.process = Aruba::InProcess
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
class Background < Base
|
3
|
-
private
|
4
|
-
|
5
|
-
def custom
|
6
|
-
'48;5;'
|
7
|
-
end
|
8
|
-
|
9
|
-
def normal
|
10
|
-
'48;2;'
|
11
|
-
end
|
12
|
-
|
13
|
-
def codes
|
14
|
-
{
|
15
|
-
black: 40,
|
16
|
-
red: 41,
|
17
|
-
green: 42,
|
18
|
-
yellow: 43,
|
19
|
-
blue: 44,
|
20
|
-
magenta: 45,
|
21
|
-
cyan: 46,
|
22
|
-
white: 47,
|
23
|
-
default: 49,
|
24
|
-
}
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/vedeu/output/base.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
class Base
|
3
|
-
class << self
|
4
|
-
def escape_sequence(colour = nil)
|
5
|
-
new(colour).escape_sequence
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
def initialize(colour = nil)
|
10
|
-
@colour = colour
|
11
|
-
end
|
12
|
-
|
13
|
-
def escape_sequence
|
14
|
-
[Esc.esc, prefix, code, suffix].join
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
attr_reader :colour
|
20
|
-
|
21
|
-
def prefix
|
22
|
-
named? || default? ? normal : custom
|
23
|
-
end
|
24
|
-
|
25
|
-
def code
|
26
|
-
no_colour || named || html || default
|
27
|
-
end
|
28
|
-
|
29
|
-
def no_colour
|
30
|
-
default unless colour
|
31
|
-
end
|
32
|
-
|
33
|
-
def default?
|
34
|
-
colour.nil? || colour == :default
|
35
|
-
end
|
36
|
-
|
37
|
-
def named
|
38
|
-
codes[colour] || codes[:default] if named?
|
39
|
-
end
|
40
|
-
|
41
|
-
def named?
|
42
|
-
colour.is_a?(Symbol)
|
43
|
-
end
|
44
|
-
|
45
|
-
def html
|
46
|
-
Translator.translate(colour)
|
47
|
-
end
|
48
|
-
|
49
|
-
def default
|
50
|
-
codes[:default]
|
51
|
-
end
|
52
|
-
|
53
|
-
def suffix
|
54
|
-
'm'
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
module Buffer
|
3
|
-
class Composition
|
4
|
-
include Virtus.model
|
5
|
-
|
6
|
-
attribute :interface, Array[Buffer::Interface]
|
7
|
-
|
8
|
-
def to_compositor
|
9
|
-
interface.inject({}) do |acc, interface|
|
10
|
-
acc[interface.name] = interface.to_compositor
|
11
|
-
acc
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def to_hash
|
16
|
-
Oj.load(to_json)
|
17
|
-
end
|
18
|
-
|
19
|
-
def to_json
|
20
|
-
Oj.dump(attributes, mode: :compat, circular: true)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
module Buffer
|
3
|
-
module Formatting
|
4
|
-
include Virtus.module
|
5
|
-
|
6
|
-
attribute :style, Vedeu::Buffer::Style
|
7
|
-
attribute :foreground, Symbol
|
8
|
-
attribute :background, Symbol
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def colour
|
13
|
-
return [] if foreground.nil? || background.nil?
|
14
|
-
|
15
|
-
[foreground, background]
|
16
|
-
end
|
17
|
-
|
18
|
-
def styles
|
19
|
-
return [] if style.nil?
|
20
|
-
|
21
|
-
style
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/vedeu/output/colour.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
class Colour
|
3
|
-
class << self
|
4
|
-
def set(pair = [])
|
5
|
-
return '' if pair.empty?
|
6
|
-
|
7
|
-
new(pair).set
|
8
|
-
end
|
9
|
-
|
10
|
-
def reset
|
11
|
-
new.reset
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def initialize(pair = [])
|
16
|
-
@pair = pair || []
|
17
|
-
end
|
18
|
-
|
19
|
-
def set
|
20
|
-
[foreground, background].join
|
21
|
-
end
|
22
|
-
|
23
|
-
def reset
|
24
|
-
[foreground(:default), background(:default)].join
|
25
|
-
end
|
26
|
-
|
27
|
-
def foreground(value = pair[0])
|
28
|
-
@foreground ||= Foreground.escape_sequence(value)
|
29
|
-
end
|
30
|
-
|
31
|
-
def background(value = pair[1])
|
32
|
-
@background ||= Background.escape_sequence(value)
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
attr_reader :pair
|
38
|
-
end
|
39
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
class Compositor
|
3
|
-
class << self
|
4
|
-
def arrange(output = {})
|
5
|
-
output.map do |interface, stream|
|
6
|
-
new({ interface: interface, stream: stream }).arrange
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def initialize(attributes = {})
|
12
|
-
@attributes = attributes || {}
|
13
|
-
@interface = attributes[:interface]
|
14
|
-
@stream = attributes[:stream]
|
15
|
-
end
|
16
|
-
|
17
|
-
def arrange
|
18
|
-
interface.enqueue(composition)
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
attr_reader :attributes, :stream
|
24
|
-
|
25
|
-
def composition
|
26
|
-
container = []
|
27
|
-
|
28
|
-
pad_stream
|
29
|
-
|
30
|
-
stream.each_with_index do |lines, index|
|
31
|
-
line = [interface.colour.set, clear(index)]
|
32
|
-
|
33
|
-
lines.each do |data|
|
34
|
-
line << Directive.enact(interface, data)
|
35
|
-
end
|
36
|
-
|
37
|
-
line << interface.colour.reset << interface.cursor
|
38
|
-
|
39
|
-
container << line.join
|
40
|
-
end
|
41
|
-
|
42
|
-
container
|
43
|
-
end
|
44
|
-
|
45
|
-
def pad_stream
|
46
|
-
if stream.size < height
|
47
|
-
remaining = height - stream.size
|
48
|
-
remaining.times { |i| stream << [{ text: '' }] }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def clear(index)
|
53
|
-
[origin(index), (' ' * width), origin(index)].join
|
54
|
-
end
|
55
|
-
|
56
|
-
def origin(index)
|
57
|
-
interface.geometry.origin(index)
|
58
|
-
end
|
59
|
-
|
60
|
-
def height
|
61
|
-
interface.geometry.height
|
62
|
-
end
|
63
|
-
|
64
|
-
def width
|
65
|
-
interface.geometry.width
|
66
|
-
end
|
67
|
-
|
68
|
-
def interface
|
69
|
-
@_interface ||= InterfaceRepository.find(@interface)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
class InvalidDirective < StandardError; end
|
3
|
-
|
4
|
-
class Directive
|
5
|
-
class << self
|
6
|
-
def enact(interface, directives = {})
|
7
|
-
new(interface, directives).enact
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def initialize(interface, directives = {})
|
12
|
-
@interface = interface
|
13
|
-
@directives = directives || {}
|
14
|
-
end
|
15
|
-
|
16
|
-
def enact
|
17
|
-
[set_position, set_colour, set_style, set_text].join
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
attr_reader :interface, :directives
|
23
|
-
|
24
|
-
def set_position
|
25
|
-
Position.set(*position)
|
26
|
-
end
|
27
|
-
|
28
|
-
def set_colour
|
29
|
-
Colour.set(colour) unless colour.empty?
|
30
|
-
end
|
31
|
-
|
32
|
-
def set_style
|
33
|
-
Array(style).map { |s| Style.set(s) }.join
|
34
|
-
end
|
35
|
-
|
36
|
-
def set_text
|
37
|
-
Wordwrap.this(text, options)
|
38
|
-
end
|
39
|
-
|
40
|
-
def position
|
41
|
-
directives.fetch(:position, [])
|
42
|
-
end
|
43
|
-
|
44
|
-
def colour
|
45
|
-
directives.fetch(:colour, [])
|
46
|
-
end
|
47
|
-
|
48
|
-
def style
|
49
|
-
directives.fetch(:style, [])
|
50
|
-
end
|
51
|
-
|
52
|
-
def text
|
53
|
-
directives.fetch(:text, '')
|
54
|
-
end
|
55
|
-
|
56
|
-
def options
|
57
|
-
{
|
58
|
-
width: interface.geometry.width,
|
59
|
-
prune: true
|
60
|
-
}
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
data/lib/vedeu/output/esc.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
module Esc
|
3
|
-
extend self
|
4
|
-
|
5
|
-
def blink
|
6
|
-
[esc, '5m'].join
|
7
|
-
end
|
8
|
-
|
9
|
-
def blink_off
|
10
|
-
[esc, '25m'].join
|
11
|
-
end
|
12
|
-
|
13
|
-
def bold
|
14
|
-
[esc, '1m'].join
|
15
|
-
end
|
16
|
-
|
17
|
-
def bold_off
|
18
|
-
[esc, '21m'].join
|
19
|
-
end
|
20
|
-
|
21
|
-
def clear
|
22
|
-
[esc, '2J'].join
|
23
|
-
end
|
24
|
-
|
25
|
-
def clear_line
|
26
|
-
[esc, '2K'].join
|
27
|
-
end
|
28
|
-
|
29
|
-
def esc
|
30
|
-
[27.chr, '['].join
|
31
|
-
end
|
32
|
-
|
33
|
-
def negative
|
34
|
-
[esc, '7m'].join
|
35
|
-
end
|
36
|
-
|
37
|
-
def positive
|
38
|
-
[esc, '27m'].join
|
39
|
-
end
|
40
|
-
|
41
|
-
def normal
|
42
|
-
[underline_off, bold_off, positive].join
|
43
|
-
end
|
44
|
-
|
45
|
-
def dim
|
46
|
-
[esc, '2m'].join
|
47
|
-
end
|
48
|
-
|
49
|
-
def reset
|
50
|
-
[esc, '0m'].join
|
51
|
-
end
|
52
|
-
|
53
|
-
def underline
|
54
|
-
[esc, '4m'].join
|
55
|
-
end
|
56
|
-
|
57
|
-
def underline_off
|
58
|
-
[esc, '24m'].join
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|