vedeu 0.6.7 → 0.6.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/docs/dsl.md +4 -4
- data/lib/vedeu/all.rb +6 -18
- data/lib/vedeu/api.rb +14 -13
- data/lib/vedeu/bindings/system.rb +5 -4
- data/lib/vedeu/buffers/virtual_buffer.rb +13 -11
- data/lib/vedeu/configuration/api.rb +4 -3
- data/lib/vedeu/cursors/cursor.rb +23 -18
- data/lib/vedeu/distributed/client.rb +11 -6
- data/lib/vedeu/distributed/server.rb +4 -3
- data/lib/vedeu/dsl/keymap.rb +6 -6
- data/lib/vedeu/editor/all.rb +19 -0
- data/lib/vedeu/{input/editor → editor}/capture.rb +1 -1
- data/lib/vedeu/{input/editor → editor}/cropper.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/cursor.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/document.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/documents.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/editor.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/insert.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/line.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/lines.rb +0 -0
- data/lib/vedeu/error.rb +21 -18
- data/lib/vedeu/esc/borders.rb +6 -4
- data/lib/vedeu/esc/colours.rb +13 -12
- data/lib/vedeu/esc/esc.rb +11 -10
- data/lib/vedeu/input/all.rb +15 -0
- data/lib/vedeu/input/input.rb +55 -52
- data/lib/vedeu/input/key.rb +36 -30
- data/lib/vedeu/input/keymap.rb +101 -92
- data/lib/vedeu/input/keymaps.rb +10 -6
- data/lib/vedeu/input/keys.rb +8 -4
- data/lib/vedeu/input/mapper.rb +125 -121
- data/lib/vedeu/input/translator.rb +159 -0
- data/lib/vedeu/internal_api.rb +16 -15
- data/lib/vedeu/logging/all.rb +13 -0
- data/lib/vedeu/logging/debug.rb +84 -0
- data/lib/vedeu/logging/lockless_log_device.rb +65 -0
- data/lib/vedeu/logging/log.rb +179 -0
- data/lib/vedeu/logging/mono_logger.rb +26 -0
- data/lib/vedeu/logging/timer.rb +68 -0
- data/lib/vedeu/menus/all.rb +12 -0
- data/lib/vedeu/{dsl/menu.rb → menus/dsl.rb} +19 -18
- data/lib/vedeu/menus/menu.rb +234 -0
- data/lib/vedeu/{null/menu.rb → menus/null.rb} +6 -6
- data/lib/vedeu/menus/repository.rb +18 -0
- data/lib/vedeu/models/cell.rb +62 -55
- data/lib/vedeu/models/escape.rb +55 -50
- data/lib/vedeu/models/page.rb +74 -69
- data/lib/vedeu/models/row.rb +55 -51
- data/lib/vedeu/models/views/all.rb +1 -0
- data/lib/vedeu/models/views/char.rb +1 -1
- data/lib/vedeu/models/views/html_char.rb +165 -0
- data/lib/vedeu/output/renderers/html.rb +5 -4
- data/lib/vedeu/repositories/model.rb +2 -0
- data/lib/vedeu/runtime/application.rb +110 -103
- data/lib/vedeu/runtime/bootstrap.rb +109 -103
- data/lib/vedeu/runtime/flags.rb +45 -41
- data/lib/vedeu/runtime/launcher.rb +1 -1
- data/lib/vedeu/runtime/main_loop.rb +51 -46
- data/lib/vedeu/runtime/traps.rb +20 -16
- data/lib/vedeu/version.rb +1 -1
- data/lib/vedeu.rb +2 -2
- data/test/lib/vedeu/buffers/virtual_buffer_test.rb +1 -1
- data/test/lib/vedeu/cursors/cursor_test.rb +11 -5
- data/test/lib/vedeu/dsl/interface_test.rb +1 -1
- data/test/lib/vedeu/dsl/keymap_test.rb +2 -2
- data/test/lib/vedeu/{input/editor → editor}/capture_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/cropper_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/cursor_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/document_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/documents_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/editor_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/insert_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/line_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/lines_test.rb +0 -0
- data/test/lib/vedeu/input/input_test.rb +58 -54
- data/test/lib/vedeu/input/key_test.rb +29 -25
- data/test/lib/vedeu/input/keymap_test.rb +74 -70
- data/test/lib/vedeu/input/keymaps_test.rb +8 -4
- data/test/lib/vedeu/input/keys_test.rb +12 -8
- data/test/lib/vedeu/input/mapper_test.rb +64 -56
- data/test/lib/vedeu/input/translator_test.rb +36 -0
- data/test/lib/vedeu/logging/debug_test.rb +39 -0
- data/test/lib/vedeu/logging/lockless_log_device_test.rb +42 -0
- data/test/lib/vedeu/logging/log_test.rb +52 -0
- data/test/lib/vedeu/logging/mono_logger_test.rb +43 -0
- data/test/lib/vedeu/logging/timer_test.rb +44 -0
- data/test/lib/vedeu/{dsl/menu_test.rb → menus/dsl_test.rb} +6 -6
- data/test/lib/vedeu/menus/menu_test.rb +305 -0
- data/test/lib/vedeu/{null/menu_test.rb → menus/null_test.rb} +5 -5
- data/test/lib/vedeu/menus/repository_test.rb +17 -0
- data/test/lib/vedeu/models/cell_test.rb +54 -50
- data/test/lib/vedeu/models/escape_test.rb +49 -45
- data/test/lib/vedeu/models/page_test.rb +167 -160
- data/test/lib/vedeu/models/row_test.rb +71 -67
- data/test/lib/vedeu/models/views/html_char_test.rb +110 -0
- data/test/lib/vedeu/output/compressor_test.rb +44 -22
- data/test/lib/vedeu/output/renderers_test.rb +4 -2
- data/test/lib/vedeu/runtime/application_test.rb +36 -32
- data/test/lib/vedeu/runtime/bootstrap_test.rb +31 -26
- data/test/lib/vedeu/runtime/flags_test.rb +33 -29
- data/test/lib/vedeu/runtime/launcher_test.rb +4 -2
- data/test/lib/vedeu/runtime/main_loop_test.rb +28 -24
- data/test/lib/vedeu/runtime/traps_test.rb +8 -4
- data/test/test_helper.rb +4 -2
- metadata +66 -63
- data/lib/vedeu/input/editor/all.rb +0 -19
- data/lib/vedeu/input/input_translator.rb +0 -155
- data/lib/vedeu/log/debug.rb +0 -79
- data/lib/vedeu/log/lockless_log_device.rb +0 -61
- data/lib/vedeu/log/log.rb +0 -172
- data/lib/vedeu/log/mono_logger.rb +0 -21
- data/lib/vedeu/log/timer.rb +0 -63
- data/lib/vedeu/models/menu.rb +0 -217
- data/lib/vedeu/models/menus.rb +0 -14
- data/lib/vedeu/output/html_char.rb +0 -161
- data/test/lib/vedeu/input/input_translator_test.rb +0 -32
- data/test/lib/vedeu/log/debug_test.rb +0 -35
- data/test/lib/vedeu/log/lockless_log_device_test.rb +0 -29
- data/test/lib/vedeu/log/log_test.rb +0 -48
- data/test/lib/vedeu/log/mono_logger_test.rb +0 -31
- data/test/lib/vedeu/log/timer_test.rb +0 -40
- data/test/lib/vedeu/models/menu_test.rb +0 -301
- data/test/lib/vedeu/models/menus_test.rb +0 -13
- data/test/lib/vedeu/output/html_char_test.rb +0 -106
@@ -0,0 +1,165 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
module Views
|
4
|
+
|
5
|
+
# Represents a {Vedeu::Views::Char} as a HTML tag with value. By
|
6
|
+
# default, a table cell is used.
|
7
|
+
#
|
8
|
+
class HTMLChar
|
9
|
+
|
10
|
+
include Vedeu::Common
|
11
|
+
|
12
|
+
# @param char [Vedeu::Views::Char]
|
13
|
+
# @param options [Hash<Symbol => String>]
|
14
|
+
# @option options start_tag [String]
|
15
|
+
# @option options end_tag [String]
|
16
|
+
# @return [String]
|
17
|
+
def self.render(char, options = {})
|
18
|
+
new(char, options).render
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns a new instance of Vedeu::Views::HTMLChar.
|
22
|
+
#
|
23
|
+
# @param char [Vedeu::Views::Char]
|
24
|
+
# @param options [Hash<Symbol => String>]
|
25
|
+
# @option options start_tag [String]
|
26
|
+
# @option options end_tag [String]
|
27
|
+
# @return [Vedeu::Views::HTMLChar]
|
28
|
+
def initialize(char, options = {})
|
29
|
+
@char = char
|
30
|
+
@options = options
|
31
|
+
end
|
32
|
+
|
33
|
+
# @return [String]
|
34
|
+
def render
|
35
|
+
"#{start_tag}#{tag_style}>#{tag_value}#{end_tag}"
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
|
40
|
+
# @!attribute [r] char
|
41
|
+
# @return [Vedeu::Views::Char]
|
42
|
+
attr_reader :char
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
# @return [String]
|
47
|
+
def tag_style
|
48
|
+
return '' unless border || present?(value)
|
49
|
+
|
50
|
+
out = " style='"
|
51
|
+
out << tag_style_background unless char.background.empty?
|
52
|
+
out << tag_style_foreground unless char.foreground.empty?
|
53
|
+
out << "'"
|
54
|
+
end
|
55
|
+
|
56
|
+
# @return [String]
|
57
|
+
def tag_style_background
|
58
|
+
"border:1px #{char.background.to_html} solid;" \
|
59
|
+
"background:#{char.background.to_html};"
|
60
|
+
end
|
61
|
+
|
62
|
+
# @return [String]
|
63
|
+
def tag_style_foreground
|
64
|
+
"color:#{char.foreground.to_html};#{border_style}"
|
65
|
+
end
|
66
|
+
|
67
|
+
# @return [String]
|
68
|
+
def tag_value
|
69
|
+
return ' ' if border || !present?(value)
|
70
|
+
|
71
|
+
value
|
72
|
+
end
|
73
|
+
|
74
|
+
# @return [String]
|
75
|
+
def border_style
|
76
|
+
case border
|
77
|
+
when :top_horizontal then css('top')
|
78
|
+
when :left_vertical then css('left')
|
79
|
+
when :right_vertical then css('right')
|
80
|
+
when :bottom_horizontal then css('bottom')
|
81
|
+
when :top_left then "#{css('top')}#{css('left')}"
|
82
|
+
when :top_right then "#{css('top')}#{css('right')}"
|
83
|
+
when :bottom_left then "#{css('bottom')}#{css('left')}"
|
84
|
+
when :bottom_right then "#{css('bottom')}#{css('right')}"
|
85
|
+
else
|
86
|
+
''
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# @return [String]
|
91
|
+
def css(direction = '')
|
92
|
+
"border-#{direction}:1px #{char.foreground.to_html} solid;"
|
93
|
+
end
|
94
|
+
|
95
|
+
# # @return [String]
|
96
|
+
# def fg
|
97
|
+
# @fg ||= colour(char, 'foreground', '#222')
|
98
|
+
# end
|
99
|
+
|
100
|
+
# # @return [String]
|
101
|
+
# def bg
|
102
|
+
# @bg ||= colour(char, 'background', '#000')
|
103
|
+
# end
|
104
|
+
|
105
|
+
# @param char [Vedeu::Views::Char]
|
106
|
+
# @param type [String] 'background' or 'foreground'
|
107
|
+
# @param default [String] A default colour (CSS style; e.g. '#b2adf2')
|
108
|
+
# @return [String]
|
109
|
+
# def colour(char, type, default)
|
110
|
+
# parent_type = char.send(:parent).send(type).send(:to_html)
|
111
|
+
# #parent_type = ('parent_' + type).to_sym
|
112
|
+
# type_to_html = char.send(type).send(:to_html)
|
113
|
+
# #parent_type_to_html = char.send(parent_type).send(:to_html)
|
114
|
+
|
115
|
+
# if present?(type_to_html)
|
116
|
+
# type_to_html
|
117
|
+
|
118
|
+
# elsif char.parent
|
119
|
+
# parent_type
|
120
|
+
# #char.parent.send(type).send(:to_html)
|
121
|
+
|
122
|
+
# else
|
123
|
+
# default
|
124
|
+
|
125
|
+
# end
|
126
|
+
# end
|
127
|
+
|
128
|
+
# @return [Symbol|NilClass]
|
129
|
+
def border
|
130
|
+
char.border
|
131
|
+
end
|
132
|
+
|
133
|
+
# @return [String]
|
134
|
+
def value
|
135
|
+
char.value
|
136
|
+
end
|
137
|
+
|
138
|
+
# @return [String]
|
139
|
+
def start_tag
|
140
|
+
options[:start_tag]
|
141
|
+
end
|
142
|
+
|
143
|
+
# @return [String]
|
144
|
+
def end_tag
|
145
|
+
options[:end_tag]
|
146
|
+
end
|
147
|
+
|
148
|
+
# @return [Hash<Symbol => String>]
|
149
|
+
def options
|
150
|
+
defaults.merge!(@options)
|
151
|
+
end
|
152
|
+
|
153
|
+
# @return [Hash<Symbol => String>]
|
154
|
+
def defaults
|
155
|
+
{
|
156
|
+
start_tag: '<td',
|
157
|
+
end_tag: '</td>',
|
158
|
+
}
|
159
|
+
end
|
160
|
+
|
161
|
+
end # HTMLChar
|
162
|
+
|
163
|
+
end # Views
|
164
|
+
|
165
|
+
end # Vedeu
|
@@ -2,8 +2,8 @@ module Vedeu
|
|
2
2
|
|
3
3
|
module Renderers
|
4
4
|
|
5
|
-
# Renders a {Vedeu::VirtualBuffer} or {Vedeu::Output} as a HTML
|
6
|
-
# a table by default.
|
5
|
+
# Renders a {Vedeu::VirtualBuffer} or {Vedeu::Output} as a HTML
|
6
|
+
# snippet; a table by default.
|
7
7
|
#
|
8
8
|
class HTML < Vedeu::Renderers::File
|
9
9
|
|
@@ -29,7 +29,7 @@ module Vedeu
|
|
29
29
|
|
30
30
|
# @return [String]
|
31
31
|
def html_body
|
32
|
-
return '' if content.is_a?(Vedeu::Escape)
|
32
|
+
return '' if content.is_a?(Vedeu::Models::Escape)
|
33
33
|
|
34
34
|
out = ''
|
35
35
|
|
@@ -68,7 +68,8 @@ module Vedeu
|
|
68
68
|
options[:template]
|
69
69
|
end
|
70
70
|
|
71
|
-
# Combines the options provided at instantiation with the
|
71
|
+
# Combines the options provided at instantiation with the
|
72
|
+
# default values.
|
72
73
|
#
|
73
74
|
# @return [Hash<Symbol => void>]
|
74
75
|
def options
|
@@ -115,6 +115,8 @@ module Vedeu
|
|
115
115
|
'Vedeu::Buffers::DSL'
|
116
116
|
elsif demodulize(self.class.name) == 'Geometry'
|
117
117
|
'Vedeu::Geometry::DSL'
|
118
|
+
elsif demodulize(self.class.name) == 'Menu'
|
119
|
+
'Vedeu::Menus::DSL'
|
118
120
|
else
|
119
121
|
'Vedeu::DSL::' + demodulize(self.class.name)
|
120
122
|
end
|
@@ -1,132 +1,139 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
|
4
|
-
#
|
5
|
-
class Application
|
3
|
+
module Runtime
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
5
|
+
# Orchestrates the running of the main application loop.
|
6
|
+
#
|
7
|
+
class Application
|
8
|
+
|
9
|
+
class << self
|
10
|
+
|
11
|
+
# @param (see #initialize)
|
12
|
+
def start(configuration)
|
13
|
+
new(configuration).start
|
14
|
+
end
|
15
|
+
|
16
|
+
# @param (see #initialize)
|
17
|
+
def restart(configuration)
|
18
|
+
new(configuration).start
|
19
|
+
end
|
20
|
+
|
21
|
+
# Stops the application! - The `:_cleanup_` event is
|
22
|
+
# triggered, which in turn triggers the client event
|
23
|
+
# `:cleanup`; the client application may treat this event as
|
24
|
+
# Vedeu signalling that it is about to terminate. Client
|
25
|
+
# applications are encouraged to use this event to close any
|
26
|
+
# open buffers, save files, empty trash, etc.
|
27
|
+
#
|
28
|
+
# @example
|
29
|
+
# Vedeu.exit
|
30
|
+
#
|
31
|
+
# @return [void]
|
32
|
+
def stop
|
33
|
+
Vedeu.trigger(:_cleanup_)
|
34
|
+
|
35
|
+
Vedeu::Runtime::MainLoop.stop!
|
36
|
+
end
|
37
|
+
alias_method :exit, :stop
|
38
|
+
|
39
|
+
end # Eigenclass
|
40
|
+
|
41
|
+
# :nocov:
|
42
|
+
|
43
|
+
# Returns a new instance of Vedeu::Runtime::Application.
|
44
|
+
#
|
45
|
+
# @param configuration [Vedeu::Configuration]
|
46
|
+
# @return [Vedeu::Runtime::Application]
|
47
|
+
def initialize(configuration)
|
48
|
+
@configuration = configuration
|
17
49
|
end
|
18
50
|
|
19
|
-
#
|
20
|
-
# - The `:_cleanup_` event is triggered, which in turn triggers the client
|
21
|
-
# event `:cleanup`; the client application may treat this event as Vedeu
|
22
|
-
# signalling that it is about to terminate. Client applications are
|
23
|
-
# encouraged to use this event to close any open buffers, save files,
|
24
|
-
# empty trash, etc.
|
51
|
+
# Starts the application!
|
25
52
|
#
|
26
|
-
#
|
27
|
-
#
|
53
|
+
# - A new terminal screen is opened (or rather the current
|
54
|
+
# terminal is requested into either :raw or :cooked mode).
|
55
|
+
# - The cursor visibility is then set dependent on this mode.
|
56
|
+
# In :raw mode, the cursor is hidden.
|
57
|
+
# - The `:_initialize_` event is triggered. The client
|
58
|
+
# application is may treat this event as Vedeu signalling that
|
59
|
+
# it is now ready.
|
60
|
+
# - We enter into the main sequence where the application will
|
61
|
+
# either run once or continuous, interactively or standalone.
|
28
62
|
#
|
29
|
-
# @return [
|
30
|
-
def
|
31
|
-
Vedeu.trigger(:
|
32
|
-
|
33
|
-
Vedeu::MainLoop.stop!
|
34
|
-
end
|
35
|
-
alias_method :exit, :stop
|
36
|
-
|
37
|
-
end # Eigenclass
|
38
|
-
|
39
|
-
# :nocov:
|
40
|
-
|
41
|
-
# Returns a new instance of Vedeu::Application.
|
42
|
-
#
|
43
|
-
# @param configuration [Vedeu::Configuration]
|
44
|
-
# @return [Vedeu::Application]
|
45
|
-
def initialize(configuration)
|
46
|
-
@configuration = configuration
|
47
|
-
end
|
48
|
-
|
49
|
-
# Starts the application!
|
50
|
-
# - A new terminal screen is opened (or rather the current terminal is
|
51
|
-
# requested into either :raw or :cooked mode).
|
52
|
-
# - The cursor visibility is then set dependent on this mode. In :raw mode,
|
53
|
-
# the cursor is hidden.
|
54
|
-
# - The `:_initialize_` event is triggered. The client application is
|
55
|
-
# may treat this event as Vedeu signalling that it is now ready.
|
56
|
-
# - We enter into the main sequence where the application will either run
|
57
|
-
# once or continuous, interactively or standalone.
|
58
|
-
#
|
59
|
-
# @return [Array] The last output sent to the terminal.
|
60
|
-
def start
|
61
|
-
Vedeu.trigger(:_drb_start_)
|
63
|
+
# @return [Array] The last output sent to the terminal.
|
64
|
+
def start
|
65
|
+
Vedeu.trigger(:_drb_start_)
|
62
66
|
|
63
|
-
|
64
|
-
|
67
|
+
Vedeu::Terminal.open do
|
68
|
+
Vedeu::Terminal.set_cursor_mode
|
65
69
|
|
66
|
-
|
70
|
+
Vedeu.trigger(:_initialize_)
|
67
71
|
|
68
|
-
|
72
|
+
runner { main_sequence }
|
73
|
+
end
|
69
74
|
end
|
70
|
-
end
|
71
75
|
|
72
|
-
|
76
|
+
protected
|
73
77
|
|
74
|
-
|
75
|
-
|
76
|
-
|
78
|
+
# @!attribute [r] configuration
|
79
|
+
# @return [Vedeu::Configuration]
|
80
|
+
attr_reader :configuration
|
77
81
|
|
78
|
-
|
82
|
+
private
|
79
83
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
84
|
+
# Runs the application loop either once, or forever (exceptions
|
85
|
+
# and signals permitting).
|
86
|
+
#
|
87
|
+
# @return [void]
|
88
|
+
def runner
|
89
|
+
if configuration.once?
|
90
|
+
yield
|
87
91
|
|
88
|
-
|
89
|
-
|
92
|
+
else
|
93
|
+
run_many { yield }
|
90
94
|
|
95
|
+
end
|
91
96
|
end
|
92
|
-
end
|
93
|
-
|
94
|
-
# For an interactive application we capture input, (usually from the user),
|
95
|
-
# and continue the main loop. If the client application does not require
|
96
|
-
# user input then Vedeu triggers the `:_standalone_` event for each run of
|
97
|
-
# the main loop. The client application is expected to respond to this event
|
98
|
-
# and 'do something useful'. When the client application has finished, it
|
99
|
-
# should trigger the `:_exit_` event.
|
100
|
-
#
|
101
|
-
# @return [void]
|
102
|
-
def main_sequence
|
103
|
-
if configuration.interactive?
|
104
|
-
Vedeu::Input.capture(Terminal)
|
105
97
|
|
106
|
-
|
107
|
-
|
98
|
+
# For an interactive application we capture input, (usually from
|
99
|
+
# the user), and continue the main loop. If the client
|
100
|
+
# application does not require user input then Vedeu triggers
|
101
|
+
# the `:_standalone_` event for each run of the main loop. The
|
102
|
+
# client application is expected to respond to this event and
|
103
|
+
# 'do something useful'. When the client application has
|
104
|
+
# finished, it should trigger the `:_exit_` event.
|
105
|
+
#
|
106
|
+
# @return [void]
|
107
|
+
def main_sequence
|
108
|
+
if configuration.interactive?
|
109
|
+
Vedeu::Input::Input.capture(Terminal)
|
110
|
+
|
111
|
+
else
|
112
|
+
Vedeu.trigger(:_standalone_)
|
108
113
|
|
114
|
+
end
|
109
115
|
end
|
110
|
-
end
|
111
116
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
117
|
+
# Runs the application in a continuous loop. This loop is
|
118
|
+
# stopped when an uncaught exception occurs or when either the
|
119
|
+
# `:_mode_switch_` or `:_exit_` event is triggered.
|
120
|
+
#
|
121
|
+
# @return [void]
|
122
|
+
def run_many
|
123
|
+
Vedeu::Runtime::MainLoop.start! { yield }
|
124
|
+
|
125
|
+
rescue Vedeu::Error::ModeSwitch
|
126
|
+
Vedeu::Terminal.switch_mode!
|
119
127
|
|
120
|
-
|
121
|
-
Vedeu::Terminal.switch_mode!
|
128
|
+
Vedeu.trigger(:_drb_restart_)
|
122
129
|
|
123
|
-
|
130
|
+
Vedeu::Runtime::Application.restart(configuration)
|
131
|
+
end
|
124
132
|
|
125
|
-
|
126
|
-
end
|
133
|
+
# :nocov:
|
127
134
|
|
128
|
-
#
|
135
|
+
end # Application
|
129
136
|
|
130
|
-
end #
|
137
|
+
end # Runtime
|
131
138
|
|
132
139
|
end # Vedeu
|
@@ -1,123 +1,129 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
# Vedeu with this data, then starts the client application.
|
7
|
-
#
|
8
|
-
class Bootstrap
|
9
|
-
|
10
|
-
# @param argv [Array<String>]
|
11
|
-
# @return [void]
|
12
|
-
def self.start(argv = ARGV)
|
13
|
-
new(argv).start
|
14
|
-
end
|
15
|
-
|
16
|
-
# Returns a new instance of Vedeu::Bootstrap.
|
3
|
+
module Runtime
|
4
|
+
|
5
|
+
# Provides the mechanism to start up a generated application.
|
17
6
|
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
def initialize(argv)
|
21
|
-
@argv = argv
|
22
|
-
end
|
23
|
-
|
24
|
-
# Loads all of the client application files so that Vedeu has access to
|
25
|
-
# them, then launches the client application.
|
7
|
+
# This class loads all necessary client application files and initializes
|
8
|
+
# Vedeu with this data, then starts the client application.
|
26
9
|
#
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
10
|
+
class Bootstrap
|
11
|
+
|
12
|
+
# @param argv [Array<String>]
|
13
|
+
# @return [void]
|
14
|
+
def self.start(argv = ARGV)
|
15
|
+
new(argv).start
|
16
|
+
end
|
17
|
+
|
18
|
+
# Returns a new instance of Vedeu::Runtime::Bootstrap.
|
19
|
+
#
|
20
|
+
# @param argv [Array<String>]
|
21
|
+
# @return [Vedeu::Runtime::Bootstrap]
|
22
|
+
def initialize(argv)
|
23
|
+
@argv = argv
|
24
|
+
end
|
33
25
|
|
34
|
-
Vedeu
|
35
|
-
|
26
|
+
# Loads all of the client application files so that Vedeu has access to
|
27
|
+
# them, then launches the client application.
|
28
|
+
#
|
29
|
+
# @return [void]
|
30
|
+
def start
|
31
|
+
configure_log!
|
32
|
+
client_configuration!
|
33
|
+
client_application!
|
34
|
+
client_initialize!
|
35
|
+
|
36
|
+
Vedeu::Launcher.execute!(argv)
|
37
|
+
end
|
36
38
|
|
37
|
-
|
39
|
+
protected
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
41
|
+
# @!attribute [r] argv
|
42
|
+
# @return [Array<String>]
|
43
|
+
attr_reader :argv
|
42
44
|
|
43
|
-
|
45
|
+
private
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
# @return [String]
|
48
|
+
def base_path
|
49
|
+
Vedeu::Configuration.base_path
|
50
|
+
end
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
# @note
|
53
|
+
# config/configuration.rb is already loaded so don't load it twice
|
54
|
+
# @return [void]
|
55
|
+
def client_configuration!
|
56
|
+
Dir[File.join(base_path, 'config/**/*')].each do |path|
|
57
|
+
next if path =~ %r{config/configuration\.rb}
|
56
58
|
|
57
|
-
|
59
|
+
load(path)
|
60
|
+
end
|
58
61
|
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# @return [void]
|
62
|
-
def client_application!
|
63
|
-
[
|
64
|
-
'app/views/templates/**/*',
|
65
|
-
'app/views/interfaces/**/*',
|
66
|
-
'app/controllers/**/*',
|
67
|
-
'app/helpers/**/*',
|
68
|
-
'app/views/**/*',
|
69
|
-
'app/models/keymaps/**/*',
|
70
|
-
].each { |path| load(File.join(base_path, path)) }
|
71
|
-
end
|
72
|
-
|
73
|
-
# @return [void]
|
74
|
-
def client_initialize!
|
75
|
-
if Vedeu::Configuration.root
|
76
|
-
Vedeu.trigger(:_goto_, *Vedeu::Configuration.root)
|
77
|
-
|
78
|
-
else
|
79
|
-
Vedeu.log_stderr(type: :debug, message: client_initialize_error)
|
80
62
|
|
63
|
+
# @return [void]
|
64
|
+
def client_application!
|
65
|
+
[
|
66
|
+
'app/views/templates/**/*',
|
67
|
+
'app/views/interfaces/**/*',
|
68
|
+
'app/controllers/**/*',
|
69
|
+
'app/helpers/**/*',
|
70
|
+
'app/views/**/*',
|
71
|
+
'app/models/keymaps/**/*',
|
72
|
+
].each { |path| load(File.join(base_path, path)) }
|
81
73
|
end
|
82
|
-
end
|
83
74
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
def load(path)
|
89
|
-
loadables(path).each { |file| Kernel.load(file) }
|
75
|
+
# @return [void]
|
76
|
+
def client_initialize!
|
77
|
+
if Vedeu::Configuration.root
|
78
|
+
Vedeu.trigger(:_goto_, *Vedeu::Configuration.root)
|
90
79
|
|
91
|
-
|
92
|
-
|
80
|
+
else
|
81
|
+
Vedeu.log_stderr(type: :debug, message: client_initialize_error)
|
93
82
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# Load each of the loadable files.
|
87
|
+
#
|
88
|
+
# @param path [String]
|
89
|
+
# @return [String]
|
90
|
+
def load(path)
|
91
|
+
loadables(path).each { |file| Kernel.load(file) }
|
92
|
+
|
93
|
+
path
|
94
|
+
end
|
95
|
+
|
96
|
+
# Collect each of the files from the client application
|
97
|
+
# directories by path excluding '.' and '..' and only loading
|
98
|
+
# files with the '.rb' extension.
|
99
|
+
#
|
100
|
+
# @param path [String]
|
101
|
+
# @return [Array<String>]
|
102
|
+
def loadables(path)
|
103
|
+
Dir.glob(path).select do |file|
|
104
|
+
File.file?(file) && File.extname(file) == '.rb'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# @return [void]
|
109
|
+
def configure_log!
|
110
|
+
Vedeu.configure do
|
111
|
+
log('/tmp/vedeu_bootstrap.log')
|
112
|
+
end unless Vedeu::Configuration.log?
|
113
|
+
end
|
114
|
+
|
115
|
+
# @return [String]
|
116
|
+
def client_initialize_error
|
117
|
+
"Please update the 'root' setting in " \
|
118
|
+
"'config/configuration.rb' to start Vedeu using this " \
|
119
|
+
"controller and action: (args are optional)\n\n" \
|
120
|
+
"Vedeu.configure do\n" \
|
121
|
+
" root :some_controller, :show, *args\n" \
|
122
|
+
"end\n\n"
|
102
123
|
end
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
Vedeu.configure do
|
108
|
-
log('/tmp/vedeu_bootstrap.log')
|
109
|
-
end unless Vedeu::Configuration.log?
|
110
|
-
end
|
111
|
-
|
112
|
-
# @return [String]
|
113
|
-
def client_initialize_error
|
114
|
-
"Please update the 'root' setting in 'config/configuration.rb' to " \
|
115
|
-
"start Vedeu using this controller and action: (args are optional)\n\n" \
|
116
|
-
"Vedeu.configure do\n" \
|
117
|
-
" root :some_controller, :show, *args\n" \
|
118
|
-
"end\n\n"
|
119
|
-
end
|
120
|
-
|
121
|
-
end # Bootstrap
|
124
|
+
|
125
|
+
end # Bootstrap
|
126
|
+
|
127
|
+
end # Runtime
|
122
128
|
|
123
129
|
end # Vedeu
|