vedeu 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +6 -0
- data/bin/vedeu_drb_client +8 -3
- data/bin/vedeu_drb_server +113 -0
- data/bin/vedeu_test +1 -1
- data/docs/events.md +0 -127
- data/examples/borders_app.rb +17 -7
- data/examples/configuration_app.rb +1 -1
- data/examples/cursor_app.rb +4 -2
- data/examples/drb_app.rb +113 -0
- data/examples/focus_app.rb +1 -1
- data/examples/geometry_app.rb +1 -1
- data/examples/hello_world.rb +1 -1
- data/examples/lines_app.rb +1 -1
- data/features/start_stop.feature +1 -1
- data/inch.yml +5 -0
- data/lib/vedeu/all.rb +2 -0
- data/lib/vedeu/api.rb +1 -0
- data/lib/vedeu/application.rb +17 -36
- data/lib/vedeu/bindings.rb +134 -27
- data/lib/vedeu/buffers/display_buffer.rb +1 -4
- data/lib/vedeu/configuration/api.rb +15 -14
- data/lib/vedeu/configuration/cli.rb +17 -16
- data/lib/vedeu/configuration/configuration.rb +3 -1
- data/lib/vedeu/cursor/cursor.rb +6 -8
- data/lib/vedeu/cursor/move_cursor.rb +1 -0
- data/lib/vedeu/cursor/toggle_cursor.rb +1 -0
- data/lib/vedeu/debug.rb +23 -0
- data/lib/vedeu/distributed/all.rb +1 -1
- data/lib/vedeu/distributed/client.rb +55 -13
- data/lib/vedeu/distributed/server.rb +207 -0
- data/lib/vedeu/distributed/subprocess.rb +22 -21
- data/lib/vedeu/distributed/templates/default_application.vedeu +3 -1
- data/lib/vedeu/distributed/test_application.rb +2 -1
- data/lib/vedeu/distributed/uri.rb +1 -0
- data/lib/vedeu/dsl/all.rb +4 -2
- data/lib/vedeu/dsl/components/border.rb +11 -10
- data/lib/vedeu/dsl/components/geometry.rb +1 -0
- data/lib/vedeu/dsl/components/keymap.rb +1 -0
- data/lib/vedeu/dsl/components/menu.rb +1 -0
- data/lib/vedeu/dsl/interface.rb +1 -0
- data/lib/vedeu/dsl/line.rb +3 -1
- data/lib/vedeu/dsl/shared/colour.rb +1 -0
- data/lib/vedeu/dsl/shared/style.rb +1 -0
- data/lib/vedeu/dsl/shared/text.rb +2 -0
- data/lib/vedeu/dsl/shared/use.rb +3 -0
- data/lib/vedeu/dsl/stream.rb +3 -1
- data/lib/vedeu/dsl/view.rb +1 -0
- data/lib/vedeu/events/event.rb +9 -6
- data/lib/vedeu/events/trigger.rb +18 -7
- data/lib/vedeu/exceptions.rb +4 -1
- data/lib/vedeu/input/input.rb +1 -0
- data/lib/vedeu/input/key.rb +0 -1
- data/lib/vedeu/input/keymap.rb +5 -3
- data/lib/vedeu/input/keys.rb +1 -0
- data/lib/vedeu/input/mapper.rb +1 -0
- data/lib/vedeu/launcher.rb +35 -12
- data/lib/vedeu/main_loop.rb +53 -0
- data/lib/vedeu/models/collection.rb +11 -3
- data/lib/vedeu/models/focus.rb +3 -3
- data/lib/vedeu/models/geometry.rb +8 -16
- data/lib/vedeu/models/group.rb +1 -0
- data/lib/vedeu/models/menu.rb +2 -1
- data/lib/vedeu/models/model.rb +7 -1
- data/lib/vedeu/models/view/char.rb +52 -44
- data/lib/vedeu/models/view/chars.rb +1 -0
- data/lib/vedeu/models/view/composition.rb +2 -1
- data/lib/vedeu/models/view/interface.rb +5 -3
- data/lib/vedeu/models/view/interfaces.rb +1 -0
- data/lib/vedeu/models/view/line.rb +2 -1
- data/lib/vedeu/models/view/stream.rb +2 -1
- data/lib/vedeu/models/view/streams.rb +1 -0
- data/lib/vedeu/output/all.rb +4 -0
- data/lib/vedeu/output/border.rb +75 -206
- data/lib/vedeu/output/compositor.rb +1 -0
- data/lib/vedeu/output/html_char.rb +119 -0
- data/lib/vedeu/output/html_renderer.rb +89 -0
- data/lib/vedeu/output/output.rb +48 -44
- data/lib/vedeu/output/position_index.rb +12 -1
- data/lib/vedeu/output/renderer.rb +28 -0
- data/lib/vedeu/output/viewport.rb +14 -14
- data/lib/vedeu/output/virtual_buffer.rb +56 -0
- data/lib/vedeu/output/virtual_terminal.rb +42 -34
- data/lib/vedeu/output/wordwrap.rb +3 -0
- data/lib/vedeu/output/writer.rb +13 -1
- data/lib/vedeu/presentation/background.rb +1 -0
- data/lib/vedeu/presentation/colour.rb +8 -7
- data/lib/vedeu/presentation/foreground.rb +1 -0
- data/lib/vedeu/presentation/presentation.rb +43 -7
- data/lib/vedeu/presentation/translator.rb +12 -0
- data/lib/vedeu/repositories/repository.rb +8 -8
- data/lib/vedeu/support/bounding_area.rb +2 -0
- data/lib/vedeu/support/coercions.rb +2 -1
- data/lib/vedeu/support/common.rb +1 -0
- data/lib/vedeu/support/console.rb +17 -23
- data/lib/vedeu/support/content_geometry.rb +2 -0
- data/lib/vedeu/support/coordinate.rb +1 -0
- data/lib/vedeu/support/esc.rb +58 -29
- data/lib/vedeu/support/grid.rb +1 -0
- data/lib/vedeu/support/limit.rb +9 -0
- data/lib/vedeu/support/log.rb +31 -9
- data/lib/vedeu/support/node.rb +8 -18
- data/lib/vedeu/support/position.rb +13 -34
- data/lib/vedeu/support/position_validator.rb +3 -0
- data/lib/vedeu/support/read.rb +1 -0
- data/lib/vedeu/support/refresh.rb +3 -2
- data/lib/vedeu/support/terminal.rb +11 -5
- data/lib/vedeu/support/trace.rb +16 -1
- data/lib/vedeu/support/visible.rb +2 -0
- data/lib/vedeu/support/write.rb +1 -0
- data/lib/vedeu/traps.rb +1 -0
- data/lib/vedeu.rb +2 -0
- data/test/integration/distributed_test.rb +10 -8
- data/test/lib/vedeu/api_test.rb +3 -7
- data/test/lib/vedeu/application_test.rb +2 -5
- data/test/lib/vedeu/configuration/api_test.rb +12 -0
- data/test/lib/vedeu/cursor/cursor_test.rb +2 -0
- data/test/lib/vedeu/distributed/client_test.rb +17 -7
- data/test/lib/vedeu/distributed/server_test.rb +56 -0
- data/test/lib/vedeu/distributed/test_application_test.rb +7 -3
- data/test/lib/vedeu/dsl/components/border_test.rb +10 -2
- data/test/lib/vedeu/dsl/interface_test.rb +6 -0
- data/test/lib/vedeu/dsl/line_test.rb +19 -0
- data/test/lib/vedeu/dsl/shared/colour_test.rb +4 -26
- data/test/lib/vedeu/dsl/shared/text_test.rb +8 -1
- data/test/lib/vedeu/dsl/stream_test.rb +13 -1
- data/test/lib/vedeu/input/input_test.rb +1 -1
- data/test/lib/vedeu/input/key_test.rb +3 -16
- data/test/lib/vedeu/launcher_test.rb +11 -1
- data/test/lib/vedeu/main_loop_test.rb +41 -0
- data/test/lib/vedeu/models/geometry_test.rb +15 -34
- data/test/lib/vedeu/models/view/char_test.rb +44 -45
- data/test/lib/vedeu/models/view/interface_test.rb +6 -0
- data/test/lib/vedeu/models/view/line_test.rb +1 -1
- data/test/lib/vedeu/models/view/stream_test.rb +1 -1
- data/test/lib/vedeu/output/border_test.rb +6 -5
- data/test/lib/vedeu/output/compositor_test.rb +2 -20
- data/test/lib/vedeu/output/html_char_test.rb +85 -0
- data/test/lib/vedeu/output/html_renderer_test.rb +37 -0
- data/test/lib/vedeu/output/position_index_test.rb +2 -10
- data/test/lib/vedeu/output/renderer_test.rb +24 -0
- data/test/lib/vedeu/output/virtual_buffer_test.rb +53 -0
- data/test/lib/vedeu/output/virtual_terminal_test.rb +32 -2
- data/test/lib/vedeu/presentation/background_test.rb +41 -1
- data/test/lib/vedeu/presentation/colour_test.rb +10 -6
- data/test/lib/vedeu/presentation/foreground_test.rb +46 -6
- data/test/lib/vedeu/presentation/presentation_test.rb +44 -1
- data/test/lib/vedeu/presentation/translator_test.rb +34 -0
- data/test/lib/vedeu/repositories/repository_test.rb +1 -1
- data/test/lib/vedeu/support/bounding_area_test.rb +4 -12
- data/test/lib/vedeu/support/console_test.rb +9 -50
- data/test/lib/vedeu/support/esc_test.rb +7 -7
- data/test/lib/vedeu/support/position_test.rb +42 -0
- data/test/lib/vedeu/support/terminal_test.rb +5 -20
- data/test/lib/vedeu/support/write_test.rb +42 -18
- data/test/support/helpers/all.rb +0 -1
- data/test/support/helpers/repository_test_module.rb +1 -0
- data/test/test_helper.rb +5 -2
- data/vedeu.gemspec +7 -5
- metadata +60 -14
- data/lib/vedeu/distributed/application.rb +0 -91
- data/test/lib/vedeu/distributed/application_test.rb +0 -24
- data/test/support/helpers/presentation.rb +0 -16
data/lib/vedeu/cursor/cursor.rb
CHANGED
@@ -9,6 +9,7 @@ module Vedeu
|
|
9
9
|
# visibility of the cursor within that interface.
|
10
10
|
#
|
11
11
|
# @api private
|
12
|
+
#
|
12
13
|
class Cursor
|
13
14
|
|
14
15
|
extend Forwardable
|
@@ -49,6 +50,8 @@ module Vedeu
|
|
49
50
|
@state = Vedeu::Visible.coerce(@attributes.fetch(:state))
|
50
51
|
@x = @attributes.fetch(:x)
|
51
52
|
@y = @attributes.fetch(:y)
|
53
|
+
|
54
|
+
@position = Vedeu::Position.new(@y, @x)
|
52
55
|
end
|
53
56
|
|
54
57
|
# Returns log friendly output.
|
@@ -76,6 +79,8 @@ module Vedeu
|
|
76
79
|
|
77
80
|
private
|
78
81
|
|
82
|
+
attr_reader :position
|
83
|
+
|
79
84
|
# The default values for a new instance of this class.
|
80
85
|
#
|
81
86
|
# @return [Hash]
|
@@ -85,7 +90,7 @@ module Vedeu
|
|
85
90
|
ox: 0,
|
86
91
|
oy: 0,
|
87
92
|
repository: Vedeu.cursors,
|
88
|
-
state:
|
93
|
+
state: false,
|
89
94
|
x: 1,
|
90
95
|
y: 1,
|
91
96
|
}
|
@@ -98,13 +103,6 @@ module Vedeu
|
|
98
103
|
[ position, visibility ].join
|
99
104
|
end
|
100
105
|
|
101
|
-
# Returns the escape sequence for setting the position of the cursor.
|
102
|
-
#
|
103
|
-
# @return [String]
|
104
|
-
def position
|
105
|
-
Vedeu::Position.new(y, x).to_s
|
106
|
-
end
|
107
|
-
|
108
106
|
# Returns the escape sequence for setting the visibility of the cursor.
|
109
107
|
#
|
110
108
|
# @return [String]
|
data/lib/vedeu/debug.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'ruby-prof'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
# Helps to debug a running application by providing a stack trace of its
|
6
|
+
# execution upon exiting.
|
7
|
+
#
|
8
|
+
# @param filename [String]
|
9
|
+
# @param block [Proc]
|
10
|
+
def self.debug(filename = 'profile.html', &block)
|
11
|
+
RubyProf.start
|
12
|
+
|
13
|
+
yield
|
14
|
+
|
15
|
+
result = RubyProf.stop
|
16
|
+
result.eliminate_methods!([/^Array/, /^Hash/])
|
17
|
+
|
18
|
+
File.open('/tmp/' + filename, 'w') do |file|
|
19
|
+
RubyProf::CallStackPrinter.new(result).print(file)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end # Vedeu
|
@@ -4,49 +4,91 @@ module Vedeu
|
|
4
4
|
|
5
5
|
module Distributed
|
6
6
|
|
7
|
+
# A class for the client side of the DRb server/client relationship.
|
8
|
+
#
|
7
9
|
# @example
|
8
|
-
# client = Vedeu::Distributed::Client.
|
10
|
+
# client = Vedeu::Distributed::Client.connect("druby://localhost:21420")
|
9
11
|
# client.input('a')
|
10
12
|
# client.output # => 'some content...'
|
11
|
-
# client.stop
|
12
13
|
#
|
13
14
|
class Client
|
14
15
|
|
16
|
+
# @param uri [String]
|
17
|
+
# @return [Client]
|
18
|
+
def self.connect(uri)
|
19
|
+
new(uri).connect
|
20
|
+
end
|
21
|
+
|
15
22
|
# @param uri [String]
|
16
23
|
# @return [Client]
|
17
24
|
def initialize(uri)
|
18
25
|
@uri = uri.to_s
|
19
26
|
end
|
20
27
|
|
28
|
+
# Simulate connecting to the DRb server by requesting its status.
|
29
|
+
#
|
30
|
+
# @return [Symbol]
|
31
|
+
def connect
|
32
|
+
server.status
|
33
|
+
|
34
|
+
rescue DRb::DRbBadURI
|
35
|
+
puts "Could not connect to DRb server, URI may be bad."
|
36
|
+
|
37
|
+
rescue DRb::DRbConnError
|
38
|
+
puts "Could not connect to DRb server."
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
# Send input to the DRb server.
|
43
|
+
#
|
21
44
|
# @param data [String|Symbol]
|
22
|
-
# @return []
|
45
|
+
# @return [void]
|
23
46
|
def input(data)
|
24
47
|
server.input(data)
|
48
|
+
|
49
|
+
rescue DRb::DRbConnError
|
50
|
+
puts "Could not connect to DRb server."
|
51
|
+
|
25
52
|
end
|
26
53
|
alias_method :read, :input
|
27
54
|
|
28
|
-
#
|
55
|
+
# Fetch output from the DRb server.
|
56
|
+
#
|
57
|
+
# @return [void]
|
29
58
|
def output
|
30
59
|
server.output
|
60
|
+
|
61
|
+
rescue DRb::DRbConnError
|
62
|
+
puts "Could not connect to DRb server."
|
63
|
+
|
31
64
|
end
|
32
65
|
alias_method :write, :output
|
33
66
|
|
34
|
-
#
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
67
|
+
# Shutdown the DRb server and the client application.
|
68
|
+
#
|
69
|
+
# @note
|
70
|
+
# {Vedeu::Application} will raise StopIteration when its `.stop` method
|
71
|
+
# is called. Here we rescue that to give a clean client exit.
|
72
|
+
#
|
73
|
+
# @return [void]
|
74
|
+
def shutdown
|
75
|
+
server.shutdown
|
76
|
+
|
77
|
+
Process.kill("KILL", server.pid)
|
78
|
+
|
79
|
+
rescue DRb::DRbConnError
|
80
|
+
puts "Could not connect to DRb server."
|
81
|
+
|
82
|
+
rescue Interrupt
|
83
|
+
puts "Client application exited."
|
39
84
|
|
40
|
-
# @return []
|
41
|
-
def stop
|
42
|
-
server.stop
|
43
85
|
end
|
44
86
|
|
45
87
|
private
|
46
88
|
|
47
89
|
attr_reader :uri
|
48
90
|
|
49
|
-
# @return []
|
91
|
+
# @return [void]
|
50
92
|
def server
|
51
93
|
@server ||= DRbObject.new_with_uri(uri)
|
52
94
|
end
|
@@ -0,0 +1,207 @@
|
|
1
|
+
require 'drb'
|
2
|
+
require 'singleton'
|
3
|
+
|
4
|
+
module Vedeu
|
5
|
+
|
6
|
+
module Distributed
|
7
|
+
|
8
|
+
# A class for the server side of the DRb server/client relationship.
|
9
|
+
#
|
10
|
+
# @api private
|
11
|
+
#
|
12
|
+
class Server
|
13
|
+
|
14
|
+
$SAFE = 1 # disable `eval` and related calls on strings passed
|
15
|
+
|
16
|
+
include Singleton
|
17
|
+
|
18
|
+
# @param data [String|Symbol]
|
19
|
+
# @return [void]
|
20
|
+
def self.input(data)
|
21
|
+
instance.input(data)
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [void]
|
25
|
+
def self.output
|
26
|
+
instance.output
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [void]
|
30
|
+
def self.restart
|
31
|
+
instance.restart
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [void]
|
35
|
+
def self.shutdown
|
36
|
+
instance.shutdown
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [void]
|
40
|
+
def self.start
|
41
|
+
instance.start
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [Symbol]
|
45
|
+
def self.status
|
46
|
+
instance.status
|
47
|
+
end
|
48
|
+
|
49
|
+
# @return [void]
|
50
|
+
def self.stop
|
51
|
+
instance.stop
|
52
|
+
end
|
53
|
+
|
54
|
+
# @param data [String|Symbol]
|
55
|
+
# @return [void]
|
56
|
+
def input(data)
|
57
|
+
Vedeu.trigger(:_drb_input_, data)
|
58
|
+
end
|
59
|
+
alias_method :read, :input
|
60
|
+
|
61
|
+
# @return [void]
|
62
|
+
def output
|
63
|
+
Vedeu.trigger(:_drb_retrieve_output_)
|
64
|
+
end
|
65
|
+
alias_method :write, :output
|
66
|
+
|
67
|
+
# @return [Fixnum] The PID of the currently running application.
|
68
|
+
def pid
|
69
|
+
Process.pid
|
70
|
+
end
|
71
|
+
|
72
|
+
# @return [void]
|
73
|
+
def restart
|
74
|
+
return not_enabled unless drb?
|
75
|
+
|
76
|
+
if drb_running?
|
77
|
+
log('Restarting')
|
78
|
+
|
79
|
+
stop
|
80
|
+
|
81
|
+
start
|
82
|
+
|
83
|
+
else
|
84
|
+
log('Not running')
|
85
|
+
|
86
|
+
start
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# When called will stop the DRb server and attempt to terminate the client
|
92
|
+
# application.
|
93
|
+
#
|
94
|
+
# @note
|
95
|
+
# :_exit_ never gets triggered as when the DRb server goes away, no
|
96
|
+
# further methods will be called.
|
97
|
+
#
|
98
|
+
# @return [void]
|
99
|
+
def shutdown
|
100
|
+
return not_enabled unless drb?
|
101
|
+
|
102
|
+
stop if drb_running?
|
103
|
+
|
104
|
+
Vedeu.trigger(:_exit_)
|
105
|
+
|
106
|
+
Terminal.restore_screen
|
107
|
+
end
|
108
|
+
|
109
|
+
# @return [Vedeu::Distributed::Server]
|
110
|
+
def start
|
111
|
+
return not_enabled unless drb?
|
112
|
+
|
113
|
+
if drb_running?
|
114
|
+
log('Already started')
|
115
|
+
|
116
|
+
else
|
117
|
+
log('Starting')
|
118
|
+
|
119
|
+
DRb.start_service(uri, self)
|
120
|
+
|
121
|
+
# DRb.thread.join # not convinced this is needed here
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# @return [Symbol]
|
126
|
+
def status
|
127
|
+
return not_enabled unless drb?
|
128
|
+
|
129
|
+
if drb_running?
|
130
|
+
log('Running')
|
131
|
+
|
132
|
+
:running
|
133
|
+
|
134
|
+
else
|
135
|
+
log('Stopped')
|
136
|
+
|
137
|
+
:stopped
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# @return [void]
|
143
|
+
def stop
|
144
|
+
return not_enabled unless drb?
|
145
|
+
|
146
|
+
if drb_running?
|
147
|
+
log('Stopping')
|
148
|
+
|
149
|
+
DRb.stop_service
|
150
|
+
|
151
|
+
DRb.thread.join
|
152
|
+
|
153
|
+
else
|
154
|
+
log('Already stopped')
|
155
|
+
|
156
|
+
end
|
157
|
+
rescue NoMethodError # raised when #join is called on NilClass.
|
158
|
+
# ...
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
private
|
163
|
+
|
164
|
+
attr_reader :configuration
|
165
|
+
|
166
|
+
# @return [Boolean]
|
167
|
+
def drb?
|
168
|
+
Vedeu::Configuration.drb?
|
169
|
+
end
|
170
|
+
|
171
|
+
# @return [String]
|
172
|
+
def drb_host
|
173
|
+
Vedeu::Configuration.drb_host
|
174
|
+
end
|
175
|
+
|
176
|
+
# @return [|NilClass]
|
177
|
+
def drb_running?
|
178
|
+
DRb.thread
|
179
|
+
end
|
180
|
+
|
181
|
+
# @return [Fixnum|String]
|
182
|
+
def drb_port
|
183
|
+
Vedeu::Configuration.drb_port
|
184
|
+
end
|
185
|
+
|
186
|
+
# @return [void]
|
187
|
+
def log(message)
|
188
|
+
Vedeu.log(type: :drb, message: "#{message}: '#{uri}'")
|
189
|
+
end
|
190
|
+
|
191
|
+
# @return [Symbol]
|
192
|
+
def not_enabled
|
193
|
+
log('Not enabled')
|
194
|
+
|
195
|
+
:drb_not_enabled
|
196
|
+
end
|
197
|
+
|
198
|
+
# @return [String]
|
199
|
+
def uri
|
200
|
+
Vedeu::Distributed::Uri.new(drb_host, drb_port).to_s
|
201
|
+
end
|
202
|
+
|
203
|
+
end # Server
|
204
|
+
|
205
|
+
end # Distributed
|
206
|
+
|
207
|
+
end # Vedeu
|
@@ -32,7 +32,7 @@ module Vedeu
|
|
32
32
|
class Subprocess
|
33
33
|
|
34
34
|
# @param application [Vedeu::TestApplication]
|
35
|
-
# @return []
|
35
|
+
# @return [Array]
|
36
36
|
def self.execute!(application)
|
37
37
|
new(application).execute!
|
38
38
|
end
|
@@ -41,51 +41,52 @@ module Vedeu
|
|
41
41
|
# @return [Vedeu::Subprocess]
|
42
42
|
def initialize(application)
|
43
43
|
@application = application
|
44
|
+
@pid = nil
|
44
45
|
end
|
45
46
|
|
46
|
-
# @return []
|
47
|
+
# @return [Array]
|
47
48
|
def execute!
|
48
49
|
file_open && file_write && file_close
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
stdin.each { |line| print line }
|
51
|
+
@pid = fork do
|
52
|
+
exec(file_path)
|
53
|
+
end
|
54
54
|
|
55
|
-
|
56
|
-
puts 'Errno::EIO: Process may have stopped giving output.'
|
55
|
+
Process.detach(@pid)
|
57
56
|
|
58
|
-
|
59
|
-
|
60
|
-
rescue PTY::ChildExited
|
61
|
-
puts 'PTY::ChildExited: Process exited.'
|
57
|
+
self
|
58
|
+
end
|
62
59
|
|
63
|
-
|
64
|
-
|
60
|
+
# Sends the KILL signal to the process.
|
61
|
+
#
|
62
|
+
# @return [void]
|
63
|
+
def kill
|
64
|
+
Process.kill('KILL', pid)
|
65
65
|
|
66
|
-
|
66
|
+
file_unlink
|
67
67
|
end
|
68
68
|
|
69
69
|
private
|
70
70
|
|
71
|
-
attr_reader
|
71
|
+
attr_reader :application
|
72
|
+
attr_accessor :pid
|
72
73
|
|
73
74
|
# @return [String]
|
74
75
|
def command
|
75
76
|
"ruby #{file_path}"
|
76
77
|
end
|
77
78
|
|
78
|
-
# @return []
|
79
|
+
# @return [Fixnum] The number of bytes written.
|
79
80
|
def file_write
|
80
81
|
file.write(application)
|
81
82
|
end
|
82
83
|
|
83
|
-
# @return []
|
84
|
+
# @return [NilClass]
|
84
85
|
def file_close
|
85
86
|
file.close
|
86
87
|
end
|
87
88
|
|
88
|
-
# @return []
|
89
|
+
# @return [Fixnum] The number of files removed; 1.
|
89
90
|
def file_unlink
|
90
91
|
File.unlink("/tmp/foo_#{timestamp}")
|
91
92
|
end
|
@@ -95,9 +96,9 @@ module Vedeu
|
|
95
96
|
file.path
|
96
97
|
end
|
97
98
|
|
98
|
-
# @return []
|
99
|
+
# @return [File]
|
99
100
|
def file_open
|
100
|
-
@file ||= File.new("/tmp/foo_#{timestamp}", "w")
|
101
|
+
@file ||= File.new("/tmp/foo_#{timestamp}", "w", 0755)
|
101
102
|
end
|
102
103
|
alias_method :file, :file_open
|
103
104
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
1
3
|
lib_dir = "<%= @object.lib_dir %>"
|
2
4
|
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
|
3
5
|
|
@@ -27,7 +29,7 @@ class VedeuTestApplication
|
|
27
29
|
stdout = STDOUT,
|
28
30
|
stderr = STDERR,
|
29
31
|
kernel = Kernel)
|
30
|
-
Vedeu::Launcher.
|
32
|
+
Vedeu::Launcher.execute!(argv, stdin, stdout, stderr, kernel)
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
@@ -27,6 +27,8 @@ module Vedeu
|
|
27
27
|
:menus,
|
28
28
|
:views
|
29
29
|
|
30
|
+
# @param attributes [Hash]
|
31
|
+
# @param block [Proc]
|
30
32
|
# @return [String]
|
31
33
|
def self.build(attributes = {}, &block)
|
32
34
|
new(attributes).build(&block)
|
@@ -41,7 +43,6 @@ module Vedeu
|
|
41
43
|
# @option attributes keymaps [String]
|
42
44
|
# @option attributes menus [String]
|
43
45
|
# @option attributes views [String]
|
44
|
-
# @param block [Proc]
|
45
46
|
# @return [TestApplication]
|
46
47
|
def initialize(attributes = {})
|
47
48
|
@attributes = defaults.merge(attributes)
|
data/lib/vedeu/dsl/all.rb
CHANGED
@@ -9,6 +9,8 @@ require 'vedeu/dsl/view'
|
|
9
9
|
|
10
10
|
module Vedeu
|
11
11
|
|
12
|
+
# Provides a mechanism to help configure and use Vedeu.
|
13
|
+
#
|
12
14
|
module DSL
|
13
15
|
|
14
16
|
# Attempts to find the missing method on the client object.
|
@@ -16,9 +18,9 @@ module Vedeu
|
|
16
18
|
# @param method [Symbol] The name of the method sought.
|
17
19
|
# @param args [Array] The arguments which the method was to be invoked with.
|
18
20
|
# @param block [Proc] The optional block provided to the method.
|
19
|
-
# @return []
|
21
|
+
# @return [void]
|
20
22
|
def method_missing(method, *args, &block)
|
21
|
-
Vedeu.log("!!!method_missing '#{method}'")
|
23
|
+
Vedeu.log(type: :debug, message: "!!!method_missing '#{method}'")
|
22
24
|
|
23
25
|
client.send(method, *args, &block) if client
|
24
26
|
end
|
@@ -39,6 +39,7 @@ module Vedeu
|
|
39
39
|
# @param name [String] The name of the interface or view to which this
|
40
40
|
# border belongs.
|
41
41
|
# @param block [Proc]
|
42
|
+
# @raise [InvalidSyntax] The required block was not given.
|
42
43
|
# @return [Vedeu::Border]
|
43
44
|
def border(name, &block)
|
44
45
|
fail InvalidSyntax, 'block not given' unless block_given?
|
@@ -70,7 +71,7 @@ module Vedeu
|
|
70
71
|
# character.
|
71
72
|
# @return [String]
|
72
73
|
def bottom_left(char)
|
73
|
-
model.
|
74
|
+
model.bottom_left = char
|
74
75
|
end
|
75
76
|
|
76
77
|
# Set the character to be used to draw the bottom right corner of the
|
@@ -87,7 +88,7 @@ module Vedeu
|
|
87
88
|
# character.
|
88
89
|
# @return [String]
|
89
90
|
def bottom_right(char)
|
90
|
-
model.
|
91
|
+
model.bottom_right = char
|
91
92
|
end
|
92
93
|
|
93
94
|
# Set the character to be used to draw a horizontal part of the border.
|
@@ -103,7 +104,7 @@ module Vedeu
|
|
103
104
|
# character.
|
104
105
|
# @return [String]
|
105
106
|
def horizontal(char)
|
106
|
-
model.
|
107
|
+
model.horizontal = char
|
107
108
|
end
|
108
109
|
|
109
110
|
# Enable/disable the bottom border.
|
@@ -122,7 +123,7 @@ module Vedeu
|
|
122
123
|
# false.
|
123
124
|
# @return [Boolean]
|
124
125
|
def bottom(boolean)
|
125
|
-
model.
|
126
|
+
model.show_bottom = !!boolean
|
126
127
|
end
|
127
128
|
alias_method :show_bottom, :bottom
|
128
129
|
|
@@ -152,7 +153,7 @@ module Vedeu
|
|
152
153
|
# false.
|
153
154
|
# @return [Boolean]
|
154
155
|
def left(boolean)
|
155
|
-
model.
|
156
|
+
model.show_left = !!boolean
|
156
157
|
end
|
157
158
|
alias_method :show_left, :left
|
158
159
|
|
@@ -182,7 +183,7 @@ module Vedeu
|
|
182
183
|
# false.
|
183
184
|
# @return [Boolean]
|
184
185
|
def right(boolean)
|
185
|
-
model.
|
186
|
+
model.show_right = !!boolean
|
186
187
|
end
|
187
188
|
alias_method :show_right, :right
|
188
189
|
|
@@ -212,7 +213,7 @@ module Vedeu
|
|
212
213
|
# false.
|
213
214
|
# @return [Boolean]
|
214
215
|
def top(boolean)
|
215
|
-
model.
|
216
|
+
model.show_top = !!boolean
|
216
217
|
end
|
217
218
|
alias_method :show_top, :top
|
218
219
|
|
@@ -239,7 +240,7 @@ module Vedeu
|
|
239
240
|
# character.
|
240
241
|
# @return [String]
|
241
242
|
def top_left(char)
|
242
|
-
model.
|
243
|
+
model.top_left = char
|
243
244
|
end
|
244
245
|
|
245
246
|
# Set the character to be used to draw the top right corner of the border.
|
@@ -255,7 +256,7 @@ module Vedeu
|
|
255
256
|
# character.
|
256
257
|
# @return [String]
|
257
258
|
def top_right(char)
|
258
|
-
model.
|
259
|
+
model.top_right = char
|
259
260
|
end
|
260
261
|
|
261
262
|
# Set the character to be used to draw a vertical part of the border.
|
@@ -271,7 +272,7 @@ module Vedeu
|
|
271
272
|
# character.
|
272
273
|
# @return [String]
|
273
274
|
def vertical(char)
|
274
|
-
model.
|
275
|
+
model.vertical = char
|
275
276
|
end
|
276
277
|
|
277
278
|
private
|
@@ -23,6 +23,7 @@ module Vedeu
|
|
23
23
|
# @param name [String] The name of the interface or view to which this
|
24
24
|
# geometry belongs.
|
25
25
|
# @param block [Proc]
|
26
|
+
# @raise [InvalidSyntax] The required block was not given.
|
26
27
|
# @return [Vedeu::Geometry]
|
27
28
|
def geometry(name, &block)
|
28
29
|
fail InvalidSyntax, 'block not given' unless block_given?
|