vedeu 0.0.24 → 0.0.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +75 -2
  3. data/bin/composition +3 -1
  4. data/examples/single_interface_app.rb +46 -0
  5. data/lib/vedeu.rb +16 -4
  6. data/lib/vedeu/application.rb +34 -3
  7. data/lib/vedeu/configuration.rb +31 -0
  8. data/lib/vedeu/launcher.rb +11 -1
  9. data/lib/vedeu/output/colour.rb +3 -7
  10. data/lib/vedeu/output/cursor.rb +2 -6
  11. data/lib/vedeu/output/esc.rb +0 -1
  12. data/lib/vedeu/output/geometry.rb +0 -4
  13. data/lib/vedeu/output/menu.rb +26 -0
  14. data/lib/vedeu/process/process.rb +1 -1
  15. data/lib/vedeu/repository/command.rb +5 -4
  16. data/lib/vedeu/repository/command_repository.rb +5 -6
  17. data/lib/vedeu/repository/storage.rb +3 -1
  18. data/lib/vedeu/support/options.rb +4 -0
  19. data/lib/vedeu/support/queue.rb +0 -1
  20. data/lib/vedeu/support/terminal.rb +2 -2
  21. data/lib/vedeu/version.rb +1 -1
  22. data/logs/.gitkeep +0 -0
  23. data/test/lib/vedeu/application_test.rb +18 -3
  24. data/test/lib/vedeu/configuration_test.rb +38 -0
  25. data/test/lib/vedeu/output/compositor_test.rb +1 -1
  26. data/test/lib/vedeu/output/cursor_test.rb +4 -4
  27. data/test/lib/vedeu/output/menu_test.rb +13 -0
  28. data/test/lib/vedeu/process/process_test.rb +2 -2
  29. data/test/lib/vedeu/repository/command_test.rb +11 -4
  30. data/test/lib/vedeu/support/json_parser_test.rb +2 -3
  31. data/test/test_helper.rb +1 -0
  32. data/vedeu.gemspec +1 -1
  33. metadata +12 -10
  34. data/.rubocop.yml +0 -2
  35. data/lib/vedeu/output/renderer.rb +0 -6
  36. data/lib/vedeu/support/event_loop.rb +0 -33
  37. data/test/lib/vedeu/output/renderer_test.rb +0 -13
  38. data/test/lib/vedeu/support/event_loop_test.rb +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 046d21e705590582e93e96ebd7be2301265256ea
4
- data.tar.gz: 0582a4583fb725376874b6b41c1d1508df473a35
3
+ metadata.gz: 5a6b5d80f3321da207ef185b7437f50b5e31aaaf
4
+ data.tar.gz: b6ca2fdd18c9912f54bfcf5629d293e9dd2e5468
5
5
  SHA512:
6
- metadata.gz: dd1aba71fdd4b148133c76e5e8e3506ab3a60c98c4e9167e68e8ab47329e641762d34a7f2ec3f1191a28745a37dac5aa21a5e6052de152f186c4053ea10519fd
7
- data.tar.gz: bc2fba75fb393c82a0b6ef51d62fd6c3e7614010a432259cd8bc18ba779c464f5341e1c0cc5b540cd052415551ef38547388c2c4c9e4d143104ca54a96fcb165
6
+ metadata.gz: 6411a9e56a0eb82187442214a9fe95cbde95cdba99370e94888ce60f23dfa1383d9d966d9d3114fcf5e52f769044a6430e69ad7fd4f95d15f6dd13fb83700fe2
7
+ data.tar.gz: db041a47634fbe157be6f23c4ddb920a6b853aa1be20b4bb6528229e64bc3abdcd535deb9b0965ce3a8191c3673b089c8c94d9ecdf6a4b3d6526a8941676e2c9
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Vedeu
4
4
 
5
- Vedeu is my attempt at creating a terminal based application framework without the need for Ncurses.
5
+ Vedeu is my attempt at creating a terminal based application framework without the need for Ncurses. I've tried to make Vedeu as simple and flexible as possible.
6
6
 
7
7
 
8
8
  ## Installation
@@ -17,7 +17,80 @@ And then execute:
17
17
 
18
18
  ## Usage
19
19
 
