vedeu 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/docs/events.md +4 -1
- data/lib/vedeu.rb +7 -8
- data/lib/vedeu/api/api.rb +5 -3
- data/lib/vedeu/api/menu.rb +2 -0
- data/lib/vedeu/application.rb +2 -3
- data/lib/vedeu/input/input.rb +7 -0
- data/lib/vedeu/models/background.rb +4 -0
- data/lib/vedeu/{support → models}/event.rb +8 -12
- data/lib/vedeu/models/foreground.rb +9 -0
- data/lib/vedeu/{support → models}/menu.rb +0 -0
- data/lib/vedeu/output/compositor.rb +3 -0
- data/lib/vedeu/repositories/events.rb +21 -28
- data/lib/vedeu/repositories/menus.rb +0 -12
- data/lib/vedeu/support/repository.rb +30 -4
- data/test/lib/vedeu/{support → models}/event_test.rb +8 -6
- data/test/lib/vedeu/{support → models}/menu_test.rb +0 -0
- data/test/lib/vedeu/repositories/events_test.rb +12 -0
- data/test/lib/vedeu/repositories/menus_test.rb +0 -19
- data/test/lib/vedeu/support/repository_test.rb +108 -6
- data/vedeu.gemspec +4 -4
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2156b1bd78d30aece557893b5bf7b96a9253c1b9
|
4
|
+
data.tar.gz: aac032a4be3cfc9e34dfa6103daafd75502ada05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84e29f41f956f91c2c48d650a525029e925c22a076490ebf0829c92b42a2935501c8b28e4b8a3d5d6098ff6c2f5126c4d89995d0c11d0b3807e830c1dca1e7c5
|
7
|
+
data.tar.gz: d30411340d6a5ab8e8fbefb4e612b66bb29a61bc3b5ed74fc220b37ac9ee02accd1caf426df4732982f8657fcee799429bee8032289591565866571e0535e004
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.1
|
data/docs/events.md
CHANGED
@@ -151,7 +151,10 @@ Vedeu triggers this event when `:_exit_` is triggered. You can hook into this to
|
|
151
151
|
|
152
152
|
### `:_initialize_`
|
153
153
|
|
154
|
-
Vedeu triggers this event when it is ready to enter the main loop. Client
|
154
|
+
Vedeu triggers this event when it is ready to enter the main loop. Client
|
155
|
+
applications can listen for this event and perform some action(s), like render
|
156
|
+
the first screen, interface or make a sound. When Vedeu triggers this event,
|
157
|
+
the :_refresh_ event is also triggered automatically.
|
155
158
|
|
156
159
|
#### How to define user events
|
157
160
|
|
data/lib/vedeu.rb
CHANGED
@@ -51,18 +51,18 @@ require 'vedeu/support/repository'
|
|
51
51
|
require 'vedeu/support/position'
|
52
52
|
require 'vedeu/support/esc'
|
53
53
|
require 'vedeu/support/terminal'
|
54
|
-
require 'vedeu/support/event'
|
55
54
|
|
56
|
-
require 'vedeu/models/
|
55
|
+
require 'vedeu/models/char'
|
57
56
|
require 'vedeu/models/colour'
|
58
|
-
require 'vedeu/models/style'
|
59
|
-
require 'vedeu/models/interface'
|
60
57
|
require 'vedeu/models/cursor'
|
61
|
-
|
62
|
-
require 'vedeu/models/
|
58
|
+
require 'vedeu/models/event'
|
59
|
+
require 'vedeu/models/geometry'
|
60
|
+
require 'vedeu/models/interface'
|
63
61
|
require 'vedeu/models/line'
|
64
|
-
require 'vedeu/models/
|
62
|
+
require 'vedeu/models/menu'
|
65
63
|
require 'vedeu/models/offset'
|
64
|
+
require 'vedeu/models/stream'
|
65
|
+
require 'vedeu/models/style'
|
66
66
|
|
67
67
|
require 'vedeu/repositories/events'
|
68
68
|
|
@@ -96,7 +96,6 @@ require 'vedeu/output/view'
|
|
96
96
|
require 'vedeu/output/viewport'
|
97
97
|
|
98
98
|
require 'vedeu/support/grid'
|
99
|
-
require 'vedeu/support/menu'
|
100
99
|
|
101
100
|
require 'vedeu/input/input'
|
102
101
|
|
data/lib/vedeu/api/api.rb
CHANGED
@@ -214,10 +214,12 @@ module Vedeu
|
|
214
214
|
end
|
215
215
|
|
216
216
|
# Trigger a registered or system event by name with arguments. If the
|
217
|
-
# event stored returns a value, that is returned.
|
217
|
+
# event stored returns a value, that is returned. If multiple events are
|
218
|
+
# registered for a name, then the result of each event will be returned as
|
219
|
+
# part of a collection.
|
218
220
|
#
|
219
|
-
# @param name [Symbol] The name of the event you wish to trigger.
|
220
|
-
#
|
221
|
+
# @param name [Symbol] The name of the event you wish to trigger. The event
|
222
|
+
# does not have to exist.
|
221
223
|
# @param args [Array] Any arguments the event needs to execute correctly.
|
222
224
|
#
|
223
225
|
# @example
|
data/lib/vedeu/api/menu.rb
CHANGED
data/lib/vedeu/application.rb
CHANGED
@@ -38,9 +38,8 @@ module Vedeu
|
|
38
38
|
# requested into either :raw or :cooked mode).
|
39
39
|
# - The cursor visibility is then set dependent on this mode. In :raw mode,
|
40
40
|
# the cursor is hidden.
|
41
|
-
# - The `:_initialize_` event is triggered.
|
42
|
-
#
|
43
|
-
# that it is now ready.
|
41
|
+
# - The `:_initialize_` event is triggered. The client application is
|
42
|
+
# may treat this event as Vedeu signalling that it is now ready.
|
44
43
|
# - We enter into the main sequence where the application will either run
|
45
44
|
# once or continuous, interactively or standalone.
|
46
45
|
#
|
data/lib/vedeu/input/input.rb
CHANGED
@@ -16,6 +16,8 @@ module Vedeu
|
|
16
16
|
# @return [Input]
|
17
17
|
def initialize; end
|
18
18
|
|
19
|
+
# Triggers the keypress event with the key(s) pressed.
|
20
|
+
#
|
19
21
|
# @return []
|
20
22
|
def capture
|
21
23
|
Vedeu.trigger(:_keypress_, keypress)
|
@@ -23,11 +25,16 @@ module Vedeu
|
|
23
25
|
|
24
26
|
private
|
25
27
|
|
28
|
+
# Returns the input from the terminal.
|
29
|
+
#
|
26
30
|
# @return [String]
|
27
31
|
def input
|
28
32
|
@_input ||= Terminal.input
|
29
33
|
end
|
30
34
|
|
35
|
+
# Returns the translated (if possible) keypress(es) as either a String or a
|
36
|
+
# Symbol.
|
37
|
+
#
|
31
38
|
# @return [String|Symbol]
|
32
39
|
def keypress
|
33
40
|
key = input
|
@@ -18,11 +18,15 @@ module Vedeu
|
|
18
18
|
["\e[", background_codes[colour], 'm'].join
|
19
19
|
end
|
20
20
|
|
21
|
+
# Returns an escape sequence.
|
22
|
+
#
|
21
23
|
# @return [String]
|
22
24
|
def numbered
|
23
25
|
["\e[48;5;", css_to_numbered, 'm'].join
|
24
26
|
end
|
25
27
|
|
28
|
+
# Returns an escape sequence.
|
29
|
+
#
|
26
30
|
# @return [String]
|
27
31
|
def rgb
|
28
32
|
if Configuration.colour_mode == 16777216
|
@@ -7,12 +7,14 @@ module Vedeu
|
|
7
7
|
|
8
8
|
# Returns a new instance of Event.
|
9
9
|
#
|
10
|
-
# @param
|
10
|
+
# @param name [Symbol]
|
11
11
|
# @param options [Hash]
|
12
|
+
# @param closure [Proc] The code to be executed when the event is triggered.
|
12
13
|
# @return [Event]
|
13
|
-
def initialize(
|
14
|
-
@
|
14
|
+
def initialize(name, options = {}, closure)
|
15
|
+
@name = name
|
15
16
|
@options = options
|
17
|
+
@closure = closure
|
16
18
|
@deadline = 0
|
17
19
|
@executed_at = 0
|
18
20
|
@now = 0
|
@@ -32,7 +34,7 @@ module Vedeu
|
|
32
34
|
|
33
35
|
private
|
34
36
|
|
35
|
-
attr_reader :closure
|
37
|
+
attr_reader :closure, :name
|
36
38
|
attr_accessor :deadline, :executed_at, :now
|
37
39
|
|
38
40
|
# Execute the code stored in the event closure.
|
@@ -66,7 +68,7 @@ module Vedeu
|
|
66
68
|
def throttle_expired?
|
67
69
|
return true if elapsed_time > delay
|
68
70
|
|
69
|
-
Vedeu.log("Throttling event '#{
|
71
|
+
Vedeu.log("Throttling event '#{name}'")
|
70
72
|
|
71
73
|
false
|
72
74
|
end
|
@@ -90,7 +92,7 @@ module Vedeu
|
|
90
92
|
def debounce_expired?
|
91
93
|
return true if set_executed > deadline
|
92
94
|
|
93
|
-
Vedeu.log("Debouncing event '#{
|
95
|
+
Vedeu.log("Debouncing event '#{name}'")
|
94
96
|
|
95
97
|
false
|
96
98
|
end
|
@@ -132,11 +134,6 @@ module Vedeu
|
|
132
134
|
nil
|
133
135
|
end
|
134
136
|
|
135
|
-
# @return [String]
|
136
|
-
def event_name
|
137
|
-
options[:event_name].to_s
|
138
|
-
end
|
139
|
-
|
140
137
|
# @return [Fixnum|Float]
|
141
138
|
def debounce
|
142
139
|
options[:debounce] || defaults[:debounce]
|
@@ -157,7 +154,6 @@ module Vedeu
|
|
157
154
|
{
|
158
155
|
delay: 0.0,
|
159
156
|
debounce: 0.0,
|
160
|
-
event_name: '',
|
161
157
|
}
|
162
158
|
end
|
163
159
|
|
@@ -8,16 +8,25 @@ module Vedeu
|
|
8
8
|
|
9
9
|
private
|
10
10
|
|
11
|
+
# Returns an escape sequence for a named foreground colour.
|
12
|
+
#
|
13
|
+
# Valid names are: `:black`, `:red`, `:green`, `:yellow`, `:blue`,
|
14
|
+
# `:magenta`, `:cyan`, `:white` and `:default`.
|
15
|
+
#
|
11
16
|
# @return [String]
|
12
17
|
def named
|
13
18
|
["\e[", foreground_codes[colour], 'm'].join
|
14
19
|
end
|
15
20
|
|
21
|
+
# Returns an escape sequence.
|
22
|
+
#
|
16
23
|
# @return [String]
|
17
24
|
def numbered
|
18
25
|
["\e[38;5;", css_to_numbered, 'm'].join
|
19
26
|
end
|
20
27
|
|
28
|
+
# Returns an escape sequence.
|
29
|
+
#
|
21
30
|
# @return [String]
|
22
31
|
def rgb
|
23
32
|
if Configuration.colour_mode == 16777216
|
File without changes
|
@@ -3,49 +3,41 @@ module Vedeu
|
|
3
3
|
# Provides a mechanism for storing and retrieving events by name. A single
|
4
4
|
# name can contain many events. Also, an event can trigger other events.
|
5
5
|
#
|
6
|
+
# @todo I really don't like the 'hashiness' of this. (GL 2014-10-29)
|
7
|
+
#
|
6
8
|
# @api private
|
7
9
|
module Events
|
8
10
|
|
9
11
|
include Repository
|
10
12
|
extend self
|
11
13
|
|
14
|
+
# @see Vedeu::API#unevent
|
15
|
+
alias_method :unevent, :remove
|
16
|
+
|
12
17
|
# @see Vedeu::API#event
|
13
|
-
def add(name,
|
18
|
+
def add(name, options = {}, &block)
|
14
19
|
Vedeu.log("Registering event: '#{name}'")
|
15
20
|
|
16
|
-
|
17
|
-
|
18
|
-
storage[name][:events] << Event.new(block, options)
|
19
|
-
storage[name]
|
21
|
+
events(name) << Event.new(name, options, block)
|
20
22
|
end
|
21
23
|
alias_method :event, :add
|
22
24
|
|
23
|
-
# @see Vedeu::API#unevent
|
24
|
-
def remove(name)
|
25
|
-
return false unless registered?(name)
|
26
|
-
|
27
|
-
storage.delete(name) { false }
|
28
|
-
|
29
|
-
true
|
30
|
-
end
|
31
|
-
alias_method :unevent, :remove
|
32
|
-
|
33
25
|
# @see Vedeu::API#trigger
|
34
26
|
def use(name, *args)
|
35
|
-
results =
|
27
|
+
results = events(name).map { |event| event.trigger(*args) }
|
36
28
|
|
37
|
-
if results.one?
|
38
|
-
results.first
|
29
|
+
return results.first if results.one?
|
39
30
|
|
40
|
-
|
41
|
-
results
|
42
|
-
|
43
|
-
end
|
31
|
+
results
|
44
32
|
end
|
45
33
|
alias_method :trigger, :use
|
46
34
|
|
47
35
|
private
|
48
36
|
|
37
|
+
def events(name)
|
38
|
+
storage[name][:events]
|
39
|
+
end
|
40
|
+
|
49
41
|
# Returns an empty collection ready for the storing of events by name with
|
50
42
|
# associated event instance.
|
51
43
|
#
|
@@ -55,12 +47,13 @@ module Vedeu
|
|
55
47
|
end
|
56
48
|
|
57
49
|
# System events needed by Vedeu to run.
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
50
|
+
event(:_clear_) { Terminal.clear_screen }
|
51
|
+
event(:_exit_) { Vedeu::Application.stop }
|
52
|
+
event(:_initialize_) { Vedeu.trigger(:_refresh_) }
|
53
|
+
event(:_keypress_) { |key| Vedeu.keypress(key) }
|
54
|
+
event(:_log_) { |msg| Vedeu.log(msg) }
|
55
|
+
event(:_mode_switch_) { fail ModeSwitch }
|
56
|
+
event(:_resize_, { delay: 0.25 }) { Vedeu.resize }
|
64
57
|
|
65
58
|
end # Events
|
66
59
|
|
@@ -35,18 +35,6 @@ module Vedeu
|
|
35
35
|
storage.store(attributes[:name], attributes)
|
36
36
|
end
|
37
37
|
|
38
|
-
# Removes the menu from the repository and associated events.
|
39
|
-
#
|
40
|
-
# @param name [String]
|
41
|
-
# @return [Boolean]
|
42
|
-
def remove(name)
|
43
|
-
return false unless registered?(name)
|
44
|
-
|
45
|
-
storage.delete(name) { false }
|
46
|
-
|
47
|
-
true
|
48
|
-
end
|
49
|
-
|
50
38
|
# Access a menu by name.
|
51
39
|
#
|
52
40
|
# @param name [String]
|
@@ -9,7 +9,7 @@ module Vedeu
|
|
9
9
|
|
10
10
|
# Return the whole repository.
|
11
11
|
#
|
12
|
-
# @return [Hash]
|
12
|
+
# @return [Array|Hash|Set]
|
13
13
|
def all
|
14
14
|
storage
|
15
15
|
end
|
@@ -39,7 +39,11 @@ module Vedeu
|
|
39
39
|
#
|
40
40
|
# @return [Array]
|
41
41
|
def registered
|
42
|
-
storage.
|
42
|
+
return [] if storage.empty?
|
43
|
+
|
44
|
+
return storage.keys if storage.is_a?(Hash)
|
45
|
+
|
46
|
+
storage
|
43
47
|
end
|
44
48
|
|
45
49
|
# Returns a boolean indicating whether the named entity is registered.
|
@@ -47,12 +51,34 @@ module Vedeu
|
|
47
51
|
# @param name [String]
|
48
52
|
# @return [Boolean]
|
49
53
|
def registered?(name)
|
50
|
-
storage.
|
54
|
+
return false if storage.empty?
|
55
|
+
|
56
|
+
storage.include?(name)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Returns the storage with the named entity removed, or false if the entity
|
60
|
+
# does not exist.
|
61
|
+
#
|
62
|
+
# @param name [String]
|
63
|
+
# @return [Hash|FalseClass]
|
64
|
+
def remove(name)
|
65
|
+
return false if storage.empty?
|
66
|
+
|
67
|
+
if registered?(name)
|
68
|
+
storage.delete(name)
|
69
|
+
storage unless storage.is_a?(Set)
|
70
|
+
|
71
|
+
else
|
72
|
+
false
|
73
|
+
|
74
|
+
end
|
51
75
|
end
|
76
|
+
alias_method :destroy, :remove
|
77
|
+
alias_method :delete, :remove
|
52
78
|
|
53
79
|
# Reset the repository.
|
54
80
|
#
|
55
|
-
# @return [Hash]
|
81
|
+
# @return [Array|Hash|Set]
|
56
82
|
def reset
|
57
83
|
@_storage = in_memory
|
58
84
|
end
|
@@ -4,18 +4,20 @@ module Vedeu
|
|
4
4
|
|
5
5
|
describe Event do
|
6
6
|
|
7
|
-
let(:
|
8
|
-
let(:options)
|
7
|
+
let(:event_name) { :some_event }
|
8
|
+
let(:options) { {} }
|
9
|
+
let(:closure) { proc { :event_triggered } }
|
10
|
+
|
9
11
|
|
10
12
|
describe '#initialize' do
|
11
13
|
it 'returns an instance of itself' do
|
12
|
-
Event.new(
|
14
|
+
Event.new(event_name, options, closure).must_be_instance_of(Event)
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
18
|
describe '#trigger' do
|
17
19
|
it 'returns the result of calling the closure when debouncing' do
|
18
|
-
event = Event.new(
|
20
|
+
event = Event.new(event_name, { debounce: 0.0025 }, closure)
|
19
21
|
event.trigger.must_equal(nil)
|
20
22
|
sleep 0.0015
|
21
23
|
event.trigger.must_equal(nil)
|
@@ -26,7 +28,7 @@ module Vedeu
|
|
26
28
|
end
|
27
29
|
|
28
30
|
it 'returns the result of calling the closure when throttling' do
|
29
|
-
event = Event.new(
|
31
|
+
event = Event.new(event_name, { delay: 0.0025 }, closure)
|
30
32
|
event.trigger.must_equal(:event_triggered)
|
31
33
|
sleep 0.0015
|
32
34
|
event.trigger.must_equal(nil)
|
@@ -35,7 +37,7 @@ module Vedeu
|
|
35
37
|
end
|
36
38
|
|
37
39
|
it 'returns the result of calling the closure with its arguments' do
|
38
|
-
event = Event.new(
|
40
|
+
event = Event.new(event_name, options, closure)
|
39
41
|
event.trigger.must_equal(:event_triggered)
|
40
42
|
end
|
41
43
|
end
|
File without changes
|
@@ -16,14 +16,26 @@ module Vedeu
|
|
16
16
|
Events.add(:chlorine) { proc { |x| x } }
|
17
17
|
Events.add(:argon) { proc { |y| y } }
|
18
18
|
Events.remove(:chlorine)
|
19
|
+
|
19
20
|
Events.registered.wont_include(:chlorine)
|
20
21
|
end
|
21
22
|
|
22
23
|
it 'removes the event by name only if the name exists' do
|
23
24
|
Events.add(:chlorine) { proc { |x| x } }
|
24
25
|
Events.add(:argon) { proc { |y| y } }
|
26
|
+
|
25
27
|
Events.remove(:potassium).must_equal(false)
|
26
28
|
end
|
29
|
+
|
30
|
+
context 'alias method: #unevent' do
|
31
|
+
it 'removes the event by name' do
|
32
|
+
Events.add(:chlorine) { proc { |x| x } }
|
33
|
+
Events.add(:argon) { proc { |y| y } }
|
34
|
+
Events.unevent(:chlorine)
|
35
|
+
|
36
|
+
Events.registered.wont_include(:chlorine)
|
37
|
+
end
|
38
|
+
end
|
27
39
|
end
|
28
40
|
|
29
41
|
describe '#trigger' do
|
@@ -153,25 +153,6 @@ module Vedeu
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
-
describe '#remove' do
|
157
|
-
it 'returns false when the menu is not registered' do
|
158
|
-
Menus.remove('not_registered').must_equal(false)
|
159
|
-
end
|
160
|
-
|
161
|
-
it 'removes the menu from the repository' do
|
162
|
-
Menus.add({ name: 'antimony' })
|
163
|
-
Menus.registered?('antimony').must_equal(true)
|
164
|
-
Menus.remove('antimony')
|
165
|
-
Menus.registered?('antimony').must_equal(false)
|
166
|
-
end
|
167
|
-
|
168
|
-
it 'returns true when the menu was registered and is now removed' do
|
169
|
-
Menus.add({ name: 'tellurium' })
|
170
|
-
Menus.remove('tellurium').must_equal(true)
|
171
|
-
Menus.registered?('tellurium').must_equal(false)
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
156
|
describe '#use' do
|
176
157
|
let(:collection) { [:calcium, :fermium, :nitrogen, :palladium] }
|
177
158
|
let(:instance) { Vedeu::Menu.new(collection) }
|
@@ -6,8 +6,12 @@ module Vedeu
|
|
6
6
|
class RepositoryTestClass
|
7
7
|
include Repository
|
8
8
|
|
9
|
+
def add(hash)
|
10
|
+
@_storage = in_memory.merge!(hash)
|
11
|
+
end
|
12
|
+
|
9
13
|
def in_memory
|
10
|
-
{}
|
14
|
+
@_storage ||= {}
|
11
15
|
end
|
12
16
|
alias_method :storage, :in_memory
|
13
17
|
|
@@ -31,7 +35,31 @@ module Vedeu
|
|
31
35
|
describe '#find' do
|
32
36
|
it 'raises an exception when the entity cannot be found' do
|
33
37
|
proc { RepositoryTestClass.new.find('terbium') }
|
34
|
-
|
38
|
+
.must_raise(EntityNotFound)
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'when the entity is found' do
|
42
|
+
it 'returns the stored entity' do
|
43
|
+
skip
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#find_or_create' do
|
49
|
+
context 'when the entity is found by name' do
|
50
|
+
it 'returns the storage entity' do
|
51
|
+
skip
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when the entity is not found by name' do
|
56
|
+
it 'stores the newly created entity' do
|
57
|
+
skip
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'returns the newly created entity' do
|
61
|
+
skip
|
62
|
+
end
|
35
63
|
end
|
36
64
|
end
|
37
65
|
|
@@ -43,16 +71,90 @@ module Vedeu
|
|
43
71
|
it 'returns a collection of the names of all the registered entities' do
|
44
72
|
RepositoryTestClass.new.registered.must_equal([])
|
45
73
|
end
|
74
|
+
|
75
|
+
it 'returns an empty collection when the storage is empty' do
|
76
|
+
RepositoryTestClass.new.registered.must_equal([])
|
77
|
+
end
|
46
78
|
end
|
47
79
|
|
48
80
|
describe '#registered?' do
|
49
|
-
it 'returns
|
50
|
-
RepositoryTestClass.new.registered?('terbium')
|
51
|
-
.must_be_instance_of(FalseClass)
|
81
|
+
it 'returns false when the storage is empty' do
|
82
|
+
RepositoryTestClass.new.registered?('terbium').must_equal(false)
|
52
83
|
end
|
53
84
|
|
54
85
|
it 'returns false when the entity is not registered' do
|
55
|
-
RepositoryTestClass.new
|
86
|
+
repo = RepositoryTestClass.new
|
87
|
+
repo.add({ name: 'samarium' })
|
88
|
+
|
89
|
+
repo.registered?('terbium').must_equal(false)
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'returns true when the entity is registered' do
|
93
|
+
skip
|
94
|
+
|
95
|
+
repo = RepositoryTestClass.new
|
96
|
+
repo.add({ name: 'samarium' })
|
97
|
+
|
98
|
+
repo.registered?('samarium').must_equal(true)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe '#remove' do
|
103
|
+
context 'when the storage is empty' do
|
104
|
+
it 'returns false' do
|
105
|
+
test_repo = RepositoryTestClass.new
|
106
|
+
test_repo.remove('francium').must_equal(false)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'when the entity is not registered' do
|
111
|
+
it 'returns false' do
|
112
|
+
test_repo = RepositoryTestClass.new
|
113
|
+
test_repo.add({
|
114
|
+
'gadolinium' => 'rare-earth metal',
|
115
|
+
'samarium' => 'a hard silvery metal'
|
116
|
+
})
|
117
|
+
test_repo.remove('francium').must_equal(false)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context 'when the entity is registered' do
|
122
|
+
it 'returns the storage with the entity removed' do
|
123
|
+
test_repo = RepositoryTestClass.new
|
124
|
+
test_repo.add({
|
125
|
+
'gadolinium' => 'rare-earth metal',
|
126
|
+
'samarium' => 'a hard silvery metal'
|
127
|
+
})
|
128
|
+
test_repo.remove('samarium').must_equal({
|
129
|
+
'gadolinium' => 'rare-earth metal',
|
130
|
+
})
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context 'alias method: #destroy' do
|
135
|
+
it 'returns the storage with the entity removed' do
|
136
|
+
test_repo = RepositoryTestClass.new
|
137
|
+
test_repo.add({
|
138
|
+
'gadolinium' => 'rare-earth metal',
|
139
|
+
'samarium' => 'a hard silvery metal'
|
140
|
+
})
|
141
|
+
test_repo.destroy('samarium').must_equal({
|
142
|
+
'gadolinium' => 'rare-earth metal',
|
143
|
+
})
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'alias method; #delete' do
|
148
|
+
it 'returns the storage with the entity removed' do
|
149
|
+
test_repo = RepositoryTestClass.new
|
150
|
+
test_repo.add({
|
151
|
+
'gadolinium' => 'rare-earth metal',
|
152
|
+
'samarium' => 'a hard silvery metal'
|
153
|
+
})
|
154
|
+
test_repo.delete('samarium').must_equal({
|
155
|
+
'gadolinium' => 'rare-earth metal',
|
156
|
+
})
|
157
|
+
end
|
56
158
|
end
|
57
159
|
end
|
58
160
|
|
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.8'
|
8
8
|
spec.authors = ['Gavin Laking']
|
9
9
|
spec.email = ['gavinlaking@gmail.com']
|
10
10
|
spec.summary = %q{A terminal case of wonderland.}
|
@@ -18,14 +18,14 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
20
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
21
|
-
spec.add_development_dependency 'guard', '2.
|
21
|
+
spec.add_development_dependency 'guard', '2.7.1'
|
22
22
|
spec.add_development_dependency 'guard-bundler', '2.0.0'
|
23
23
|
spec.add_development_dependency 'guard-minitest', '2.3.2'
|
24
24
|
spec.add_development_dependency 'minitest', '5.4.2'
|
25
|
-
spec.add_development_dependency 'minitest-reporters', '1.0.
|
25
|
+
spec.add_development_dependency 'minitest-reporters', '1.0.7'
|
26
26
|
spec.add_development_dependency 'mocha', '1.1.0'
|
27
27
|
spec.add_development_dependency 'pry', '0.10.1'
|
28
28
|
spec.add_development_dependency 'rake', '10.3.2'
|
29
29
|
spec.add_development_dependency 'simplecov', '0.9.1'
|
30
|
-
spec.add_development_dependency 'yard', '0.8.7.
|
30
|
+
spec.add_development_dependency 'yard', '0.8.7.6'
|
31
31
|
end
|
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.8
|
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-
|
11
|
+
date: 2014-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: 2.7.1
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
40
|
+
version: 2.7.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: guard-bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - '='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.0.
|
89
|
+
version: 1.0.7
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.0.
|
96
|
+
version: 1.0.7
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: mocha
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - '='
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.8.7.
|
159
|
+
version: 0.8.7.6
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - '='
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.8.7.
|
166
|
+
version: 0.8.7.6
|
167
167
|
description: A GUI framework for terminal/console applications.
|
168
168
|
email:
|
169
169
|
- gavinlaking@gmail.com
|
@@ -211,11 +211,13 @@ files:
|
|
211
211
|
- lib/vedeu/models/colour.rb
|
212
212
|
- lib/vedeu/models/composition.rb
|
213
213
|
- lib/vedeu/models/cursor.rb
|
214
|
+
- lib/vedeu/models/event.rb
|
214
215
|
- lib/vedeu/models/foreground.rb
|
215
216
|
- lib/vedeu/models/geometry.rb
|
216
217
|
- lib/vedeu/models/interface.rb
|
217
218
|
- lib/vedeu/models/keymap.rb
|
218
219
|
- lib/vedeu/models/line.rb
|
220
|
+
- lib/vedeu/models/menu.rb
|
219
221
|
- lib/vedeu/models/offset.rb
|
220
222
|
- lib/vedeu/models/stream.rb
|
221
223
|
- lib/vedeu/models/style.rb
|
@@ -238,12 +240,10 @@ files:
|
|
238
240
|
- lib/vedeu/support/colour_translator.rb
|
239
241
|
- lib/vedeu/support/common.rb
|
240
242
|
- lib/vedeu/support/esc.rb
|
241
|
-
- lib/vedeu/support/event.rb
|
242
243
|
- lib/vedeu/support/exceptions.rb
|
243
244
|
- lib/vedeu/support/grid.rb
|
244
245
|
- lib/vedeu/support/keymap_validator.rb
|
245
246
|
- lib/vedeu/support/log.rb
|
246
|
-
- lib/vedeu/support/menu.rb
|
247
247
|
- lib/vedeu/support/position.rb
|
248
248
|
- lib/vedeu/support/presentation.rb
|
249
249
|
- lib/vedeu/support/refresh.rb
|
@@ -276,11 +276,13 @@ files:
|
|
276
276
|
- test/lib/vedeu/models/colour_test.rb
|
277
277
|
- test/lib/vedeu/models/composition_test.rb
|
278
278
|
- test/lib/vedeu/models/cursor_test.rb
|
279
|
+
- test/lib/vedeu/models/event_test.rb
|
279
280
|
- test/lib/vedeu/models/foreground_test.rb
|
280
281
|
- test/lib/vedeu/models/geometry_test.rb
|
281
282
|
- test/lib/vedeu/models/interface_test.rb
|
282
283
|
- test/lib/vedeu/models/keymap_test.rb
|
283
284
|
- test/lib/vedeu/models/line_test.rb
|
285
|
+
- test/lib/vedeu/models/menu_test.rb
|
284
286
|
- test/lib/vedeu/models/offset_test.rb
|
285
287
|
- test/lib/vedeu/models/stream_test.rb
|
286
288
|
- test/lib/vedeu/models/style_test.rb
|
@@ -303,11 +305,9 @@ files:
|
|
303
305
|
- test/lib/vedeu/support/colour_translator_test.rb
|
304
306
|
- test/lib/vedeu/support/common_test.rb
|
305
307
|
- test/lib/vedeu/support/esc_test.rb
|
306
|
-
- test/lib/vedeu/support/event_test.rb
|
307
308
|
- test/lib/vedeu/support/grid_test.rb
|
308
309
|
- test/lib/vedeu/support/keymap_validator_test.rb
|
309
310
|
- test/lib/vedeu/support/log_test.rb
|
310
|
-
- test/lib/vedeu/support/menu_test.rb
|
311
311
|
- test/lib/vedeu/support/position_test.rb
|
312
312
|
- test/lib/vedeu/support/presentation_test.rb
|
313
313
|
- test/lib/vedeu/support/refresh_test.rb
|
@@ -369,11 +369,13 @@ test_files:
|
|
369
369
|
- test/lib/vedeu/models/colour_test.rb
|
370
370
|
- test/lib/vedeu/models/composition_test.rb
|
371
371
|
- test/lib/vedeu/models/cursor_test.rb
|
372
|
+
- test/lib/vedeu/models/event_test.rb
|
372
373
|
- test/lib/vedeu/models/foreground_test.rb
|
373
374
|
- test/lib/vedeu/models/geometry_test.rb
|
374
375
|
- test/lib/vedeu/models/interface_test.rb
|
375
376
|
- test/lib/vedeu/models/keymap_test.rb
|
376
377
|
- test/lib/vedeu/models/line_test.rb
|
378
|
+
- test/lib/vedeu/models/menu_test.rb
|
377
379
|
- test/lib/vedeu/models/offset_test.rb
|
378
380
|
- test/lib/vedeu/models/stream_test.rb
|
379
381
|
- test/lib/vedeu/models/style_test.rb
|
@@ -396,11 +398,9 @@ test_files:
|
|
396
398
|
- test/lib/vedeu/support/colour_translator_test.rb
|
397
399
|
- test/lib/vedeu/support/common_test.rb
|
398
400
|
- test/lib/vedeu/support/esc_test.rb
|
399
|
-
- test/lib/vedeu/support/event_test.rb
|
400
401
|
- test/lib/vedeu/support/grid_test.rb
|
401
402
|
- test/lib/vedeu/support/keymap_validator_test.rb
|
402
403
|
- test/lib/vedeu/support/log_test.rb
|
403
|
-
- test/lib/vedeu/support/menu_test.rb
|
404
404
|
- test/lib/vedeu/support/position_test.rb
|
405
405
|
- test/lib/vedeu/support/presentation_test.rb
|
406
406
|
- test/lib/vedeu/support/refresh_test.rb
|