sprout 1.0.32.pre → 1.0.35.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 +2 -1
- data/Gemfile.lock +4 -2
- data/README.textile +12 -13
- data/VERSION +1 -0
- data/doc/Dir.html +288 -0
- data/doc/Rake/Task.html +184 -0
- data/doc/Sprout.html +144 -0
- data/doc/Sprout/ArchiveUnpacker.html +1246 -0
- data/doc/Sprout/Base.html +126 -0
- data/doc/Sprout/Base/ClassMethods.html +434 -0
- data/doc/Sprout/Concern.html +353 -0
- data/doc/Sprout/Daemon.html +166 -0
- data/doc/Sprout/Daemon/ClassMethods.html +244 -0
- data/doc/Sprout/Daemon/InstanceMethods.html +601 -0
- data/doc/Sprout/Errors.html +101 -0
- data/doc/Sprout/Errors/ArchiveUnpackerError.html +125 -0
- data/doc/Sprout/Errors/DestinationExistsError.html +133 -0
- data/doc/Sprout/Errors/DuplicateMemberError.html +132 -0
- data/doc/Sprout/Errors/ExecutableError.html +125 -0
- data/doc/Sprout/Errors/ExecutableRegistrationError.html +132 -0
- data/doc/Sprout/Errors/ExecutionError.html +121 -0
- data/doc/Sprout/Errors/GeneratorError.html +125 -0
- data/doc/Sprout/Errors/InvalidArgumentError.html +132 -0
- data/doc/Sprout/Errors/LoadError.html +121 -0
- data/doc/Sprout/Errors/MissingArgumentError.html +132 -0
- data/doc/Sprout/Errors/MissingExecutableError.html +132 -0
- data/doc/Sprout/Errors/MissingGeneratorError.html +132 -0
- data/doc/Sprout/Errors/MissingTemplateError.html +132 -0
- data/doc/Sprout/Errors/ProcessRunnerError.html +121 -0
- data/doc/Sprout/Errors/RemoteFileLoaderError.html +110 -0
- data/doc/Sprout/Errors/SproutError.html +114 -0
- data/doc/Sprout/Errors/UnknownArchiveType.html +122 -0
- data/doc/Sprout/Errors/UsageError.html +121 -0
- data/doc/Sprout/Errors/ValidationError.html +121 -0
- data/doc/Sprout/Errors/VersionRequirementNotMetError.html +121 -0
- data/doc/Sprout/Executable.html +173 -0
- data/doc/Sprout/Executable/Boolean.html +483 -0
- data/doc/Sprout/Executable/ClassMethods.html +417 -0
- data/doc/Sprout/Executable/CollectionParam.html +483 -0
- data/doc/Sprout/Executable/FileParam.html +484 -0
- data/doc/Sprout/Executable/Files.html +292 -0
- data/doc/Sprout/Executable/InstanceMethods.html +2006 -0
- data/doc/Sprout/Executable/Number.html +141 -0
- data/doc/Sprout/Executable/Param.html +2818 -0
- data/doc/Sprout/Executable/ParameterFactory.html +232 -0
- data/doc/Sprout/Executable/Path.html +223 -0
- data/doc/Sprout/Executable/Paths.html +253 -0
- data/doc/Sprout/Executable/StringParam.html +213 -0
- data/doc/Sprout/Executable/Strings.html +167 -0
- data/doc/Sprout/Executable/Url.html +160 -0
- data/doc/Sprout/Executable/Urls.html +170 -0
- data/doc/Sprout/FileTarget.html +1109 -0
- data/doc/Sprout/Generator.html +689 -0
- data/doc/Sprout/Generator/Base.html +1626 -0
- data/doc/Sprout/Generator/Command.html +690 -0
- data/doc/Sprout/Generator/DirectoryManifest.html +476 -0
- data/doc/Sprout/Generator/FileManifest.html +572 -0
- data/doc/Sprout/Generator/Manifest.html +377 -0
- data/doc/Sprout/Generator/TemplateManifest.html +196 -0
- data/doc/Sprout/GeneratorGenerator.html +1018 -0
- data/doc/Sprout/Library.html +1141 -0
- data/doc/Sprout/LibraryGenerator.html +309 -0
- data/doc/Sprout/Log.html +496 -0
- data/doc/Sprout/MXMLC.html +6373 -0
- data/doc/Sprout/Platform.html +714 -0
- data/doc/Sprout/ProcessRunner.html +1352 -0
- data/doc/Sprout/ProgressBar.html +376 -0
- data/doc/Sprout/ProgressBarImpl.html +2119 -0
- data/doc/Sprout/ProgressBarManager.html +434 -0
- data/doc/Sprout/ProgressBarOutputStream.html +416 -0
- data/doc/Sprout/RDocParser.html +211 -0
- data/doc/Sprout/RemoteFileLoader.html +172 -0
- data/doc/Sprout/RemoteFileTarget.html +679 -0
- data/doc/Sprout/ReversedProgressBar.html +194 -0
- data/doc/Sprout/RubyFeature.html +155 -0
- data/doc/Sprout/RubyFeature/ClassMethods.html +1065 -0
- data/doc/Sprout/RubyGenerator.html +764 -0
- data/doc/Sprout/Specification.html +767 -0
- data/doc/Sprout/System.html +191 -0
- data/doc/Sprout/System/BaseSystem.html +1455 -0
- data/doc/Sprout/System/JavaSystem.html +122 -0
- data/doc/Sprout/System/OSXSystem.html +335 -0
- data/doc/Sprout/System/ThreadMock.html +193 -0
- data/doc/Sprout/System/UnixSystem.html +584 -0
- data/doc/Sprout/System/VistaSystem.html +251 -0
- data/doc/Sprout/System/WinNixSystem.html +325 -0
- data/doc/Sprout/System/WinSystem.html +571 -0
- data/doc/Sprout/ToolGenerator.html +931 -0
- data/doc/Sprout/VERSION.html +128 -0
- data/doc/SproutTestCase.html +1412 -0
- data/doc/String.html +286 -0
- data/doc/_index.html +1035 -0
- data/doc/class_list.html +36 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +53 -0
- data/doc/css/style.css +310 -0
- data/doc/file.README.html +96 -0
- data/doc/file.archive_unpacker.html +288 -0
- data/doc/file.base.html +208 -0
- data/doc/file.base_system.html +278 -0
- data/doc/file.boolean.html +135 -0
- data/doc/file.collection_param.html +139 -0
- data/doc/file.command.html +126 -0
- data/doc/file.concern.html +136 -0
- data/doc/file.daemon.html +309 -0
- data/doc/file.dir.html +76 -0
- data/doc/file.directory_manifest.html +122 -0
- data/doc/file.errors.html +147 -0
- data/doc/file.executable.html +638 -0
- data/doc/file.file_manifest.html +109 -0
- data/doc/file.file_param.html +120 -0
- data/doc/file.file_target.html +140 -0
- data/doc/file.files.html +85 -0
- data/doc/file.generator.html +296 -0
- data/doc/file.generator_class.html +72 -0
- data/doc/file.generator_generator.html +137 -0
- data/doc/file.generator_test.html +92 -0
- data/doc/file.generator_test_helper.html +67 -0
- data/doc/file.java_system.html +62 -0
- data/doc/file.library.html +291 -0
- data/doc/file.library_generator.html +74 -0
- data/doc/file.log.html +100 -0
- data/doc/file.manifest.html +67 -0
- data/doc/file.mxmlc.html +740 -0
- data/doc/file.number.html +67 -0
- data/doc/file.osx_system.html +79 -0
- data/doc/file.param.html +491 -0
- data/doc/file.parameter_factory.html +119 -0
- data/doc/file.path.html +81 -0
- data/doc/file.paths.html +80 -0
- data/doc/file.platform.html +124 -0
- data/doc/file.process_runner.html +224 -0
- data/doc/file.progress_bar.html +390 -0
- data/doc/file.rdoc_parser.html +145 -0
- data/doc/file.remote_file_loader.html +117 -0
- data/doc/file.remote_file_target.html +176 -0
- data/doc/file.ruby_base.html +64 -0
- data/doc/file.ruby_feature.html +244 -0
- data/doc/file.ruby_generator.html +118 -0
- data/doc/file.ruby_input.html +62 -0
- data/doc/file.ruby_test_case.html +78 -0
- data/doc/file.ruby_test_helper.html +61 -0
- data/doc/file.specification.html +248 -0
- data/doc/file.sprout.html +64 -0
- data/doc/file.sprout_test_case.html +280 -0
- data/doc/file.string.html +72 -0
- data/doc/file.string_param.html +76 -0
- data/doc/file.strings.html +71 -0
- data/doc/file.system.html +86 -0
- data/doc/file.template_manifest.html +67 -0
- data/doc/file.tool.html +92 -0
- data/doc/file.tool_generator.html +90 -0
- data/doc/file.unix_system.html +128 -0
- data/doc/file.url.html +71 -0
- data/doc/file.urls.html +70 -0
- data/doc/file.version.html +71 -0
- data/doc/file.vista_system.html +69 -0
- data/doc/file.win_nix_system.html +88 -0
- data/doc/file.win_system.html +129 -0
- data/doc/file_list.html +230 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +96 -0
- data/doc/js/app.js +202 -0
- data/doc/js/full_list.js +149 -0
- data/doc/js/jquery.js +154 -0
- data/doc/method_list.html +3355 -0
- data/doc/top-level-namespace.html +192 -0
- data/lib/sprout/archive_unpacker.rb +203 -137
- data/lib/sprout/base.rb +38 -11
- data/lib/sprout/concern.rb +51 -0
- data/lib/sprout/daemon.rb +256 -0
- data/lib/sprout/executable.rb +40 -11
- data/lib/sprout/executable/boolean.rb +47 -1
- data/lib/sprout/executable/collection_param.rb +33 -1
- data/lib/sprout/executable/file_param.rb +16 -3
- data/lib/sprout/executable/files.rb +5 -0
- data/lib/sprout/executable/number.rb +5 -1
- data/lib/sprout/executable/param.rb +232 -16
- data/lib/sprout/executable/parameter_factory.rb +39 -1
- data/lib/sprout/executable/path.rb +7 -1
- data/lib/sprout/executable/paths.rb +6 -1
- data/lib/sprout/executable/string_param.rb +8 -1
- data/lib/sprout/executable/strings.rb +7 -1
- data/lib/sprout/executable/url.rb +8 -1
- data/lib/sprout/executable/urls.rb +7 -1
- data/lib/sprout/file_target.rb +11 -11
- data/lib/sprout/generator.rb +244 -0
- data/lib/sprout/generator/base.rb +0 -94
- data/lib/sprout/generators/generator/generator_generator.rb +35 -1
- data/lib/sprout/generators/generator/templates/generator_class.rb +3 -3
- data/lib/sprout/library.rb +75 -0
- data/lib/sprout/log.rb +11 -12
- data/lib/sprout/process_runner.rb +29 -9
- data/lib/sprout/remote_file_target.rb +20 -9
- data/lib/sprout/system/base_system.rb +11 -3
- data/lib/sprout/test/sprout_test_case.rb +1 -0
- data/lib/sprout/version.rb +7 -11
- data/rakefile.rb +7 -12
- data/script/add_param_handler.rb +43 -0
- data/sprout.gemspec +2 -3
- data/test/fixtures/executable/fdb.rb +764 -0
- data/test/fixtures/executable/flex3sdk_gem/fdb +60 -0
- data/test/fixtures/executable/mxmlc.rb +9 -11
- data/test/unit/daemon_test.rb +61 -0
- data/test/unit/process_runner_test.rb +21 -0
- data/test/unit/remote_file_target_test.rb +45 -11
- data/test/unit/sprout_test_helper.rb +1 -1
- metadata +210 -29
@@ -0,0 +1,126 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta name="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>File: command</title>
|
7
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
9
|
+
|
10
|
+
<script type="text/javascript" charset="utf-8">
|
11
|
+
relpath = '';
|
12
|
+
if (relpath != '') relpath += '/';
|
13
|
+
</script>
|
14
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
15
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<script type="text/javascript" charset="utf-8">
|
20
|
+
if (window.top.frames.main) document.body.className = 'frames';
|
21
|
+
</script>
|
22
|
+
|
23
|
+
<div id="header">
|
24
|
+
<div id="menu">
|
25
|
+
|
26
|
+
<a href="_index.html" title="Index">Index</a> »
|
27
|
+
<span class="title">File: command</span>
|
28
|
+
|
29
|
+
|
30
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<div id="search">
|
34
|
+
<a id="class_list_link" href="#">Class List</a>
|
35
|
+
<a id="method_list_link" href="#">Method List</a>
|
36
|
+
<a id ="file_list_link" href="#">File List</a>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div class="clear"></div>
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<iframe id="search_frame"></iframe>
|
43
|
+
|
44
|
+
<div id="content"><div id='filecontents'>
|
45
|
+
<p>module Sprout::Generator</p>
|
46
|
+
|
47
|
+
<pre class="code"><span class='kw'>class</span> <span class='const'>Command</span>
|
48
|
+
<span class='id attr_accessor'>attr_accessor</span> <span class='symbol'>:logger</span>
|
49
|
+
<span class='id attr_accessor'>attr_accessor</span> <span class='symbol'>:working_dir</span>
|
50
|
+
|
51
|
+
<span class='kw'>def</span> <span class='id initialize'>initialize</span> <span class='id generator'>generator</span>
|
52
|
+
<span class='ivar'>@generator</span> <span class='op'>=</span> <span class='id generator'>generator</span>
|
53
|
+
<span class='ivar'>@working_dir</span> <span class='op'>=</span> <span class='const'>DirectoryManifest</span><span class='period'>.</span><span class='id new'>new</span>
|
54
|
+
<span class='ivar'>@working_dir</span><span class='period'>.</span><span class='id generator'>generator</span> <span class='op'>=</span> <span class='id generator'>generator</span>
|
55
|
+
<span class='ivar'>@working_dir</span><span class='period'>.</span><span class='id path'>path</span> <span class='op'>=</span> <span class='id generator'>generator</span><span class='period'>.</span><span class='id path'>path</span>
|
56
|
+
<span class='kw'>end</span>
|
57
|
+
|
58
|
+
<span class='kw'>def</span> <span class='id directory'>directory</span> <span class='id path'>path</span><span class='comma'>,</span> <span class='op'>&</span><span class='id block'>block</span>
|
59
|
+
<span class='id raise'>raise</span> <span class='const'>Sprout</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>GeneratorError</span><span class='period'>.</span><span class='id new'>new</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Cannot create directory with nil path</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id path'>path</span><span class='period'>.</span><span class='id nil?'>nil?</span>
|
60
|
+
<span class='id manifest'>manifest</span> <span class='op'>=</span> <span class='const'>DirectoryManifest</span><span class='period'>.</span><span class='id new'>new</span>
|
61
|
+
<span class='id manifest'>manifest</span><span class='period'>.</span><span class='id generator'>generator</span> <span class='op'>=</span> <span class='ivar'>@generator</span>
|
62
|
+
<span class='id manifest'>manifest</span><span class='period'>.</span><span class='id path'>path</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id join'>join</span><span class='lparen'>(</span><span class='ivar'>@working_dir</span><span class='period'>.</span><span class='id path'>path</span><span class='comma'>,</span> <span class='id path'>path</span><span class='rparen'>)</span>
|
63
|
+
<span class='ivar'>@working_dir</span><span class='period'>.</span><span class='id children'>children</span> <span class='op'><<</span> <span class='id manifest'>manifest</span>
|
64
|
+
<span class='id parent'>parent</span> <span class='op'>=</span> <span class='ivar'>@working_dir</span>
|
65
|
+
<span class='ivar'>@working_dir</span> <span class='op'>=</span> <span class='id manifest'>manifest</span>
|
66
|
+
<span class='kw'>yield</span> <span class='kw'>if</span> <span class='id block_given?'>block_given?</span>
|
67
|
+
<span class='ivar'>@working_dir</span> <span class='op'>=</span> <span class='id parent'>parent</span>
|
68
|
+
<span class='kw'>end</span>
|
69
|
+
|
70
|
+
<span class='kw'>def</span> <span class='id template'>template</span> <span class='id path'>path</span><span class='comma'>,</span> <span class='id template'>template</span><span class='op'>=</span><span class='kw'>nil</span>
|
71
|
+
<span class='id raise'>raise</span> <span class='const'>Sprout</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>GeneratorError</span><span class='period'>.</span><span class='id new'>new</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Cannot create file with nil path</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id path'>path</span><span class='period'>.</span><span class='id nil?'>nil?</span>
|
72
|
+
<span class='id manifest'>manifest</span> <span class='op'>=</span> <span class='const'>TemplateManifest</span><span class='period'>.</span><span class='id new'>new</span>
|
73
|
+
<span class='id manifest'>manifest</span><span class='period'>.</span><span class='id generator'>generator</span> <span class='op'>=</span> <span class='ivar'>@generator</span>
|
74
|
+
<span class='id manifest'>manifest</span><span class='period'>.</span><span class='id path'>path</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id join'>join</span><span class='lparen'>(</span> <span class='id working_dir'>working_dir</span><span class='period'>.</span><span class='id path'>path</span><span class='comma'>,</span> <span class='id path'>path</span> <span class='rparen'>)</span>
|
75
|
+
<span class='id manifest'>manifest</span><span class='period'>.</span><span class='id template'>template</span> <span class='op'>=</span> <span class='id template'>template</span>
|
76
|
+
<span class='id manifest'>manifest</span><span class='period'>.</span><span class='id templates'>templates</span> <span class='op'>=</span> <span class='ivar'>@generator</span><span class='period'>.</span><span class='id template_paths'>template_paths</span>
|
77
|
+
<span class='id working_dir'>working_dir</span><span class='period'>.</span><span class='id children'>children</span> <span class='op'><<</span> <span class='id manifest'>manifest</span>
|
78
|
+
<span class='kw'>end</span>
|
79
|
+
|
80
|
+
<span class='kw'>def</span> <span class='id file'>file</span> <span class='id path'>path</span><span class='comma'>,</span> <span class='id template'>template</span><span class='op'>=</span><span class='kw'>nil</span>
|
81
|
+
<span class='id raise'>raise</span> <span class='id sprout'>sprout</span><span class='op'>::</span><span class='id errors'>errors</span><span class='op'>::</span><span class='id generatorerror'>generatorerror</span><span class='period'>.</span><span class='id new'>new</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Cannot create file with nil path</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id path'>path</span><span class='period'>.</span><span class='id nil?'>nil?</span>
|
82
|
+
<span class='id manifest'>manifest</span> <span class='op'>=</span> <span class='const'>FileManifest</span><span class='period'>.</span><span class='id new'>new</span>
|
83
|
+
<span class='id manifest'>manifest</span><span class='period'>.</span><span class='id generator'>generator</span> <span class='op'>=</span> <span class='ivar'>@generator</span>
|
84
|
+
<span class='id manifest'>manifest</span><span class='period'>.</span><span class='id path'>path</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id join'>join</span><span class='lparen'>(</span> <span class='id working_dir'>working_dir</span><span class='period'>.</span><span class='id path'>path</span><span class='comma'>,</span> <span class='id path'>path</span> <span class='rparen'>)</span>
|
85
|
+
<span class='id manifest'>manifest</span><span class='period'>.</span><span class='id template'>template</span> <span class='op'>=</span> <span class='id template'>template</span>
|
86
|
+
<span class='id manifest'>manifest</span><span class='period'>.</span><span class='id templates'>templates</span> <span class='op'>=</span> <span class='ivar'>@generator</span><span class='period'>.</span><span class='id template_paths'>template_paths</span>
|
87
|
+
<span class='id working_dir'>working_dir</span><span class='period'>.</span><span class='id children'>children</span> <span class='op'><<</span> <span class='id manifest'>manifest</span>
|
88
|
+
<span class='kw'>end</span>
|
89
|
+
|
90
|
+
<span class='kw'>def</span> <span class='id generator'>generator</span> <span class='id name'>name</span><span class='comma'>,</span> <span class='id options'>options</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span>
|
91
|
+
<span class='id raise'>raise</span> <span class='id sprout'>sprout</span><span class='op'>::</span><span class='id errors'>errors</span><span class='op'>::</span><span class='id generatorerror'>generatorerror</span><span class='period'>.</span><span class='id new'>new</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Cannot call another generator with nil name</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id name'>name</span><span class='period'>.</span><span class='id nil?'>nil?</span>
|
92
|
+
<span class='id instance'>instance</span> <span class='op'>=</span> <span class='const'>Sprout</span><span class='op'>::</span><span class='const'>Generator</span><span class='period'>.</span><span class='id create_instance'>create_instance</span> <span class='id name'>name</span><span class='comma'>,</span> <span class='id options'>options</span>
|
93
|
+
<span class='id instance'>instance</span><span class='period'>.</span><span class='id logger'>logger</span> <span class='op'>=</span> <span class='id logger'>logger</span>
|
94
|
+
<span class='id instance'>instance</span><span class='period'>.</span><span class='id path'>path</span> <span class='op'>=</span> <span class='id working_dir'>working_dir</span><span class='period'>.</span><span class='id path'>path</span>
|
95
|
+
<span class='id instance'>instance</span><span class='period'>.</span><span class='id from_hash'>from_hash</span> <span class='id options'>options</span>
|
96
|
+
<span class='id working_dir'>working_dir</span><span class='period'>.</span><span class='id generators'>generators</span> <span class='op'><<</span> <span class='id instance'>instance</span>
|
97
|
+
<span class='kw'>end</span>
|
98
|
+
|
99
|
+
<span class='kw'>def</span> <span class='id execute'>execute</span>
|
100
|
+
<span class='kw'>begin</span>
|
101
|
+
<span class='id working_dir'>working_dir</span><span class='period'>.</span><span class='id create'>create</span>
|
102
|
+
<span class='kw'>rescue</span> <span class='const'>StandardError</span> <span class='op'>=></span> <span class='id e'>e</span>
|
103
|
+
<span class='ivar'>@generator</span><span class='period'>.</span><span class='id say'>say</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>[</span><span class='embexpr_beg'>#{</span><span class='id e'>e</span><span class='period'>.</span><span class='id class'>class</span><span class='rbrace'>}</span><span class='tstring_content'>] </span><span class='embexpr_beg'>#{</span><span class='id e'>e</span><span class='period'>.</span><span class='id message'>message</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
104
|
+
<span class='id working_dir'>working_dir</span><span class='period'>.</span><span class='id children'>children</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id child'>child</span><span class='op'>|</span>
|
105
|
+
<span class='id child'>child</span><span class='period'>.</span><span class='id destroy'>destroy</span>
|
106
|
+
<span class='kw'>end</span>
|
107
|
+
<span class='id raise'>raise</span> <span class='id e'>e</span>
|
108
|
+
<span class='kw'>end</span>
|
109
|
+
<span class='kw'>end</span>
|
110
|
+
|
111
|
+
<span class='kw'>def</span> <span class='id unexecute'>unexecute</span>
|
112
|
+
<span class='id working_dir'>working_dir</span><span class='period'>.</span><span class='id destroy'>destroy</span>
|
113
|
+
<span class='kw'>end</span>
|
114
|
+
<span class='kw'>end</span></pre>
|
115
|
+
|
116
|
+
<p>end</p>
|
117
|
+
</div></div>
|
118
|
+
|
119
|
+
<div id="footer">
|
120
|
+
Generated on Wed Dec 22 11:58:32 2010 by
|
121
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
122
|
+
0.6.3 (ruby-1.9.2).
|
123
|
+
</div>
|
124
|
+
|
125
|
+
</body>
|
126
|
+
</html>
|
@@ -0,0 +1,136 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta name="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>File: concern</title>
|
7
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
9
|
+
|
10
|
+
<script type="text/javascript" charset="utf-8">
|
11
|
+
relpath = '';
|
12
|
+
if (relpath != '') relpath += '/';
|
13
|
+
</script>
|
14
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
15
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<script type="text/javascript" charset="utf-8">
|
20
|
+
if (window.top.frames.main) document.body.className = 'frames';
|
21
|
+
</script>
|
22
|
+
|
23
|
+
<div id="header">
|
24
|
+
<div id="menu">
|
25
|
+
|
26
|
+
<a href="_index.html" title="Index">Index</a> »
|
27
|
+
<span class="title">File: concern</span>
|
28
|
+
|
29
|
+
|
30
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<div id="search">
|
34
|
+
<a id="class_list_link" href="#">Class List</a>
|
35
|
+
<a id="method_list_link" href="#">Method List</a>
|
36
|
+
<a id ="file_list_link" href="#">File List</a>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div class="clear"></div>
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<iframe id="search_frame"></iframe>
|
43
|
+
|
44
|
+
<div id="content"><div id='filecontents'>
|
45
|
+
<p>module Sprout</p>
|
46
|
+
|
47
|
+
<pre class="code"><span class='comment'>##
|
48
|
+
</span><span class='comment'># This class was copied from Rails source code and provides
|
49
|
+
</span><span class='comment'># our RubyFeature with the ability to more clearly mix in
|
50
|
+
</span><span class='comment'># functionality against a class and behave as if inheritance
|
51
|
+
</span><span class='comment'># works at the class mixin level.
|
52
|
+
</span><span class='comment'>#
|
53
|
+
</span><span class='comment'># TODO: I'd like to update our system so that this
|
54
|
+
</span><span class='comment'># functionality is no longer necessary - if you have ideas
|
55
|
+
</span><span class='comment'># or opinions about this code, please let me know!
|
56
|
+
</span><span class='kw'>module</span> <span class='const'>Concern</span>
|
57
|
+
|
58
|
+
<span class='comment'>##
|
59
|
+
</span> <span class='comment'># Callback handler when a class is extended. This
|
60
|
+
</span> <span class='comment'># handler will set the @_dependencies array on the
|
61
|
+
</span> <span class='comment'># concrete class that just extended a
|
62
|
+
</span> <span class='comment'># 'Concern'.
|
63
|
+
</span> <span class='comment'>#
|
64
|
+
</span> <span class='comment'># This callback is often triggered with:
|
65
|
+
</span> <span class='comment'>#
|
66
|
+
</span> <span class='comment'># class Foo
|
67
|
+
</span> <span class='comment'># extend Concern
|
68
|
+
</span> <span class='comment'># end
|
69
|
+
</span> <span class='comment'>#
|
70
|
+
</span> <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id extended'>extended</span><span class='lparen'>(</span><span class='id base'>base</span><span class='rparen'>)</span>
|
71
|
+
<span class='id base'>base</span><span class='period'>.</span><span class='id instance_variable_set'>instance_variable_set</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@_dependencies</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
72
|
+
<span class='kw'>end</span>
|
73
|
+
|
74
|
+
<span class='comment'>##
|
75
|
+
</span> <span class='comment'># Apply both class and instance features found in the
|
76
|
+
</span> <span class='comment'># base class to the new subclass.
|
77
|
+
</span> <span class='kw'>def</span> <span class='id append_features'>append_features</span><span class='lparen'>(</span><span class='id base'>base</span><span class='rparen'>)</span>
|
78
|
+
<span class='kw'>if</span> <span class='id base'>base</span><span class='period'>.</span><span class='id instance_variable_defined?'>instance_variable_defined?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@_dependencies</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
79
|
+
<span class='id base'>base</span><span class='period'>.</span><span class='id instance_variable_get'>instance_variable_get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@_dependencies</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='op'><<</span> <span class='kw'>self</span>
|
80
|
+
<span class='kw'>return</span> <span class='kw'>false</span>
|
81
|
+
<span class='kw'>else</span>
|
82
|
+
<span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='id base'>base</span> <span class='op'><</span> <span class='kw'>self</span>
|
83
|
+
<span class='ivar'>@_dependencies</span><span class='period'>.</span><span class='id each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id dep'>dep</span><span class='op'>|</span> <span class='id base'>base</span><span class='period'>.</span><span class='id send'>send</span><span class='lparen'>(</span><span class='symbol'>:include</span><span class='comma'>,</span> <span class='id dep'>dep</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
84
|
+
<span class='kw'>super</span>
|
85
|
+
<span class='id base'>base</span><span class='period'>.</span><span class='id extend'>extend</span> <span class='id const_get'>const_get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>ClassMethods</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id const_defined?'>const_defined?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>ClassMethods</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
86
|
+
<span class='id base'>base</span><span class='period'>.</span><span class='id send'>send</span> <span class='symbol'>:include</span><span class='comma'>,</span> <span class='id const_get'>const_get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>InstanceMethods</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id const_defined?'>const_defined?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>InstanceMethods</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
87
|
+
<span class='id base'>base</span><span class='period'>.</span><span class='id class_eval'>class_eval</span><span class='lparen'>(</span><span class='op'>&</span><span class='ivar'>@_included_block</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id instance_variable_defined?'>instance_variable_defined?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>@_included_block</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
88
|
+
<span class='kw'>end</span>
|
89
|
+
<span class='kw'>end</span>
|
90
|
+
|
91
|
+
<span class='comment'>##
|
92
|
+
</span> <span class='comment'># Handle inclusion of this module.
|
93
|
+
</span> <span class='kw'>def</span> <span class='id included'>included</span><span class='lparen'>(</span><span class='id base'>base</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&</span><span class='id block'>block</span><span class='rparen'>)</span>
|
94
|
+
<span class='kw'>if</span> <span class='id base'>base</span><span class='period'>.</span><span class='id nil?'>nil?</span>
|
95
|
+
<span class='ivar'>@_included_block</span> <span class='op'>=</span> <span class='id block'>block</span>
|
96
|
+
<span class='kw'>else</span>
|
97
|
+
<span class='kw'>super</span>
|
98
|
+
<span class='kw'>end</span>
|
99
|
+
<span class='kw'>end</span>
|
100
|
+
<span class='kw'>end</span></pre>
|
101
|
+
|
102
|
+
<p>end</p>
|
103
|
+
|
104
|
+
<h1>begin</h1>
|
105
|
+
|
106
|
+
<p>Copyright © 2004-2010 David Heinemeier Hansson</p>
|
107
|
+
|
108
|
+
<p>Permission is hereby granted, free of charge, to any person obtaining a
|
109
|
+
copy of this software and associated documentation files (the “Software”),
|
110
|
+
to deal in the Software without restriction, including without limitation
|
111
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
112
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
113
|
+
Software is furnished to do so, subject to the following conditions:</p>
|
114
|
+
|
115
|
+
<p>The above copyright notice and this permission notice shall be included in
|
116
|
+
all copies or substantial portions of the Software.</p>
|
117
|
+
|
118
|
+
<p>THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
119
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
120
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
121
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
122
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
123
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
124
|
+
DEALINGS IN THE SOFTWARE.</p>
|
125
|
+
|
126
|
+
<h1>end</h1>
|
127
|
+
</div></div>
|
128
|
+
|
129
|
+
<div id="footer">
|
130
|
+
Generated on Wed Dec 22 11:58:31 2010 by
|
131
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
132
|
+
0.6.3 (ruby-1.9.2).
|
133
|
+
</div>
|
134
|
+
|
135
|
+
</body>
|
136
|
+
</html>
|
@@ -0,0 +1,309 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta name="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>File: daemon</title>
|
7
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
9
|
+
|
10
|
+
<script type="text/javascript" charset="utf-8">
|
11
|
+
relpath = '';
|
12
|
+
if (relpath != '') relpath += '/';
|
13
|
+
</script>
|
14
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
15
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<script type="text/javascript" charset="utf-8">
|
20
|
+
if (window.top.frames.main) document.body.className = 'frames';
|
21
|
+
</script>
|
22
|
+
|
23
|
+
<div id="header">
|
24
|
+
<div id="menu">
|
25
|
+
|
26
|
+
<a href="_index.html" title="Index">Index</a> »
|
27
|
+
<span class="title">File: daemon</span>
|
28
|
+
|
29
|
+
|
30
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<div id="search">
|
34
|
+
<a id="class_list_link" href="#">Class List</a>
|
35
|
+
<a id="method_list_link" href="#">Method List</a>
|
36
|
+
<a id ="file_list_link" href="#">File List</a>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div class="clear"></div>
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<iframe id="search_frame"></iframe>
|
43
|
+
|
44
|
+
<div id="content"><div id='filecontents'>
|
45
|
+
<p>module Sprout</p>
|
46
|
+
|
47
|
+
<pre class="code"><span class='comment'>##
|
48
|
+
</span><span class='comment'># The Sprout::Daemon module exposes the Domain Specific Language
|
49
|
+
</span><span class='comment'># provided by the Sprout::Executable module, but with
|
50
|
+
</span><span class='comment'># enhancements (and modifications) to support long-lived processes
|
51
|
+
</span><span class='comment'># (like FDB and FCSH).
|
52
|
+
</span><span class='comment'>#
|
53
|
+
</span><span class='comment'># NOTE: Any class that includes Sprout::Daemon should first include
|
54
|
+
</span><span class='comment'># Sprout::Executable. This is an admittedly smelly constraint, but it works
|
55
|
+
</span><span class='comment'># for now.
|
56
|
+
</span><span class='comment'>#
|
57
|
+
</span><span class='comment'># class Foo
|
58
|
+
</span><span class='comment'># include Sprout::Executable
|
59
|
+
</span><span class='comment'># include Sprout::Daemon
|
60
|
+
</span><span class='comment'>#
|
61
|
+
</span><span class='comment'># ##
|
62
|
+
</span><span class='comment'># # Keep in mind that we're still working
|
63
|
+
</span><span class='comment'># # with Executable, so add_param is available
|
64
|
+
</span><span class='comment'># # for the initialization of the process.
|
65
|
+
</span><span class='comment'># add_param :input, File
|
66
|
+
</span><span class='comment'>#
|
67
|
+
</span><span class='comment'># ##
|
68
|
+
</span><span class='comment'># # Expose the do_something action after
|
69
|
+
</span><span class='comment'># # the process is started.
|
70
|
+
</span><span class='comment'># add_action :do_something
|
71
|
+
</span><span class='comment'>#
|
72
|
+
</span><span class='comment'># ##
|
73
|
+
</span><span class='comment'># # Expose the do_something_else action after
|
74
|
+
</span><span class='comment'># # the process is started.
|
75
|
+
</span><span class='comment'># add_action :do_something_else
|
76
|
+
</span><span class='comment'># end
|
77
|
+
</span><span class='comment'>#
|
78
|
+
</span><span class='comment'># You can also create a globally-accessible rake task to expose
|
79
|
+
</span><span class='comment'># your new Daemon instance to Rake by creating a method like the following:
|
80
|
+
</span><span class='comment'>#
|
81
|
+
</span><span class='comment'># def foo *args, &block
|
82
|
+
</span><span class='comment'># foo_tool = Foo.new
|
83
|
+
</span><span class='comment'># foo_tool.to_rake *args, &block
|
84
|
+
</span><span class='comment'># end
|
85
|
+
</span><span class='comment'>#
|
86
|
+
</span><span class='comment'># Note: The aforementioned rake helper is usually written at the bottom of
|
87
|
+
</span><span class='comment'># the class file that is referenced.
|
88
|
+
</span><span class='comment'>#
|
89
|
+
</span><span class='comment'># The aforementioned Rake task could be used like:
|
90
|
+
</span><span class='comment'>#
|
91
|
+
</span><span class='comment'># foo :bar do |t|
|
92
|
+
</span><span class='comment'># t.do_something
|
93
|
+
</span><span class='comment'># t.do_something_else
|
94
|
+
</span><span class='comment'># end
|
95
|
+
</span><span class='comment'>#
|
96
|
+
</span><span class='comment'># @see: Sprout::Daemon::ClassMethods
|
97
|
+
</span><span class='comment'># @see: Sprout::Daemon::InstanceMethods
|
98
|
+
</span><span class='comment'>#
|
99
|
+
</span><span class='kw'>module</span> <span class='const'>Daemon</span>
|
100
|
+
|
101
|
+
<span class='id extend'>extend</span> <span class='const'>Concern</span>
|
102
|
+
|
103
|
+
<span class='comment'>##
|
104
|
+
</span> <span class='comment'># These are the methods that will be available
|
105
|
+
</span> <span class='comment'># on any class that includes Sprout::Daemon.
|
106
|
+
</span> <span class='kw'>module</span> <span class='const'>ClassMethods</span>
|
107
|
+
|
108
|
+
<span class='comment'>##
|
109
|
+
</span> <span class='comment'># Add an action that can be called while
|
110
|
+
</span> <span class='comment'># the long-lived process is active.
|
111
|
+
</span> <span class='comment'>#
|
112
|
+
</span> <span class='comment'># This method should raise a Sprout::Errors::UsageError
|
113
|
+
</span> <span class='comment'># if the provided action name is already defined for
|
114
|
+
</span> <span class='comment'># the provided instance.
|
115
|
+
</span> <span class='kw'>def</span> <span class='id add_action'>add_action</span> <span class='id name'>name</span><span class='comma'>,</span> <span class='id arguments'>arguments</span><span class='op'>=</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='id options'>options</span><span class='op'>=</span><span class='kw'>nil</span>
|
116
|
+
<span class='id options'>options</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
117
|
+
<span class='id options'>options</span><span class='lbracket'>[</span><span class='symbol'>:name</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id name'>name</span>
|
118
|
+
<span class='id options'>options</span><span class='lbracket'>[</span><span class='symbol'>:arguments</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id arguments'>arguments</span>
|
119
|
+
<span class='id create_action_method'>create_action_method</span> <span class='id options'>options</span>
|
120
|
+
<span class='kw'>end</span>
|
121
|
+
|
122
|
+
<span class='comment'>##
|
123
|
+
</span> <span class='comment'># Create an (often shorter) alias to another
|
124
|
+
</span> <span class='comment'># action name.
|
125
|
+
</span> <span class='kw'>def</span> <span class='id add_action_alias'>add_action_alias</span> <span class='id alias_name'>alias_name</span><span class='comma'>,</span> <span class='id source_name'>source_name</span>
|
126
|
+
<span class='id define_method'>define_method</span><span class='lparen'>(</span><span class='id alias_name'>alias_name</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='op'>*</span><span class='id params'>params</span><span class='op'>|</span>
|
127
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id send'>send</span><span class='lparen'>(</span><span class='id source_name'>source_name</span><span class='comma'>,</span> <span class='id params'>params</span><span class='rparen'>)</span>
|
128
|
+
<span class='kw'>end</span>
|
129
|
+
<span class='kw'>end</span>
|
130
|
+
|
131
|
+
<span class='id private'>private</span>
|
132
|
+
|
133
|
+
<span class='comment'>##
|
134
|
+
</span> <span class='comment'># Actually create the method for a provided
|
135
|
+
</span> <span class='comment'># action.
|
136
|
+
</span> <span class='comment'>#
|
137
|
+
</span> <span class='comment'># This method should explode if the method name
|
138
|
+
</span> <span class='comment'># already exists.
|
139
|
+
</span> <span class='kw'>def</span> <span class='id create_action_method'>create_action_method</span> <span class='id options'>options</span>
|
140
|
+
<span class='id name'>name</span> <span class='op'>=</span> <span class='id options'>options</span><span class='lbracket'>[</span><span class='symbol'>:name</span><span class='rbracket'>]</span>
|
141
|
+
<span class='id accessor_can_be_defined_at'>accessor_can_be_defined_at</span> <span class='id name'>name</span>
|
142
|
+
|
143
|
+
<span class='id define_method'>define_method</span><span class='lparen'>(</span><span class='id name'>name</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='op'>*</span><span class='id params'>params</span><span class='op'>|</span>
|
144
|
+
<span class='id action'>action</span> <span class='op'>=</span> <span class='id name'>name</span><span class='period'>.</span><span class='id to_s'>to_s</span>
|
145
|
+
<span class='id action'>action</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>y</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id name'>name</span> <span class='op'>==</span> <span class='symbol'>:confirm</span> <span class='comment'># Convert affirmation
|
146
|
+
</span> <span class='id action'>action</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='id params'>params</span><span class='period'>.</span><span class='id join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'> </span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='id params'>params</span><span class='period'>.</span><span class='id nil?'>nil?</span>
|
147
|
+
<span class='id action_stack'>action_stack</span> <span class='op'><<</span> <span class='id action'>action</span>
|
148
|
+
<span class='kw'>end</span>
|
149
|
+
<span class='kw'>end</span>
|
150
|
+
|
151
|
+
<span class='comment'>##
|
152
|
+
</span> <span class='comment'># TODO: Raise an exception if the name is
|
153
|
+
</span> <span class='comment'># already taken?
|
154
|
+
</span> <span class='kw'>def</span> <span class='id accessor_can_be_defined_at'>accessor_can_be_defined_at</span> <span class='id name'>name</span>
|
155
|
+
<span class='kw'>end</span>
|
156
|
+
|
157
|
+
<span class='kw'>end</span>
|
158
|
+
|
159
|
+
<span class='comment'>##
|
160
|
+
</span> <span class='comment'># Instance methods that will be available on any
|
161
|
+
</span> <span class='comment'># class that includes Sprout::Daemon.
|
162
|
+
</span> <span class='kw'>module</span> <span class='const'>InstanceMethods</span>
|
163
|
+
|
164
|
+
<span class='comment'>##
|
165
|
+
</span> <span class='comment'># The prompt expression for this daemon process.
|
166
|
+
</span> <span class='comment'>#
|
167
|
+
</span> <span class='comment'># When executing a series of commands, the
|
168
|
+
</span> <span class='comment'># wrapper will wait until it matches this expression
|
169
|
+
</span> <span class='comment'># on stdout before continuing the series.
|
170
|
+
</span> <span class='comment'>#
|
171
|
+
</span> <span class='comment'># For FDB, this value is set like:
|
172
|
+
</span> <span class='comment'>#
|
173
|
+
</span> <span class='comment'># set :prompt, /^\(fdb\) /
|
174
|
+
</span> <span class='comment'>#
|
175
|
+
</span> <span class='comment'># Most processes can trigger a variety of different
|
176
|
+
</span> <span class='comment'># prompts, these can be expressed here using the | (or) operator.
|
177
|
+
</span> <span class='comment'>#
|
178
|
+
</span> <span class='comment'># FDB actually uses the following:
|
179
|
+
</span> <span class='comment'>#
|
180
|
+
</span> <span class='comment'># set :prompt, /^\(fdb\) |\(y or n\) /
|
181
|
+
</span> <span class='comment'>#
|
182
|
+
</span> <span class='id attr_accessor'>attr_accessor</span> <span class='symbol'>:prompt</span>
|
183
|
+
|
184
|
+
<span class='comment'>##
|
185
|
+
</span> <span class='comment'># This is the array of actions that have
|
186
|
+
</span> <span class='comment'># been provided at the class level to this instance.
|
187
|
+
</span> <span class='id attr_reader'>attr_reader</span> <span class='symbol'>:action_stack</span>
|
188
|
+
|
189
|
+
<span class='kw'>def</span> <span class='id initialize'>initialize</span>
|
190
|
+
<span class='kw'>super</span>
|
191
|
+
<span class='ivar'>@action_stack</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
192
|
+
<span class='kw'>end</span>
|
193
|
+
|
194
|
+
<span class='comment'>##
|
195
|
+
</span> <span class='comment'># Execute the Daemon executable, followed
|
196
|
+
</span> <span class='comment'># by the collection of stored actions in
|
197
|
+
</span> <span class='comment'># the order they were called.
|
198
|
+
</span> <span class='comment'>#
|
199
|
+
</span> <span class='comment'># If none of the stored actions result in
|
200
|
+
</span> <span class='comment'># terminating the process, the underlying
|
201
|
+
</span> <span class='comment'># daemon will be connected to the terminal
|
202
|
+
</span> <span class='comment'># for user (manual) input.
|
203
|
+
</span> <span class='kw'>def</span> <span class='id execute'>execute</span>
|
204
|
+
<span class='id runner'>runner</span> <span class='op'>=</span> <span class='kw'>super</span>
|
205
|
+
<span class='id execute_actions'>execute_actions</span> <span class='id runner'>runner</span>
|
206
|
+
<span class='id handle_user_session'>handle_user_session</span> <span class='id runner'>runner</span>
|
207
|
+
<span class='const'>Process</span><span class='period'>.</span><span class='id wait'>wait</span> <span class='id runner'>runner</span><span class='period'>.</span><span class='id pid'>pid</span>
|
208
|
+
<span class='kw'>end</span>
|
209
|
+
|
210
|
+
<span class='id protected'>protected</span>
|
211
|
+
|
212
|
+
<span class='comment'>##
|
213
|
+
</span> <span class='comment'># This is the override of the underlying
|
214
|
+
</span> <span class='comment'># Sprout::Executable template method so that we
|
215
|
+
</span> <span class='comment'># create a 'task' instead of a 'file' task.
|
216
|
+
</span> <span class='kw'>def</span> <span class='id create_outer_task'>create_outer_task</span> <span class='op'>*</span><span class='id args'>args</span>
|
217
|
+
<span class='id task'>task</span> <span class='op'>*</span><span class='id args'>args</span> <span class='kw'>do</span>
|
218
|
+
<span class='id execute'>execute</span>
|
219
|
+
<span class='kw'>end</span>
|
220
|
+
<span class='kw'>end</span>
|
221
|
+
|
222
|
+
<span class='comment'>##
|
223
|
+
</span> <span class='comment'># This is the override of the underlying
|
224
|
+
</span> <span class='comment'># Sprout::Executable template method so that we
|
225
|
+
</span> <span class='comment'># are NOT added to the CLEAN collection.
|
226
|
+
</span> <span class='comment'># (Work performed in the Executable)
|
227
|
+
</span> <span class='kw'>def</span> <span class='id update_rake_task_name_from_args'>update_rake_task_name_from_args</span> <span class='op'>*</span><span class='id args'>args</span>
|
228
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id rake_task_name'>rake_task_name</span> <span class='op'>=</span> <span class='id parse_rake_task_arg'>parse_rake_task_arg</span> <span class='id args'>args</span><span class='period'>.</span><span class='id last'>last</span>
|
229
|
+
<span class='kw'>end</span>
|
230
|
+
|
231
|
+
<span class='comment'>##
|
232
|
+
</span> <span class='comment'># This is the override of the underlying
|
233
|
+
</span> <span class='comment'># Sprout::Executable template method so that we
|
234
|
+
</span> <span class='comment'># create the process in a thread
|
235
|
+
</span> <span class='comment'># in order to read and write to it.
|
236
|
+
</span> <span class='kw'>def</span> <span class='id system_execute'>system_execute</span> <span class='id binary'>binary</span><span class='comma'>,</span> <span class='id params'>params</span>
|
237
|
+
<span class='const'>Sprout</span><span class='period'>.</span><span class='id current_system'>current_system</span><span class='period'>.</span><span class='id execute_thread'>execute_thread</span> <span class='id binary'>binary</span><span class='comma'>,</span> <span class='id params'>params</span>
|
238
|
+
<span class='kw'>end</span>
|
239
|
+
|
240
|
+
<span class='id private'>private</span>
|
241
|
+
|
242
|
+
<span class='comment'>##
|
243
|
+
</span> <span class='comment'># Execute the collection of provided actions.
|
244
|
+
</span> <span class='kw'>def</span> <span class='id execute_actions'>execute_actions</span> <span class='id runner'>runner</span>
|
245
|
+
<span class='id action_stack'>action_stack</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id action'>action</span><span class='op'>|</span>
|
246
|
+
<span class='kw'>if</span> <span class='id wait_for_prompt'>wait_for_prompt</span> <span class='id runner'>runner</span>
|
247
|
+
<span class='const'>Sprout</span><span class='op'>::</span><span class='const'>Log</span><span class='period'>.</span><span class='id puts'>puts</span> <span class='id action'>action</span>
|
248
|
+
<span class='id execute_action'>execute_action</span> <span class='id runner'>runner</span><span class='comma'>,</span> <span class='id action'>action</span>
|
249
|
+
<span class='kw'>end</span>
|
250
|
+
<span class='kw'>end</span>
|
251
|
+
<span class='kw'>end</span>
|
252
|
+
|
253
|
+
<span class='comment'>##
|
254
|
+
</span> <span class='comment'># Execute a single action.
|
255
|
+
</span> <span class='kw'>def</span> <span class='id execute_action'>execute_action</span> <span class='id runner'>runner</span><span class='comma'>,</span> <span class='id action'>action</span>
|
256
|
+
<span class='id runner'>runner</span><span class='period'>.</span><span class='id puts'>puts</span> <span class='id action'>action</span><span class='period'>.</span><span class='id strip'>strip</span>
|
257
|
+
<span class='kw'>end</span>
|
258
|
+
|
259
|
+
<span class='comment'>##
|
260
|
+
</span> <span class='comment'># Expose the running process to manual
|
261
|
+
</span> <span class='comment'># input on the terminal, and write stdout
|
262
|
+
</span> <span class='comment'># back to the user.
|
263
|
+
</span> <span class='kw'>def</span> <span class='id handle_user_session'>handle_user_session</span> <span class='id runner'>runner</span>
|
264
|
+
<span class='kw'>while</span> <span class='op'>!</span><span class='id runner'>runner</span><span class='period'>.</span><span class='id r'>r</span><span class='period'>.</span><span class='id eof?'>eof?</span>
|
265
|
+
<span class='kw'>if</span> <span class='id wait_for_prompt'>wait_for_prompt</span> <span class='id runner'>runner</span>
|
266
|
+
<span class='id input'>input</span> <span class='op'>=</span> <span class='gvar'>$stdin</span><span class='period'>.</span><span class='id gets'>gets</span><span class='period'>.</span><span class='id chomp!'>chomp!</span>
|
267
|
+
<span class='id execute_action'>execute_action</span> <span class='id runner'>runner</span><span class='comma'>,</span> <span class='id input'>input</span>
|
268
|
+
<span class='kw'>end</span>
|
269
|
+
<span class='kw'>end</span>
|
270
|
+
<span class='kw'>end</span>
|
271
|
+
|
272
|
+
<span class='comment'>##
|
273
|
+
</span> <span class='comment'># Wait for the underlying process to present
|
274
|
+
</span> <span class='comment'># an input prompt, so that another action
|
275
|
+
</span> <span class='comment'># can be submitted, or user input can be
|
276
|
+
</span> <span class='comment'># collected.
|
277
|
+
</span> <span class='kw'>def</span> <span class='id wait_for_prompt'>wait_for_prompt</span> <span class='id runner'>runner</span><span class='comma'>,</span> <span class='id expected_prompt'>expected_prompt</span><span class='op'>=</span><span class='kw'>nil</span>
|
278
|
+
<span class='comment'>##
|
279
|
+
</span> <span class='comment'># TODO: This should also check for a variety of prompts...
|
280
|
+
</span> <span class='id expected_prompt'>expected_prompt</span> <span class='op'>=</span> <span class='id expected_prompt'>expected_prompt</span> <span class='op'>||</span> <span class='id prompt'>prompt</span>
|
281
|
+
<span class='id line'>line</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
|
282
|
+
|
283
|
+
<span class='kw'>while</span> <span class='id runner'>runner</span><span class='period'>.</span><span class='id alive?'>alive?</span> <span class='kw'>do</span>
|
284
|
+
<span class='const'>Sprout</span><span class='op'>::</span><span class='const'>Log</span><span class='period'>.</span><span class='id flush'>flush</span>
|
285
|
+
<span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>if</span> <span class='id runner'>runner</span><span class='period'>.</span><span class='id r'>r</span><span class='period'>.</span><span class='id eof?'>eof?</span>
|
286
|
+
<span class='id char'>char</span> <span class='op'>=</span> <span class='id runner'>runner</span><span class='period'>.</span><span class='id readpartial'>readpartial</span> <span class='int'>1</span>
|
287
|
+
<span class='id line'>line</span> <span class='op'><<</span> <span class='id char'>char</span>
|
288
|
+
<span class='kw'>if</span> <span class='id char'>char</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span>
|
289
|
+
<span class='id line'>line</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
|
290
|
+
<span class='kw'>end</span>
|
291
|
+
<span class='const'>Sprout</span><span class='op'>::</span><span class='const'>Log</span><span class='period'>.</span><span class='id printf'>printf</span> <span class='id char'>char</span>
|
292
|
+
<span class='kw'>return</span> <span class='kw'>true</span> <span class='kw'>if</span> <span class='id line'>line</span><span class='period'>.</span><span class='id match'>match</span> <span class='id expected_prompt'>expected_prompt</span>
|
293
|
+
<span class='kw'>end</span>
|
294
|
+
<span class='kw'>end</span>
|
295
|
+
|
296
|
+
<span class='kw'>end</span>
|
297
|
+
<span class='kw'>end</span></pre>
|
298
|
+
|
299
|
+
<p>end</p>
|
300
|
+
</div></div>
|
301
|
+
|
302
|
+
<div id="footer">
|
303
|
+
Generated on Wed Dec 22 11:58:31 2010 by
|
304
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
305
|
+
0.6.3 (ruby-1.9.2).
|
306
|
+
</div>
|
307
|
+
|
308
|
+
</body>
|
309
|
+
</html>
|