20
- Expect documentation soon!
20
+ Expect proper documentation soon!
21
+
22
+ ### Getting Started
23
+
24
+ require 'vedeu'
25
+
26
+ class MyApp
27
+ include Vedeu
28
+
29
+ interface :main, { }
30
+
31
+ command :exit, { entity: SomeClass,
32
+ keypress: 'q',
33
+ keyword: 'quit' }
34
+ end
35
+
36
+ ### On Defining Interfaces
37
+
38
+ interface :main, {
39
+ y: 1,
40
+ x: 1,
41
+ width: :auto, # will set to terminal width
42
+ height: 10, # also accepts :auto
43
+ foreground: :white,
44
+ background: :black,
45
+ cursor: false,
46
+ layer: 0 }
47
+
48
+ Referring to the above example, interfaces have a name, and various default attributes.
49
+
50
+ `:y` sets the starting row point. (See Geometry)
51
+ `:x` sets the starting column point.
52
+ `:width` sets how many characters wide the interface will be.
53
+ `:height` sets how many characters tall the interface will be.
54
+
55
+ `:foreground` sets the default foreground colour. (See Colours)
56
+ `:background` sets the default background colour.
57
+
58
+ `:cursor` a boolean specifying whether the cursor should show.
59
+
60
+ `:layer` an integer specifying the z-index of the interface.
61
+ (See Layers)
62
+
63
+ ### On Defining Commands
64
+
65
+ command :do_something, {
66
+ entity: SomeClass,
67
+ keypress: 's',
68
+ keyword: 'start',
69
+ arguments: [:some, { :values => :here }, "etc"] }
70
+
71
+ As above, commands have a name, a class which performs the action
72
+ (you define this), and they can be invoked with a keypress or a keyword. At this time, Vedeu will call the `.dispatch` method on your class, passing any arguments you originally defined in the command. In the future, both the method called and the arguments could be dynamic.
73
+
74
+
75
+ ### Geometry
76
+
77
+ Geometry for Vedeu, as the same for ANSI terminals, is set top-left, which is point 1, 1. Interfaces have internal geometry which is handled automatically. Unless you are doing something special, you will probably only set it on a per-interface basis.
78
+
79
+
80
+ ### Colours
81
+
82
+ Vedeu uses the standard ANSI terminal colours, though you can also set arbitrary colours using HTML/CSS style notation (i.e. '#aadd00').
83
+
84
+ :black, :red, :green, :yellow, :blue, :magenta, :cyan, :white, :default
85
+
86
+
87
+ ### Layers
88
+
89
+ Vedeu allows the overlaying of interfaces. To render these correctly,
90
+ Vedeu uses two rules.
91
+
92
+ 1) The :layer value. 0 would be default, or bottom. 1 would be placed on top of 0. 2 on top of 1, and so on.
93
+ 2) If two interfaces occupy the same 'space', the interface which was defined last, wins.
21
94
 
22
95
 
23
96
  ## Contributing
data/bin/composition CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- $:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib')
2
+ lib_dir = File.dirname(__FILE__) + '/../lib'
3
+
4
+ $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
3
5
 
4
6
  -> { its -> { a } }
5
7
  trap('INT') { exit! }
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'vedeu'
4
+
5
+ class SingleInterfaceApp
6
+ include Vedeu
7
+
8
+ interface :main, {
9
+ y: 1,
10
+ x: 1,
11
+ width: :auto,
12
+ height: :auto,
13
+ foreground: :white,
14
+ background: :black,
15
+ cursor: true,
16
+ layer: 0 }
17
+
18
+ command :refresh, {
19
+ entity: SingleInterfaceApp,
20
+ keyword: 'refresh',
21
+ keypress: 'r',
22
+ arguments: [] }
23
+ command :exit, {
24
+ entity: Vedeu::Exit,
25
+ keyword: 'exit',
26
+ keypress: 'q',
27
+ arguments: [] }
28
+
29
+ def self.start
30
+ Vedeu::Launcher.new(ARGV.dup).execute!
31
+ end
32
+
33
+ def self.dispatch
34
+ {
35
+ 'main' => [
36
+ [
37
+ {
38
+ :text => "The time is: #{Time.now}.",
39
+ }
40
+ ]
41
+ ]
42
+ }
43
+ end
44
+ end
45
+
46
+ SingleInterfaceApp.start
data/lib/vedeu.rb CHANGED
@@ -2,11 +2,11 @@ require 'date'
2
2
  require 'logger'
3
3
  require 'io/console'
4
4
  require 'oj'
5
+ require 'optparse'
5
6
  require 'virtus'
6
7
 
7
8
  require_relative 'vedeu/input/input'
8
9
 
9
- require_relative 'vedeu/support/event_loop'
10
10
  require_relative 'vedeu/support/exit'
