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.

Files changed (234) hide show
  1. data/Gemfile +1 -1
  2. data/Gemfile.lock +0 -2
  3. data/README.textile +1 -1
  4. data/VERSION +1 -1
  5. data/lib/sprout/concern.rb +5 -7
  6. data/lib/sprout/daemon.rb +183 -143
  7. data/lib/sprout/executable/base.rb +564 -0
  8. data/lib/sprout/executable.rb +1 -550
  9. data/lib/sprout/generator/base.rb +2 -3
  10. data/lib/sprout/generator.rb +2 -1
  11. data/lib/sprout/generators/ruby/templates/ruby_base.rb +1 -2
  12. data/lib/sprout/library.rb +3 -3
  13. data/lib/sprout/output_buffer.rb +35 -0
  14. data/lib/sprout/process_runner.rb +68 -17
  15. data/lib/sprout/progress_bar.rb +5 -5
  16. data/lib/sprout/remote_file_target.rb +1 -1
  17. data/lib/sprout/system/base_system.rb +3 -3
  18. data/lib/sprout/system/unix_system.rb +1 -1
  19. data/lib/sprout/{test/sprout_test_case.rb → test_helper.rb} +214 -14
  20. data/lib/sprout/version.rb +1 -1
  21. data/lib/sprout.rb +133 -2
  22. data/rakefile.rb +2 -0
  23. data/test/fixtures/examples/echo_inputs.rb +1 -2
  24. data/test/fixtures/executable/fdb.rb +7 -9
  25. data/test/fixtures/executable/flex3sdk_gem/fdb +49 -18
  26. data/test/fixtures/executable/mxmlc.rb +1 -2
  27. data/test/fixtures/executable/subclass/executable_subclass.rb +0 -1
  28. data/test/fixtures/executable/subclass/executable_superclass.rb +1 -2
  29. data/test/fixtures/specification/flex4sdk.rb +35 -24
  30. data/test/unit/archive_unpacker_test.rb +1 -1
  31. data/test/unit/boolean_param_test.rb +1 -1
  32. data/test/unit/daemon_test.rb +35 -3
  33. data/test/unit/executable_option_parser_test.rb +2 -3
  34. data/test/unit/executable_param_test.rb +1 -1
  35. data/test/unit/executable_test.rb +8 -15
  36. data/test/unit/fake_other_executable.rb +1 -2
  37. data/test/unit/file_param_test.rb +1 -1
  38. data/test/unit/file_target_test.rb +1 -1
  39. data/test/unit/files_param_test.rb +1 -1
  40. data/test/unit/generator_generator_test.rb +1 -1
  41. data/test/unit/generator_test.rb +1 -1
  42. data/test/unit/library_generator_test.rb +1 -1
  43. data/test/unit/library_test.rb +1 -1
  44. data/test/unit/osx_system_test.rb +1 -1
  45. data/test/unit/path_param_test.rb +1 -1
  46. data/test/unit/paths_param_test.rb +1 -1
  47. data/test/unit/platform_test.rb +1 -1
  48. data/test/unit/process_runner_test.rb +1 -1
  49. data/test/unit/rdoc_parser_test.rb +1 -1
  50. data/test/unit/remote_file_loader_test.rb +1 -1
  51. data/test/unit/remote_file_target_test.rb +1 -1
  52. data/test/unit/ruby_feature_test.rb +1 -1
  53. data/test/unit/ruby_generator_test.rb +1 -1
  54. data/test/unit/specification_test.rb +8 -1
  55. data/test/unit/sprout_test.rb +2 -2
  56. data/test/unit/string_param_test.rb +1 -1
  57. data/test/unit/string_test.rb +1 -1
  58. data/test/unit/strings_param_test.rb +1 -1
  59. data/test/unit/test_helper.rb +33 -1
  60. data/test/unit/tool_generator_test.rb +1 -1
  61. data/test/unit/unix_system_test.rb +1 -1
  62. data/test/unit/user_test.rb +1 -1
  63. data/test/unit/vista_system_test.rb +1 -1
  64. data/test/unit/win_nix_system_test.rb +1 -1
  65. data/test/unit/win_system_test.rb +1 -1
  66. data/test-stderr.log +1 -0
  67. data/test-stdout.log +237 -0
  68. metadata +15 -190
  69. data/doc/Dir.html +0 -288
  70. data/doc/Rake/Task.html +0 -184
  71. data/doc/Sprout/ArchiveUnpacker.html +0 -1246
  72. data/doc/Sprout/Base/ClassMethods.html +0 -434
  73. data/doc/Sprout/Base.html +0 -126
  74. data/doc/Sprout/Concern.html +0 -353
  75. data/doc/Sprout/Daemon/ClassMethods.html +0 -244
  76. data/doc/Sprout/Daemon/InstanceMethods.html +0 -601
  77. data/doc/Sprout/Daemon.html +0 -166
  78. data/doc/Sprout/Errors/ArchiveUnpackerError.html +0 -125
  79. data/doc/Sprout/Errors/DestinationExistsError.html +0 -133
  80. data/doc/Sprout/Errors/DuplicateMemberError.html +0 -132
  81. data/doc/Sprout/Errors/ExecutableError.html +0 -125
  82. data/doc/Sprout/Errors/ExecutableRegistrationError.html +0 -132
  83. data/doc/Sprout/Errors/ExecutionError.html +0 -121
  84. data/doc/Sprout/Errors/GeneratorError.html +0 -125
  85. data/doc/Sprout/Errors/InvalidArgumentError.html +0 -132
  86. data/doc/Sprout/Errors/LoadError.html +0 -121
  87. data/doc/Sprout/Errors/MissingArgumentError.html +0 -132
  88. data/doc/Sprout/Errors/MissingExecutableError.html +0 -132
  89. data/doc/Sprout/Errors/MissingGeneratorError.html +0 -132
  90. data/doc/Sprout/Errors/MissingTemplateError.html +0 -132
  91. data/doc/Sprout/Errors/ProcessRunnerError.html +0 -121
  92. data/doc/Sprout/Errors/RemoteFileLoaderError.html +0 -110
  93. data/doc/Sprout/Errors/SproutError.html +0 -114
  94. data/doc/Sprout/Errors/UnknownArchiveType.html +0 -122
  95. data/doc/Sprout/Errors/UsageError.html +0 -121
  96. data/doc/Sprout/Errors/ValidationError.html +0 -121
  97. data/doc/Sprout/Errors/VersionRequirementNotMetError.html +0 -121
  98. data/doc/Sprout/Errors.html +0 -101
  99. data/doc/Sprout/Executable/Boolean.html +0 -483
  100. data/doc/Sprout/Executable/ClassMethods.html +0 -417
  101. data/doc/Sprout/Executable/CollectionParam.html +0 -483
  102. data/doc/Sprout/Executable/FileParam.html +0 -484
  103. data/doc/Sprout/Executable/Files.html +0 -292
  104. data/doc/Sprout/Executable/InstanceMethods.html +0 -2006
  105. data/doc/Sprout/Executable/Number.html +0 -141
  106. data/doc/Sprout/Executable/Param.html +0 -2818
  107. data/doc/Sprout/Executable/ParameterFactory.html +0 -232
  108. data/doc/Sprout/Executable/Path.html +0 -223
  109. data/doc/Sprout/Executable/Paths.html +0 -253
  110. data/doc/Sprout/Executable/StringParam.html +0 -213
  111. data/doc/Sprout/Executable/Strings.html +0 -167
  112. data/doc/Sprout/Executable/Url.html +0 -160
  113. data/doc/Sprout/Executable/Urls.html +0 -170
  114. data/doc/Sprout/Executable.html +0 -173
  115. data/doc/Sprout/FileTarget.html +0 -1109
  116. data/doc/Sprout/Generator/Base.html +0 -1626
  117. data/doc/Sprout/Generator/Command.html +0 -690
  118. data/doc/Sprout/Generator/DirectoryManifest.html +0 -476
  119. data/doc/Sprout/Generator/FileManifest.html +0 -572
  120. data/doc/Sprout/Generator/Manifest.html +0 -377
  121. data/doc/Sprout/Generator/TemplateManifest.html +0 -196
  122. data/doc/Sprout/Generator.html +0 -689
  123. data/doc/Sprout/GeneratorGenerator.html +0 -1018
  124. data/doc/Sprout/Library.html +0 -1141
  125. data/doc/Sprout/LibraryGenerator.html +0 -309
  126. data/doc/Sprout/Log.html +0 -496
  127. data/doc/Sprout/MXMLC.html +0 -6373
  128. data/doc/Sprout/Platform.html +0 -714
  129. data/doc/Sprout/ProcessRunner.html +0 -1352
  130. data/doc/Sprout/ProgressBar.html +0 -376
  131. data/doc/Sprout/ProgressBarImpl.html +0 -2119
  132. data/doc/Sprout/ProgressBarManager.html +0 -434
  133. data/doc/Sprout/ProgressBarOutputStream.html +0 -416
  134. data/doc/Sprout/RDocParser.html +0 -211
  135. data/doc/Sprout/RemoteFileLoader.html +0 -172
  136. data/doc/Sprout/RemoteFileTarget.html +0 -679
  137. data/doc/Sprout/ReversedProgressBar.html +0 -194
  138. data/doc/Sprout/RubyFeature/ClassMethods.html +0 -1065
  139. data/doc/Sprout/RubyFeature.html +0 -155
  140. data/doc/Sprout/RubyGenerator.html +0 -764
  141. data/doc/Sprout/Specification.html +0 -767
  142. data/doc/Sprout/System/BaseSystem.html +0 -1455
  143. data/doc/Sprout/System/JavaSystem.html +0 -122
  144. data/doc/Sprout/System/OSXSystem.html +0 -335
  145. data/doc/Sprout/System/ThreadMock.html +0 -193
  146. data/doc/Sprout/System/UnixSystem.html +0 -584
  147. data/doc/Sprout/System/VistaSystem.html +0 -251
  148. data/doc/Sprout/System/WinNixSystem.html +0 -325
  149. data/doc/Sprout/System/WinSystem.html +0 -571
  150. data/doc/Sprout/System.html +0 -191
  151. data/doc/Sprout/ToolGenerator.html +0 -931
  152. data/doc/Sprout/VERSION.html +0 -128
  153. data/doc/Sprout.html +0 -144
  154. data/doc/SproutTestCase.html +0 -1412
  155. data/doc/String.html +0 -286
  156. data/doc/_index.html +0 -1035
  157. data/doc/class_list.html +0 -36
  158. data/doc/css/common.css +0 -1
  159. data/doc/css/full_list.css +0 -53
  160. data/doc/css/style.css +0 -310
  161. data/doc/file.README.html +0 -96
  162. data/doc/file.archive_unpacker.html +0 -288
  163. data/doc/file.base.html +0 -208
  164. data/doc/file.base_system.html +0 -278
  165. data/doc/file.boolean.html +0 -135
  166. data/doc/file.collection_param.html +0 -139
  167. data/doc/file.command.html +0 -126
  168. data/doc/file.concern.html +0 -136
  169. data/doc/file.daemon.html +0 -309
  170. data/doc/file.dir.html +0 -76
  171. data/doc/file.directory_manifest.html +0 -122
  172. data/doc/file.errors.html +0 -147
  173. data/doc/file.executable.html +0 -638
  174. data/doc/file.file_manifest.html +0 -109
  175. data/doc/file.file_param.html +0 -120
  176. data/doc/file.file_target.html +0 -140
  177. data/doc/file.files.html +0 -85
  178. data/doc/file.generator.html +0 -296
  179. data/doc/file.generator_class.html +0 -72
  180. data/doc/file.generator_generator.html +0 -137
  181. data/doc/file.generator_test.html +0 -92
  182. data/doc/file.generator_test_helper.html +0 -67
  183. data/doc/file.java_system.html +0 -62
  184. data/doc/file.library.html +0 -291
  185. data/doc/file.library_generator.html +0 -74
  186. data/doc/file.log.html +0 -100
  187. data/doc/file.manifest.html +0 -67
  188. data/doc/file.mxmlc.html +0 -740
  189. data/doc/file.number.html +0 -67
  190. data/doc/file.osx_system.html +0 -79
  191. data/doc/file.param.html +0 -491
  192. data/doc/file.parameter_factory.html +0 -119
  193. data/doc/file.path.html +0 -81
  194. data/doc/file.paths.html +0 -80
  195. data/doc/file.platform.html +0 -124
  196. data/doc/file.process_runner.html +0 -224
  197. data/doc/file.progress_bar.html +0 -390
  198. data/doc/file.rdoc_parser.html +0 -145
  199. data/doc/file.remote_file_loader.html +0 -117
  200. data/doc/file.remote_file_target.html +0 -176
  201. data/doc/file.ruby_base.html +0 -64
  202. data/doc/file.ruby_feature.html +0 -244
  203. data/doc/file.ruby_generator.html +0 -118
  204. data/doc/file.ruby_input.html +0 -62
  205. data/doc/file.ruby_test_case.html +0 -78
  206. data/doc/file.ruby_test_helper.html +0 -61
  207. data/doc/file.specification.html +0 -248
  208. data/doc/file.sprout.html +0 -64
  209. data/doc/file.sprout_test_case.html +0 -280
  210. data/doc/file.string.html +0 -72
  211. data/doc/file.string_param.html +0 -76
  212. data/doc/file.strings.html +0 -71
  213. data/doc/file.system.html +0 -86
  214. data/doc/file.template_manifest.html +0 -67
  215. data/doc/file.tool.html +0 -92
  216. data/doc/file.tool_generator.html +0 -90
  217. data/doc/file.unix_system.html +0 -128
  218. data/doc/file.url.html +0 -71
  219. data/doc/file.urls.html +0 -70
  220. data/doc/file.version.html +0 -71
  221. data/doc/file.vista_system.html +0 -69
  222. data/doc/file.win_nix_system.html +0 -88
  223. data/doc/file.win_system.html +0 -129
  224. data/doc/file_list.html +0 -230
  225. data/doc/frames.html +0 -13
  226. data/doc/index.html +0 -96
  227. data/doc/js/app.js +0 -202
  228. data/doc/js/full_list.js +0 -149
  229. data/doc/js/jquery.js +0 -154
  230. data/doc/method_list.html +0 -3355
  231. data/doc/top-level-namespace.html +0 -192
  232. data/lib/sprout/base.rb +0 -121
  233. data/lib/sprout/log.rb +0 -46
  234. data/test/unit/sprout_test_helper.rb +0 -33
