vedeu 0.0.40 → 0.0.41
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -9
- data/bin/log +1 -1
- data/lib/vedeu.rb +10 -1
- data/lib/vedeu/instrumentation.rb +26 -24
- data/lib/vedeu/launcher.rb +0 -2
- data/lib/vedeu/parsing/menu_parser.rb +56 -0
- data/lib/vedeu/parsing/parser.rb +6 -0
- data/lib/vedeu/support/events.rb +1 -1
- data/lib/vedeu/support/menu.rb +8 -8
- data/test/lib/vedeu/models/colour_test.rb +2 -2
- data/test/lib/vedeu/parsing/parser_test.rb +1 -1
- data/test/lib/vedeu/support/esc_test.rb +2 -2
- data/test/lib/vedeu/support/geometry_test.rb +17 -17
- data/test/lib/vedeu/support/menu_test.rb +100 -62
- data/test/lib/vedeu/support/persistence_test.rb +2 -2
- data/vedeu.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3aaa948386201db5583b301f0ce46662822e87e
|
4
|
+
data.tar.gz: 7b1660cd10ca3bb5ecac23f2a93a3f0558980708
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8748d5c29561d109b1e2025e661c8778fd0bb5e5ffc09283eef8d9449869063b79bcf70d5e310518920c553218ff3b29a91fe6275c01f223cc58beb86d3411ea
|
7
|
+
data.tar.gz: 9583f518bf8d5eb588f695e56265c30564f2b7033fb11431ee465f8f5cefd01530b1ffac3618cce6016147a01b657b72ea0a27a9f35fc186b6bd18cd8a8584e6
|
data/README.md
CHANGED
@@ -56,7 +56,7 @@ Expect proper documentation soon!
|
|
56
56
|
|
57
57
|
To understand how Vedeu works, you need to familiarise yourself with some terms.
|
58
58
|
|
59
|
-
- Interface: This is an area on the screen where you can take input or direct output. You will define it's colour and style, its dimensions, including position and give it a name. You can then direct the output of a command to this interface and Vedeu will ensure the content is placed there.
|
59
|
+
- Interface: This is an area on the screen where you can take input or direct output. You will define it's colour and style, its dimensions, including position and give it a name. You can then direct the output of a command to this interface and Vedeu will ensure the content is placed there.
|
60
60
|
|
61
61
|
- Line: An interface is composed of many lines. Their length being the width of the interface and their number being the height of the interface.
|
62
62
|
|
@@ -78,17 +78,17 @@ To understand how Vedeu works, you need to familiarise yourself with some terms.
|
|
78
78
|
|
79
79
|
Referring to the above example, interfaces have a name, and various default attributes.
|
80
80
|
|
81
|
-
`y` sets the starting row point. (See Geometry)
|
82
|
-
`x` sets the starting column point.
|
81
|
+
- `y` sets the starting row point. (See Geometry)
|
82
|
+
- `x` sets the starting column point.
|
83
83
|
|
84
|
-
`width` sets character width of the interface
|
85
|
-
`height` sets character height of the interface
|
86
|
-
Note: not setting a width or height will set the values to the terminal's reported width and height.
|
84
|
+
- `width` sets character width of the interface
|
85
|
+
- `height` sets character height of the interface
|
87
86
|
|
88
|
-
|
89
|
-
`background` sets the default background colour.
|
87
|
+
Note: not setting a width or height will set the values to the terminal's reported width and height.
|
90
88
|
|
91
|
-
`
|
89
|
+
- `foreground` sets the default foreground colour. (See Colours)
|
90
|
+
- `background` sets the default background colour.
|
91
|
+
- `cursor` is a Boolean specifying whether the cursor should show.
|
92
92
|
|
93
93
|
|
94
94
|
### On Defining Events
|
data/bin/log
CHANGED
data/lib/vedeu.rb
CHANGED
@@ -3,10 +3,15 @@ require 'vedeu/support/builder'
|
|
3
3
|
require 'vedeu/support/events'
|
4
4
|
require 'vedeu/support/geometry'
|
5
5
|
require 'vedeu/support/menu'
|
6
|
+
require 'vedeu/parsing/parser'
|
6
7
|
require 'vedeu/launcher'
|
7
8
|
|
8
9
|
module Vedeu
|
9
|
-
|
10
|
+
def self.debug?
|
11
|
+
false
|
12
|
+
end
|
13
|
+
|
14
|
+
Vedeu::Instrumentation::Trace.call if debug?
|
10
15
|
|
11
16
|
# :nocov:
|
12
17
|
module ClassMethods
|
@@ -43,6 +48,10 @@ module Vedeu
|
|
43
48
|
Vedeu::Instrumentation::Log.logger.debug(message)
|
44
49
|
end
|
45
50
|
|
51
|
+
def self.error(exception)
|
52
|
+
Vedeu::Instrumentation::Log.error(exception)
|
53
|
+
end
|
54
|
+
|
46
55
|
def self.included(receiver)
|
47
56
|
receiver.send(:include, ClassMethods)
|
48
57
|
receiver.extend(ClassMethods)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'date'
|
2
2
|
require 'logger'
|
3
|
-
require 'ruby-prof'
|
3
|
+
# require 'ruby-prof'
|
4
4
|
|
5
5
|
require 'vedeu'
|
6
6
|
|
@@ -17,8 +17,10 @@ module Vedeu
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.error(exception)
|
20
|
-
|
21
|
-
|
20
|
+
backtrace = exception.backtrace.join("\n")
|
21
|
+
message = exception.message + "\n" + backtrace
|
22
|
+
|
23
|
+
logger.debug(message)
|
22
24
|
end
|
23
25
|
|
24
26
|
private
|
@@ -28,34 +30,34 @@ module Vedeu
|
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
31
|
-
class Profile
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
# class Profile
|
34
|
+
# def self.call(filename = 'profile.html', &block)
|
35
|
+
# new(filename).profile(&block)
|
36
|
+
# end
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
|
38
|
+
# def initialize(filename)
|
39
|
+
# @filename = filename
|
40
|
+
# end
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
+
# def profile(&block)
|
43
|
+
# RubyProf.start
|
42
44
|
|
43
|
-
|
45
|
+
# yield
|
44
46
|
|
45
|
-
|
47
|
+
# result = RubyProf.stop.eliminate_methods!([/^Array/, /^Hash/])
|
46
48
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
# File.open(filename, 'w') do |file|
|
50
|
+
# RubyProf::CallStackPrinter.new(result).print(file)
|
51
|
+
# RubyProf::GraphPrinter.new(result).print(file)
|
52
|
+
# end
|
53
|
+
# end
|
52
54
|
|
53
|
-
|
55
|
+
# private
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
57
|
+
# def filename
|
58
|
+
# Vedeu.root_path + '/tmp/' + @filename
|
59
|
+
# end
|
60
|
+
# end
|
59
61
|
|
60
62
|
class Trace
|
61
63
|
def self.call(options = {})
|
data/lib/vedeu/launcher.rb
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
module Vedeu
|
2
|
+
class MenuParser
|
3
|
+
# Convert a Vedeu::Menu into an interface view.
|
4
|
+
#
|
5
|
+
# @param output [Hash] a key/value pair.
|
6
|
+
#
|
7
|
+
# @return [Hash]
|
8
|
+
def self.parse(output = {})
|
9
|
+
new(output).parse
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(output = {})
|
13
|
+
@output = output
|
14
|
+
end
|
15
|
+
|
16
|
+
def parse
|
17
|
+
{ interfaces: interface }
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
attr_reader :output
|
23
|
+
|
24
|
+
def interface
|
25
|
+
{ name: name, lines: lines }
|
26
|
+
end
|
27
|
+
|
28
|
+
def lines
|
29
|
+
lines = []
|
30
|
+
items.each do |sel, cur, item|
|
31
|
+
if sel && cur
|
32
|
+
lines << { streams: { text: "*> #{item}" } }
|
33
|
+
|
34
|
+
elsif cur
|
35
|
+
lines << { streams: { text: " > #{item}" } }
|
36
|
+
|
37
|
+
elsif sel
|
38
|
+
lines << { streams: { text: "* #{item}" } }
|
39
|
+
|
40
|
+
else
|
41
|
+
lines << { streams: { text: " #{item}" } }
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
lines
|
46
|
+
end
|
47
|
+
|
48
|
+
def items
|
49
|
+
output.last
|
50
|
+
end
|
51
|
+
|
52
|
+
def name
|
53
|
+
output.first
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/vedeu/parsing/parser.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'vedeu/parsing/compositor'
|
2
2
|
require 'vedeu/parsing/hash_parser'
|
3
3
|
require 'vedeu/parsing/json_parser'
|
4
|
+
require 'vedeu/parsing/menu_parser'
|
4
5
|
|
5
6
|
module Vedeu
|
6
7
|
ParseError = Class.new(StandardError)
|
@@ -31,10 +32,15 @@ module Vedeu
|
|
31
32
|
def parser
|
32
33
|
return JSONParser if json?
|
33
34
|
return HashParser if hash?
|
35
|
+
return MenuParser if menu?
|
34
36
|
|
35
37
|
fail ParseError, 'Cannot process output from command.'
|
36
38
|
end
|
37
39
|
|
40
|
+
def menu?
|
41
|
+
output.is_a?(Array)
|
42
|
+
end
|
43
|
+
|
38
44
|
def hash?
|
39
45
|
output.is_a?(Hash)
|
40
46
|
end
|
data/lib/vedeu/support/events.rb
CHANGED
data/lib/vedeu/support/menu.rb
CHANGED
@@ -35,13 +35,13 @@ module Vedeu
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def current_item
|
38
|
-
|
38
|
+
@collection[@current]
|
39
39
|
end
|
40
40
|
|
41
41
|
def selected_item
|
42
42
|
return nil unless @selected
|
43
43
|
|
44
|
-
|
44
|
+
@collection[@selected]
|
45
45
|
end
|
46
46
|
|
47
47
|
def items
|
@@ -87,37 +87,37 @@ module Vedeu
|
|
87
87
|
def top_item
|
88
88
|
@current = 0
|
89
89
|
|
90
|
-
|
90
|
+
items
|
91
91
|
end
|
92
92
|
|
93
93
|
def bottom_item
|
94
94
|
@current = last
|
95
95
|
|
96
|
-
|
96
|
+
items
|
97
97
|
end
|
98
98
|
|
99
99
|
def next_item
|
100
100
|
@current += 1 if @current < last
|
101
101
|
|
102
|
-
|
102
|
+
items
|
103
103
|
end
|
104
104
|
|
105
105
|
def prev_item
|
106
106
|
@current -= 1 if @current > 0
|
107
107
|
|
108
|
-
|
108
|
+
items
|
109
109
|
end
|
110
110
|
|
111
111
|
def select_item
|
112
112
|
@selected = @current
|
113
113
|
|
114
|
-
|
114
|
+
items
|
115
115
|
end
|
116
116
|
|
117
117
|
def deselect_item
|
118
118
|
@selected = nil
|
119
119
|
|
120
|
-
|
120
|
+
items
|
121
121
|
end
|
122
122
|
|
123
123
|
def last
|
@@ -10,7 +10,7 @@ module Vedeu
|
|
10
10
|
}).background.must_equal("\e[48;5;16m")
|
11
11
|
end
|
12
12
|
|
13
|
-
it 'returns an empty string
|
13
|
+
it 'returns an empty string when the value is empty' do
|
14
14
|
Colour.new.background.must_equal('')
|
15
15
|
end
|
16
16
|
end
|
@@ -22,7 +22,7 @@ module Vedeu
|
|
22
22
|
}).foreground.must_equal("\e[38;5;196m")
|
23
23
|
end
|
24
24
|
|
25
|
-
it 'returns an empty string
|
25
|
+
it 'returns an empty string when the value is empty' do
|
26
26
|
Colour.new.foreground.must_equal('')
|
27
27
|
end
|
28
28
|
end
|
@@ -8,7 +8,7 @@ module Vedeu
|
|
8
8
|
Esc.background_colour.must_equal("\e[48;5;16m")
|
9
9
|
end
|
10
10
|
|
11
|
-
it 'returns an empty string
|
11
|
+
it 'returns an empty string when the value is empty' do
|
12
12
|
Esc.background_colour('').must_equal('')
|
13
13
|
end
|
14
14
|
end
|
@@ -18,7 +18,7 @@ module Vedeu
|
|
18
18
|
Esc.foreground_colour.must_equal("\e[38;5;231m")
|
19
19
|
end
|
20
20
|
|
21
|
-
it 'returns an empty string
|
21
|
+
it 'returns an empty string when the value is empty' do
|
22
22
|
Esc.foreground_colour('').must_equal('')
|
23
23
|
end
|
24
24
|
end
|
@@ -44,12 +44,12 @@ module Vedeu
|
|
44
44
|
end
|
45
45
|
|
46
46
|
describe '#terminal_height' do
|
47
|
-
it 'raises an exception
|
47
|
+
it 'raises an exception when the value is less than 1' do
|
48
48
|
geometry = Geometry.new({ height: 6, width: 18, terminal_height: -2 })
|
49
49
|
proc { geometry.terminal_height }.must_raise(OutOfBoundsError)
|
50
50
|
end
|
51
51
|
|
52
|
-
it 'raises an exception
|
52
|
+
it 'raises an exception when the value is greater than the terminal height' do
|
53
53
|
console = IO.console
|
54
54
|
console.stub :winsize, [25, 80] do
|
55
55
|
geometry = Geometry.new({ height: 6, width: 18, terminal_height: 30 })
|
@@ -65,7 +65,7 @@ module Vedeu
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
it 'returns the default height
|
68
|
+
it 'returns the default height when not set' do
|
69
69
|
console = IO.console
|
70
70
|
console.stub :winsize, [25, 80] do
|
71
71
|
geometry = Geometry.new({ height: 6, width: 18 })
|
@@ -75,12 +75,12 @@ module Vedeu
|
|
75
75
|
end
|
76
76
|
|
77
77
|
describe '#height' do
|
78
|
-
it 'raises an exception
|
78
|
+
it 'raises an exception when the value is less than 1' do
|
79
79
|
geometry = Geometry.new({ height: -6, width: 18 })
|
80
80
|
proc { geometry.height }.must_raise(OutOfBoundsError)
|
81
81
|
end
|
82
82
|
|
83
|
-
it 'raises an exception
|
83
|
+
it 'raises an exception when the value is greater than the terminal height' do
|
84
84
|
console = IO.console
|
85
85
|
console.stub :winsize, [25, 80] do
|
86
86
|
geometry = Geometry.new({ height: 30, width: 18 })
|
@@ -95,12 +95,12 @@ module Vedeu
|
|
95
95
|
end
|
96
96
|
|
97
97
|
describe '#y' do
|
98
|
-
it 'raises an exception
|
98
|
+
it 'raises an exception when the value is less than 1' do
|
99
99
|
geometry = Geometry.new({ height: 6, width: 18, y: -2 })
|
100
100
|
proc { geometry.y }.must_raise(OutOfBoundsError)
|
101
101
|
end
|
102
102
|
|
103
|
-
it 'raises an exception
|
103
|
+
it 'raises an exception when the value is greater than the terminal height' do
|
104
104
|
console = IO.console
|
105
105
|
console.stub :winsize, [25, 80] do
|
106
106
|
geometry = Geometry.new({ height: 6, width: 18, y: 30 })
|
@@ -113,19 +113,19 @@ module Vedeu
|
|
113
113
|
geometry.y.must_equal(6)
|
114
114
|
end
|
115
115
|
|
116
|
-
it 'returns 1
|
116
|
+
it 'returns 1 when not set' do
|
117
117
|
geometry = Geometry.new({ height: 6, width: 18 })
|
118
118
|
geometry.y.must_equal(1)
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
122
|
describe '#terminal_width' do
|
123
|
-
it 'raises an exception
|
123
|
+
it 'raises an exception when the value is less than 1' do
|
124
124
|
geometry = Geometry.new({ height: 6, width: 18, terminal_width: -2 })
|
125
125
|
proc { geometry.terminal_width }.must_raise(OutOfBoundsError)
|
126
126
|
end
|
127
127
|
|
128
|
-
it 'raises an exception
|
128
|
+
it 'raises an exception when the value is greater than the terminal width' do
|
129
129
|
console = IO.console
|
130
130
|
console.stub :winsize, [25, 80] do
|
131
131
|
geometry = Geometry.new({ height: 6, width: 18, terminal_width: 85 })
|
@@ -141,7 +141,7 @@ module Vedeu
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
-
it 'returns the default width
|
144
|
+
it 'returns the default width when not set' do
|
145
145
|
console = IO.console
|
146
146
|
console.stub :winsize, [25, 80] do
|
147
147
|
geometry = Geometry.new({ height: 6, width: 18 })
|
@@ -151,12 +151,12 @@ module Vedeu
|
|
151
151
|
end
|
152
152
|
|
153
153
|
describe '#width' do
|
154
|
-
it 'raises an exception
|
154
|
+
it 'raises an exception when the value is less than 1' do
|
155
155
|
geometry = Geometry.new({ height: 6, width: -18 })
|
156
156
|
proc { geometry.width }.must_raise(OutOfBoundsError)
|
157
157
|
end
|
158
158
|
|
159
|
-
it 'raises an exception
|
159
|
+
it 'raises an exception when the value is greater than the terminal width' do
|
160
160
|
console = IO.console
|
161
161
|
console.stub :winsize, [25, 80] do
|
162
162
|
geometry = Geometry.new({ height: 6, width: 85 })
|
@@ -171,12 +171,12 @@ module Vedeu
|
|
171
171
|
end
|
172
172
|
|
173
173
|
describe '#x' do
|
174
|
-
it 'raises an exception
|
174
|
+
it 'raises an exception when the value is less than 1' do
|
175
175
|
geometry = Geometry.new({ height: 6, width: 18, x: -2 })
|
176
176
|
proc { geometry.x }.must_raise(OutOfBoundsError)
|
177
177
|
end
|
178
178
|
|
179
|
-
it 'raises an exception
|
179
|
+
it 'raises an exception when the value is greater than the terminal width' do
|
180
180
|
console = IO.console
|
181
181
|
console.stub :winsize, [25, 80] do
|
182
182
|
geometry = Geometry.new({ height: 6, width: 18, x: 85 })
|
@@ -189,7 +189,7 @@ module Vedeu
|
|
189
189
|
geometry.x.must_equal(6)
|
190
190
|
end
|
191
191
|
|
192
|
-
it 'returns 1
|
192
|
+
it 'returns 1 when not set' do
|
193
193
|
geometry = Geometry.new({ height: 6, width: 18 })
|
194
194
|
geometry.x.must_equal(1)
|
195
195
|
end
|
@@ -201,7 +201,7 @@ module Vedeu
|
|
201
201
|
geometry.centred.must_equal(false)
|
202
202
|
end
|
203
203
|
|
204
|
-
it 'sets the centred attribute to true
|
204
|
+
it 'sets the centred attribute to true when not set' do
|
205
205
|
geometry = Geometry.new({ height: 6, width: 18 })
|
206
206
|
geometry.centred.must_equal(true)
|
207
207
|
end
|
@@ -24,19 +24,21 @@ module Vedeu
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'returns the selected index when an item is selected' do
|
27
|
-
menu.next_item
|
27
|
+
menu.next_item
|
28
|
+
menu.select_item
|
28
29
|
menu.selected.must_equal(1)
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
32
33
|
describe '#current_item' do
|
33
|
-
it 'returns
|
34
|
-
menu.current_item.must_equal(
|
34
|
+
it 'returns the current item from the collection' do
|
35
|
+
menu.current_item.must_equal('hydrogen')
|
35
36
|
end
|
36
37
|
|
37
|
-
it 'when the current item has changed
|
38
|
-
menu.next_item
|
39
|
-
menu.
|
38
|
+
it 'when the current item has changed' do
|
39
|
+
menu.next_item
|
40
|
+
menu.next_item
|
41
|
+
menu.current_item.must_equal('nitrogen')
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
@@ -45,9 +47,10 @@ module Vedeu
|
|
45
47
|
menu.selected_item.must_equal(nil)
|
46
48
|
end
|
47
49
|
|
48
|
-
it 'returns
|
49
|
-
menu.next_item
|
50
|
-
menu.
|
50
|
+
it 'returns the selected item from the collection' do
|
51
|
+
menu.next_item
|
52
|
+
menu.select_item
|
53
|
+
menu.selected_item.must_equal('carbon')
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
@@ -64,7 +67,8 @@ module Vedeu
|
|
64
67
|
end
|
65
68
|
|
66
69
|
it 'returns a tuple when the current has changed' do
|
67
|
-
menu.next_item
|
70
|
+
menu.next_item
|
71
|
+
menu.items.must_equal(
|
68
72
|
[
|
69
73
|
[false, false, 'hydrogen'],
|
70
74
|
[false, true, 'carbon'],
|
@@ -75,7 +79,8 @@ module Vedeu
|
|
75
79
|
end
|
76
80
|
|
77
81
|
it 'returns a tuple when an item is selected' do
|
78
|
-
menu.next_item
|
82
|
+
menu.next_item
|
83
|
+
menu.select_item
|
79
84
|
menu.items.must_equal(
|
80
85
|
[
|
81
86
|
[false, false, 'hydrogen'],
|
@@ -88,8 +93,10 @@ module Vedeu
|
|
88
93
|
|
89
94
|
it 'returns a tuple when the current has changed and an item ' \
|
90
95
|
'is selected' do
|
91
|
-
menu.next_item
|
92
|
-
menu.
|
96
|
+
menu.next_item
|
97
|
+
menu.select_item
|
98
|
+
menu.next_item
|
99
|
+
menu.next_item
|
93
100
|
menu.items.must_equal(
|
94
101
|
[
|
95
102
|
[false, false, 'hydrogen'],
|
@@ -104,29 +111,53 @@ module Vedeu
|
|
104
111
|
describe '#render' do
|
105
112
|
it 'returns a tuple' do
|
106
113
|
menu.render.must_equal(
|
107
|
-
[
|
114
|
+
[
|
115
|
+
' > hydrogen',
|
116
|
+
' carbon',
|
117
|
+
' nitrogen',
|
118
|
+
' oxygen'
|
119
|
+
]
|
108
120
|
)
|
109
121
|
end
|
110
122
|
|
111
123
|
it 'returns a tuple when the current has changed' do
|
112
|
-
menu.next_item
|
113
|
-
|
124
|
+
menu.next_item
|
125
|
+
menu.render.must_equal(
|
126
|
+
[
|
127
|
+
' hydrogen',
|
128
|
+
' > carbon',
|
129
|
+
' nitrogen',
|
130
|
+
' oxygen'
|
131
|
+
]
|
114
132
|
)
|
115
133
|
end
|
116
134
|
|
117
135
|
it 'returns a tuple when an item is selected' do
|
118
|
-
menu.next_item
|
136
|
+
menu.next_item
|
137
|
+
menu.select_item
|
119
138
|
menu.render.must_equal(
|
120
|
-
[
|
139
|
+
[
|
140
|
+
' hydrogen',
|
141
|
+
'*> carbon',
|
142
|
+
' nitrogen',
|
143
|
+
' oxygen'
|
144
|
+
]
|
121
145
|
)
|
122
146
|
end
|
123
147
|
|
124
148
|
it 'returns a tuple when the current has changed and an item ' \
|
125
149
|
'is selected' do
|
126
|
-
menu.next_item
|
127
|
-
menu.
|
150
|
+
menu.next_item
|
151
|
+
menu.select_item
|
152
|
+
menu.next_item
|
153
|
+
menu.next_item
|
128
154
|
menu.render.must_equal(
|
129
|
-
[
|
155
|
+
[
|
156
|
+
' hydrogen',
|
157
|
+
'* carbon',
|
158
|
+
' nitrogen',
|
159
|
+
' > oxygen'
|
160
|
+
]
|
130
161
|
)
|
131
162
|
end
|
132
163
|
end
|
@@ -134,94 +165,101 @@ module Vedeu
|
|
134
165
|
describe '#top_item' do
|
135
166
|
it 'sets current to the index of the first item' do
|
136
167
|
menu.next_item
|
137
|
-
menu.top_item
|
138
|
-
|
139
|
-
|
140
|
-
it 'returns the instance' do
|
141
|
-
menu.top_item.must_equal(menu)
|
168
|
+
menu.top_item
|
169
|
+
menu.current.must_equal(0)
|
142
170
|
end
|
143
171
|
|
144
|
-
it '
|
145
|
-
menu.top_item.
|
172
|
+
it 'returns the items' do
|
173
|
+
menu.top_item.must_equal(menu.items)
|
146
174
|
end
|
147
175
|
end
|
148
176
|
|
149
177
|
describe '#bottom_item' do
|
150
178
|
it 'sets current to the index of the last item' do
|
151
|
-
menu.bottom_item
|
152
|
-
|
153
|
-
|
154
|
-
it 'returns the instance' do
|
155
|
-
menu.top_item.must_equal(menu)
|
179
|
+
menu.bottom_item
|
180
|
+
menu.current.must_equal(3)
|
156
181
|
end
|
157
182
|
|
158
|
-
it '
|
159
|
-
menu.bottom_item.
|
183
|
+
it 'returns the items' do
|
184
|
+
menu.bottom_item.must_equal(menu.items)
|
160
185
|
end
|
161
186
|
end
|
162
187
|
|
163
188
|
describe '#next_item' do
|
164
189
|
it 'sets the current to the index of the next item' do
|
165
|
-
menu.next_item
|
190
|
+
menu.next_item
|
191
|
+
menu.current.must_equal(1)
|
166
192
|
end
|
167
193
|
|
168
|
-
it 'returns the
|
169
|
-
menu.next_item.must_equal(menu)
|
194
|
+
it 'returns the items' do
|
195
|
+
menu.next_item.must_equal(menu.items)
|
170
196
|
end
|
171
197
|
|
172
|
-
it '
|
173
|
-
menu.next_item
|
198
|
+
it 'does not loop' do
|
199
|
+
menu.next_item
|
200
|
+
menu.next_item
|
201
|
+
menu.next_item
|
202
|
+
menu.next_item
|
203
|
+
menu.next_item
|
204
|
+
menu.current.must_equal(3)
|
174
205
|
end
|
175
206
|
end
|
176
207
|
|
177
208
|
describe '#prev_item' do
|
178
209
|
it 'does not loop' do
|
179
|
-
menu.prev_item
|
210
|
+
menu.prev_item
|
211
|
+
menu.current.must_equal(0)
|
180
212
|
end
|
181
213
|
|
182
214
|
it 'sets the current to the index of the previous item' do
|
183
|
-
menu.next_item
|
215
|
+
menu.next_item
|
216
|
+
menu.next_item
|
217
|
+
menu.prev_item
|
218
|
+
menu.current.must_equal(1)
|
184
219
|
end
|
185
220
|
|
186
|
-
it 'returns the
|
187
|
-
menu.prev_item.must_equal(menu)
|
221
|
+
it 'returns the items' do
|
222
|
+
menu.prev_item.must_equal(menu.items)
|
188
223
|
end
|
189
224
|
|
190
|
-
it '
|
191
|
-
menu.next_item
|
225
|
+
it 'does not loop' do
|
226
|
+
menu.next_item
|
227
|
+
menu.next_item
|
228
|
+
menu.next_item
|
229
|
+
menu.prev_item
|
230
|
+
menu.prev_item
|
231
|
+
menu.current.must_equal(1)
|
192
232
|
end
|
193
233
|
end
|
194
234
|
|
195
235
|
describe '#select_item' do
|
196
236
|
it 'sets the selected index to the current index' do
|
197
|
-
menu.select_item
|
237
|
+
menu.select_item
|
238
|
+
menu.selected.must_equal(0)
|
198
239
|
end
|
199
240
|
|
200
241
|
it 'sets the selected index to the current index' do
|
201
|
-
menu.next_item
|
202
|
-
|
203
|
-
|
204
|
-
it 'returns the instance' do
|
205
|
-
menu.select_item.must_equal(menu)
|
242
|
+
menu.next_item
|
243
|
+
menu.select_item
|
244
|
+
menu.selected.must_equal(1)
|
206
245
|
end
|
207
246
|
|
208
|
-
it '
|
209
|
-
menu.select_item.
|
247
|
+
it 'returns the items' do
|
248
|
+
menu.select_item.must_equal(menu.items)
|
210
249
|
end
|
211
250
|
end
|
212
251
|
|
213
252
|
describe '#deselect_item' do
|
214
253
|
it 'sets the selected index to nil' do
|
215
|
-
menu.next_item
|
216
|
-
menu.
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
menu.deselect_item.must_equal(menu)
|
254
|
+
menu.next_item
|
255
|
+
menu.next_item
|
256
|
+
menu.select_item
|
257
|
+
menu.deselect_item
|
258
|
+
menu.selected.must_equal(nil)
|
221
259
|
end
|
222
260
|
|
223
|
-
it '
|
224
|
-
menu.deselect_item.
|
261
|
+
it 'returns the items' do
|
262
|
+
menu.deselect_item.must_equal(menu.items)
|
225
263
|
end
|
226
264
|
end
|
227
265
|
|
@@ -30,11 +30,11 @@ module Vedeu
|
|
30
30
|
end
|
31
31
|
|
32
32
|
describe '#query' do
|
33
|
-
it 'returns false
|
33
|
+
it 'returns false when the value is not provided' do
|
34
34
|
Persistence.query(nil).must_equal(false)
|
35
35
|
end
|
36
36
|
|
37
|
-
it 'returns the record
|
37
|
+
it 'returns the record when found' do
|
38
38
|
Persistence.create({ name: 'hydrogen' })
|
39
39
|
|
40
40
|
Persistence.query('hydrogen').name.must_equal('hydrogen')
|
data/vedeu.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'vedeu'
|
7
|
-
spec.version = '0.0.
|
7
|
+
spec.version = '0.0.41'
|
8
8
|
spec.authors = ['Gavin Laking']
|
9
9
|
spec.email = ['gavinlaking@gmail.com']
|
10
10
|
spec.summary = %q{A terminal case of wonderland.}
|
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.41
|
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-07-
|
11
|
+
date: 2014-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -192,6 +192,7 @@ files:
|
|
192
192
|
- lib/vedeu/parsing/compositor.rb
|
193
193
|
- lib/vedeu/parsing/hash_parser.rb
|
194
194
|
- lib/vedeu/parsing/json_parser.rb
|
195
|
+
- lib/vedeu/parsing/menu_parser.rb
|
195
196
|
- lib/vedeu/parsing/parser.rb
|
196
197
|
- lib/vedeu/parsing/text_adaptor.rb
|
197
198
|
- lib/vedeu/support/builder.rb
|