vedeu 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/api.md +5 -0
- data/examples/focus_app.rb +92 -0
- data/lib/vedeu/api/interface.rb +10 -1
- data/lib/vedeu/output/compositor.rb +8 -1
- data/lib/vedeu/output/render.rb +5 -2
- data/lib/vedeu/repositories/buffers.rb +0 -1
- data/lib/vedeu/repositories/cursors.rb +0 -1
- data/lib/vedeu/repositories/focus.rb +28 -18
- data/lib/vedeu/repositories/groups.rb +0 -1
- data/lib/vedeu/repositories/interfaces.rb +0 -1
- data/lib/vedeu/repositories/keymaps.rb +0 -1
- data/lib/vedeu/repositories/menus.rb +0 -1
- data/lib/vedeu/repositories/offsets.rb +0 -1
- data/lib/vedeu/support/refresh.rb +5 -5
- data/lib/vedeu/support/repository.rb +2 -0
- data/test/lib/vedeu/api/interface_test.rb +27 -0
- data/test/lib/vedeu/output/compositor_test.rb +4 -2
- data/test/lib/vedeu/output/render_test.rb +5 -6
- data/test/lib/vedeu/repositories/focus_test.rb +21 -1
- 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: 2df80a2e1733e5183dbf7afef9ce4b5ba8a833b4
|
4
|
+
data.tar.gz: ebda4b179298868faf99b0aa9e074022d6a0c407
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15805aa4cea7d6b7a41b11d6da45436488bbe2613380760f36ffd52d0db75d9e7954b18dec7524712cad114062d4ba74339bd54c6ec04d401f9cac757da73ba5
|
7
|
+
data.tar.gz: 2ca96c51ea3811ae78e6c7ea023fbd460c00e8ede0ca02ce6a0c2033c0e596a1059a8269f44634fd33c703573e2caa1925f17a3f0bb5f89f5433097c01392f15
|
data/docs/api.md
CHANGED
@@ -59,12 +59,17 @@ Note: Nesting indicates where an API method is allowed/supposed to be used.
|
|
59
59
|
#### Interfaces
|
60
60
|
|
61
61
|
- interface
|
62
|
+
- background
|
62
63
|
- centred (or centred!)
|
63
64
|
- cursor
|
64
65
|
- colour
|
65
66
|
- delay
|
67
|
+
- focus!
|
68
|
+
- foreground
|
66
69
|
- group
|
67
70
|
- height
|
71
|
+
- keys
|
72
|
+
- line
|
68
73
|
- name
|
69
74
|
- style
|
70
75
|
- use
|
@@ -0,0 +1,92 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
lib_dir = File.dirname(__FILE__) + '/../../lib'
|
4
|
+
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
|
5
|
+
|
6
|
+
-> { its -> { a } }
|
7
|
+
trap('INT') { exit! }
|
8
|
+
|
9
|
+
require 'vedeu'
|
10
|
+
|
11
|
+
# This example application shows how interface focus works.
|
12
|
+
#
|
13
|
+
# First, we set up the interfaces, noting that 'copper' should have focus when
|
14
|
+
# the application starts. Also note that 'status' should not show a cursor.
|
15
|
+
#
|
16
|
+
# The focus order is: copper, aluminium, boron, dubnium, status.
|
17
|
+
#
|
18
|
+
# Use 'space' to change focus.
|
19
|
+
class VedeuFocusApp
|
20
|
+
include Vedeu
|
21
|
+
|
22
|
+
event(:_initialize_) { Vedeu.trigger(:_refresh_) }
|
23
|
+
|
24
|
+
interface 'aluminium' do
|
25
|
+
colour foreground: '#ffffff', background: '#330000'
|
26
|
+
cursor true
|
27
|
+
height 2
|
28
|
+
width 2
|
29
|
+
x 3
|
30
|
+
y 3
|
31
|
+
end
|
32
|
+
|
33
|
+
interface 'boron' do
|
34
|
+
colour foreground: '#ffffff', background: '#003300'
|
35
|
+
cursor true
|
36
|
+
height 2
|
37
|
+
width 2
|
38
|
+
x 6
|
39
|
+
y 3
|
40
|
+
end
|
41
|
+
|
42
|
+
interface 'copper' do
|
43
|
+
colour foreground: '#ffffff', background: '#000033'
|
44
|
+
cursor true
|
45
|
+
focus!
|
46
|
+
height 2
|
47
|
+
width 2
|
48
|
+
x 3
|
49
|
+
y 6
|
50
|
+
end
|
51
|
+
|
52
|
+
interface 'dubnium' do
|
53
|
+
colour foreground: '#ffffff', background: '#333300'
|
54
|
+
cursor true
|
55
|
+
height 2
|
56
|
+
width 2
|
57
|
+
x 6
|
58
|
+
y 6
|
59
|
+
end
|
60
|
+
|
61
|
+
interface 'status' do
|
62
|
+
colour foreground: '#ffffff', background: '#000000'
|
63
|
+
cursor false
|
64
|
+
height 2
|
65
|
+
width 10
|
66
|
+
x 9
|
67
|
+
y 3
|
68
|
+
end
|
69
|
+
|
70
|
+
render do
|
71
|
+
view('aluminium') { line 'Al' }
|
72
|
+
view('boron') { line 'B' }
|
73
|
+
view('copper') { line 'Cu' }
|
74
|
+
view('dubnium') { line 'Db' }
|
75
|
+
view('status') { line Vedeu::Focus.current }
|
76
|
+
|
77
|
+
# Tell Vedeu that each interface can use 'space'.
|
78
|
+
keys('aluminium', 'boron', 'copper', 'dubnium', 'status') do
|
79
|
+
key(' ') do
|
80
|
+
Vedeu::Focus.next_item
|
81
|
+
|
82
|
+
render { view('status') { line Vedeu::Focus.current } }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.start
|
88
|
+
Vedeu::Launcher.new(['--debug']).execute!
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
VedeuFocusApp.start
|
data/lib/vedeu/api/interface.rb
CHANGED
@@ -29,7 +29,7 @@ module Vedeu
|
|
29
29
|
end
|
30
30
|
alias_method :centred!, :centred
|
31
31
|
|
32
|
-
# Set the cursor visibility on an interface
|
32
|
+
# Set the cursor visibility on an interface.
|
33
33
|
#
|
34
34
|
# @param value [Boolean] Any value other than nil or false will evaluate
|
35
35
|
# to true.
|
@@ -70,6 +70,15 @@ module Vedeu
|
|
70
70
|
attributes[:delay] = value
|
71
71
|
end
|
72
72
|
|
73
|
+
# Specify this interface as being in focus when the application starts.
|
74
|
+
# If multiple interfaces are defined, and this is included in each, then
|
75
|
+
# the last defined will be the interface in focus.
|
76
|
+
#
|
77
|
+
# @return [String] The name of the interface in focus.
|
78
|
+
def focus!
|
79
|
+
attributes[:focus] = true
|
80
|
+
end
|
81
|
+
|
73
82
|
# Specify a group for an interface. Interfaces of the same group can be
|
74
83
|
# targetted together; for example you may want to refresh multiple
|
75
84
|
# interfaces at once.
|
@@ -26,13 +26,20 @@ module Vedeu
|
|
26
26
|
#
|
27
27
|
# @return [Array]
|
28
28
|
def render
|
29
|
-
Terminal.output(view)
|
29
|
+
Terminal.output(view, cursor)
|
30
30
|
end
|
31
31
|
|
32
32
|
private
|
33
33
|
|
34
34
|
attr_reader :name
|
35
35
|
|
36
|
+
# Renders the cursor into the currently focussed interface. May be hidden.
|
37
|
+
#
|
38
|
+
# @return [String]
|
39
|
+
def cursor
|
40
|
+
Interface.new(Vedeu::Interfaces.find(Focus.current)).cursor.to_s
|
41
|
+
end
|
42
|
+
|
36
43
|
# Renders the buffer unless empty, otherwise clears the area which the
|
37
44
|
# interface occupies.
|
38
45
|
#
|
data/lib/vedeu/output/render.rb
CHANGED
@@ -30,7 +30,7 @@ module Vedeu
|
|
30
30
|
#
|
31
31
|
# @return [String]
|
32
32
|
def render
|
33
|
-
out = [
|
33
|
+
out = [clear]
|
34
34
|
|
35
35
|
Vedeu.log("Rendering view: '#{interface.name}'")
|
36
36
|
|
@@ -38,7 +38,6 @@ module Vedeu
|
|
38
38
|
out << interface.origin(index)
|
39
39
|
out << line.join
|
40
40
|
end
|
41
|
-
out << interface.cursor.to_s if interface.in_focus?
|
42
41
|
out.join
|
43
42
|
end
|
44
43
|
|
@@ -46,6 +45,10 @@ module Vedeu
|
|
46
45
|
|
47
46
|
attr_reader :interface
|
48
47
|
|
48
|
+
def clear
|
49
|
+
Clear.call(interface)
|
50
|
+
end
|
51
|
+
|
49
52
|
end # Render
|
50
53
|
|
51
54
|
end # Vedeu
|
@@ -7,7 +7,6 @@ module Vedeu
|
|
7
7
|
# @api private
|
8
8
|
module Focus
|
9
9
|
|
10
|
-
include Common
|
11
10
|
include Repository
|
12
11
|
extend self
|
13
12
|
|
@@ -25,9 +24,15 @@ module Vedeu
|
|
25
24
|
def add(attributes)
|
26
25
|
validate_attributes!(attributes)
|
27
26
|
|
28
|
-
return storage
|
27
|
+
return storage if registered?(attributes[:name])
|
29
28
|
|
30
|
-
|
29
|
+
if attributes[:focus]
|
30
|
+
storage.unshift(attributes[:name])
|
31
|
+
|
32
|
+
else
|
33
|
+
storage.push(attributes[:name])
|
34
|
+
|
35
|
+
end
|
31
36
|
end
|
32
37
|
|
33
38
|
# Focus an interface by name.
|
@@ -40,11 +45,7 @@ module Vedeu
|
|
40
45
|
|
41
46
|
storage.rotate!(storage.index(name))
|
42
47
|
|
43
|
-
|
44
|
-
|
45
|
-
refresh
|
46
|
-
|
47
|
-
current
|
48
|
+
update
|
48
49
|
end
|
49
50
|
|
50
51
|
# Return the interface currently focussed.
|
@@ -72,12 +73,9 @@ module Vedeu
|
|
72
73
|
def next_item
|
73
74
|
storage.rotate!
|
74
75
|
|
75
|
-
|
76
|
-
|
77
|
-
refresh
|
78
|
-
|
79
|
-
current
|
76
|
+
update
|
80
77
|
end
|
78
|
+
alias_method :next, :next_item
|
81
79
|
|
82
80
|
# Put the previous interface relative to the current interface in focus.
|
83
81
|
#
|
@@ -85,12 +83,10 @@ module Vedeu
|
|
85
83
|
def prev_item
|
86
84
|
storage.rotate!(-1)
|
87
85
|
|
88
|
-
|
89
|
-
|
90
|
-
refresh
|
91
|
-
|
92
|
-
current
|
86
|
+
update
|
93
87
|
end
|
88
|
+
alias_method :prev, :prev_item
|
89
|
+
alias_method :previous, :prev_item
|
94
90
|
|
95
91
|
# Refresh the interface in focus.
|
96
92
|
#
|
@@ -117,6 +113,20 @@ module Vedeu
|
|
117
113
|
|
118
114
|
private
|
119
115
|
|
116
|
+
# Return the name of the interface in focus after triggering the refresh
|
117
|
+
# event for that interface. Returns false if the storage is empty.
|
118
|
+
#
|
119
|
+
# @return [String|FalseClass]
|
120
|
+
def update
|
121
|
+
return false if storage.empty?
|
122
|
+
|
123
|
+
Vedeu.log("Interface in focus: '#{current}'")
|
124
|
+
|
125
|
+
refresh
|
126
|
+
|
127
|
+
current
|
128
|
+
end
|
129
|
+
|
120
130
|
# Returns an empty collection ready for the storing of interface names.
|
121
131
|
#
|
122
132
|
# @return [Array]
|
@@ -5,7 +5,7 @@ module Vedeu
|
|
5
5
|
# @api private
|
6
6
|
module Refresh
|
7
7
|
|
8
|
-
include
|
8
|
+
include Common
|
9
9
|
extend self
|
10
10
|
|
11
11
|
# System event to refresh all registered interfaces.
|
@@ -22,7 +22,7 @@ module Vedeu
|
|
22
22
|
#
|
23
23
|
# @return [|NoInterfacesDefined]
|
24
24
|
def by_focus
|
25
|
-
by_name(
|
25
|
+
by_name(Focus.current)
|
26
26
|
end
|
27
27
|
|
28
28
|
# Refresh an interface, or collection of interfaces belonging to a group.
|
@@ -31,7 +31,7 @@ module Vedeu
|
|
31
31
|
# @return [Array|GroupNotFound] A collection of the names of interfaces
|
32
32
|
# refreshed, or an exception if the group was not found.
|
33
33
|
def by_group(group_name)
|
34
|
-
|
34
|
+
Groups.find(group_name).each { |name| by_name(name) }
|
35
35
|
end
|
36
36
|
|
37
37
|
# Refresh an interface by name.
|
@@ -39,7 +39,7 @@ module Vedeu
|
|
39
39
|
# @param name [String] The name of the interface to be refreshed.
|
40
40
|
# @return [Array|BufferNotFound]
|
41
41
|
def by_name(name)
|
42
|
-
|
42
|
+
Compositor.render(name)
|
43
43
|
end
|
44
44
|
|
45
45
|
# Register a refresh event for an interface or group of interfaces by name.
|
@@ -61,7 +61,7 @@ module Vedeu
|
|
61
61
|
|
62
62
|
return false if Events.registered?(event)
|
63
63
|
|
64
|
-
Events.add(event, { delay: delay }) {
|
64
|
+
Events.add(event, { delay: delay }) { Refresh.send(type, name) }
|
65
65
|
|
66
66
|
true
|
67
67
|
end
|
@@ -165,6 +165,33 @@ module Vedeu
|
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
168
|
+
describe '#focus!' do
|
169
|
+
it 'returns true' do
|
170
|
+
API::Interface.new({ name: 'curium' }).focus!.must_equal(true)
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'sets the interface as current' do
|
174
|
+
Vedeu.interface('curium') { focus! }
|
175
|
+
|
176
|
+
Focus.current.must_equal('curium')
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'multiple calls will set the last to being current' do
|
180
|
+
Vedeu.interface('curium') { focus! }
|
181
|
+
Vedeu.interface('iodine') {}
|
182
|
+
Vedeu.interface('dysprosium') { focus! }
|
183
|
+
|
184
|
+
Focus.current.must_equal('dysprosium')
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'no calls will leave the first interface defined as being current' do
|
188
|
+
Vedeu.interface('curium') {}
|
189
|
+
Vedeu.interface('dysprosium') {}
|
190
|
+
|
191
|
+
Focus.current.must_equal('curium')
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
168
195
|
describe '#group' do
|
169
196
|
it 'sets the group attribute' do
|
170
197
|
Vedeu.interface 'iron' do
|
@@ -28,7 +28,8 @@ module Vedeu
|
|
28
28
|
Compositor.render('xenon').must_equal([
|
29
29
|
"\e[1;1H \e[1;1H" \
|
30
30
|
"\e[2;1H \e[2;1H" \
|
31
|
-
"\e[3;1H \e[3;1H"
|
31
|
+
"\e[3;1H \e[3;1H",
|
32
|
+
|
32
33
|
"\e[1;1H\e[?25l"
|
33
34
|
])
|
34
35
|
end
|
@@ -63,7 +64,8 @@ module Vedeu
|
|
63
64
|
"\e[3;1H \e[3;1H" \
|
64
65
|
"\e[1;1Hargon" \
|
65
66
|
"\e[2;1Hboron" \
|
66
|
-
"\e[3;1Hradon"
|
67
|
+
"\e[3;1Hradon",
|
68
|
+
|
67
69
|
"\e[1;1H\e[?25l"
|
68
70
|
])
|
69
71
|
end
|
@@ -39,7 +39,6 @@ module Vedeu
|
|
39
39
|
"\e[1;1Hthis is the first" \
|
40
40
|
"\e[2;1Hthis is the second and it is lon" \
|
41
41
|
"\e[3;1Hthis is the third, it is even lo" \
|
42
|
-
"\e[1;1H\e[?25l"
|
43
42
|
)
|
44
43
|
end
|
45
44
|
|
@@ -56,8 +55,7 @@ module Vedeu
|
|
56
55
|
Render.call(interface).must_equal(
|
57
56
|
"\e[1;1H \e[1;1H" \
|
58
57
|
"\e[2;1H \e[2;1H" \
|
59
|
-
"\e[3;1H \e[3;1H"
|
60
|
-
"\e[1;1H\e[?25l"
|
58
|
+
"\e[3;1H \e[3;1H"
|
61
59
|
)
|
62
60
|
end
|
63
61
|
|
@@ -90,8 +88,7 @@ module Vedeu
|
|
90
88
|
"\e[3;1H \e[3;1H" \
|
91
89
|
"\e[1;1Hthis is the first" \
|
92
90
|
"\e[2;1H" \
|
93
|
-
"\e[3;1Hthis is the third, it is even lo"
|
94
|
-
"\e[1;1H\e[?25l"
|
91
|
+
"\e[3;1Hthis is the third, it is even lo"
|
95
92
|
)
|
96
93
|
end
|
97
94
|
|
@@ -136,7 +133,9 @@ module Vedeu
|
|
136
133
|
[
|
137
134
|
"\e[1;1H \e[1;1H" \
|
138
135
|
"\e[2;1H \e[2;1H" \
|
139
|
-
"\e[1;1Ht\e[38;2;255;255;255m\e[48;2;0;0;0mh\e[38;2;255;255;255m\e[48;2;0;0;0me\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0mg\e[38;2;255;255;255m\e[48;2;0;0;0mr\e[38;2;255;255;255m\e[48;2;0;0;0ma\e[38;2;255;255;255m\e[48;2;0;0;0ms\e[38;2;255;255;255m\e[48;2;0;0;0ms\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0mi\e[38;2;255;255;255m\e[48;2;0;0;0ms\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;255;0mg\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;255;0mr\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;255;0me\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;255;0me\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;255;0mn\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0ma\e[38;2;255;255;255m\e[48;2;0;0;0mn\e[38;2;255;255;255m\e[48;2;0;0;0md\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0mt\e[38;2;255;255;255m\e[48;2;0;0;0mh\e[38;2;255;255;255m\e[48;2;0;0;0me\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0ms\e[38;2;255;255;255m\e[48;2;0;0;0mk\e[38;2;255;255;255m\e[48;2;0;0;0my\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0mi\e[38;2;255;255;255m\e[48;2;0;0;0ms\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;0;255mb\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;0;255ml\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;0;255mu\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;0;255me\e[38;2;255;255;255m\e[48;2;0;0;0m.\e[38;2;255;255;255m\e[48;2;0;0;0m"
|
136
|
+
"\e[1;1Ht\e[38;2;255;255;255m\e[48;2;0;0;0mh\e[38;2;255;255;255m\e[48;2;0;0;0me\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0mg\e[38;2;255;255;255m\e[48;2;0;0;0mr\e[38;2;255;255;255m\e[48;2;0;0;0ma\e[38;2;255;255;255m\e[48;2;0;0;0ms\e[38;2;255;255;255m\e[48;2;0;0;0ms\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0mi\e[38;2;255;255;255m\e[48;2;0;0;0ms\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;255;0mg\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;255;0mr\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;255;0me\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;255;0me\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;255;0mn\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0ma\e[38;2;255;255;255m\e[48;2;0;0;0mn\e[38;2;255;255;255m\e[48;2;0;0;0md\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0mt\e[38;2;255;255;255m\e[48;2;0;0;0mh\e[38;2;255;255;255m\e[48;2;0;0;0me\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0ms\e[38;2;255;255;255m\e[48;2;0;0;0mk\e[38;2;255;255;255m\e[48;2;0;0;0my\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0mi\e[38;2;255;255;255m\e[48;2;0;0;0ms\e[38;2;255;255;255m\e[48;2;0;0;0m \e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;0;255mb\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;0;255ml\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;0;255mu\e[38;2;255;255;255m\e[48;2;0;0;0m\e[38;2;0;0;255me\e[38;2;255;255;255m\e[48;2;0;0;0m.\e[38;2;255;255;255m\e[48;2;0;0;0m",
|
137
|
+
|
138
|
+
"\e[1;1H\e[?25l"
|
140
139
|
]
|
141
140
|
)
|
142
141
|
end
|
@@ -8,7 +8,7 @@ module Vedeu
|
|
8
8
|
after { Focus.reset }
|
9
9
|
|
10
10
|
describe '#add' do
|
11
|
-
it 'adds an interface to storage
|
11
|
+
it 'adds an interface to storage' do
|
12
12
|
Focus.add({ name: 'thallium' }).must_equal(['thallium'])
|
13
13
|
end
|
14
14
|
|
@@ -18,6 +18,18 @@ module Vedeu
|
|
18
18
|
Focus.registered.must_equal(['thallium'])
|
19
19
|
end
|
20
20
|
|
21
|
+
it 'adds the interface to storage focussed' do
|
22
|
+
Focus.add({ name: 'thallium' })
|
23
|
+
Focus.add({ name: 'lead', focus: true })
|
24
|
+
Focus.registered.must_equal(['lead', 'thallium'])
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'adds the interface to storage unfocussed' do
|
28
|
+
Focus.add({ name: 'thallium' })
|
29
|
+
Focus.add({ name: 'lead' })
|
30
|
+
Focus.registered.must_equal(['thallium', 'lead'])
|
31
|
+
end
|
32
|
+
|
21
33
|
it 'raises an exception if the attributes does not have a :name key' do
|
22
34
|
attributes = { no_name_key: '' }
|
23
35
|
|
@@ -70,6 +82,10 @@ module Vedeu
|
|
70
82
|
Focus.add({ name: 'bismuth' })
|
71
83
|
Focus.next_item.must_equal('lead')
|
72
84
|
end
|
85
|
+
|
86
|
+
it 'returns false if storage is empty' do
|
87
|
+
Focus.next_item.must_equal(false)
|
88
|
+
end
|
73
89
|
end
|
74
90
|
|
75
91
|
describe '#prev_item' do
|
@@ -79,6 +95,10 @@ module Vedeu
|
|
79
95
|
Focus.add({ name: 'bismuth' })
|
80
96
|
Focus.prev_item.must_equal('bismuth')
|
81
97
|
end
|
98
|
+
|
99
|
+
it 'returns false if storage is empty' do
|
100
|
+
Focus.prev_item.must_equal(false)
|
101
|
+
end
|
82
102
|
end
|
83
103
|
|
84
104
|
describe '#refresh' do
|
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.2.
|
7
|
+
spec.version = '0.2.6'
|
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.2.
|
4
|
+
version: 0.2.6
|
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-10-
|
11
|
+
date: 2014-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -187,6 +187,7 @@ files:
|
|
187
187
|
- docs/events.md
|
188
188
|
- docs/getting_started.md
|
189
189
|
- examples/cursor_app/cursor_app.rb
|
190
|
+
- examples/focus_app.rb
|
190
191
|
- examples/hello_world.rb
|
191
192
|
- examples/lines_app/lines_app.rb
|
192
193
|
- lib/vedeu.rb
|