data/Gemfile CHANGED
@@ -13,7 +13,7 @@ end
13
13
 
14
14
  group :development do
15
15
  gem "yard"
16
- gem "RedCloth"
16
+ #gem "RedCloth" # This doesn't work Windows for some reason...
17
17
  gem "shoulda"
18
18
  gem "mocha"
19
19
  gem "flay"
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/doc/1.0/frames.html ("No Frames":http://projectsprouts.org/doc/1.0)
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.0.35.pre
1
+ 1.1.2.pre
@@ -1,14 +1,12 @@
1
1
  module Sprout
2
2
 
3
3
  ##
4
- # This class was copied from Rails source code and provides
5
- # our RubyFeature with the ability to more clearly mix in
6
- # functionality against a class and behave as if inheritance
7
- # works at the class mixin level.
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 module exposes the Domain Specific Language
6
- # provided by the Sprout::Executable module, but with
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
- # NOTE: Any class that includes Sprout::Daemon should first include
11
- # Sprout::Executable. This is an admittedly smelly constraint, but it works
12
- # for now.
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 expose
36
- # your new Daemon instance to Rake by creating a method like the following:
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
- # Note: The aforementioned rake helper is usually written at the bottom of
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 :bar do |t|
41
+ # foo 'Bar.txt' do |t|
49
42
  # t.do_something
50
43
  # t.do_something_else
51
44
  # end
52
45
  #
53
- # @see: Sprout::Daemon::ClassMethods
54
- # @see: Sprout::Daemon::InstanceMethods
55
- #
56
- module Daemon
46
+ class Daemon < Executable::Base
57
47
 
58
- extend Concern
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 another
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
- # Instance methods that will be available on any
118
- # class that includes Sprout::Daemon.
119
- module InstanceMethods
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
- # This is the array of actions that have
143
- # been provided at the class level to this instance.
144
- attr_reader :action_stack
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
- def initialize
147
- super
148
- @action_stack = []
149
- end
149
+ ##
150
+ # @return [Array<Hash>] Return or create a new array.
151
+ def action_stack
152
+ @action_stack ||= []
153
+ end
150
154
 
151
- ##
152
- # Execute the Daemon executable, followed
153
- # by the collection of stored actions in
154
- # the order they were called.
155
- #
156
- # If none of the stored actions result in
157
- # terminating the process, the underlying
158
- # daemon will be connected to the terminal
159
- # for user (manual) input.
160
- def execute
161
- runner = super
162
- execute_actions runner
163
- handle_user_session runner
164
- Process.wait runner.pid
165
- end
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
- protected
194
+ def wait
195
+ Process.wait process_runner.pid
196
+ end
168
197
 
169
- ##
170
- # This is the override of the underlying
171
- # Sprout::Executable template method so that we
172
- # create a 'task' instead of a 'file' task.
173
- def create_outer_task *args
174
- task *args do
175
- execute
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
- # This is the override of the underlying
181
- # Sprout::Executable template method so that we
182
- # are NOT added to the CLEAN collection.
183
- # (Work performed in the Executable)
184
- def update_rake_task_name_from_args *args
185
- self.rake_task_name = parse_rake_task_arg args.last
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
- private
236
+ def process_launched?
237
+ @process_launched
238
+ end
198
239
 
199
- ##
200
- # Execute the collection of provided actions.
201
- def execute_actions runner
202
- action_stack.each do |action|
203
- if wait_for_prompt runner
204
- Sprout::Log.puts action
205
- execute_action runner, action
206
- end
207
- end
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
- # Execute a single action.
212
- def execute_action runner, action
213
- runner.puts action.strip
214
- end
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
- # Expose the running process to manual
218
- # input on the terminal, and write stdout
219
- # back to the user.
220
- def handle_user_session runner
221
- while !runner.r.eof?
222
- if wait_for_prompt runner
223
- input = $stdin.gets.chomp!
224
- execute_action runner, input
225
- end
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
- while runner.alive? do
241
- Sprout::Log.flush
242
- return false if runner.r.eof?
243
- char = runner.readpartial 1
244
- line << char
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