sprout 1.0.35.pre → 1.1.2.pre
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sprout might be problematic. Click here for more details.
- data/Gemfile +1 -1
- data/Gemfile.lock +0 -2
- data/README.textile +1 -1
- data/VERSION +1 -1
- data/lib/sprout/concern.rb +5 -7
- data/lib/sprout/daemon.rb +183 -143
- data/lib/sprout/executable/base.rb +564 -0
- data/lib/sprout/executable.rb +1 -550
- data/lib/sprout/generator/base.rb +2 -3
- data/lib/sprout/generator.rb +2 -1
- data/lib/sprout/generators/ruby/templates/ruby_base.rb +1 -2
- data/lib/sprout/library.rb +3 -3
- data/lib/sprout/output_buffer.rb +35 -0
- data/lib/sprout/process_runner.rb +68 -17
- data/lib/sprout/progress_bar.rb +5 -5
- data/lib/sprout/remote_file_target.rb +1 -1
- data/lib/sprout/system/base_system.rb +3 -3
- data/lib/sprout/system/unix_system.rb +1 -1
- data/lib/sprout/{test/sprout_test_case.rb → test_helper.rb} +214 -14
- data/lib/sprout/version.rb +1 -1
- data/lib/sprout.rb +133 -2
- data/rakefile.rb +2 -0
- data/test/fixtures/examples/echo_inputs.rb +1 -2
- data/test/fixtures/executable/fdb.rb +7 -9
- data/test/fixtures/executable/flex3sdk_gem/fdb +49 -18
- data/test/fixtures/executable/mxmlc.rb +1 -2
- data/test/fixtures/executable/subclass/executable_subclass.rb +0 -1
- data/test/fixtures/executable/subclass/executable_superclass.rb +1 -2
- data/test/fixtures/specification/flex4sdk.rb +35 -24
- data/test/unit/archive_unpacker_test.rb +1 -1
- data/test/unit/boolean_param_test.rb +1 -1
- data/test/unit/daemon_test.rb +35 -3
- data/test/unit/executable_option_parser_test.rb +2 -3
- data/test/unit/executable_param_test.rb +1 -1
- data/test/unit/executable_test.rb +8 -15
- data/test/unit/fake_other_executable.rb +1 -2
- data/test/unit/file_param_test.rb +1 -1
- data/test/unit/file_target_test.rb +1 -1
- data/test/unit/files_param_test.rb +1 -1
- data/test/unit/generator_generator_test.rb +1 -1
- data/test/unit/generator_test.rb +1 -1
- data/test/unit/library_generator_test.rb +1 -1
- data/test/unit/library_test.rb +1 -1
- data/test/unit/osx_system_test.rb +1 -1
- data/test/unit/path_param_test.rb +1 -1
- data/test/unit/paths_param_test.rb +1 -1
- data/test/unit/platform_test.rb +1 -1
- data/test/unit/process_runner_test.rb +1 -1
- data/test/unit/rdoc_parser_test.rb +1 -1
- data/test/unit/remote_file_loader_test.rb +1 -1
- data/test/unit/remote_file_target_test.rb +1 -1
- data/test/unit/ruby_feature_test.rb +1 -1
- data/test/unit/ruby_generator_test.rb +1 -1
- data/test/unit/specification_test.rb +8 -1
- data/test/unit/sprout_test.rb +2 -2
- data/test/unit/string_param_test.rb +1 -1
- data/test/unit/string_test.rb +1 -1
- data/test/unit/strings_param_test.rb +1 -1
- data/test/unit/test_helper.rb +33 -1
- data/test/unit/tool_generator_test.rb +1 -1
- data/test/unit/unix_system_test.rb +1 -1
- data/test/unit/user_test.rb +1 -1
- data/test/unit/vista_system_test.rb +1 -1
- data/test/unit/win_nix_system_test.rb +1 -1
- data/test/unit/win_system_test.rb +1 -1
- data/test-stderr.log +1 -0
- data/test-stdout.log +237 -0
- metadata +15 -190
- data/doc/Dir.html +0 -288
- data/doc/Rake/Task.html +0 -184
- data/doc/Sprout/ArchiveUnpacker.html +0 -1246
- data/doc/Sprout/Base/ClassMethods.html +0 -434
- data/doc/Sprout/Base.html +0 -126
- data/doc/Sprout/Concern.html +0 -353
- data/doc/Sprout/Daemon/ClassMethods.html +0 -244
- data/doc/Sprout/Daemon/InstanceMethods.html +0 -601
- data/doc/Sprout/Daemon.html +0 -166
- data/doc/Sprout/Errors/ArchiveUnpackerError.html +0 -125
- data/doc/Sprout/Errors/DestinationExistsError.html +0 -133
- data/doc/Sprout/Errors/DuplicateMemberError.html +0 -132
- data/doc/Sprout/Errors/ExecutableError.html +0 -125
- data/doc/Sprout/Errors/ExecutableRegistrationError.html +0 -132
- data/doc/Sprout/Errors/ExecutionError.html +0 -121
- data/doc/Sprout/Errors/GeneratorError.html +0 -125
- data/doc/Sprout/Errors/InvalidArgumentError.html +0 -132
- data/doc/Sprout/Errors/LoadError.html +0 -121
- data/doc/Sprout/Errors/MissingArgumentError.html +0 -132
- data/doc/Sprout/Errors/MissingExecutableError.html +0 -132
- data/doc/Sprout/Errors/MissingGeneratorError.html +0 -132
- data/doc/Sprout/Errors/MissingTemplateError.html +0 -132
- data/doc/Sprout/Errors/ProcessRunnerError.html +0 -121
- data/doc/Sprout/Errors/RemoteFileLoaderError.html +0 -110
- data/doc/Sprout/Errors/SproutError.html +0 -114
- data/doc/Sprout/Errors/UnknownArchiveType.html +0 -122
- data/doc/Sprout/Errors/UsageError.html +0 -121
- data/doc/Sprout/Errors/ValidationError.html +0 -121
- data/doc/Sprout/Errors/VersionRequirementNotMetError.html +0 -121
- data/doc/Sprout/Errors.html +0 -101
- data/doc/Sprout/Executable/Boolean.html +0 -483
- data/doc/Sprout/Executable/ClassMethods.html +0 -417
- data/doc/Sprout/Executable/CollectionParam.html +0 -483
- data/doc/Sprout/Executable/FileParam.html +0 -484
- data/doc/Sprout/Executable/Files.html +0 -292
- data/doc/Sprout/Executable/InstanceMethods.html +0 -2006
- data/doc/Sprout/Executable/Number.html +0 -141
- data/doc/Sprout/Executable/Param.html +0 -2818
- data/doc/Sprout/Executable/ParameterFactory.html +0 -232
- data/doc/Sprout/Executable/Path.html +0 -223
- data/doc/Sprout/Executable/Paths.html +0 -253
- data/doc/Sprout/Executable/StringParam.html +0 -213
- data/doc/Sprout/Executable/Strings.html +0 -167
- data/doc/Sprout/Executable/Url.html +0 -160
- data/doc/Sprout/Executable/Urls.html +0 -170
- data/doc/Sprout/Executable.html +0 -173
- data/doc/Sprout/FileTarget.html +0 -1109
- data/doc/Sprout/Generator/Base.html +0 -1626
- data/doc/Sprout/Generator/Command.html +0 -690
- data/doc/Sprout/Generator/DirectoryManifest.html +0 -476
- data/doc/Sprout/Generator/FileManifest.html +0 -572
- data/doc/Sprout/Generator/Manifest.html +0 -377
- data/doc/Sprout/Generator/TemplateManifest.html +0 -196
- data/doc/Sprout/Generator.html +0 -689
- data/doc/Sprout/GeneratorGenerator.html +0 -1018
- data/doc/Sprout/Library.html +0 -1141
- data/doc/Sprout/LibraryGenerator.html +0 -309
- data/doc/Sprout/Log.html +0 -496
- data/doc/Sprout/MXMLC.html +0 -6373
- data/doc/Sprout/Platform.html +0 -714
- data/doc/Sprout/ProcessRunner.html +0 -1352
- data/doc/Sprout/ProgressBar.html +0 -376
- data/doc/Sprout/ProgressBarImpl.html +0 -2119
- data/doc/Sprout/ProgressBarManager.html +0 -434
- data/doc/Sprout/ProgressBarOutputStream.html +0 -416
- data/doc/Sprout/RDocParser.html +0 -211
- data/doc/Sprout/RemoteFileLoader.html +0 -172
- data/doc/Sprout/RemoteFileTarget.html +0 -679
- data/doc/Sprout/ReversedProgressBar.html +0 -194
- data/doc/Sprout/RubyFeature/ClassMethods.html +0 -1065
- data/doc/Sprout/RubyFeature.html +0 -155
- data/doc/Sprout/RubyGenerator.html +0 -764
- data/doc/Sprout/Specification.html +0 -767
- data/doc/Sprout/System/BaseSystem.html +0 -1455
- data/doc/Sprout/System/JavaSystem.html +0 -122
- data/doc/Sprout/System/OSXSystem.html +0 -335
- data/doc/Sprout/System/ThreadMock.html +0 -193
- data/doc/Sprout/System/UnixSystem.html +0 -584
- data/doc/Sprout/System/VistaSystem.html +0 -251
- data/doc/Sprout/System/WinNixSystem.html +0 -325
- data/doc/Sprout/System/WinSystem.html +0 -571
- data/doc/Sprout/System.html +0 -191
- data/doc/Sprout/ToolGenerator.html +0 -931
- data/doc/Sprout/VERSION.html +0 -128
- data/doc/Sprout.html +0 -144
- data/doc/SproutTestCase.html +0 -1412
- data/doc/String.html +0 -286
- data/doc/_index.html +0 -1035
- data/doc/class_list.html +0 -36
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -53
- data/doc/css/style.css +0 -310
- data/doc/file.README.html +0 -96
- data/doc/file.archive_unpacker.html +0 -288
- data/doc/file.base.html +0 -208
- data/doc/file.base_system.html +0 -278
- data/doc/file.boolean.html +0 -135
- data/doc/file.collection_param.html +0 -139
- data/doc/file.command.html +0 -126
- data/doc/file.concern.html +0 -136
- data/doc/file.daemon.html +0 -309
- data/doc/file.dir.html +0 -76
- data/doc/file.directory_manifest.html +0 -122
- data/doc/file.errors.html +0 -147
- data/doc/file.executable.html +0 -638
- data/doc/file.file_manifest.html +0 -109
- data/doc/file.file_param.html +0 -120
- data/doc/file.file_target.html +0 -140
- data/doc/file.files.html +0 -85
- data/doc/file.generator.html +0 -296
- data/doc/file.generator_class.html +0 -72
- data/doc/file.generator_generator.html +0 -137
- data/doc/file.generator_test.html +0 -92
- data/doc/file.generator_test_helper.html +0 -67
- data/doc/file.java_system.html +0 -62
- data/doc/file.library.html +0 -291
- data/doc/file.library_generator.html +0 -74
- data/doc/file.log.html +0 -100
- data/doc/file.manifest.html +0 -67
- data/doc/file.mxmlc.html +0 -740
- data/doc/file.number.html +0 -67
- data/doc/file.osx_system.html +0 -79
- data/doc/file.param.html +0 -491
- data/doc/file.parameter_factory.html +0 -119
- data/doc/file.path.html +0 -81
- data/doc/file.paths.html +0 -80
- data/doc/file.platform.html +0 -124
- data/doc/file.process_runner.html +0 -224
- data/doc/file.progress_bar.html +0 -390
- data/doc/file.rdoc_parser.html +0 -145
- data/doc/file.remote_file_loader.html +0 -117
- data/doc/file.remote_file_target.html +0 -176
- data/doc/file.ruby_base.html +0 -64
- data/doc/file.ruby_feature.html +0 -244
- data/doc/file.ruby_generator.html +0 -118
- data/doc/file.ruby_input.html +0 -62
- data/doc/file.ruby_test_case.html +0 -78
- data/doc/file.ruby_test_helper.html +0 -61
- data/doc/file.specification.html +0 -248
- data/doc/file.sprout.html +0 -64
- data/doc/file.sprout_test_case.html +0 -280
- data/doc/file.string.html +0 -72
- data/doc/file.string_param.html +0 -76
- data/doc/file.strings.html +0 -71
- data/doc/file.system.html +0 -86
- data/doc/file.template_manifest.html +0 -67
- data/doc/file.tool.html +0 -92
- data/doc/file.tool_generator.html +0 -90
- data/doc/file.unix_system.html +0 -128
- data/doc/file.url.html +0 -71
- data/doc/file.urls.html +0 -70
- data/doc/file.version.html +0 -71
- data/doc/file.vista_system.html +0 -69
- data/doc/file.win_nix_system.html +0 -88
- data/doc/file.win_system.html +0 -129
- data/doc/file_list.html +0 -230
- data/doc/frames.html +0 -13
- data/doc/index.html +0 -96
- data/doc/js/app.js +0 -202
- data/doc/js/full_list.js +0 -149
- data/doc/js/jquery.js +0 -154
- data/doc/method_list.html +0 -3355
- data/doc/top-level-namespace.html +0 -192
- data/lib/sprout/base.rb +0 -121
- data/lib/sprout/log.rb +0 -46
- data/test/unit/sprout_test_helper.rb +0 -33
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -4,7 +4,6 @@ GEM
|
|
4
4
|
ParseTree (3.0.6)
|
5
5
|
RubyInline (>= 3.7.0)
|
6
6
|
sexp_processor (>= 3.0.0)
|
7
|
-
RedCloth (4.2.3)
|
8
7
|
RubyInline (3.8.6)
|
9
8
|
ZenTest (~> 4.3)
|
10
9
|
ZenTest (4.4.0)
|
@@ -38,7 +37,6 @@ PLATFORMS
|
|
38
37
|
ruby
|
39
38
|
|
40
39
|
DEPENDENCIES
|
41
|
-
RedCloth
|
42
40
|
archive-tar-minitar (= 0.5.2)
|
43
41
|
bundler (>= 0.9.19)
|
44
42
|
flay
|
data/README.textile
CHANGED
@@ -25,7 +25,7 @@ To get started with Sprouts in *Flash*, follow the directions provided by the "F
|
|
25
25
|
h2. Some Links
|
26
26
|
|
27
27
|
* "Web Site":http://projectsprouts.org
|
28
|
-
* "See the Documentation":http://projectsprouts.org/
|
28
|
+
* "See the Documentation":http://projectsprouts.org/docs/1.1/frames.html ("No Frames":http://projectsprouts.org/docs/1.1)
|
29
29
|
* "Meet the Community":http://groups.google.com/group/projectsprouts
|
30
30
|
|
31
31
|
h1. MIT License
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.2.pre
|
data/lib/sprout/concern.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
module Sprout
|
2
2
|
|
3
3
|
##
|
4
|
-
# This class was copied from Rails source code and
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
4
|
+
# This class was copied from Rails source code and enhances
|
5
|
+
# Ruby's native mixin functionality for our Sprout::RubyFeature.
|
6
|
+
#
|
7
|
+
# I'd like to work to get rid of this class, and the confusion
|
8
|
+
# that it introduces.
|
8
9
|
#
|
9
|
-
# TODO: I'd like to update our system so that this
|
10
|
-
# functionality is no longer necessary - if you have ideas
|
11
|
-
# or opinions about this code, please let me know!
|
12
10
|
module Concern
|
13
11
|
|
14
12
|
##
|
data/lib/sprout/daemon.rb
CHANGED
@@ -2,18 +2,14 @@
|
|
2
2
|
module Sprout
|
3
3
|
|
4
4
|
##
|
5
|
-
# The Sprout::Daemon
|
6
|
-
# provided by the Sprout::Executable
|
5
|
+
# The Sprout::Daemon class exposes the Domain Specific Language
|
6
|
+
# provided by the Sprout::Executable, along with
|
7
7
|
# enhancements (and modifications) to support long-lived processes
|
8
8
|
# (like FDB and FCSH).
|
9
9
|
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# class Foo
|
15
|
-
# include Sprout::Executable
|
16
|
-
# include Sprout::Daemon
|
10
|
+
# ##
|
11
|
+
# # The Foo class extends Sprout::Daemon
|
12
|
+
# class Foo < Sprout::Daemon
|
17
13
|
#
|
18
14
|
# ##
|
19
15
|
# # Keep in mind that we're still working
|
@@ -32,35 +28,24 @@ module Sprout
|
|
32
28
|
# add_action :do_something_else
|
33
29
|
# end
|
34
30
|
#
|
35
|
-
# You can also create a globally-accessible rake task to
|
36
|
-
# your new Daemon instance
|
31
|
+
# You can also create a globally-accessible rake task to use
|
32
|
+
# your new Daemon instance by creating a method like the following:
|
37
33
|
#
|
38
34
|
# def foo *args, &block
|
39
35
|
# foo_tool = Foo.new
|
40
36
|
# foo_tool.to_rake *args, &block
|
41
37
|
# end
|
42
38
|
#
|
43
|
-
#
|
44
|
-
# the class file that is referenced.
|
45
|
-
#
|
46
|
-
# The aforementioned Rake task could be used like:
|
39
|
+
# The previous Rake task could be used like:
|
47
40
|
#
|
48
|
-
# foo
|
41
|
+
# foo 'Bar.txt' do |t|
|
49
42
|
# t.do_something
|
50
43
|
# t.do_something_else
|
51
44
|
# end
|
52
45
|
#
|
53
|
-
|
54
|
-
# @see: Sprout::Daemon::InstanceMethods
|
55
|
-
#
|
56
|
-
module Daemon
|
46
|
+
class Daemon < Executable::Base
|
57
47
|
|
58
|
-
|
59
|
-
|
60
|
-
##
|
61
|
-
# These are the methods that will be available
|
62
|
-
# on any class that includes Sprout::Daemon.
|
63
|
-
module ClassMethods
|
48
|
+
class << self
|
64
49
|
|
65
50
|
##
|
66
51
|
# Add an action that can be called while
|
@@ -69,20 +54,39 @@ module Sprout
|
|
69
54
|
# This method should raise a Sprout::Errors::UsageError
|
70
55
|
# if the provided action name is already defined for
|
71
56
|
# the provided instance.
|
57
|
+
#
|
58
|
+
# @param name [Symbol, String] The name of the method.
|
59
|
+
# @param arguments [Array<Object>] An array of arguments that the method accepts.
|
60
|
+
# @param options [Hash] The options hash is reserved for future use.
|
61
|
+
#
|
62
|
+
# class Foo < Sprout::Daemon
|
63
|
+
#
|
64
|
+
# add_action :continue
|
65
|
+
#
|
66
|
+
# add_action :quit
|
67
|
+
# end
|
68
|
+
#
|
69
|
+
# @return [nil]
|
72
70
|
def add_action name, arguments=nil, options=nil
|
73
71
|
options ||= {}
|
74
72
|
options[:name] = name
|
75
73
|
options[:arguments] = arguments
|
76
74
|
create_action_method options
|
75
|
+
nil
|
77
76
|
end
|
78
77
|
|
79
78
|
##
|
80
|
-
# Create an (often shorter) alias to
|
79
|
+
# Create an (often shorter) alias to an existing
|
81
80
|
# action name.
|
81
|
+
#
|
82
|
+
# @return [nil]
|
83
|
+
#
|
84
|
+
# @see add_action
|
82
85
|
def add_action_alias alias_name, source_name
|
83
86
|
define_method(alias_name) do |*params|
|
84
87
|
self.send(source_name, params)
|
85
88
|
end
|
89
|
+
nil
|
86
90
|
end
|
87
91
|
|
88
92
|
private
|
@@ -102,6 +106,7 @@ module Sprout
|
|
102
106
|
action = "y" if name == :confirm # Convert affirmation
|
103
107
|
action << " #{params.join(' ')}" unless params.nil?
|
104
108
|
action_stack << action
|
109
|
+
execute_actions if process_launched?
|
105
110
|
end
|
106
111
|
end
|
107
112
|
|
@@ -113,144 +118,179 @@ module Sprout
|
|
113
118
|
|
114
119
|
end
|
115
120
|
|
121
|
+
|
116
122
|
##
|
117
|
-
#
|
118
|
-
#
|
119
|
-
|
123
|
+
# The prompt expression for this daemon process.
|
124
|
+
#
|
125
|
+
# When executing a series of commands, the
|
126
|
+
# wrapper will wait until it matches this expression
|
127
|
+
# on stdout before continuing the series.
|
128
|
+
#
|
129
|
+
# For FDB, this value is set like:
|
130
|
+
#
|
131
|
+
# set :prompt, /^\(fdb\) /
|
132
|
+
#
|
133
|
+
# Most processes can trigger a variety of different
|
134
|
+
# prompts, these can be expressed here using the | (or) operator.
|
135
|
+
#
|
136
|
+
# FDB actually uses the following:
|
137
|
+
#
|
138
|
+
# set :prompt, /^\(fdb\) |\(y or n\) /
|
139
|
+
#
|
140
|
+
# @return [Regexp]
|
141
|
+
attr_accessor :prompt
|
120
142
|
|
121
|
-
##
|
122
|
-
# The prompt expression for this daemon process.
|
123
|
-
#
|
124
|
-
# When executing a series of commands, the
|
125
|
-
# wrapper will wait until it matches this expression
|
126
|
-
# on stdout before continuing the series.
|
127
|
-
#
|
128
|
-
# For FDB, this value is set like:
|
129
|
-
#
|
130
|
-
# set :prompt, /^\(fdb\) /
|
131
|
-
#
|
132
|
-
# Most processes can trigger a variety of different
|
133
|
-
# prompts, these can be expressed here using the | (or) operator.
|
134
|
-
#
|
135
|
-
# FDB actually uses the following:
|
136
|
-
#
|
137
|
-
# set :prompt, /^\(fdb\) |\(y or n\) /
|
138
|
-
#
|
139
|
-
attr_accessor :prompt
|
140
143
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
144
|
+
##
|
145
|
+
# The Sprout::ProcessRunner that delegates to the long-running process,
|
146
|
+
# via stdin, stdout and stderr.
|
147
|
+
attr_reader :process_runner
|
145
148
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
149
|
+
##
|
150
|
+
# @return [Array<Hash>] Return or create a new array.
|
151
|
+
def action_stack
|
152
|
+
@action_stack ||= []
|
153
|
+
end
|
150
154
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
155
|
+
##
|
156
|
+
# Execute the Daemon executable, followed
|
157
|
+
# by the collection of stored actions in
|
158
|
+
# the order they were called.
|
159
|
+
#
|
160
|
+
# If none of the stored actions result in
|
161
|
+
# terminating the process, the underlying
|
162
|
+
# daemon will be connected to the terminal
|
163
|
+
# for user (manual) input.
|
164
|
+
#
|
165
|
+
# You can also send wait=false to connect
|
166
|
+
# to a daemon process from Ruby and execute
|
167
|
+
# actions over time. This might look like:
|
168
|
+
#
|
169
|
+
# fdb = FlashSDK::FDB.new
|
170
|
+
# fdb.execute false
|
171
|
+
#
|
172
|
+
# # Do something else while FDB
|
173
|
+
# # is open, then:
|
174
|
+
#
|
175
|
+
# fdb.run
|
176
|
+
# fdb.break "AsUnitRunner:12"
|
177
|
+
# fdb.continue
|
178
|
+
# fdb.kill
|
179
|
+
# fdb.confirm
|
180
|
+
# fdb.quit
|
181
|
+
#
|
182
|
+
# @param wait [Boolean] default true. Send false to
|
183
|
+
# connect to a daemon from Ruby code.
|
184
|
+
#
|
185
|
+
def execute should_wait=true
|
186
|
+
@process_runner = super()
|
187
|
+
@process_launched = true
|
188
|
+
wait_for_prompt
|
189
|
+
execute_actions
|
190
|
+
handle_user_session if should_wait
|
191
|
+
wait if should_wait
|
192
|
+
end
|
166
193
|
|
167
|
-
|
194
|
+
def wait
|
195
|
+
Process.wait process_runner.pid
|
196
|
+
end
|
168
197
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
198
|
+
##
|
199
|
+
# Wait for the underlying process to present
|
200
|
+
# an input prompt, so that another action
|
201
|
+
# can be submitted, or user input can be
|
202
|
+
# collected.
|
203
|
+
def wait_for_prompt expected_prompt=nil
|
204
|
+
expected_prompt = expected_prompt || prompt
|
205
|
+
line = ''
|
206
|
+
|
207
|
+
while process_runner.alive? do
|
208
|
+
#puts ">> ERROR #{process_runner.readpartial_err 1}"
|
209
|
+
|
210
|
+
return false if process_runner.r.eof?
|
211
|
+
char = process_runner.readpartial 1
|
212
|
+
line << char
|
213
|
+
if char == "\n"
|
214
|
+
line = ''
|
176
215
|
end
|
216
|
+
Sprout.stdout.printf char
|
217
|
+
Sprout.stdout.flush
|
218
|
+
return true unless line.match(expected_prompt).nil?
|
177
219
|
end
|
220
|
+
end
|
178
221
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
222
|
+
##
|
223
|
+
# Expose the running process to manual
|
224
|
+
# input on the terminal, and write stdout
|
225
|
+
# back to the user.
|
226
|
+
def handle_user_session
|
227
|
+
while !process_runner.r.eof?
|
228
|
+
input = $stdin.gets.chomp!
|
229
|
+
execute_action input, true
|
230
|
+
wait_for_prompt
|
186
231
|
end
|
232
|
+
end
|
187
233
|
|
188
|
-
|
189
|
-
# This is the override of the underlying
|
190
|
-
# Sprout::Executable template method so that we
|
191
|
-
# create the process in a thread
|
192
|
-
# in order to read and write to it.
|
193
|
-
def system_execute binary, params
|
194
|
-
Sprout.current_system.execute_thread binary, params
|
195
|
-
end
|
234
|
+
protected
|
196
235
|
|
197
|
-
|
236
|
+
def process_launched?
|
237
|
+
@process_launched
|
238
|
+
end
|
198
239
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
240
|
+
##
|
241
|
+
# This is the override of the underlying
|
242
|
+
# Sprout::Executable template method so that we
|
243
|
+
# create a 'task' instead of a 'file' task.
|
244
|
+
#
|
245
|
+
# @return [Rake::Task]
|
246
|
+
def create_outer_task *args
|
247
|
+
task *args do
|
248
|
+
execute
|
208
249
|
end
|
250
|
+
end
|
209
251
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
252
|
+
##
|
253
|
+
# This is the override of the underlying
|
254
|
+
# Sprout::Executable template method so that we
|
255
|
+
# are NOT added to the CLEAN collection.
|
256
|
+
# (Work performed in the Executable)
|
257
|
+
#
|
258
|
+
# @return [String]
|
259
|
+
def update_rake_task_name_from_args *args
|
260
|
+
self.rake_task_name = parse_rake_task_arg args.last
|
261
|
+
end
|
215
262
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
end
|
227
|
-
end
|
263
|
+
##
|
264
|
+
# This is the override of the underlying
|
265
|
+
# Sprout::Executable template method so that we
|
266
|
+
# create the process in a thread
|
267
|
+
# in order to read and write to it.
|
268
|
+
#
|
269
|
+
# @return [Thread]
|
270
|
+
def system_execute binary, params
|
271
|
+
Sprout.current_system.execute_thread binary, params
|
272
|
+
end
|
228
273
|
|
229
|
-
|
230
|
-
# Wait for the underlying process to present
|
231
|
-
# an input prompt, so that another action
|
232
|
-
# can be submitted, or user input can be
|
233
|
-
# collected.
|
234
|
-
def wait_for_prompt runner, expected_prompt=nil
|
235
|
-
##
|
236
|
-
# TODO: This should also check for a variety of prompts...
|
237
|
-
expected_prompt = expected_prompt || prompt
|
238
|
-
line = ''
|
274
|
+
private
|
239
275
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
if char == "\n"
|
246
|
-
line = ''
|
247
|
-
end
|
248
|
-
Sprout::Log.printf char
|
249
|
-
return true if line.match expected_prompt
|
250
|
-
end
|
276
|
+
##
|
277
|
+
# Execute the collection of provided actions.
|
278
|
+
def execute_actions
|
279
|
+
action_stack.each do |action|
|
280
|
+
break unless execute_action(action)
|
251
281
|
end
|
282
|
+
@action_stack = []
|
283
|
+
end
|
252
284
|
|
285
|
+
##
|
286
|
+
# Execute a single action.
|
287
|
+
def execute_action action, silence=false
|
288
|
+
action = action.strip
|
289
|
+
Sprout.stdout.puts(action) unless silence
|
290
|
+
process_runner.puts action
|
291
|
+
wait_for_prompt
|
253
292
|
end
|
293
|
+
|
254
294
|
end
|
255
295
|
end
|
256
296
|
|