vedeu 0.5.12 → 0.5.13
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/lib/vedeu/all.rb +2 -0
- data/lib/vedeu/buffers/buffer.rb +3 -3
- data/lib/vedeu/configuration/api.rb +11 -1
- data/lib/vedeu/cursor/cursor.rb +1 -1
- data/lib/vedeu/cursor/reposition.rb +4 -0
- data/lib/vedeu/input/key.rb +1 -1
- data/lib/vedeu/log/lockless_log_device.rb +135 -0
- data/lib/vedeu/log/log.rb +0 -76
- data/lib/vedeu/log/mono_logger.rb +21 -0
- data/lib/vedeu/output/clear/named_interface.rb +2 -2
- data/lib/vedeu/output/output.rb +1 -1
- data/lib/vedeu/plugins.rb +2 -4
- data/lib/vedeu/plugins/plugin.rb +4 -4
- data/lib/vedeu/terminal.rb +1 -1
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/borders/render_border_test.rb +33 -2
- data/test/lib/vedeu/configuration/api_test.rb +20 -0
- data/test/lib/vedeu/distributed/server_test.rb +45 -12
- data/test/lib/vedeu/events/event_aliases_test.rb +20 -3
- data/test/lib/vedeu/log/lockless_log_device_test.rb +29 -0
- data/test/lib/vedeu/log/mono_logger_test.rb +31 -0
- data/test/lib/vedeu/output/output_test.rb +2 -1
- data/test/lib/vedeu/runtime/launcher_test.rb +26 -1
- data/vedeu.gemspec +1 -1
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27a3b30fd311b0147e59815b8665b9b0cfd337d9
|
4
|
+
data.tar.gz: 1dd71d249cb99304d00f7cb51a44345f73665b88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 245b56f9f631573bad0ca75880c56b4f72b3bee92068ca49d67a94bf4435cd78d4111c747c57b55ec77bb9d1ee3f09790f24ee9e7738a744cee92c152ed7db44
|
7
|
+
data.tar.gz: 0a9b9d0bf6ada6f16396c56f6a683e5f104bddab17632f5a85c76765bb176e7b5053fc0f91e55a31ca2adbd7919a64e9056c4cb4850b0fc8e6f848fd0e5dc482
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.2.
|
1
|
+
2.2.3
|
data/lib/vedeu/all.rb
CHANGED
@@ -2,6 +2,8 @@ require 'vedeu/version'
|
|
2
2
|
require 'vedeu/runtime/launcher'
|
3
3
|
require 'vedeu/runtime/bootstrap'
|
4
4
|
require 'vedeu/exceptions'
|
5
|
+
require 'vedeu/log/lockless_log_device'
|
6
|
+
require 'vedeu/log/mono_logger'
|
5
7
|
require 'vedeu/log/log'
|
6
8
|
require 'vedeu/log/debug'
|
7
9
|
require 'vedeu/log/timer'
|
data/lib/vedeu/buffers/buffer.rb
CHANGED
@@ -108,7 +108,7 @@ module Vedeu
|
|
108
108
|
# ':_hide_group_' event to which this named interface belongs will also hide
|
109
109
|
# the interface.
|
110
110
|
#
|
111
|
-
# @return [
|
111
|
+
# @return [Array<Array<Array<Vedeu::Views::Char>>>]
|
112
112
|
def hide
|
113
113
|
Vedeu::Output.render(clear_buffer)
|
114
114
|
end
|
@@ -141,7 +141,7 @@ module Vedeu
|
|
141
141
|
# ':_show_group_' event to which this named interface belongs will also show
|
142
142
|
# the interface.
|
143
143
|
#
|
144
|
-
# @return [
|
144
|
+
# @return [Array<Array<Array<Vedeu::Views::Char>>>]
|
145
145
|
def show
|
146
146
|
Vedeu::Output.render(buffer)
|
147
147
|
end
|
@@ -168,7 +168,7 @@ module Vedeu
|
|
168
168
|
|
169
169
|
# Clear the buffer.
|
170
170
|
#
|
171
|
-
# @return [
|
171
|
+
# @return [Array<Array<Vedeu::Views::Char>>]
|
172
172
|
def clear_buffer
|
173
173
|
@clear_buffer ||= Vedeu::Clear::NamedInterface.render(name)
|
174
174
|
end
|
@@ -63,7 +63,7 @@ module Vedeu
|
|
63
63
|
alias_method :interactive, :interactive!
|
64
64
|
|
65
65
|
# Sets boolean to prevent user intervention. This is the same as setting
|
66
|
-
# {#interactive!} to false.
|
66
|
+
# {include:Vedeu::Config::API#interactive!} to false.
|
67
67
|
#
|
68
68
|
# Vedeu.configure do
|
69
69
|
# standalone! # => same as `standalone true` or `interactive false`
|
@@ -261,6 +261,11 @@ module Vedeu
|
|
261
261
|
# Only log specific message types. A complete list of message types can
|
262
262
|
# be found at {Vedeu::Log.message_types}.
|
263
263
|
#
|
264
|
+
# Vedeu.configure do
|
265
|
+
# log_only :debug, :event
|
266
|
+
# # ...
|
267
|
+
# end
|
268
|
+
#
|
264
269
|
# @param types [Array<Symbol>] The message types which should be logged.
|
265
270
|
# @return [Array<Symbol>]
|
266
271
|
def log_only(*types)
|
@@ -291,6 +296,11 @@ module Vedeu
|
|
291
296
|
# other resources). By default the base path is just cwd but this will
|
292
297
|
# not work for many applications.
|
293
298
|
#
|
299
|
+
# Vedeu.configure do
|
300
|
+
# base_path '/path/to/application'
|
301
|
+
# # ...
|
302
|
+
# end
|
303
|
+
#
|
294
304
|
# @param path [String]
|
295
305
|
# @return [String]
|
296
306
|
def base_path(path = nil)
|
data/lib/vedeu/cursor/cursor.rb
CHANGED
@@ -55,6 +55,10 @@ module Vedeu
|
|
55
55
|
|
56
56
|
private
|
57
57
|
|
58
|
+
# Build a new instance of the entity that is being repositioned and replace
|
59
|
+
# existing stored version.
|
60
|
+
#
|
61
|
+
# @return [Vedeu::Cursor|Vedeu::Geometry]
|
58
62
|
def build_entity!
|
59
63
|
@_entity ||= entity.new(name: name,
|
60
64
|
y: coordinate.y_position,
|
data/lib/vedeu/input/key.rb
CHANGED
@@ -14,7 +14,7 @@ module Vedeu
|
|
14
14
|
# @param input [String|Symbol]
|
15
15
|
# @param block [Proc]
|
16
16
|
# @raise [Vedeu::InvalidSyntax] The required block was not given.
|
17
|
-
# @return [Key]
|
17
|
+
# @return [Vedeu::Key]
|
18
18
|
def initialize(input = nil, &block)
|
19
19
|
fail Vedeu::InvalidSyntax, 'block not given' unless block_given?
|
20
20
|
|
@@ -0,0 +1,135 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Ensures we can always write to the log file by creating a lock-less
|
4
|
+
# log device.
|
5
|
+
#
|
6
|
+
class LocklessLogDevice < Logger::LogDevice
|
7
|
+
|
8
|
+
# Returns a new instance of Vedeu::LocklessLogDevice.
|
9
|
+
#
|
10
|
+
# @param log [void]
|
11
|
+
# @return [Vedeu::LocklessLogDevice]
|
12
|
+
def initialize(log = nil)
|
13
|
+
@dev = nil
|
14
|
+
@filename = nil
|
15
|
+
|
16
|
+
if log.respond_to?(:write) && log.respond_to?(:close)
|
17
|
+
@dev = log
|
18
|
+
|
19
|
+
else
|
20
|
+
@dev = open_logfile(log)
|
21
|
+
@dev.sync = true
|
22
|
+
@filename = log
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# @param message [String]
|
28
|
+
# @return [void]
|
29
|
+
def write(message)
|
30
|
+
@dev.write(message)
|
31
|
+
|
32
|
+
rescue StandardError => exception
|
33
|
+
warn("log writing failed. #{exception}")
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [void]
|
37
|
+
def close
|
38
|
+
@dev.close
|
39
|
+
rescue
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
# @param filename [String]
|
46
|
+
# @return [void]
|
47
|
+
def open_logfile(log)
|
48
|
+
if FileTest.exist?(log)
|
49
|
+
open(log, (File::WRONLY | File::APPEND))
|
50
|
+
|
51
|
+
else
|
52
|
+
logdev = open(log, (File::WRONLY | File::APPEND | File::CREAT))
|
53
|
+
logdev.sync = true
|
54
|
+
logdev
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end # LocklessLogDevice
|
60
|
+
|
61
|
+
end # Vedeu
|
62
|
+
|
63
|
+
# module Vedeu
|
64
|
+
|
65
|
+
# # Ensures we can always write to the log file by creating a lock-less
|
66
|
+
# # log device.
|
67
|
+
# #
|
68
|
+
# class LocklessLogDevice < Logger::LogDevice
|
69
|
+
|
70
|
+
# # Returns a new instance of Vedeu::LocklessLogDevice.
|
71
|
+
# #
|
72
|
+
# # @param file_or_filename [void]
|
73
|
+
# # @return [Vedeu::LocklessLogDevice]
|
74
|
+
# def initialize(file_or_filename = nil)
|
75
|
+
# @file_or_filename = file_or_filename
|
76
|
+
# end
|
77
|
+
|
78
|
+
# # @param message [String]
|
79
|
+
# # @return [void]
|
80
|
+
# def write(message)
|
81
|
+
# device.write(message)
|
82
|
+
|
83
|
+
# rescue StandardError => exception
|
84
|
+
# warn("Log writing failed. #{exception}")
|
85
|
+
|
86
|
+
# end
|
87
|
+
|
88
|
+
# # @return [void]
|
89
|
+
# def close
|
90
|
+
# device.close
|
91
|
+
|
92
|
+
# rescue
|
93
|
+
# nil
|
94
|
+
|
95
|
+
# end
|
96
|
+
|
97
|
+
# protected
|
98
|
+
|
99
|
+
# # @!attribute [r] file_or_filename
|
100
|
+
# # @return [String]
|
101
|
+
# attr_reader :file_or_filename
|
102
|
+
# alias_method :file, :file_or_filename
|
103
|
+
# alias_method :filename, :file_or_filename
|
104
|
+
|
105
|
+
# private
|
106
|
+
|
107
|
+
# # @return [File]
|
108
|
+
# def device
|
109
|
+
# if file?
|
110
|
+
# file
|
111
|
+
|
112
|
+
# elsif exists?
|
113
|
+
# open(filename, (File::WRONLY | File::APPEND))
|
114
|
+
|
115
|
+
# else
|
116
|
+
# device = open(filename, (File::WRONLY | File::APPEND | File::CREAT))
|
117
|
+
# device.sync = true
|
118
|
+
|
119
|
+
# end
|
120
|
+
# end
|
121
|
+
|
122
|
+
# # @return [Boolean]
|
123
|
+
# def exists?
|
124
|
+
# FileTest.exist?(filename)
|
125
|
+
# end
|
126
|
+
|
127
|
+
# # @return [Boolean]
|
128
|
+
# def file?
|
129
|
+
# file_or_filename.respond_to?(:write) &&
|
130
|
+
# file_or_filename.respond_to?(:close)
|
131
|
+
# end
|
132
|
+
|
133
|
+
# end # LocklessLogDevice
|
134
|
+
|
135
|
+
# end # Vedeu
|
data/lib/vedeu/log/log.rb
CHANGED
@@ -1,81 +1,5 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
# Allows the creation of a lock-less log device.
|
4
|
-
#
|
5
|
-
class MonoLogger < Logger
|
6
|
-
|
7
|
-
# Create a trappable Logger instance.
|
8
|
-
#
|
9
|
-
# @param logdev [String|IO] The filename (String) or IO object (typically
|
10
|
-
# STDOUT, STDERR or an open file).
|
11
|
-
#
|
12
|
-
def initialize(logdev)
|
13
|
-
@level = DEBUG
|
14
|
-
@default_formatter = Formatter.new
|
15
|
-
@formatter = nil
|
16
|
-
@logdev = LocklessLogDevice.new(logdev) if logdev
|
17
|
-
end
|
18
|
-
|
19
|
-
# Ensures we can always write to the log file by creating a lock-less
|
20
|
-
# log device.
|
21
|
-
#
|
22
|
-
class LocklessLogDevice < LogDevice
|
23
|
-
|
24
|
-
# Returns a new instance of Vedeu::LocklessLogDevice.
|
25
|
-
#
|
26
|
-
# @param log [void]
|
27
|
-
# @return [void]
|
28
|
-
def initialize(log = nil)
|
29
|
-
@dev = nil
|
30
|
-
@filename = nil
|
31
|
-
|
32
|
-
if log.respond_to?(:write) && log.respond_to?(:close)
|
33
|
-
@dev = log
|
34
|
-
|
35
|
-
else
|
36
|
-
@dev = open_logfile(log)
|
37
|
-
@dev.sync = true
|
38
|
-
@filename = log
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# @param message [String]
|
44
|
-
# @return [void]
|
45
|
-
def write(message)
|
46
|
-
@dev.write(message)
|
47
|
-
|
48
|
-
rescue StandardError => exception
|
49
|
-
warn("log writing failed. #{exception}")
|
50
|
-
end
|
51
|
-
|
52
|
-
# @return [void]
|
53
|
-
def close
|
54
|
-
@dev.close
|
55
|
-
rescue
|
56
|
-
nil
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
# @param filename [String]
|
62
|
-
# @return [void]
|
63
|
-
def open_logfile(filename)
|
64
|
-
if FileTest.exist?(filename)
|
65
|
-
open(filename, (File::WRONLY | File::APPEND))
|
66
|
-
|
67
|
-
else
|
68
|
-
logdev = open(filename, (File::WRONLY | File::APPEND | File::CREAT))
|
69
|
-
logdev.sync = true
|
70
|
-
logdev
|
71
|
-
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
end # LocklessLogDevice
|
76
|
-
|
77
|
-
end # MonoLogger
|
78
|
-
|
79
3
|
# Provides the ability to log anything to the Vedeu log file.
|
80
4
|
#
|
81
5
|
class Log
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
# Allows the creation of a lock-less log device.
|
4
|
+
#
|
5
|
+
class MonoLogger < Logger
|
6
|
+
|
7
|
+
# Create a trappable Logger instance.
|
8
|
+
#
|
9
|
+
# @param logdev [String|IO] The filename (String) or IO object (typically
|
10
|
+
# STDOUT, STDERR or an open file).
|
11
|
+
# @return [Vedeu::MonoLogger]
|
12
|
+
def initialize(logdev)
|
13
|
+
@level = Logger::DEBUG
|
14
|
+
@default_formatter = Logger::Formatter.new
|
15
|
+
@formatter = nil
|
16
|
+
@logdev = Vedeu::LocklessLogDevice.new(logdev) if logdev
|
17
|
+
end
|
18
|
+
|
19
|
+
end # MonoLogger
|
20
|
+
|
21
|
+
end # Vedeu
|
@@ -10,7 +10,7 @@ module Vedeu
|
|
10
10
|
|
11
11
|
class << self
|
12
12
|
|
13
|
-
# @return [
|
13
|
+
# @return [Array<Array<Vedeu::Views::Char>>]
|
14
14
|
# @see #initialize
|
15
15
|
def render(name)
|
16
16
|
new(name).render
|
@@ -28,7 +28,7 @@ module Vedeu
|
|
28
28
|
@name = name
|
29
29
|
end
|
30
30
|
|
31
|
-
# @return [
|
31
|
+
# @return [Array<Array<Vedeu::Views::Char>>]
|
32
32
|
def render
|
33
33
|
output
|
34
34
|
end
|
data/lib/vedeu/output/output.rb
CHANGED
data/lib/vedeu/plugins.rb
CHANGED
@@ -24,11 +24,9 @@ module Vedeu
|
|
24
24
|
# @param plugin [Vedeu::Plugin]
|
25
25
|
# @return [Array<void>]
|
26
26
|
def register(name, plugin = false)
|
27
|
-
|
28
|
-
Vedeu.log(type: :debug, message: "Registering plugin: #{name}")
|
27
|
+
Vedeu.log(type: :debug, message: "Attempting to register plugin: #{name}")
|
29
28
|
|
30
|
-
|
31
|
-
end
|
29
|
+
plugins << plugin if plugin && not_loaded?(name)
|
32
30
|
end
|
33
31
|
|
34
32
|
# Find all installed plugins and store them.
|
data/lib/vedeu/plugins/plugin.rb
CHANGED
@@ -40,11 +40,11 @@ module Vedeu
|
|
40
40
|
begin
|
41
41
|
require gem_name unless enabled?
|
42
42
|
rescue LoadError => error
|
43
|
-
|
44
|
-
|
43
|
+
raise Vedeu::VedeuError,
|
44
|
+
"Unable to load plugin #{gem_name} due to #{error}."
|
45
45
|
rescue => error
|
46
|
-
|
47
|
-
|
46
|
+
raise Vedeu::VedeuError,
|
47
|
+
"require '#{gem_name}' failed with #{error}."
|
48
48
|
end
|
49
49
|
|
50
50
|
@enabled = true
|
data/lib/vedeu/terminal.rb
CHANGED
data/lib/vedeu/version.rb
CHANGED
@@ -6,10 +6,17 @@ module Vedeu
|
|
6
6
|
|
7
7
|
let(:described) { Vedeu::RenderBorder }
|
8
8
|
let(:instance) { described.new(border) }
|
9
|
-
let(:border) {
|
9
|
+
let(:border) {
|
10
|
+
Vedeu::Border.new(enabled: enabled,
|
11
|
+
name: _name,
|
12
|
+
title: title,
|
13
|
+
caption: caption)
|
14
|
+
}
|
10
15
|
let(:visible) { false }
|
11
16
|
let(:enabled) { false }
|
12
17
|
let(:_name) { 'Vedeu::RenderBorder' }
|
18
|
+
let(:title) {}
|
19
|
+
let(:caption) {}
|
13
20
|
|
14
21
|
it { described.must_respond_to(:with) }
|
15
22
|
|
@@ -20,7 +27,7 @@ module Vedeu
|
|
20
27
|
|
21
28
|
describe '#render' do
|
22
29
|
let(:geometry) {
|
23
|
-
Vedeu::Geometry.new(name: _name, x: 1, xn:
|
30
|
+
Vedeu::Geometry.new(name: _name, x: 1, xn: 7, y: 1, yn: 4)
|
24
31
|
}
|
25
32
|
let(:interface) {
|
26
33
|
Vedeu::Interface.new(name: _name, visible: visible)
|
@@ -46,6 +53,30 @@ module Vedeu
|
|
46
53
|
context 'when the border is enabled' do
|
47
54
|
let(:enabled) { true }
|
48
55
|
|
56
|
+
context 'and a title is given' do
|
57
|
+
let(:title) { 'T' }
|
58
|
+
|
59
|
+
# @todo Add more tests.
|
60
|
+
# it { skip }
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'and a title is not given' do
|
64
|
+
# @todo Add more tests.
|
65
|
+
# it { skip }
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'and a caption is given' do
|
69
|
+
let(:caption) { 'C' }
|
70
|
+
|
71
|
+
# @todo Add more tests.
|
72
|
+
# it { skip }
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'and a caption is not given' do
|
76
|
+
# @todo Add more tests.
|
77
|
+
# it { skip }
|
78
|
+
end
|
79
|
+
|
49
80
|
# @todo Add more tests.
|
50
81
|
# it { skip }
|
51
82
|
end
|
@@ -9,6 +9,11 @@ end # YourApp
|
|
9
9
|
|
10
10
|
module Vedeu
|
11
11
|
|
12
|
+
class SomeRenderer
|
13
|
+
end # SomeRenderer
|
14
|
+
class OtherRenderer
|
15
|
+
end # OtherRenderer
|
16
|
+
|
12
17
|
module Config
|
13
18
|
|
14
19
|
describe API do
|
@@ -235,7 +240,22 @@ module Vedeu
|
|
235
240
|
end
|
236
241
|
|
237
242
|
describe '#renderer' do
|
243
|
+
let(:some) { Vedeu::SomeRenderer.new }
|
244
|
+
let(:other) { Vedeu::OtherRenderer.new }
|
245
|
+
|
246
|
+
# before do
|
247
|
+
# Vedeu::Configuration.stubs(:renderers).
|
248
|
+
# returns([some])
|
249
|
+
# end
|
250
|
+
|
238
251
|
it { instance.must_respond_to(:renderers) }
|
252
|
+
|
253
|
+
# it 'sets the options to the desired value' do
|
254
|
+
# configuration = Vedeu.configure do
|
255
|
+
# renderer proc { other }
|
256
|
+
# end
|
257
|
+
# configuration.renderers.must_equal([some, other])
|
258
|
+
# end
|
239
259
|
end
|
240
260
|
|
241
261
|
describe '#root' do
|
@@ -100,17 +100,32 @@ module Vedeu
|
|
100
100
|
end
|
101
101
|
|
102
102
|
context 'when the server is enabled' do
|
103
|
+
let(:enabled) { true }
|
103
104
|
|
104
105
|
context 'and the server is running' do
|
105
|
-
|
106
|
-
|
107
|
-
|
106
|
+
let(:running) { true }
|
107
|
+
|
108
|
+
it {
|
109
|
+
Vedeu.expects(:log).
|
110
|
+
with(type: :drb,
|
111
|
+
message: "Attempting to start: 'druby://localhost:21420'")
|
112
|
+
Vedeu.expects(:log).
|
113
|
+
with(type: :drb,
|
114
|
+
message: "Already started: 'druby://localhost:21420'")
|
115
|
+
subject
|
116
|
+
}
|
108
117
|
end
|
109
118
|
|
110
119
|
context 'and the server is not running' do
|
111
|
-
|
112
|
-
|
113
|
-
|
120
|
+
it {
|
121
|
+
Vedeu.expects(:log).
|
122
|
+
with(type: :drb,
|
123
|
+
message: "Attempting to start: 'druby://localhost:21420'")
|
124
|
+
Vedeu.expects(:log).
|
125
|
+
with(type: :drb,
|
126
|
+
message: "Starting: 'druby://localhost:21420'")
|
127
|
+
subject
|
128
|
+
}
|
114
129
|
end
|
115
130
|
|
116
131
|
end
|
@@ -146,17 +161,35 @@ module Vedeu
|
|
146
161
|
end
|
147
162
|
|
148
163
|
context 'when the server is enabled' do
|
164
|
+
let(:enabled) { true }
|
149
165
|
|
150
166
|
context 'and the server is running' do
|
151
|
-
|
152
|
-
|
153
|
-
|
167
|
+
let(:running) { true }
|
168
|
+
|
169
|
+
it {
|
170
|
+
Vedeu.expects(:log).
|
171
|
+
with(type: :drb,
|
172
|
+
message: "Attempting to stop: 'druby://localhost:21420'")
|
173
|
+
Vedeu.expects(:log).
|
174
|
+
with(type: :drb,
|
175
|
+
message: "Stopping: 'druby://localhost:21420'")
|
176
|
+
Vedeu.expects(:log).
|
177
|
+
with(type: :drb,
|
178
|
+
message: "Attempted to #join on DRb.thread.")
|
179
|
+
subject
|
180
|
+
}
|
154
181
|
end
|
155
182
|
|
156
183
|
context 'and the server is not running' do
|
157
|
-
|
158
|
-
|
159
|
-
|
184
|
+
it {
|
185
|
+
Vedeu.expects(:log).
|
186
|
+
with(type: :drb,
|
187
|
+
message: "Attempting to stop: 'druby://localhost:21420'")
|
188
|
+
Vedeu.expects(:log).
|
189
|
+
with(type: :drb,
|
190
|
+
message: "Already stopped: 'druby://localhost:21420'")
|
191
|
+
subject
|
192
|
+
}
|
160
193
|
end
|
161
194
|
|
162
195
|
end
|
@@ -44,6 +44,11 @@ module Vedeu
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
describe '.find' do
|
48
|
+
# @todo Add more tests
|
49
|
+
# it { skip }
|
50
|
+
end
|
51
|
+
|
47
52
|
describe '.registered?' do
|
48
53
|
let(:alias_name) { :alias_test }
|
49
54
|
|
@@ -103,17 +108,29 @@ module Vedeu
|
|
103
108
|
end
|
104
109
|
|
105
110
|
describe '.trigger' do
|
106
|
-
let(:alias_name) {}
|
111
|
+
let(:alias_name) { :some_alias }
|
107
112
|
let(:args) {}
|
108
113
|
|
109
114
|
subject { described.trigger(alias_name, *args) }
|
110
115
|
|
111
116
|
context 'when the alias name is registered' do
|
112
|
-
|
113
|
-
|
117
|
+
before do
|
118
|
+
Vedeu::Trigger.stubs(:trigger)
|
119
|
+
|
120
|
+
described.add(:some_alias, :some_event)
|
121
|
+
described.add(:some_alias, :other_event)
|
122
|
+
end
|
123
|
+
|
124
|
+
it {
|
125
|
+
Vedeu::Trigger.expects(:trigger).with(:some_event, nil)
|
126
|
+
Vedeu::Trigger.expects(:trigger).with(:other_event, nil)
|
127
|
+
subject
|
128
|
+
}
|
114
129
|
end
|
115
130
|
|
116
131
|
context 'when the alias name is not registered' do
|
132
|
+
let(:alias_name) {}
|
133
|
+
|
117
134
|
it { subject.must_equal([]) }
|
118
135
|
end
|
119
136
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe LocklessLogDevice do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::LocklessLogDevice }
|
8
|
+
let(:instance) { described.new(file_or_filename) }
|
9
|
+
let(:file_or_filename) {}
|
10
|
+
|
11
|
+
describe '#initialize' do
|
12
|
+
# it { instance.must_be_instance_of(described) }
|
13
|
+
# it {
|
14
|
+
# instance.instance_variable_get('@file_or_filename').
|
15
|
+
# must_equal(file_or_filename)
|
16
|
+
# }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#write' do
|
20
|
+
subject { instance.write(message) }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#close' do
|
24
|
+
subject { instance.close }
|
25
|
+
end
|
26
|
+
|
27
|
+
end # LocklessLogDevice
|
28
|
+
|
29
|
+
end # Vedeu
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe MonoLogger do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::MonoLogger }
|
8
|
+
let(:instance) { described.new(logdev) }
|
9
|
+
let(:logdev) {}
|
10
|
+
|
11
|
+
describe '#initialize' do
|
12
|
+
it { instance.must_be_instance_of(described) }
|
13
|
+
it { instance.instance_variable_get('@level').must_equal(Logger::DEBUG) }
|
14
|
+
it {
|
15
|
+
instance.instance_variable_get('@default_formatter').
|
16
|
+
must_be_instance_of(Logger::Formatter)
|
17
|
+
}
|
18
|
+
it { instance.instance_variable_get('@Formatter').must_equal(nil) }
|
19
|
+
|
20
|
+
context 'when a log device is given' do
|
21
|
+
# it { instance.instance_variable_get('@logdev').must_be_instance_of(Vedeu::LocklessLogDevice) }
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when a log device is not given' do
|
25
|
+
# it { instance.instance_variable_get('@logdev').must_be_instance_of(Vedeu::LocklessLogDevice) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end # MonoLogger
|
30
|
+
|
31
|
+
end # Vedeu
|
@@ -26,8 +26,9 @@ module Vedeu
|
|
26
26
|
let(:virtual_buffer) { [] }
|
27
27
|
|
28
28
|
before do
|
29
|
+
Vedeu::Configuration.stubs(:drb?).returns(drb)
|
29
30
|
# Vedeu::Renderers::HTML.stubs(:to_file)
|
30
|
-
Vedeu::VirtualBuffers.stubs(:retrieve).returns(virtual_buffer)
|
31
|
+
# Vedeu::VirtualBuffers.stubs(:retrieve).returns(virtual_buffer)
|
31
32
|
end
|
32
33
|
|
33
34
|
it {
|
@@ -37,7 +37,6 @@ module Vedeu
|
|
37
37
|
|
38
38
|
describe '#execute!' do
|
39
39
|
before do
|
40
|
-
Configuration.stubs(:configure)# .returns(test_configuration)
|
41
40
|
Application.stubs(:start)
|
42
41
|
Kernel.stubs(:exit)
|
43
42
|
Kernel.stubs(:puts)
|
@@ -48,6 +47,32 @@ module Vedeu
|
|
48
47
|
it 'returns 0 for successful execution' do
|
49
48
|
subject.must_equal(0)
|
50
49
|
end
|
50
|
+
|
51
|
+
context 'when an uncaught exception occurs' do
|
52
|
+
before do
|
53
|
+
Vedeu::Application.stubs(:start).raises(StandardError, 'Oops!')
|
54
|
+
Vedeu::Configuration.stubs(:debug?).returns(debug)
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'but debugging is disabled' do
|
58
|
+
let(:debug) { false }
|
59
|
+
|
60
|
+
it {
|
61
|
+
Vedeu.expects(:log_stdout).with(type: :error, message: 'Oops!')
|
62
|
+
subject
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'and debugging is enabled' do
|
67
|
+
let(:debug) { true }
|
68
|
+
|
69
|
+
# Need to stub a backtrace.
|
70
|
+
# it {
|
71
|
+
# Vedeu.expects(:log_stdout).with(type: :error, message: 'Oops!')
|
72
|
+
# subject
|
73
|
+
# }
|
74
|
+
end
|
75
|
+
end
|
51
76
|
end
|
52
77
|
|
53
78
|
end # Launcher
|
data/vedeu.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency 'guard', '2.13.0'
|
24
24
|
spec.add_development_dependency 'guard-minitest', '2.4.4'
|
25
25
|
spec.add_development_dependency 'minitest', '5.8.0'
|
26
|
-
spec.add_development_dependency 'minitest-reporters', '1.0.
|
26
|
+
spec.add_development_dependency 'minitest-reporters', '1.0.20'
|
27
27
|
spec.add_development_dependency 'mocha', '1.1.0'
|
28
28
|
spec.add_development_dependency 'pry', '0.10.1'
|
29
29
|
spec.add_development_dependency 'rubocop', '0.33.0'
|
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.5.
|
4
|
+
version: 0.5.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Laking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.0.
|
61
|
+
version: 1.0.20
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.0.
|
68
|
+
version: 1.0.20
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mocha
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -348,7 +348,9 @@ files:
|
|
348
348
|
- lib/vedeu/input/mapper.rb
|
349
349
|
- lib/vedeu/internal_api.rb
|
350
350
|
- lib/vedeu/log/debug.rb
|
351
|
+
- lib/vedeu/log/lockless_log_device.rb
|
351
352
|
- lib/vedeu/log/log.rb
|
353
|
+
- lib/vedeu/log/mono_logger.rb
|
352
354
|
- lib/vedeu/log/timer.rb
|
353
355
|
- lib/vedeu/models/cell.rb
|
354
356
|
- lib/vedeu/models/escape.rb
|
@@ -506,7 +508,9 @@ files:
|
|
506
508
|
- test/lib/vedeu/input/mapper_test.rb
|
507
509
|
- test/lib/vedeu/internal_api_test.rb
|
508
510
|
- test/lib/vedeu/log/debug_test.rb
|
511
|
+
- test/lib/vedeu/log/lockless_log_device_test.rb
|
509
512
|
- test/lib/vedeu/log/log_test.rb
|
513
|
+
- test/lib/vedeu/log/mono_logger_test.rb
|
510
514
|
- test/lib/vedeu/log/timer_test.rb
|
511
515
|
- test/lib/vedeu/models/cell_test.rb
|
512
516
|
- test/lib/vedeu/models/escape_test.rb
|
@@ -609,7 +613,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
609
613
|
version: '0'
|
610
614
|
requirements: []
|
611
615
|
rubyforge_project:
|
612
|
-
rubygems_version: 2.4.
|
616
|
+
rubygems_version: 2.4.5.1
|
613
617
|
signing_key:
|
614
618
|
specification_version: 4
|
615
619
|
summary: A terminal case of wonderland.
|
@@ -692,7 +696,9 @@ test_files:
|
|
692
696
|
- test/lib/vedeu/input/mapper_test.rb
|
693
697
|
- test/lib/vedeu/internal_api_test.rb
|
694
698
|
- test/lib/vedeu/log/debug_test.rb
|
699
|
+
- test/lib/vedeu/log/lockless_log_device_test.rb
|
695
700
|
- test/lib/vedeu/log/log_test.rb
|
701
|
+
- test/lib/vedeu/log/mono_logger_test.rb
|
696
702
|
- test/lib/vedeu/log/timer_test.rb
|
697
703
|
- test/lib/vedeu/models/cell_test.rb
|
698
704
|
- test/lib/vedeu/models/escape_test.rb
|