vedeu 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -26
- data/lib/vedeu.rb +2 -0
- data/lib/vedeu/application.rb +6 -20
- data/lib/vedeu/interface/dummy.rb +9 -0
- data/lib/vedeu/interface/interface.rb +39 -14
- data/lib/vedeu/interface/interfaces.rb +4 -4
- data/lib/vedeu/process/commands.rb +0 -6
- data/lib/vedeu/process/exit.rb +7 -0
- data/lib/vedeu/process/process.rb +16 -14
- data/lib/vedeu/support/terminal.rb +1 -1
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/application_test.rb +4 -4
- data/test/lib/vedeu/interface/dummy_test.rb +22 -0
- data/test/lib/vedeu/interface/interface_test.rb +11 -47
- data/test/lib/vedeu/interface/interfaces_test.rb +4 -4
- data/test/lib/vedeu/process/commands_test.rb +0 -12
- data/test/lib/vedeu/process/exit_test.rb +15 -0
- data/test/lib/vedeu/process/process_test.rb +2 -3
- data/test/support/test_app/bin/testapp +2 -10
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78eafb32b9a942a36cbc9ed4d65bf96542e39c03
|
4
|
+
data.tar.gz: 6e79f409e8be1e884060585b04066ae0995e7aac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fb0a166b340bae5d0ba423c698f6304f20777291ab316defa98b5b4dbcdf91fed7160b1c567663346052fdced575e11d32fc0aec7fc6c59cae10ce48993cccb
|
7
|
+
data.tar.gz: c4e0c6cdea25d795fde8bc46358f74656efc15e69609efcd390c24d8464ce9f1163dcceaf44337ecf6f9b05081e7ce2d248a692e7905ebe0899440546b190c71
|
data/README.md
CHANGED
@@ -24,32 +24,40 @@ TODO: Write detailed documentation
|
|
24
24
|
|
25
25
|
## Notes
|
26
26
|
|
27
|
-
Application
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
27
|
+
Application
|
28
|
+
|-- Interfaces
|
29
|
+
| |-- Dummy < Interface
|
30
|
+
|
|
31
|
+
|-- Process
|
32
|
+
| |-- Commands
|
33
|
+
| | |-- Command
|
34
|
+
| |
|
35
|
+
| |-- Compositor
|
36
|
+
| | |-- Directive
|
37
|
+
| | | |-- Colour
|
38
|
+
| | | | |-- Foreground < Base
|
39
|
+
| | | | |-- Background < Base
|
40
|
+
| | | |
|
41
|
+
| | | |-- Position
|
42
|
+
| | | |-- Style
|
43
|
+
| | | |-- Esc
|
44
|
+
| | |
|
45
|
+
| | |-- Terminal
|
46
|
+
| |
|
47
|
+
| |-- Terminal
|
48
|
+
|
|
49
|
+
|-- Terminal
|
50
|
+
|
51
|
+
Base
|
52
|
+
|-- Translator
|
53
|
+
|-- Esc
|
54
|
+
|
55
|
+
Interface
|
56
|
+
|-- Terminal
|
57
|
+
|
58
|
+
Terminal
|
59
|
+
|-- Esc
|
60
|
+
|-- Position
|
53
61
|
|
54
62
|
|
55
63
|
## Contributing
|
data/lib/vedeu.rb
CHANGED
@@ -16,9 +16,11 @@ require_relative 'vedeu/output/translator'
|
|
16
16
|
|
17
17
|
require_relative 'vedeu/interface/interfaces'
|
18
18
|
require_relative 'vedeu/interface/interface'
|
19
|
+
require_relative 'vedeu/interface/dummy'
|
19
20
|
|
20
21
|
require_relative 'vedeu/process/commands'
|
21
22
|
require_relative 'vedeu/process/command'
|
23
|
+
require_relative 'vedeu/process/exit'
|
22
24
|
require_relative 'vedeu/process/process'
|
23
25
|
|
24
26
|
require_relative 'vedeu/application'
|
data/lib/vedeu/application.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Vedeu
|
2
2
|
class Application
|
3
3
|
class << self
|
4
|
-
def start(interfaces = nil, options = {}
|
5
|
-
new(interfaces, options).start
|
4
|
+
def start(interfaces = nil, options = {})
|
5
|
+
new(interfaces, options).start
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
@@ -10,15 +10,9 @@ module Vedeu
|
|
10
10
|
@interfaces, @options = interfaces, options
|
11
11
|
end
|
12
12
|
|
13
|
-
def start
|
14
|
-
|
15
|
-
|
16
|
-
else
|
17
|
-
Terminal.open(options) do
|
18
|
-
initial_state
|
19
|
-
|
20
|
-
Process.event_loop
|
21
|
-
end
|
13
|
+
def start
|
14
|
+
Terminal.open(options) do
|
15
|
+
Process.main_sequence(interfaces)
|
22
16
|
end
|
23
17
|
ensure
|
24
18
|
Terminal.close
|
@@ -26,15 +20,7 @@ module Vedeu
|
|
26
20
|
|
27
21
|
private
|
28
22
|
|
29
|
-
attr_reader :options
|
30
|
-
|
31
|
-
def initial_state
|
32
|
-
interfaces.initial
|
33
|
-
end
|
34
|
-
|
35
|
-
def interfaces
|
36
|
-
@interfaces ||= Interfaces.default
|
37
|
-
end
|
23
|
+
attr_reader :interfaces, :options
|
38
24
|
|
39
25
|
def options
|
40
26
|
defaults.merge!(@options)
|
@@ -1,37 +1,62 @@
|
|
1
1
|
module Vedeu
|
2
|
+
class NotImplementedError < StandardError; end
|
3
|
+
|
2
4
|
class Interface
|
3
5
|
def initialize(options = {})
|
4
6
|
@options = options
|
5
7
|
end
|
6
8
|
|
7
|
-
def
|
9
|
+
def initial_state
|
10
|
+
raise NotImplementedError, 'Subclasses implement this method.'
|
11
|
+
end
|
8
12
|
|
9
|
-
def
|
10
|
-
|
13
|
+
def event_loop
|
14
|
+
while true do
|
15
|
+
command = input
|
11
16
|
|
12
|
-
|
13
|
-
end
|
17
|
+
break if command == :stop
|
14
18
|
|
15
|
-
|
16
|
-
|
19
|
+
output(command)
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
def input
|
20
|
-
|
24
|
+
evaluate
|
25
|
+
end
|
26
|
+
|
27
|
+
def output(command)
|
28
|
+
Compositor.write(command)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
attr_reader :options
|
34
|
+
|
35
|
+
def evaluate
|
36
|
+
Commands.execute(read)
|
37
|
+
end
|
38
|
+
|
39
|
+
def read
|
40
|
+
Terminal.input
|
21
41
|
end
|
22
42
|
|
23
43
|
def width
|
24
|
-
options[:width]
|
44
|
+
options[:width]
|
25
45
|
end
|
26
46
|
|
27
47
|
def height
|
28
|
-
options[:height]
|
48
|
+
options[:height]
|
29
49
|
end
|
30
50
|
|
31
|
-
|
51
|
+
def options
|
52
|
+
defaults.merge!(@options)
|
53
|
+
end
|
32
54
|
|
33
|
-
|
55
|
+
def defaults
|
56
|
+
{
|
57
|
+
width: Terminal.width,
|
58
|
+
height: Terminal.height
|
59
|
+
}
|
60
|
+
end
|
34
61
|
end
|
35
|
-
|
36
|
-
class Dummy < Interface; end
|
37
62
|
end
|
@@ -29,12 +29,12 @@ module Vedeu
|
|
29
29
|
interfaces
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
33
|
-
interfaces.values.map { |io| io.call.
|
32
|
+
def initial_state
|
33
|
+
interfaces.values.map { |io| io.call.initial_state }
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
37
|
-
interfaces.values.map { |io| io.call.
|
36
|
+
def event_loop
|
37
|
+
interfaces.values.map { |io| io.call.event_loop }
|
38
38
|
end
|
39
39
|
|
40
40
|
private
|
@@ -1,31 +1,33 @@
|
|
1
1
|
module Vedeu
|
2
2
|
class Process
|
3
3
|
class << self
|
4
|
-
def
|
5
|
-
new.
|
4
|
+
def main_sequence(interfaces = nil)
|
5
|
+
new(interfaces).main_sequence
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
-
def initialize
|
10
|
-
|
11
|
-
|
12
|
-
while true do
|
13
|
-
command = evaluate
|
9
|
+
def initialize(interfaces = nil)
|
10
|
+
@interfaces = interfaces
|
11
|
+
end
|
14
12
|
|
15
|
-
|
13
|
+
def main_sequence
|
14
|
+
initial_state
|
16
15
|
|
17
|
-
|
18
|
-
end
|
16
|
+
event_loop
|
19
17
|
end
|
20
18
|
|
21
19
|
private
|
22
20
|
|
23
|
-
def
|
24
|
-
|
21
|
+
def event_loop
|
22
|
+
interfaces.event_loop
|
23
|
+
end
|
24
|
+
|
25
|
+
def initial_state
|
26
|
+
interfaces.initial_state
|
25
27
|
end
|
26
28
|
|
27
|
-
def
|
28
|
-
|
29
|
+
def interfaces
|
30
|
+
@interfaces ||= Interfaces.default
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
data/lib/vedeu/version.rb
CHANGED
@@ -2,10 +2,10 @@ require_relative '../../test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
describe Application do
|
5
|
-
let(:described_class){ Application }
|
6
|
-
let(:instance)
|
7
|
-
let(:interfaces)
|
8
|
-
let(:options)
|
5
|
+
let(:described_class) { Application }
|
6
|
+
let(:instance) { described_class.new(interfaces, options) }
|
7
|
+
let(:interfaces) {}
|
8
|
+
let(:options) { {} }
|
9
9
|
|
10
10
|
describe '#start' do
|
11
11
|
before { Esc.stubs(:clear).returns('') }
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative '../../../test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
describe Dummy do
|
5
|
+
let(:described_class) { Dummy }
|
6
|
+
let(:instance) { described_class.new }
|
7
|
+
|
8
|
+
describe '#initial_state' do
|
9
|
+
subject { instance.initial_state }
|
10
|
+
|
11
|
+
it { subject.must_be_instance_of(NilClass) }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#input' do
|
15
|
+
subject { instance.input }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#output' do
|
19
|
+
subject { instance.output }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -2,75 +2,39 @@ require_relative '../../../test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
describe Interface do
|
5
|
-
let(:described_class)
|
6
|
-
let(:instance)
|
7
|
-
let(:options)
|
5
|
+
let(:described_class) { Interface }
|
6
|
+
let(:instance) { described_class.new(options) }
|
7
|
+
let(:options) { {} }
|
8
8
|
|
9
9
|
before do
|
10
10
|
Terminal.stubs(:width).returns(80)
|
11
11
|
Terminal.stubs(:height).returns(25)
|
12
|
-
Terminal.stubs(:show_cursor)
|
13
|
-
Terminal.stubs(:hide_cursor)
|
14
12
|
end
|
15
13
|
|
16
14
|
it { instance.must_be_instance_of(Interface) }
|
17
15
|
|
18
|
-
describe '#
|
19
|
-
subject { instance.
|
16
|
+
describe '#initial_state' do
|
17
|
+
subject { instance.initial_state }
|
20
18
|
|
21
|
-
|
22
|
-
let(:io) { capture_io { subject }.join }
|
23
|
-
|
24
|
-
it { io.must_be_instance_of(String) }
|
25
|
-
end
|
19
|
+
it { proc { subject }.must_raise(NotImplementedError) }
|
26
20
|
end
|
27
21
|
|
28
|
-
describe '#
|
29
|
-
subject { instance.
|
30
|
-
|
31
|
-
it { subject.must_be_instance_of(NilClass) }
|
22
|
+
describe '#event_loop' do
|
23
|
+
subject { instance.event_loop }
|
32
24
|
|
33
|
-
|
34
|
-
let(:io) { capture_io { subject }.join }
|
35
|
-
|
36
|
-
it { io.must_be_instance_of(String) }
|
37
|
-
end
|
25
|
+
it { skip }
|
38
26
|
end
|
39
27
|
|
40
28
|
describe '#input' do
|
41
29
|
subject { instance.input }
|
42
30
|
|
43
|
-
it {
|
44
|
-
|
45
|
-
context 'capturing output' do
|
46
|
-
let(:io) { capture_io { subject }.join }
|
47
|
-
|
48
|
-
it { io.must_be_instance_of(String) }
|
49
|
-
end
|
31
|
+
it { skip }
|
50
32
|
end
|
51
33
|
|
52
34
|
describe '#output' do
|
53
35
|
subject { instance.output }
|
54
36
|
|
55
|
-
it {
|
56
|
-
|
57
|
-
context 'capturing output' do
|
58
|
-
let(:io) { capture_io { subject }.join }
|
59
|
-
|
60
|
-
it { io.must_be_instance_of(String) }
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe '#width' do
|
65
|
-
subject { instance.width }
|
66
|
-
|
67
|
-
it { subject.must_be_instance_of(Fixnum) }
|
68
|
-
end
|
69
|
-
|
70
|
-
describe '#height' do
|
71
|
-
subject { instance.height }
|
72
|
-
|
73
|
-
it { subject.must_be_instance_of(Fixnum) }
|
37
|
+
it { skip }
|
74
38
|
end
|
75
39
|
end
|
76
40
|
end
|
@@ -48,14 +48,14 @@ module Vedeu
|
|
48
48
|
it { subject.must_be_instance_of(Hash) }
|
49
49
|
end
|
50
50
|
|
51
|
-
describe '#
|
52
|
-
subject { instance.
|
51
|
+
describe '#initial_state' do
|
52
|
+
subject { instance.initial_state }
|
53
53
|
|
54
54
|
it { subject.must_be_instance_of(Array) }
|
55
55
|
end
|
56
56
|
|
57
|
-
describe '#
|
58
|
-
subject { instance.
|
57
|
+
describe '#event_loop' do
|
58
|
+
subject { instance.event_loop }
|
59
59
|
|
60
60
|
it { subject.must_be_instance_of(Array) }
|
61
61
|
end
|
@@ -47,16 +47,4 @@ module Vedeu
|
|
47
47
|
it { subject.must_be_instance_of(String) }
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|
51
|
-
describe Exit do
|
52
|
-
let(:described_class) { Exit }
|
53
|
-
|
54
|
-
describe '.dispatch' do
|
55
|
-
subject { described_class.dispatch }
|
56
|
-
|
57
|
-
it { subject.must_be_instance_of(Symbol) }
|
58
|
-
|
59
|
-
it { subject.must_equal(:stop) }
|
60
|
-
end
|
61
|
-
end
|
62
50
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative '../../../test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
describe Exit do
|
5
|
+
let(:described_class) { Exit }
|
6
|
+
|
7
|
+
describe '.dispatch' do
|
8
|
+
subject { described_class.dispatch }
|
9
|
+
|
10
|
+
it { subject.must_be_instance_of(Symbol) }
|
11
|
+
|
12
|
+
it { subject.must_equal(:stop) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -2,9 +2,8 @@ require_relative '../../../test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
describe Process do
|
5
|
-
let(:described_class)
|
6
|
-
let(:instance)
|
7
|
-
let(:block) {}
|
5
|
+
let(:described_class) { Process }
|
6
|
+
let(:instance) { described_class.new }
|
8
7
|
|
9
8
|
it { instance.must_be_instance_of(Process) }
|
10
9
|
end
|
@@ -5,28 +5,20 @@ trap('INT') { exit! }
|
|
5
5
|
|
6
6
|
require_relative '../../../../lib/vedeu'
|
7
7
|
|
8
|
-
# define an interface
|
9
|
-
# Vedeu::Interfaces.define do |interface|
|
10
|
-
# interface.add("", ...)
|
11
|
-
# end
|
12
|
-
|
13
8
|
class Fake
|
14
9
|
def self.dispatch
|
15
10
|
puts "Fake dispatched..."
|
16
11
|
[
|
17
|
-
[[
|
18
|
-
[[:
|
12
|
+
[[17, 6], [:red, :white], "Fake executed...", :reset],
|
13
|
+
[[19, 5], [:green, :white], "Test executed...", :reset],
|
19
14
|
]
|
20
15
|
end
|
21
16
|
end
|
22
17
|
|
23
|
-
# use default interface
|
24
18
|
Vedeu::Interfaces.default
|
25
19
|
|
26
|
-
# define some commands
|
27
20
|
Vedeu::Commands.define do |command|
|
28
21
|
command.add("test", Fake)
|
29
22
|
end
|
30
23
|
|
31
|
-
# create main loop
|
32
24
|
Vedeu::Application.start
|
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.0.
|
4
|
+
version: 0.0.5
|
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-05-
|
11
|
+
date: 2014-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -154,6 +154,7 @@ files:
|
|
154
154
|
- bin/vedeu
|
155
155
|
- lib/vedeu.rb
|
156
156
|
- lib/vedeu/application.rb
|
157
|
+
- lib/vedeu/interface/dummy.rb
|
157
158
|
- lib/vedeu/interface/interface.rb
|
158
159
|
- lib/vedeu/interface/interfaces.rb
|
159
160
|
- lib/vedeu/output/background.rb
|
@@ -168,10 +169,12 @@ files:
|
|
168
169
|
- lib/vedeu/output/translator.rb
|
169
170
|
- lib/vedeu/process/command.rb
|
170
171
|
- lib/vedeu/process/commands.rb
|
172
|
+
- lib/vedeu/process/exit.rb
|
171
173
|
- lib/vedeu/process/process.rb
|
172
174
|
- lib/vedeu/support/terminal.rb
|
173
175
|
- lib/vedeu/version.rb
|
174
176
|
- test/lib/vedeu/application_test.rb
|
177
|
+
- test/lib/vedeu/interface/dummy_test.rb
|
175
178
|
- test/lib/vedeu/interface/interface_test.rb
|
176
179
|
- test/lib/vedeu/interface/interfaces_test.rb
|
177
180
|
- test/lib/vedeu/output/background_test.rb
|
@@ -186,6 +189,7 @@ files:
|
|
186
189
|
- test/lib/vedeu/output/translator_test.rb
|
187
190
|
- test/lib/vedeu/process/command_test.rb
|
188
191
|
- test/lib/vedeu/process/commands_test.rb
|
192
|
+
- test/lib/vedeu/process/exit_test.rb
|
189
193
|
- test/lib/vedeu/process/process_test.rb
|
190
194
|
- test/lib/vedeu/support/terminal_test.rb
|
191
195
|
- test/lib/vedeu/version_test.rb
|
@@ -218,6 +222,7 @@ specification_version: 4
|
|
218
222
|
summary: A terminal case of wonderland.
|
219
223
|
test_files:
|
220
224
|
- test/lib/vedeu/application_test.rb
|
225
|
+
- test/lib/vedeu/interface/dummy_test.rb
|
221
226
|
- test/lib/vedeu/interface/interface_test.rb
|
222
227
|
- test/lib/vedeu/interface/interfaces_test.rb
|
223
228
|
- test/lib/vedeu/output/background_test.rb
|
@@ -232,6 +237,7 @@ test_files:
|
|
232
237
|
- test/lib/vedeu/output/translator_test.rb
|
233
238
|
- test/lib/vedeu/process/command_test.rb
|
234
239
|
- test/lib/vedeu/process/commands_test.rb
|
240
|
+
- test/lib/vedeu/process/exit_test.rb
|
235
241
|
- test/lib/vedeu/process/process_test.rb
|
236
242
|
- test/lib/vedeu/support/terminal_test.rb
|
237
243
|
- test/lib/vedeu/version_test.rb
|