vedeu 0.6.8 → 0.6.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +9 -0
- data/README.md +1 -1
- data/docs/api.md +60 -67
- data/docs/configuration.md +8 -5
- data/docs/events.md +31 -15
- data/docs/events/application.md +12 -0
- data/docs/events/document.md +57 -0
- data/docs/events/drb.md +43 -0
- data/docs/events/focus.md +24 -0
- data/docs/events/menu.md +57 -0
- data/docs/events/movement.md +57 -0
- data/docs/events/refresh.md +25 -0
- data/docs/events/system.md +90 -0
- data/docs/events/visibility.md +68 -0
- data/lib/vedeu.rb +2 -2
- data/lib/vedeu/all.rb +3 -2
- data/lib/vedeu/api.rb +18 -18
- data/lib/vedeu/application/controller.rb +1 -1
- data/lib/vedeu/application/helper.rb +1 -1
- data/lib/vedeu/application/view.rb +1 -1
- data/lib/vedeu/bindings/application.rb +1 -12
- data/lib/vedeu/bindings/bindings.rb +3 -1
- data/lib/vedeu/bindings/document.rb +9 -62
- data/lib/vedeu/bindings/drb.rb +12 -56
- data/lib/vedeu/bindings/focus.rb +3 -28
- data/lib/vedeu/bindings/menus.rb +10 -66
- data/lib/vedeu/bindings/movement.rb +4 -69
- data/lib/vedeu/bindings/refresh.rb +3 -33
- data/lib/vedeu/bindings/system.rb +14 -100
- data/lib/vedeu/bindings/visibility.rb +20 -71
- data/lib/vedeu/borders/all.rb +4 -3
- data/lib/vedeu/borders/border.rb +39 -33
- data/lib/vedeu/borders/dsl.rb +40 -33
- data/lib/vedeu/borders/null.rb +2 -2
- data/lib/vedeu/borders/render.rb +29 -24
- data/lib/vedeu/borders/repository.rb +2 -2
- data/lib/vedeu/buffers/all.rb +8 -7
- data/lib/vedeu/buffers/buffer.rb +47 -39
- data/lib/vedeu/buffers/null.rb +2 -2
- data/lib/vedeu/buffers/refresh.rb +4 -3
- data/lib/vedeu/buffers/virtual_buffer.rb +122 -118
- data/lib/vedeu/buffers/virtual_buffers.rb +62 -56
- data/lib/vedeu/colours/background.rb +2 -1
- data/lib/vedeu/colours/colour.rb +21 -19
- data/lib/vedeu/colours/foreground.rb +2 -1
- data/lib/vedeu/colours/repository.rb +6 -5
- data/lib/vedeu/colours/translator.rb +39 -35
- data/lib/vedeu/configuration/api.rb +59 -51
- data/lib/vedeu/configuration/cli.rb +9 -7
- data/lib/vedeu/configuration/configuration.rb +41 -32
- data/lib/vedeu/cursors/cursor.rb +1 -1
- data/lib/vedeu/cursors/refresh.rb +20 -16
- data/lib/vedeu/distributed/server.rb +8 -6
- data/lib/vedeu/distributed/subprocess.rb +90 -86
- data/lib/vedeu/distributed/uri.rb +4 -3
- data/lib/vedeu/dsl/composition.rb +2 -2
- data/lib/vedeu/dsl/group.rb +4 -4
- data/lib/vedeu/dsl/interface.rb +5 -5
- data/lib/vedeu/dsl/presentation.rb +2 -2
- data/lib/vedeu/dsl/text.rb +1 -1
- data/lib/vedeu/editor/cropper.rb +4 -4
- data/lib/vedeu/editor/cursor.rb +6 -4
- data/lib/vedeu/editor/document.rb +20 -18
- data/lib/vedeu/editor/editor.rb +2 -2
- data/lib/vedeu/editor/line.rb +10 -5
- data/lib/vedeu/editor/lines.rb +2 -2
- data/lib/vedeu/internal_api.rb +4 -4
- data/lib/vedeu/models/focus.rb +197 -191
- data/lib/vedeu/models/group.rb +171 -159
- data/lib/vedeu/models/groups.rb +14 -10
- data/lib/vedeu/models/interface.rb +116 -110
- data/lib/vedeu/models/interfaces.rb +24 -20
- data/lib/vedeu/models/toggleable.rb +4 -4
- data/lib/vedeu/models/views/char.rb +1 -1
- data/lib/vedeu/models/views/composition.rb +1 -1
- data/lib/vedeu/models/views/line.rb +1 -1
- data/lib/vedeu/models/views/stream.rb +1 -1
- data/lib/vedeu/models/views/view.rb +1 -1
- data/lib/vedeu/null/interface.rb +1 -1
- data/lib/vedeu/null/view.rb +1 -1
- data/lib/vedeu/output/clear/named_interface.rb +1 -1
- data/lib/vedeu/output/compressor.rb +78 -73
- data/lib/vedeu/output/direct.rb +61 -57
- data/lib/vedeu/output/output.rb +34 -29
- data/lib/vedeu/output/{presentation.rb → presentation/presentation.rb} +2 -1
- data/lib/vedeu/output/presentation/style.rb +64 -18
- data/lib/vedeu/output/presentation/styles.rb +39 -0
- data/lib/vedeu/output/renderers/html.rb +2 -2
- data/lib/vedeu/output/renderers/json.rb +2 -1
- data/lib/vedeu/output/renderers/terminal.rb +3 -3
- data/lib/vedeu/output/renderers/text.rb +3 -3
- data/lib/vedeu/output/text.rb +186 -180
- data/lib/vedeu/output/wordwrap.rb +142 -138
- data/lib/vedeu/refresh/refresh.rb +2 -2
- data/lib/vedeu/templating/helpers.rb +11 -6
- data/lib/vedeu/templating/view_template.rb +1 -1
- data/lib/vedeu/terminal/terminal.rb +2 -2
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/borders/render_test.rb +1 -1
- data/test/lib/vedeu/buffers/buffer_test.rb +16 -14
- data/test/lib/vedeu/buffers/virtual_buffer_test.rb +105 -101
- data/test/lib/vedeu/buffers/virtual_buffers_test.rb +43 -39
- data/test/lib/vedeu/colours/colour_test.rb +4 -4
- data/test/lib/vedeu/cursors/cursor_test.rb +2 -2
- data/test/lib/vedeu/cursors/repository_test.rb +3 -3
- data/test/lib/vedeu/distributed/subprocess_test.rb +33 -29
- data/test/lib/vedeu/dsl/group_test.rb +3 -3
- data/test/lib/vedeu/dsl/interface_test.rb +6 -5
- data/test/lib/vedeu/dsl/line_test.rb +4 -2
- data/test/lib/vedeu/dsl/presentation_test.rb +2 -2
- data/test/lib/vedeu/dsl/text_test.rb +8 -8
- data/test/lib/vedeu/editor/document_test.rb +10 -6
- data/test/lib/vedeu/input/keymap_test.rb +1 -10
- data/test/lib/vedeu/models/focus_test.rb +177 -170
- data/test/lib/vedeu/models/group_test.rb +99 -95
- data/test/lib/vedeu/models/groups_test.rb +13 -9
- data/test/lib/vedeu/models/interface_test.rb +93 -87
- data/test/lib/vedeu/models/interfaces_test.rb +24 -20
- data/test/lib/vedeu/models/views/char_test.rb +2 -2
- data/test/lib/vedeu/models/views/line_test.rb +11 -7
- data/test/lib/vedeu/models/views/stream_test.rb +1 -1
- data/test/lib/vedeu/models/views/view_test.rb +1 -1
- data/test/lib/vedeu/output/clear/named_group_test.rb +1 -1
- data/test/lib/vedeu/output/clear/named_interface_test.rb +3 -1
- data/test/lib/vedeu/output/compressor_test.rb +126 -122
- data/test/lib/vedeu/output/direct_test.rb +49 -43
- data/test/lib/vedeu/output/output_test.rb +35 -31
- data/test/lib/vedeu/output/{presentation_test.rb → presentation/presentation_test.rb} +11 -7
- data/test/lib/vedeu/output/presentation/style_test.rb +88 -48
- data/test/lib/vedeu/output/presentation/styles_test.rb +84 -0
- data/test/lib/vedeu/output/text_test.rb +109 -105
- data/test/lib/vedeu/output/viewport_test.rb +3 -1
- data/test/lib/vedeu/output/wordwrap_test.rb +209 -205
- data/test/lib/vedeu/refresh/refresh_test.rb +3 -1
- data/test/lib/vedeu/templating/helpers_test.rb +6 -6
- data/test/lib/vedeu/templating/view_template_test.rb +1 -1
- metadata +17 -8
- data/lib/vedeu/output/style.rb +0 -76
- data/test/lib/vedeu/output/style_test.rb +0 -120
@@ -8,7 +8,8 @@ module Vedeu
|
|
8
8
|
|
9
9
|
# Custom log for configuration.
|
10
10
|
#
|
11
|
-
# @param from [String] Which configuration set the options
|
11
|
+
# @param from [String] Which configuration set the options
|
12
|
+
# ('API' or 'CLI').
|
12
13
|
# @param options [Hash] The configuration options set.
|
13
14
|
# @return [Hash] The options param.
|
14
15
|
def log(from, options)
|
@@ -20,13 +21,13 @@ module Vedeu
|
|
20
21
|
|
21
22
|
end
|
22
23
|
|
23
|
-
# Allows the customisation of Vedeu's behaviour through the
|
24
|
-
# or command-line arguments.
|
24
|
+
# Allows the customisation of Vedeu's behaviour through the
|
25
|
+
# configuration API or command-line arguments.
|
25
26
|
#
|
26
|
-
# Provides access to Vedeu's configuration, which was set with
|
27
|
-
# defaults (influenced by environment variables),
|
28
|
-
# application settings (via the configuration
|
29
|
-
# arguments provided.
|
27
|
+
# Provides access to Vedeu's configuration, which was set with
|
28
|
+
# sensible defaults (influenced by environment variables),
|
29
|
+
# overridden by client application settings (via the configuration
|
30
|
+
# API), or any command-line arguments provided.
|
30
31
|
#
|
31
32
|
class Configuration
|
32
33
|
|
@@ -49,10 +50,10 @@ module Vedeu
|
|
49
50
|
end
|
50
51
|
alias_method :compression?, :compression
|
51
52
|
|
52
|
-
# Provides the mechanism to configure Vedeu. If the client
|
53
|
-
# sets options, override the defaults with those,
|
54
|
-
# arguments are provided at application
|
55
|
-
# with the arguments provided.
|
53
|
+
# Provides the mechanism to configure Vedeu. If the client
|
54
|
+
# application sets options, override the defaults with those,
|
55
|
+
# and when command-line arguments are provided at application
|
56
|
+
# invocation, override any options with the arguments provided.
|
56
57
|
#
|
57
58
|
# @example
|
58
59
|
# Vedeu.configure do
|
@@ -73,7 +74,8 @@ module Vedeu
|
|
73
74
|
end
|
74
75
|
|
75
76
|
# Returns the configuration singleton.
|
76
|
-
# Append configuration methods to access the configuration
|
77
|
+
# Append configuration methods to access the configuration
|
78
|
+
# variable.
|
77
79
|
#
|
78
80
|
# @example
|
79
81
|
# Vedeu.configuration
|
@@ -90,8 +92,9 @@ module Vedeu
|
|
90
92
|
instance.options[:colour_mode]
|
91
93
|
end
|
92
94
|
|
93
|
-
# Returns whether debugging is enabled or disabled. Default is
|
94
|
-
# meaning nothing apart from warnings are written to the
|
95
|
+
# Returns whether debugging is enabled or disabled. Default is
|
96
|
+
# false; meaning nothing apart from warnings are written to the
|
97
|
+
# log file.
|
95
98
|
#
|
96
99
|
# @return [Boolean]
|
97
100
|
def debug?
|
@@ -99,7 +102,8 @@ module Vedeu
|
|
99
102
|
end
|
100
103
|
alias_method :debug, :debug?
|
101
104
|
|
102
|
-
# Returns whether the DRb server is enabled or disabled. Default
|
105
|
+
# Returns whether the DRb server is enabled or disabled. Default
|
106
|
+
# is false.
|
103
107
|
#
|
104
108
|
# @return [Boolean]
|
105
109
|
def drb?
|
@@ -135,9 +139,10 @@ module Vedeu
|
|
135
139
|
instance.options[:drb_width]
|
136
140
|
end
|
137
141
|
|
138
|
-
# Returns whether the application is interactive (required user
|
139
|
-
# standalone (will run until terminates of natural
|
140
|
-
# true; meaning the application will require
|
142
|
+
# Returns whether the application is interactive (required user
|
143
|
+
# input) or standalone (will run until terminates of natural
|
144
|
+
# causes.) Default is true; meaning the application will require
|
145
|
+
# user input.
|
141
146
|
#
|
142
147
|
# @return [Boolean]
|
143
148
|
def interactive?
|
@@ -152,7 +157,8 @@ module Vedeu
|
|
152
157
|
instance.options[:log]
|
153
158
|
end
|
154
159
|
|
155
|
-
# Returns a boolean indicating whether the log has been
|
160
|
+
# Returns a boolean indicating whether the log has been
|
161
|
+
# configured.
|
156
162
|
#
|
157
163
|
# @return [Boolean]
|
158
164
|
def log?
|
@@ -164,9 +170,9 @@ module Vedeu
|
|
164
170
|
instance.options[:log_only] || []
|
165
171
|
end
|
166
172
|
|
167
|
-
# Returns whether the application will run through its main loop
|
168
|
-
# not. Default is false; meaning the application will
|
169
|
-
# until terminated by the user.
|
173
|
+
# Returns whether the application will run through its main loop
|
174
|
+
# once or not. Default is false; meaning the application will
|
175
|
+
# loop forever or until terminated by the user.
|
170
176
|
#
|
171
177
|
# @return [Boolean]
|
172
178
|
def once?
|
@@ -181,8 +187,8 @@ module Vedeu
|
|
181
187
|
instance.options[:renderers]
|
182
188
|
end
|
183
189
|
|
184
|
-
# Returns the root of the client application. Vedeu will execute
|
185
|
-
# controller first.
|
190
|
+
# Returns the root of the client application. Vedeu will execute
|
191
|
+
# this controller first.
|
186
192
|
#
|
187
193
|
# @return [Class]
|
188
194
|
def root
|
@@ -210,7 +216,8 @@ module Vedeu
|
|
210
216
|
instance.options[:stderr]
|
211
217
|
end
|
212
218
|
|
213
|
-
# Returns the terminal mode for the application. Default is
|
219
|
+
# Returns the terminal mode for the application. Default is
|
220
|
+
# `:raw`.
|
214
221
|
#
|
215
222
|
# @return [Symbol]
|
216
223
|
def terminal_mode
|
@@ -243,9 +250,10 @@ module Vedeu
|
|
243
250
|
@options = defaults
|
244
251
|
end
|
245
252
|
|
246
|
-
# Set up default configuration and then allow the client
|
247
|
-
# modify it via the configuration API. After this,
|
248
|
-
# arguments as potential configuration
|
253
|
+
# Set up default configuration and then allow the client
|
254
|
+
# application to modify it via the configuration API. After this,
|
255
|
+
# process any command line arguments as potential configuration
|
256
|
+
# and apply that.
|
249
257
|
#
|
250
258
|
# @param args [Array]
|
251
259
|
# @param block [Proc]
|
@@ -270,8 +278,8 @@ module Vedeu
|
|
270
278
|
|
271
279
|
private
|
272
280
|
|
273
|
-
# The Vedeu default options, which of course are influenced by
|
274
|
-
# variables also.
|
281
|
+
# The Vedeu default options, which of course are influenced by
|
282
|
+
# environment variables also.
|
275
283
|
#
|
276
284
|
# @return [Hash<Symbol => void>]
|
277
285
|
def defaults
|
@@ -298,8 +306,9 @@ module Vedeu
|
|
298
306
|
}
|
299
307
|
end
|
300
308
|
|
301
|
-
# Attempt to determine the terminal colour mode via $TERM
|
302
|
-
# variable, or be optimistic and settle for 256
|
309
|
+
# Attempt to determine the terminal colour mode via $TERM
|
310
|
+
# environment variable, or be optimistic and settle for 256
|
311
|
+
# colours.
|
303
312
|
#
|
304
313
|
# @return [Fixnum]
|
305
314
|
def detect_colour_mode
|
data/lib/vedeu/cursors/cursor.rb
CHANGED
@@ -2,8 +2,9 @@ module Vedeu
|
|
2
2
|
|
3
3
|
module Cursors
|
4
4
|
|
5
|
-
# Handle the refreshing (redrawing) of a cursor, without redrawing
|
6
|
-
# interface; unless the cursor's offset has caused the
|
5
|
+
# Handle the refreshing (redrawing) of a cursor, without redrawing
|
6
|
+
# the whole interface; unless the cursor's offset has caused the
|
7
|
+
# view to change.
|
7
8
|
#
|
8
9
|
class Refresh
|
9
10
|
|
@@ -14,7 +15,7 @@ module Vedeu
|
|
14
15
|
:width
|
15
16
|
|
16
17
|
# @param (see #initialize)
|
17
|
-
def self.by_name(name =
|
18
|
+
def self.by_name(name = nil)
|
18
19
|
new(name).by_name
|
19
20
|
end
|
20
21
|
|
@@ -22,13 +23,14 @@ module Vedeu
|
|
22
23
|
#
|
23
24
|
# @param name [String] The name of the cursor.
|
24
25
|
# @return [Vedeu::Cursors::Refresh]
|
25
|
-
def initialize(name)
|
26
|
-
@name = name
|
26
|
+
def initialize(name = nil)
|
27
|
+
@name = name || Vedeu.focus
|
27
28
|
end
|
28
29
|
|
29
|
-
# Renders the cursor in the terminal. If the cursor's x or y
|
30
|
-
# greater or equal to the interface's width or
|
31
|
-
# the view is also refreshed, causing
|
30
|
+
# Renders the cursor in the terminal. If the cursor's x or y
|
31
|
+
# offsets are greater or equal to the interface's width or
|
32
|
+
# height respectively, then the view is also refreshed, causing
|
33
|
+
# the content to be offset also.
|
32
34
|
#
|
33
35
|
# @return [Array]
|
34
36
|
def by_name
|
@@ -47,9 +49,9 @@ module Vedeu
|
|
47
49
|
|
48
50
|
private
|
49
51
|
|
50
|
-
# Returns true when the view should be refreshed. This is
|
51
|
-
# checking that the offsets for x and y are
|
52
|
-
# of the named interface.
|
52
|
+
# Returns true when the view should be refreshed. This is
|
53
|
+
# determined by checking that the offsets for x and y are
|
54
|
+
# outside the width and height of the named interface.
|
53
55
|
#
|
54
56
|
# @return [Boolean]
|
55
57
|
def refresh_view?
|
@@ -65,11 +67,13 @@ module Vedeu
|
|
65
67
|
# Fetch the border by name.
|
66
68
|
#
|
67
69
|
# @note
|
68
|
-
# Vedeu::Borders::Border is used in this way because when
|
69
|
-
# border defined, it will fallback to a
|
70
|
-
# Vedeu::
|
71
|
-
#
|
72
|
-
#
|
70
|
+
# {Vedeu::Borders::Border} is used in this way because when
|
71
|
+
# there is not a border defined, it will fallback to a
|
72
|
+
# {Vedeu::Borders::Null} which uses
|
73
|
+
# {Vedeu::Geometry::Geometry} to determine it's dimensions
|
74
|
+
# based on the name also. When a {Vedeu::Geometry::Geometry}
|
75
|
+
# cannot be found, this falls back to a
|
76
|
+
# {Vedeu::Geometry::Null} which uses the dimensions of the
|
73
77
|
# current terminal.
|
74
78
|
#
|
75
79
|
# @return (see Vedeu::Borders::Repository#by_name)
|
@@ -1,10 +1,12 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
# Provides a mechanism to control a running client application via
|
3
|
+
# Provides a mechanism to control a running client application via
|
4
|
+
# DRb.
|
4
5
|
#
|
5
6
|
module Distributed
|
6
7
|
|
7
|
-
# A class for the server side of the DRb server/client
|
8
|
+
# A class for the server side of the DRb server/client
|
9
|
+
# relationship.
|
8
10
|
class Server
|
9
11
|
|
10
12
|
$SAFE = 1 # disable `eval` and related calls on strings passed
|
@@ -106,12 +108,12 @@ module Vedeu
|
|
106
108
|
end
|
107
109
|
end
|
108
110
|
|
109
|
-
# When called will stop the DRb server and attempt to terminate
|
110
|
-
# application.
|
111
|
+
# When called will stop the DRb server and attempt to terminate
|
112
|
+
# the client application.
|
111
113
|
#
|
112
114
|
# @note
|
113
|
-
# :_exit_ never gets triggered as when the DRb server goes
|
114
|
-
# further methods will be called.
|
115
|
+
# :_exit_ never gets triggered as when the DRb server goes
|
116
|
+
# away, no further methods will be called.
|
115
117
|
#
|
116
118
|
# @return [void]
|
117
119
|
def shutdown
|
@@ -1,96 +1,100 @@
|
|
1
1
|
module Vedeu
|
2
2
|
|
3
|
-
|
4
|
-
# Vedeu::TestApplication.build
|
5
|
-
#
|
6
|
-
class Subprocess
|
3
|
+
module Distributed
|
7
4
|
|
8
|
-
# @
|
9
|
-
|
10
|
-
new(application).execute!
|
11
|
-
end
|
12
|
-
|
13
|
-
# Returns a new instance of Vedeu::Subprocess.
|
5
|
+
# @example
|
6
|
+
# Vedeu::TestApplication.build
|
14
7
|
#
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
# :nocov:
|
23
|
-
# @return [Array]
|
24
|
-
def execute!
|
25
|
-
file_open && file_write && file_close
|
26
|
-
|
27
|
-
@pid = fork do
|
28
|
-
exec(file_path)
|
8
|
+
class Subprocess
|
9
|
+
|
10
|
+
# @param (see #initialize)
|
11
|
+
def self.execute!(application)
|
12
|
+
new(application).execute!
|
29
13
|
end
|
30
14
|
|
31
|
-
|
15
|
+
# Returns a new instance of Vedeu::Distributed::Subprocess.
|
16
|
+
#
|
17
|
+
# @param application [Vedeu::TestApplication]
|
18
|
+
# @return [Vedeu::Distributed::Subprocess]
|
19
|
+
def initialize(application)
|
20
|
+
@application = application
|
21
|
+
@pid = nil
|
22
|
+
end
|
32
23
|
|
33
|
-
|
34
|
-
|
35
|
-
|
24
|
+
# :nocov:
|
25
|
+
# @return [Array]
|
26
|
+
def execute!
|
27
|
+
file_open && file_write && file_close
|
36
28
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
29
|
+
@pid = fork do
|
30
|
+
exec(file_path)
|
31
|
+
end
|
32
|
+
|
33
|
+
Process.detach(@pid)
|
34
|
+
|
35
|
+
self
|
36
|
+
end
|
37
|
+
# :nocov:
|
38
|
+
|
39
|
+
# Sends the KILL signal to the process.
|
40
|
+
#
|
41
|
+
# @return [void]
|
42
|
+
def kill
|
43
|
+
Process.kill('KILL', pid)
|
44
|
+
|
45
|
+
file_unlink
|
46
|
+
end
|
47
|
+
|
48
|
+
protected
|
49
|
+
|
50
|
+
# @!attribute [r] application
|
51
|
+
# @return [Vedeu::TestApplication]
|
52
|
+
attr_reader :application
|
53
|
+
|
54
|
+
# @!attribute [r] pid
|
55
|
+
# @return [Fixnum]
|
56
|
+
attr_reader :pid
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
# @return [String]
|
61
|
+
def command
|
62
|
+
"ruby #{file_path}"
|
63
|
+
end
|
64
|
+
|
65
|
+
# @return [Fixnum] The number of bytes written.
|
66
|
+
def file_write
|
67
|
+
file.write(application)
|
68
|
+
end
|
69
|
+
|
70
|
+
# @return [NilClass]
|
71
|
+
def file_close
|
72
|
+
file.close
|
73
|
+
end
|
74
|
+
|
75
|
+
# @return [Fixnum] The number of files removed; 1.
|
76
|
+
def file_unlink
|
77
|
+
File.unlink("/tmp/foo_#{timestamp}")
|
78
|
+
end
|
79
|
+
|
80
|
+
# return [String]
|
81
|
+
def file_path
|
82
|
+
file.path
|
83
|
+
end
|
84
|
+
|
85
|
+
# @return [File]
|
86
|
+
def file_open
|
87
|
+
@file ||= File.new("/tmp/foo_#{timestamp}", 'w', 0755)
|
88
|
+
end
|
89
|
+
alias_method :file, :file_open
|
90
|
+
|
91
|
+
# return [Fixnum]
|
92
|
+
def timestamp
|
93
|
+
@timestamp ||= Time.now.to_i
|
94
|
+
end
|
95
|
+
|
96
|
+
end # Subprocess
|
97
|
+
|
98
|
+
end # Distributed
|
95
99
|
|
96
100
|
end # Vedeu
|