11
11
  require_relative 'vedeu/support/json_parser'
12
12
  require_relative 'vedeu/support/queue'
@@ -27,11 +27,11 @@ require_relative 'vedeu/output/directive'
27
27
  require_relative 'vedeu/output/foreground'
28
28
  require_relative 'vedeu/output/geometry'
29
29
  require_relative 'vedeu/output/layer'
30
+ require_relative 'vedeu/output/menu'
30
31
  require_relative 'vedeu/output/esc'
31
32
  require_relative 'vedeu/output/colour'
32
33
  require_relative 'vedeu/output/output'
33
34
  require_relative 'vedeu/output/position'
34
- require_relative 'vedeu/output/renderer'
35
35
  require_relative 'vedeu/output/style'
36
36
  require_relative 'vedeu/output/translator'
37
37
  require_relative 'vedeu/output/wordwrap'
@@ -48,6 +48,7 @@ require_relative 'vedeu/repository/dummy_interface'
48
48
  require_relative 'vedeu/repository/dummy_command'
49
49
 
50
50
  require_relative 'vedeu/application'
51
+ require_relative 'vedeu/configuration'
51
52
  require_relative 'vedeu/launcher'
52
53
  require_relative 'vedeu/version'
53
54
 
@@ -60,9 +61,20 @@ module Vedeu
60
61
  end
61
62
  end
62
63
  end
63
- # :nocov:
64
64
 
65
- # :nocov:
65
+ def self.debug(filename = 'profile.html', &block)
66
+ RubyProf.start
67
+
68
+ yield
69
+
70
+ result = RubyProf.stop
71
+ result.eliminate_methods!([/^Array/, /^Hash/])
72
+
73
+ File.open(Vedeu.root_path + '/tmp/' + filename, 'w') do |file|
74
+ RubyProf::CallStackPrinter.new(result).print(file)
75
+ end
76
+ end
77
+
66
78
  def self.included(receiver)
67
79
  receiver.extend(ClassMethods)
68
80
  end
@@ -7,14 +7,14 @@ module Vedeu
7
7
  end
8
8
 
9
9
  def initialize(options = {})
10
- @options = options
10
+ @options = options || {}
11
11
  end
12
12
 
13
13
  def start
14
14
  Terminal.open(options) do
15
15
  Output.render
16
16
 
17
- EventLoop.main_sequence
17
+ runner { main_sequence }
18
18
  end
19
19
  ensure
20
20
  Terminal.close
@@ -24,12 +24,43 @@ module Vedeu
24
24
 
25
25
  attr_reader :options
26
26
 
27
+ def runner
28
+ if interactive?
29
+ interactive { yield }
30
+ else
31
+ run_once { yield }
32
+ end
33
+ end
34
+
35
+ def main_sequence
36
+ Input.capture
37
+
38
+ Process.evaluate
39
+
40
+ Output.render
41
+ end
42
+
43
+ def interactive?
44
+ options.fetch(:interactive)
45
+ end
46
+
47
+ def interactive
48
+ loop { yield }
49
+ rescue StopIteration
50
+ end
51
+
52
+ def run_once
53
+ yield
54
+ end
55
+
27
56
  def options
28
57
  defaults.merge!(@options)
29
58
  end
30
59
 
31
60
  def defaults
32
- {}
61
+ {
62
+ interactive: true
63
+ }
33
64
  end
34
65
  end
35
66
  end
@@ -0,0 +1,31 @@
1
+ module Vedeu
2
+ class Configuration
3
+ class << self
4
+ def configure(args = [])
5
+ new(args).configure
6
+ end
7
+ end
8
+
9
+ def initialize(args = [])
10
+ @args = args || []
11
+ @options = {}
12
+ end
13
+
14
+ def configure
15
+ parser = OptionParser.new do |opts|
16
+ opts.banner = "Usage: #{$PROGRAM_NAME} [options]"
17
+
18
+ opts.on("-1", "--run-once", "Run application once.") do
19
+ @options[:interactive] = false
20
+ end
21
+ end
22
+ parser.parse!(args)
23
+
24
+ options
25
+ end
26
+
27
+ private
28
+
29
+ attr_accessor :args, :options
30
+ end
31
+ end
@@ -16,7 +16,7 @@ module Vedeu
16
16
  def execute!
17
17
  $stdin, $stdout, $stderr = @stdin, @stdout, @stderr
18
18
 
19
- Application.start
19
+ Application.start(configuration)
20
20
 
21
21
  @exit_code = 0
22
22
  ensure
