vedeu 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -2
- data/Rakefile +8 -0
- data/bin/vedeu +1 -1
- data/config/cucumber.yml +8 -0
- data/features/getting_started.feature +10 -0
- data/features/step_definitions/vedeu_steps.rb +11 -0
- data/features/support/env.rb +12 -0
- data/lib/vedeu.rb +30 -9
- data/lib/vedeu/application.rb +1 -1
- data/lib/vedeu/launcher.rb +26 -0
- data/lib/vedeu/output/colour.rb +1 -1
- data/lib/vedeu/output/compositor.rb +9 -6
- data/lib/vedeu/output/directive.rb +1 -1
- data/lib/vedeu/output/geometry.rb +1 -1
- data/lib/vedeu/output/position.rb +2 -2
- data/lib/vedeu/output/style.rb +1 -1
- data/lib/vedeu/output/wordwrap.rb +2 -1
- data/lib/vedeu/process/event_loop.rb +2 -2
- data/lib/vedeu/process/input.rb +30 -0
- data/lib/vedeu/repository/command.rb +32 -0
- data/lib/vedeu/repository/command_repository.rb +27 -0
- data/lib/vedeu/{process → repository}/dummy_command.rb +2 -2
- data/lib/vedeu/repository/dummy_interface.rb +4 -0
- data/lib/vedeu/repository/interface.rb +52 -0
- data/lib/vedeu/repository/interface_repository.rb +49 -0
- data/lib/vedeu/repository/repository.rb +35 -0
- data/lib/vedeu/repository/storage.rb +46 -0
- data/lib/vedeu/support/terminal.rb +5 -6
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/application_test.rb +1 -1
- data/test/lib/vedeu/output/compositor_test.rb +15 -13
- data/test/lib/vedeu/output/directive_test.rb +1 -1
- data/test/lib/vedeu/output/position_test.rb +1 -1
- data/test/lib/vedeu/process/event_loop_test.rb +2 -3
- data/test/lib/vedeu/process/input_test.rb +19 -0
- data/test/lib/vedeu/repository/command_repository_test.rb +55 -0
- data/test/lib/vedeu/repository/command_test.rb +39 -0
- data/test/lib/vedeu/repository/interface_repository_test.rb +71 -0
- data/test/lib/vedeu/repository/interface_test.rb +65 -0
- data/test/lib/vedeu/repository/repository_test.rb +88 -0
- data/test/lib/vedeu/repository/storage_test.rb +50 -0
- data/test/test_helper.rb +8 -0
- data/vedeu.gemspec +3 -0
- metadata +75 -21
- data/lib/vedeu/interface/dummy_interface.rb +0 -14
- data/lib/vedeu/interface/interface.rb +0 -57
- data/lib/vedeu/interface/interfaces.rb +0 -66
- data/lib/vedeu/process/command.rb +0 -51
- data/lib/vedeu/process/commands.rb +0 -35
- data/test/lib/vedeu/interface/dummy_test.rb +0 -22
- data/test/lib/vedeu/interface/interface_test.rb +0 -45
- data/test/lib/vedeu/interface/interfaces_test.rb +0 -108
- data/test/lib/vedeu/process/command_test.rb +0 -48
- data/test/lib/vedeu/process/commands_test.rb +0 -56
- data/test/lib/vedeu/process/dummy_command_test.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91075694e8c8b20c64f154ab41f71176a871ca64
|
4
|
+
data.tar.gz: 1637599541bcad4e9895c55d58e2a180a0fe8f06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b552c855f7c1b9d1774324ca2435d99dc85ed85bc5622a22b8284ee216dc93c5fe7f31c188cd19ce697085a821adae90f2359f49658e33acf4df268c34c93e73
|
7
|
+
data.tar.gz: f63e7b4cfff15aa2a65a6da620effc55c60544426fb50b334326adbe555f2f2ae6422a537742fe263185ed8cf53de570e8160db9ff3a566c4cfee23774f2a886
|
data/README.md
CHANGED
@@ -25,9 +25,10 @@ TODO: Write detailed documentation
|
|
25
25
|
## Notes
|
26
26
|
|
27
27
|
Application
|
28
|
-
|--
|
29
|
-
| |--
|
28
|
+
|-- EventLoop
|
29
|
+
| |-- InterfaceRepository
|
30
30
|
|
|
31
|
+
|-- InterfaceRepository
|
31
32
|
|-- Terminal
|
32
33
|
|
33
34
|
Base
|
@@ -37,6 +38,8 @@ TODO: Write detailed documentation
|
|
37
38
|
Interface
|
38
39
|
|-- Commands
|
39
40
|
| |-- Command
|
41
|
+
| | |-- CommandRepository
|
42
|
+
| |
|
40
43
|
| |-- Exit
|
41
44
|
|
|
42
45
|
|-- Compositor
|
@@ -51,6 +54,7 @@ TODO: Write detailed documentation
|
|
51
54
|
| | |-- Style
|
52
55
|
| | |-- Esc
|
53
56
|
| |
|
57
|
+
| |-- InterfaceRepository
|
54
58
|
| |-- Position
|
55
59
|
| | |-- Esc
|
56
60
|
| |
|
@@ -60,6 +64,9 @@ TODO: Write detailed documentation
|
|
60
64
|
|-- Geometry
|
61
65
|
| |-- Terminal
|
62
66
|
|
|
67
|
+
|-- Input
|
68
|
+
|-- InterfaceRepository
|
69
|
+
|-- Position
|
63
70
|
|-- Terminal
|
64
71
|
|
65
72
|
Terminal
|
@@ -87,6 +94,18 @@ These numbers are based on the area available to the terminal. If the terminal i
|
|
87
94
|
]
|
88
95
|
]
|
89
96
|
|
97
|
+
## Usage
|
98
|
+
|
99
|
+
class MyApp
|
100
|
+
include Vedeu
|
101
|
+
|
102
|
+
interface :status, geometry: { y: 1, x: 1, width: :auto, height: 1 }
|
103
|
+
interface :main, geometry: { y: 2, x: 1, width: :auto, height: :auto }
|
104
|
+
|
105
|
+
command :exit, Vedeu::Exit.dispatch, { keyword: "exit", keypress: "q" }
|
106
|
+
command :help, MyApp.help, { keyword: "help", keypress: "h" }
|
107
|
+
end
|
108
|
+
|
90
109
|
## Contributing
|
91
110
|
|
92
111
|
1. Fork it ( http://github.com/<my-github-username>/vedeu/fork )
|
data/Rakefile
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rake/testtask"
|
3
|
+
require 'cucumber'
|
4
|
+
require 'cucumber/rake/task'
|
5
|
+
|
6
|
+
Cucumber::Rake::Task.new(:cucumber) do |t|
|
7
|
+
t.cucumber_opts = "features --format progress"
|
8
|
+
end
|
3
9
|
|
4
10
|
Rake::TestTask.new do |t|
|
5
11
|
t.libs << 'lib/vedeu'
|
@@ -9,3 +15,5 @@ Rake::TestTask.new do |t|
|
|
9
15
|
end
|
10
16
|
|
11
17
|
task :default => :test
|
18
|
+
|
19
|
+
Rake::Task['cucumber'].execute
|
data/bin/vedeu
CHANGED
data/config/cucumber.yml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<%
|
2
|
+
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
3
|
+
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
4
|
+
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'rerun'} --strict --tags ~@wip --tags ~@ok --tags ~@pending --tags ~@failing"
|
5
|
+
%>
|
6
|
+
default: <%= std_opts %> features --format rerun
|
7
|
+
wip: --tags @wip:99 --wip features --format pretty
|
8
|
+
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Given(/^the interface "(.*?)" is defined$/) do |interface|
|
2
|
+
Vedeu::Interface.create({ name: interface, klass: Vedeu::DummyInterface, options: {} })
|
3
|
+
end
|
4
|
+
|
5
|
+
Given(/^the command "(.*?)" is defined$/) do |command|
|
6
|
+
Vedeu::Command.create({ name: command, klass: Vedeu::DummyCommand, options: { keyword: command } })
|
7
|
+
end
|
8
|
+
|
9
|
+
When(/^the input "(.*?)" is entered$/) do |input|
|
10
|
+
pending
|
11
|
+
end
|
@@ -0,0 +1,12 @@
|
|
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
|
data/lib/vedeu.rb
CHANGED
@@ -18,23 +18,44 @@ require_relative 'vedeu/output/style'
|
|
18
18
|
require_relative 'vedeu/output/translator'
|
19
19
|
require_relative 'vedeu/output/wordwrap'
|
20
20
|
|
21
|
-
require_relative 'vedeu/interface/interfaces'
|
22
|
-
require_relative 'vedeu/interface/interface'
|
23
|
-
require_relative 'vedeu/interface/dummy_interface'
|
24
|
-
|
25
|
-
require_relative 'vedeu/process/dummy_command'
|
26
|
-
require_relative 'vedeu/process/commands'
|
27
|
-
require_relative 'vedeu/process/command'
|
28
21
|
require_relative 'vedeu/process/event_loop'
|
29
22
|
require_relative 'vedeu/process/exit'
|
23
|
+
require_relative 'vedeu/process/input'
|
24
|
+
|
25
|
+
require_relative 'vedeu/repository/repository'
|
26
|
+
require_relative 'vedeu/repository/command_repository'
|
27
|
+
require_relative 'vedeu/repository/command'
|
28
|
+
require_relative 'vedeu/repository/interface_repository'
|
29
|
+
require_relative 'vedeu/repository/interface'
|
30
|
+
require_relative 'vedeu/repository/storage'
|
31
|
+
require_relative 'vedeu/repository/dummy_interface'
|
32
|
+
require_relative 'vedeu/repository/dummy_command'
|
30
33
|
|
31
34
|
require_relative 'vedeu/application'
|
35
|
+
require_relative 'vedeu/launcher'
|
32
36
|
require_relative 'vedeu/version'
|
33
37
|
|
34
38
|
module Vedeu
|
39
|
+
module ClassMethods
|
40
|
+
def interface(name, options = {})
|
41
|
+
interface_name = name.is_a?(Symbol) ? name.to_s : name
|
42
|
+
|
43
|
+
Interface.create({ name: interface_name, options: options })
|
44
|
+
end
|
45
|
+
|
46
|
+
def command(name, klass, options = {})
|
47
|
+
command_name = name.is_a?(Symbol) ? name.to_s : name
|
48
|
+
|
49
|
+
Command.create({ name: command_name, klass: klass, options: options })
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.included(receiver)
|
54
|
+
receiver.extend(ClassMethods)
|
55
|
+
end
|
56
|
+
|
35
57
|
def self.logger
|
36
|
-
@logger ||= Logger
|
37
|
-
.new(root_path + '/logs/vedeu.log').tap do |log|
|
58
|
+
@logger ||= Logger.new(root_path + '/logs/vedeu.log').tap do |log|
|
38
59
|
log.formatter = proc do |mode, time, prog, msg|
|
39
60
|
"\n#{time.iso8601}: #{msg}\n"
|
40
61
|
end
|
data/lib/vedeu/application.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Vedeu
|
2
|
+
class Launcher
|
3
|
+
def initialize(argv, stdin = STDIN,
|
4
|
+
stdout = STDOUT,
|
5
|
+
stderr = STDERR,
|
6
|
+
kernel = Kernel)
|
7
|
+
@argv = argv
|
8
|
+
@stdin = stdin
|
9
|
+
@stdout = stdout
|
10
|
+
@stderr = stderr
|
11
|
+
@kernel = kernel
|
12
|
+
@exit_code = 1
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute!
|
16
|
+
$stdin, $stdout, $stderr = @stdin, @stdout, @stderr
|
17
|
+
|
18
|
+
Vedeu::Application.start
|
19
|
+
|
20
|
+
@exit_code = 0
|
21
|
+
ensure
|
22
|
+
$stdin, $stdout, $stderr = STDIN, STDOUT, STDERR
|
23
|
+
@kernel.exit(@exit_code)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/vedeu/output/colour.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
module Vedeu
|
2
|
+
class UndefinedInterface < StandardError; end
|
3
|
+
|
2
4
|
class Compositor
|
3
5
|
class << self
|
4
|
-
def arrange(output = [], interface =
|
6
|
+
def arrange(output = [], interface = 'dummy')
|
5
7
|
return if output.nil? || output.empty?
|
6
8
|
|
7
9
|
if output.is_a?(Array)
|
@@ -14,8 +16,9 @@ module Vedeu
|
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
17
|
-
def initialize(output = [], interface =
|
18
|
-
@output
|
19
|
+
def initialize(output = [], interface = 'dummy')
|
20
|
+
@output = output || []
|
21
|
+
@interface = interface
|
19
22
|
end
|
20
23
|
|
21
24
|
def arrange
|
@@ -26,7 +29,7 @@ module Vedeu
|
|
26
29
|
|
27
30
|
def composition
|
28
31
|
container = []
|
29
|
-
streams
|
32
|
+
streams = []
|
30
33
|
output.map do |line|
|
31
34
|
line.each_with_index do |stream, index|
|
32
35
|
streams << clear(index)
|
@@ -43,7 +46,7 @@ module Vedeu
|
|
43
46
|
end
|
44
47
|
|
45
48
|
def origin(index)
|
46
|
-
|
49
|
+
target_interface.origin(index)
|
47
50
|
end
|
48
51
|
|
49
52
|
def width
|
@@ -65,7 +68,7 @@ module Vedeu
|
|
65
68
|
end
|
66
69
|
|
67
70
|
def interface
|
68
|
-
@_interface ||=
|
71
|
+
@_interface ||= InterfaceRepository.find_by_name(@interface)
|
69
72
|
end
|
70
73
|
end
|
71
74
|
end
|
data/lib/vedeu/output/style.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
module Vedeu
|
2
|
+
class Input
|
3
|
+
class << self
|
4
|
+
def evaluate(input, args = [])
|
5
|
+
new(input, args).evaluate
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(input, args = [])
|
10
|
+
@input = input
|
11
|
+
@args = args || []
|
12
|
+
end
|
13
|
+
|
14
|
+
def evaluate
|
15
|
+
command.execute(*args) if exists?
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
attr_reader :input, :args
|
21
|
+
|
22
|
+
def exists?
|
23
|
+
command.is_a?(Command)
|
24
|
+
end
|
25
|
+
|
26
|
+
def command
|
27
|
+
@command ||= CommandRepository.find_by_input(input)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Vedeu
|
2
|
+
class Command
|
3
|
+
attr_accessor :id, :attributes, :name, :klass, :keyword, :keypress
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def create(attributes = {})
|
7
|
+
new(attributes).create
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(attributes = {})
|
12
|
+
@attributes = attributes || {}
|
13
|
+
@name = attributes[:name]
|
14
|
+
@klass = attributes[:klass]
|
15
|
+
@keyword = attributes.fetch(:options, {}).fetch(:keyword, "")
|
16
|
+
@keypress = attributes.fetch(:options, {}).fetch(:keypress, "")
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
CommandRepository.create(self)
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
24
|
+
def execute(args = [])
|
25
|
+
executable.call(*args)
|
26
|
+
end
|
27
|
+
|
28
|
+
def executable
|
29
|
+
Proc.new { |*args| attributes[:klass].dispatch(*args) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Vedeu
|
2
|
+
class CommandRepository
|
3
|
+
extend Repository
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def find_by_input(input)
|
7
|
+
return nil if input.nil? || input.empty?
|
8
|
+
return by_keypress(input) if input.size == 1
|
9
|
+
return by_keyword(input) if input.size > 1
|
10
|
+
end
|
11
|
+
|
12
|
+
def klass
|
13
|
+
Command
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def by_keypress(input)
|
19
|
+
query(klass, :keypress, input)
|
20
|
+
end
|
21
|
+
|
22
|
+
def by_keyword(input)
|
23
|
+
query(klass, :keyword, input)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|