@@ -24,5 +24,15 @@ module Vedeu
24
24
  @kernel.exit(@exit_code)
25
25
  end
26
26
  # :nocov:
27
+
28
+ private
29
+
30
+ attr_reader :argv
31
+
32
+ # :nocov:
33
+ def configuration
34
+ Configuration.configure(argv)
35
+ end
36
+ # :nocov:
27
37
  end
28
38
  end
@@ -1,12 +1,11 @@
1
1
  module Vedeu
2
2
  class Colour
3
3
  class << self
4
- def define(pair = [])
4
+ def set(pair = [])
5
5
  return '' if pair.empty?
6
6
 
7
- new(pair).define
7
+ new(pair).set
8
8
  end
9
- alias_method :set, :define
10
9
 
11
10
  def reset
12
11
  new.reset
@@ -17,10 +16,9 @@ module Vedeu
17
16
  @pair = pair || []
18
17
  end
19
18
 
20
- def define
19
+ def set
21
20
  [foreground, background].join
22
21
  end
23
- alias_method :set, :define
24
22
 
25
23
  def reset
26
24
  [foreground(:default), background(:default)].join
@@ -29,12 +27,10 @@ module Vedeu
29
27
  def foreground(value = pair[0])
30
28
  @foreground ||= Foreground.escape_sequence(value)
31
29
  end
32
- alias_method :fg, :foreground
33
30
 
34
31
  def background(value = pair[1])
35
32
  @background ||= Background.escape_sequence(value)
36
33
  end
37
- alias_method :bg, :background
38
34
 
39
35
  private
40
36
 
@@ -25,29 +25,25 @@ module Vedeu
25
25
  def right(count = 1)
26
26
  [Esc.esc, "#{count || 1}", 'C'].join
27
27
  end
28
- alias_method :forward, :right
29
28
 
30
29
  def left(count = 1)
31
30
  [Esc.esc, "#{count || 1}", 'D'].join
32
31
  end
33
- alias_method :backward, :left
34
32
 
35
33
  def save
36
34
  [Esc.esc, 's'].join
37
35
  end
38
36
 
39
- def unsave
37
+ def restore
40
38
  [Esc.esc, 'u'].join
41
39
  end
42
- alias_method :restore, :unsave
43
40
 
44
41
  def save_all
45
42
  [Esc.esc, '7'].join
46
43
  end
47
44
 
48
- def unsave_all
45
+ def restore_all
49
46
  [Esc.esc, '8'].join
50
47
  end
51
- alias_method :restore_all, :unsave_all
52
48
  end
53
49
  end
@@ -13,7 +13,6 @@ module Vedeu
13
13
  def bold
14
14
  [esc, '1m'].join
15
15
  end
16
- alias_method :bright, :bold
17
16
 
18
17
  def bold_off
19
18
  [esc, '21m'].join
@@ -11,14 +11,10 @@ module Vedeu
11
11
  def y
12
12
  values[:y]
13
13
  end
14
- alias_method :row, :y
15
- alias_method :line, :y
16
14
 
17
15
  def x
18
16
  values[:x]
19
17
  end
20
- alias_method :column, :x
21
- alias_method :col, :x
22
18
 
23
19
  def width
24
20
  values[:width]
@@ -0,0 +1,26 @@
1
+ module Vedeu
2
+ class Menu
3
+ attr_accessor :label, :value
4
+
5
+ def initialize(attributes = {})
6
+ @attributes = attributes || {}
7
+ end
8
+
9
+ def label
10
+ attributes[:label] || defaults[:label]
11
+ end
12
+
13
+ def value
14
+ attributes[:value] || defaults[:value]
15
+ end
16
+
17
+ private
18
+
19
+ def defaults
20
+ {
21
+ label: '',
22
+ value: ''
23
+ }
24
+ end
25
+ end
26
+ end
@@ -9,7 +9,7 @@ module Vedeu
9
9
  def initialize; end
10
10
 
11
11
  def evaluate
12
- fail Collapse if result == :stop
12
+ fail StopIteration if result == :stop
13
13
 
14
14
  Compositor.arrange(result) unless no_result?
15
15
  end
@@ -2,10 +2,11 @@ module Vedeu
2
2
  class Command
3
3
  include Virtus.model
4
4
 
5
- attribute :name, String
6
- attribute :entity, Class
7
- attribute :keyword, String, default: ''
8
- attribute :keypress, String, default: ''
5
+ attribute :name, String
6
+ attribute :entity, Class
7
+ attribute :keyword, String, default: ''
8
+ attribute :keypress, String, default: ''
9
+ attribute :arguments, Array, default: []
9
10
 
10
11
  def execute(args = [])
11
12
  executable.call(*args)
@@ -22,13 +22,12 @@ module Vedeu
22
22
 
23
23
  # :nocov:
24
24
  module ClassMethods
25
- def command(name, entity, keypress = '', keyword = '')
25
+ def command(name, options = {})
26
+ command_name = name.is_a?(Symbol) ? name.to_s : name
27
+
26
28
  CommandRepository.create({
27
- name: name,
28
- entity: entity,
29
- keypress: keypress,
30
- keyword: keyword
31
- })
29
+ name: command_name
30
+ }.merge!(options))
32
31
  end
33
32
  end
34
33
  # :nocov:
@@ -34,8 +34,10 @@ module Vedeu
34
34
 
35
35
  private
36
36
 
37
+ attr_reader :map
38
+
37
39
  def map_for_class(entity)
38
- @map[entity.to_s.to_sym] ||= {}
40
+ map[entity.to_s.to_sym] ||= {}
39
41
  end
40
42
 
41
43
  def map_for(record)
@@ -0,0 +1,4 @@
1
+ module Vedeu
2
+ class Options
3
+ end
4
+ end
@@ -22,7 +22,6 @@ module Vedeu
22
22
  def clear
23
23
  store.clear
24
24
  end
25
- alias_method :reset, :clear
26
25
 
27
26
  def view
28
27
  store.inspect
@@ -43,7 +43,6 @@ module Vedeu
43
43
  yield instance
44
44
  end if block_given?
45
45
  end
46
- alias_method :open_cooked, :cooked
47
46
 
48
47
  def raw(instance, &block)
49
48
  console.raw do
@@ -52,7 +51,6 @@ module Vedeu
52
51
  yield instance
53
52
  end if block_given?
54
53
  end
55
- alias_method :open_raw, :raw
56
54
  # :nocov:
57
55
 
58
56
  def console
@@ -81,6 +79,8 @@ module Vedeu
81
79
  end
82
80
 
83
81
  def reset_position
82
+ puts
83
+
84
84
  clear_line(height - 1)
85
85
  end
86
86
  end
data/lib/vedeu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vedeu
2
- VERSION = '0.0.24'
2
+ VERSION = '0.0.25'
3
3
  end
data/logs/.gitkeep ADDED
File without changes
@@ -16,12 +16,27 @@ module Vedeu
16
16
  before do
17
17
  Terminal.stubs(:open).yields(self)
18
18
  Output.stubs(:render)
19
- EventLoop.stubs(:main_sequence)
19
+ Input.stubs(:capture)
20
+ Process.stubs(:evaluate)
20
21
  Terminal.stubs(:close)
21
22
  end
22
23
 
23
- it 'returns a NilClass' do
24
- subject.must_be_instance_of(NilClass)
24
+ context 'when the application should run interactively' do
25
+ let(:options) { { interactive: true } }
26
+
27
+ before { Process.stubs(:evaluate).raises(StopIteration) }
28
+
29
+ it 'returns a NilClass' do
30
+ subject.must_be_instance_of(NilClass)
31
+ end
32
+ end
33
+
34
+ context 'when the application should run once' do
35
+ let(:options) { { interactive: false } }
36
+
37
+ it 'returns a NilClass' do
38
+ subject.must_be_instance_of(NilClass)
39
+ end
25
40
  end
26
41
  end
27
42
  end
@@ -0,0 +1,38 @@
1
+ require_relative '../../test_helper'
2
+
3
+ module Vedeu
4
+ describe Configuration do
5
+ let(:described_class) { Configuration }
6
+ let(:described_instance) { described_class.new(args) }
7
+ let(:args) { [] }
8
+ let(:subject) { described_instance }
9
+
10
+ it 'returns a Configuration instance' do
11
+ subject.must_be_instance_of(Configuration)
12
+ end
13
+
14
+ it 'sets an instance variable' do
15
+ subject.instance_variable_get('@args').must_equal([])
16
+ end
17
+
18
+ it 'sets an instance variable' do
19
+ subject.instance_variable_get('@options').must_equal({})
20
+ end
21
+
22
+ describe '#configure' do
23
+ let(:subject) { described_class.configure(args) }
24
+
25
+ it 'returns a Hash' do
26
+ subject.must_be_instance_of(Hash)
27
+ end
28
+
29
+ context 'when the option is --run-once' do
30
+ let(:args) { ['--run-once'] }
31
+
32
+ it 'returns the options which instructs Vedeu to run once' do
33
+ subject.must_equal({ interactive: false })
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -100,7 +100,7 @@ module Vedeu
100
100
  [
101
101
  [
102
102
  "\e[38;2;39m\e[48;2;49m\e[1;1H \e[1;1HSome text...
103
- ...\e[0m\e[38;2;39m\e[48;2;49m\e[?25h",
103
+ ...\e[38;2;39m\e[48;2;49m\e[?25h",
104
104
  "\e[38;2;39m\e[48;2;49m\e[2;1H \e[2;1H\e[38;2;39m\e[48;2;49m\e[?25h"
105
105
  ]
106
106
  ]
@@ -136,8 +136,8 @@ module Vedeu
136
136
  end
137
137
  end
138
138
 
139
- describe '.unsave' do
140
- let(:subject) { described_class.unsave }
139
+ describe '.restore' do
140
+ let(:subject) { described_class.restore }
141
141
 
142
142
  it 'returns a String' do
143
143
  subject.must_be_instance_of(String)
@@ -160,8 +160,8 @@ module Vedeu
160
160
  end
161
161
  end
162
162
 
163
- describe '.unsave_all' do
164
- let(:subject) { described_class.unsave_all }
163
+ describe '.restore_all' do
164
+ let(:subject) { described_class.restore_all }
165
165
 
166
166
  it 'returns a String' do
167
167
  subject.must_be_instance_of(String)
@@ -0,0 +1,13 @@
1
+ require_relative '../../../test_helper'
2
+
3
+ module Vedeu
4
+ describe Menu do
5
+ let(:described_class) { Menu }
6
+ let(:described_instance) { described_class.new(index) }
7
+ let(:index) {}
8
+
9
+ it 'returns a Menu instance' do
10
+ described_instance.must_be_instance_of(Menu)
11
+ end
12
+ end
13
+ end
@@ -48,7 +48,7 @@ module Vedeu
48
48
  let(:result) { :stop }
49
49
 
50
50
  it 'raises an exception' do
51
- proc { subject }.must_raise(Collapse)
51
+ proc { subject }.must_raise(StopIteration)
52
52
  end
53
53
  end
54
54
 
@@ -74,7 +74,7 @@ module Vedeu
74
74
  let(:result) { :stop }
75
75
 
76
76
  it 'raises an exception' do
77
- proc { subject }.must_raise(Collapse)
77
+ proc { subject }.must_raise(StopIteration)
78
78
  end
79
79
  end
80
80
 
@@ -7,10 +7,11 @@ module Vedeu
7
7
  let(:subject) { described_instance }
8
8
  let(:attributes) {
9
9
  {
10
- name: 'dummy',
11
- entity: DummyCommand,
12
- keyword: "dummy",
13
- keypress: "d"
10
+ name: 'dummy',
11
+ entity: DummyCommand,
12
+ keyword: "dummy",
13
+ keypress: "d",
14
+ arguments: []
14
15
  }
15
16
  }
16
17
 
@@ -42,6 +43,12 @@ module Vedeu
42
43
  subject.keyword.must_equal('dummy')
43
44
  end
44
45
 
46
+ it 'has an arguments attribute' do
47
+ subject.arguments.must_be_instance_of(Array)
48
+
49
+ subject.arguments.must_equal([])
50
+ end
51
+
45
52
  describe '#execute' do
46
53
  let(:subject) { described_instance.execute(args) }
47
54
  let(:args) { [] }
@@ -3,8 +3,7 @@ require_relative '../../../test_helper'
3
3
  module Vedeu
4
4
  describe JSONParser do
5
5
  let(:described_class) { JSONParser }
6
- let(:described_instance) { described_class.new(json) }
7
- let(:subject) { described_instance }
6
+ let(:subject) { described_class.new(json) }
8
7
  let(:json) { "[]" }
9
8
 
10
9
  it 'returns a JSONParser instance' do
@@ -24,7 +23,7 @@ module Vedeu
24
23
  end
25
24
 
26
25
  describe '#parse' do
27
- let(:subject) { described_instance.parse }
26
+ let(:subject) { described_class.parse(json) }
28
27
 
29
28
  context 'when the JSON contains a single interface' do
30
29
  let(:json) { File.read('test/support/single_interface.json') }
data/test/test_helper.rb CHANGED
@@ -2,6 +2,7 @@ require 'simplecov'
2
2
  require 'minitest/autorun'
3
3
  require 'minitest/pride'
4
4
  require 'pry'
5
+ require 'ruby-prof'
5
6
 
6
7
  SimpleCov.start do
7
8
  command_name 'MiniTest::Spec'
data/vedeu.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency 'mocha', '1.1.0'
29
29
  spec.add_development_dependency 'pry', '0.10.0'
30
30
  spec.add_development_dependency 'rake', '10.3.2'
31
- spec.add_development_dependency 'rubocop'
31
+ spec.add_development_dependency 'ruby-prof'
32
32
  spec.add_development_dependency 'simplecov', '0.8.2'
33
33
 
34
34
  spec.add_dependency "oj"
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.24
4
+ version: 0.0.25
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-06-24 00:00:00.000000000 Z
11
+ date: 2014-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba
@@ -165,7 +165,7 @@ dependencies:
165
165
  - !ruby/object:Gem::Version
166
166
  version: 10.3.2
167
167
  - !ruby/object:Gem::Dependency
168
- name: rubocop
168
+ name: ruby-prof
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ">="
@@ -230,7 +230,6 @@ extensions: []
230
230
  extra_rdoc_files: []
231
231
  files:
232
232
  - ".gitignore"
233
- - ".rubocop.yml"
234
233
  - ".ruby-version"
235
234
  - Gemfile
236
235
  - Guardfile
@@ -250,11 +249,13 @@ files:
250
249
  - documentation/diagram/StyleDirective.png
251
250
  - documentation/diagram/rr-1.35.837.png
252
251
  - documentation/index.html
252
+ - examples/single_interface_app.rb
253
253
  - features/getting_started.feature
254
254
  - features/step_definitions/vedeu_steps.rb
255
255
  - features/support/env.rb
256
256
  - lib/vedeu.rb
257
257
  - lib/vedeu/application.rb
258
+ - lib/vedeu/configuration.rb
258
259
  - lib/vedeu/input/input.rb
259
260
  - lib/vedeu/launcher.rb
260
261
  - lib/vedeu/output/background.rb
@@ -273,9 +274,9 @@ files:
273
274
  - lib/vedeu/output/foreground.rb
274
275
  - lib/vedeu/output/geometry.rb
275
276
  - lib/vedeu/output/layer.rb
277
+ - lib/vedeu/output/menu.rb
276
278
  - lib/vedeu/output/output.rb
277
279
  - lib/vedeu/output/position.rb
278
- - lib/vedeu/output/renderer.rb
279
280
  - lib/vedeu/output/style.rb
280
281
  - lib/vedeu/output/translator.rb
281
282
  - lib/vedeu/output/wordwrap.rb
@@ -288,13 +289,15 @@ files:
288
289
  - lib/vedeu/repository/interface_repository.rb
289
290
  - lib/vedeu/repository/repository.rb
290
291
  - lib/vedeu/repository/storage.rb
291
- - lib/vedeu/support/event_loop.rb
292
292
  - lib/vedeu/support/exit.rb
293
293
  - lib/vedeu/support/json_parser.rb
294
+ - lib/vedeu/support/options.rb
294
295
  - lib/vedeu/support/queue.rb
295
296
  - lib/vedeu/support/terminal.rb
296
297
  - lib/vedeu/version.rb
298
+ - logs/.gitkeep
297
299
  - test/lib/vedeu/application_test.rb
300
+ - test/lib/vedeu/configuration_test.rb
298
301
  - test/lib/vedeu/input/input_test.rb
299
302
  - test/lib/vedeu/launcher_test.rb
300
303
  - test/lib/vedeu/output/background_test.rb
@@ -313,9 +316,9 @@ files:
313
316
  - test/lib/vedeu/output/foreground_test.rb
314
317
  - test/lib/vedeu/output/geometry_test.rb
315
318
  - test/lib/vedeu/output/layer_test.rb
319
+ - test/lib/vedeu/output/menu_test.rb
316
320
  - test/lib/vedeu/output/output_test.rb
317
321
  - test/lib/vedeu/output/position_test.rb
318
- - test/lib/vedeu/output/renderer_test.rb
319
322
  - test/lib/vedeu/output/style_test.rb
320
323
  - test/lib/vedeu/output/translator_test.rb
321
324
  - test/lib/vedeu/output/wordwrap_test.rb
@@ -328,7 +331,6 @@ files:
328
331
  - test/lib/vedeu/repository/interface_test.rb
329
332
  - test/lib/vedeu/repository/repository_test.rb
330
333
  - test/lib/vedeu/repository/storage_test.rb
331
- - test/lib/vedeu/support/event_loop_test.rb
332
334
  - test/lib/vedeu/support/exit_test.rb
333
335
  - test/lib/vedeu/support/json_parser_test.rb
334
336
  - test/lib/vedeu/support/queue_test.rb
@@ -372,6 +374,7 @@ test_files:
372
374
  - features/step_definitions/vedeu_steps.rb
373
375
  - features/support/env.rb
374
376
  - test/lib/vedeu/application_test.rb
377
+ - test/lib/vedeu/configuration_test.rb
375
378
  - test/lib/vedeu/input/input_test.rb
376
379
  - test/lib/vedeu/launcher_test.rb
377
380
  - test/lib/vedeu/output/background_test.rb
@@ -390,9 +393,9 @@ test_files:
390
393
  - test/lib/vedeu/output/foreground_test.rb
391
394
  - test/lib/vedeu/output/geometry_test.rb
392
395
  - test/lib/vedeu/output/layer_test.rb
396
+ - test/lib/vedeu/output/menu_test.rb
393
397
  - test/lib/vedeu/output/output_test.rb
394
398
  - test/lib/vedeu/output/position_test.rb
395
- - test/lib/vedeu/output/renderer_test.rb
396
399
  - test/lib/vedeu/output/style_test.rb
397
400
  - test/lib/vedeu/output/translator_test.rb
398
401
  - test/lib/vedeu/output/wordwrap_test.rb
@@ -405,7 +408,6 @@ test_files:
405
408
  - test/lib/vedeu/repository/interface_test.rb
406
409
  - test/lib/vedeu/repository/repository_test.rb
407
410
  - test/lib/vedeu/repository/storage_test.rb
408
- - test/lib/vedeu/support/event_loop_test.rb
409
411
  - test/lib/vedeu/support/exit_test.rb
410
412
  - test/lib/vedeu/support/json_parser_test.rb
411
413
  - test/lib/vedeu/support/queue_test.rb
data/.rubocop.yml DELETED
@@ -1,2 +0,0 @@
1
- Documentation:
2
- Enabled: false
@@ -1,6 +0,0 @@
1
- module Vedeu
2
- class Renderer
3
- def initialize
4
- end
5
- end
6
- end
@@ -1,33 +0,0 @@
1
- module Vedeu
2
- class Collapse < StandardError; end
3
-
4
- class EventLoop
5
- class << self
6
- def main_sequence
7
- new.main_sequence
8
- end
9
- end
10
-
11
- def initialize
12
- @running = true
13
- end
14
-
15
- # :nocov:
16
- def main_sequence
17
- while @running do
18
- Input.capture
19
-
20
- Process.evaluate
21
-
22
- Output.render
23
- end
24
- rescue Collapse
25
- stop
26
- end
27
- # :nocov:
28
-
29
- def stop
30
- @running = false
31
- end
32
- end
33
- end
@@ -1,13 +0,0 @@
1
- require_relative '../../../test_helper'
2
-
3
- module Vedeu
4
- describe Renderer do
5
- let(:described_class) { Renderer }
6
- let(:described_instance) { described_class.new }
7
- let(:subject) { described_instance }
8
-
9
- it 'returns a Renderer instance' do
10
- subject.must_be_instance_of(Renderer)
11
- end
12
- end
13
- end
@@ -1,39 +0,0 @@
1
- require_relative '../../../test_helper'
2
-
3
- module Vedeu
4
- describe EventLoop do
5
- let(:described_class) { EventLoop }
6
- let(:defined) { mock }
7
- let(:subject) { described_class.new }
8
-
9
- before do
10
- Input.stubs(:capture)
11
- Process.stubs(:evaluate).raises(Collapse)
12
- Output.stubs(:render)
13
- end
14
-
15
- it 'returns an EventLoop instance' do
16
- subject.must_be_instance_of(EventLoop)
17
- end
18
-
19
- it 'sets an instance variable' do
20
- subject.instance_variable_get('@running').must_equal(true)
21
- end
22
-
23
- describe '.main_sequence' do
24
- let(:subject) { described_class.main_sequence }
25
-
26
- it 'returns a FalseClass' do
27
- subject.must_be_instance_of(FalseClass)
28
- end
29
- end
30
-
31
- describe '#stop' do
32
- let(:subject) { described_class.new.stop }
33
-
34
- it 'returns a FalseClass' do
35
- subject.must_be_instance_of(FalseClass)
36
- end
37
- end
38
- end
39
- end