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
data/doc/file.dir.html
ADDED
@@ -0,0 +1,76 @@
|
|
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: dir</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: dir</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>class Dir</p>
|
46
|
+
|
47
|
+
<pre class="code"><span class='comment'>##
|
48
|
+
</span><span class='comment'># Return true if the directory has no children.
|
49
|
+
</span><span class='comment'>#
|
50
|
+
</span><span class='comment'># Code found here: http://www.ruby-forum.com/topic/84762
|
51
|
+
</span><span class='kw'>def</span> <span class='id empty?'>empty?</span>
|
52
|
+
<span class='const'>Dir</span><span class='period'>.</span><span class='id glob'>glob</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span> <span class='id path'>path</span> <span class='rbrace'>}</span><span class='tstring_content'>/*</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='const'>File</span><span class='op'>::</span><span class='const'>FNM_DOTMATCH</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id e'>e</span><span class='op'>|</span>
|
53
|
+
<span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>unless</span> <span class='qwords_beg'>%w( </span><span class='tstring_content'>.</span><span class='words_sep'> </span><span class='tstring_content'>..</span><span class='words_sep'> )</span><span class='period'>.</span><span class='id include?'>include?</span><span class='lparen'>(</span><span class='const'>File</span><span class='op'>::</span><span class='id basename'>basename</span><span class='lparen'>(</span><span class='id e'>e</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
54
|
+
<span class='kw'>end</span>
|
55
|
+
<span class='kw'>return</span> <span class='kw'>true</span>
|
56
|
+
<span class='kw'>end</span>
|
57
|
+
|
58
|
+
<span class='comment'>##
|
59
|
+
</span><span class='comment'># Return true if the provided path has no children.
|
60
|
+
</span><span class='comment'>#
|
61
|
+
</span><span class='comment'># Code found here: http://www.ruby-forum.com/topic/84762
|
62
|
+
</span><span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id empty?'>empty?</span> <span class='id path'>path</span>
|
63
|
+
<span class='id new'>new</span><span class='lparen'>(</span><span class='id path'>path</span><span class='rparen'>)</span><span class='period'>.</span><span class='id empty?'>empty?</span>
|
64
|
+
<span class='kw'>end</span></pre>
|
65
|
+
|
66
|
+
<p>end</p>
|
67
|
+
</div></div>
|
68
|
+
|
69
|
+
<div id="footer">
|
70
|
+
Generated on Wed Dec 22 11:58:31 2010 by
|
71
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
72
|
+
0.6.3 (ruby-1.9.2).
|
73
|
+
</div>
|
74
|
+
|
75
|
+
</body>
|
76
|
+
</html>
|
@@ -0,0 +1,122 @@
|
|
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: directory_manifest</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: directory_manifest</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'>DirectoryManifest</span> <span class='op'><</span> <span class='const'>Manifest</span>
|
48
|
+
<span class='id attr_reader'>attr_reader</span> <span class='symbol'>:children</span>
|
49
|
+
<span class='id attr_reader'>attr_reader</span> <span class='symbol'>:generators</span>
|
50
|
+
|
51
|
+
<span class='kw'>def</span> <span class='id initialize'>initialize</span>
|
52
|
+
<span class='kw'>super</span>
|
53
|
+
<span class='ivar'>@children</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
54
|
+
<span class='ivar'>@generators</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
55
|
+
<span class='kw'>end</span>
|
56
|
+
|
57
|
+
<span class='kw'>def</span> <span class='id create'>create</span>
|
58
|
+
<span class='kw'>if</span> <span class='op'>!</span><span class='const'>File</span><span class='period'>.</span><span class='id directory?'>directory?</span><span class='lparen'>(</span><span class='id path'>path</span><span class='rparen'>)</span>
|
59
|
+
<span class='const'>FileUtils</span><span class='period'>.</span><span class='id mkdir_p'>mkdir_p</span> <span class='id path'>path</span>
|
60
|
+
<span class='id say'>say</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Created directory: </span><span class='embexpr_beg'>#{</span><span class='id path'>path</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
61
|
+
<span class='kw'>else</span>
|
62
|
+
<span class='id say'>say</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Skipped existing: </span><span class='embexpr_beg'>#{</span><span class='id path'>path</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span><span class='lparen'>(</span><span class='id path'>path</span> <span class='op'>==</span> <span class='const'>Dir</span><span class='period'>.</span><span class='id pwd'>pwd</span><span class='rparen'>)</span>
|
63
|
+
<span class='kw'>end</span>
|
64
|
+
<span class='id create_children'>create_children</span>
|
65
|
+
<span class='id execute_generators'>execute_generators</span>
|
66
|
+
<span class='kw'>end</span>
|
67
|
+
|
68
|
+
<span class='kw'>def</span> <span class='id destroy'>destroy</span>
|
69
|
+
<span class='id unexecute_generators'>unexecute_generators</span>
|
70
|
+
<span class='id success'>success</span> <span class='op'>=</span> <span class='id destroy_children'>destroy_children</span>
|
71
|
+
|
72
|
+
<span class='kw'>if</span> <span class='id success'>success</span> <span class='op'>&&</span> <span class='id can_remove?'>can_remove?</span>
|
73
|
+
<span class='const'>FileUtils</span><span class='period'>.</span><span class='id rmdir'>rmdir</span> <span class='id path'>path</span>
|
74
|
+
<span class='id say'>say</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Removed directory: </span><span class='embexpr_beg'>#{</span><span class='id path'>path</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
75
|
+
<span class='kw'>true</span>
|
76
|
+
<span class='kw'>else</span>
|
77
|
+
<span class='id say'>say</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Skipped remove directory: </span><span class='embexpr_beg'>#{</span><span class='id path'>path</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
78
|
+
<span class='kw'>false</span>
|
79
|
+
<span class='kw'>end</span>
|
80
|
+
<span class='kw'>end</span>
|
81
|
+
|
82
|
+
<span class='id private'>private</span>
|
83
|
+
|
84
|
+
<span class='kw'>def</span> <span class='id can_remove?'>can_remove?</span>
|
85
|
+
<span class='const'>File</span><span class='period'>.</span><span class='id directory?'>directory?</span><span class='lparen'>(</span><span class='id path'>path</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='const'>Dir</span><span class='period'>.</span><span class='id empty?'>empty?</span><span class='lparen'>(</span><span class='id path'>path</span><span class='rparen'>)</span>
|
86
|
+
<span class='kw'>end</span>
|
87
|
+
|
88
|
+
<span class='kw'>def</span> <span class='id create_children'>create_children</span>
|
89
|
+
<span class='id created'>created</span> <span class='op'>=</span> <span class='id children'>children</span><span class='period'>.</span><span class='id select'>select</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id child'>child</span><span class='op'>|</span> <span class='id child'>child</span><span class='period'>.</span><span class='id create'>create</span> <span class='rbrace'>}</span>
|
90
|
+
<span class='kw'>return</span> <span class='lparen'>(</span><span class='id created'>created</span><span class='period'>.</span><span class='id size'>size</span> <span class='op'>==</span> <span class='id children'>children</span><span class='period'>.</span><span class='id size'>size</span><span class='rparen'>)</span>
|
91
|
+
<span class='kw'>end</span>
|
92
|
+
|
93
|
+
<span class='kw'>def</span> <span class='id destroy_children'>destroy_children</span>
|
94
|
+
<span class='id destroyed'>destroyed</span> <span class='op'>=</span> <span class='id children'>children</span><span class='period'>.</span><span class='id reverse'>reverse</span><span class='period'>.</span><span class='id select'>select</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id child'>child</span><span class='op'>|</span> <span class='id child'>child</span><span class='period'>.</span><span class='id destroy'>destroy</span> <span class='rbrace'>}</span>
|
95
|
+
<span class='kw'>return</span> <span class='lparen'>(</span><span class='id destroyed'>destroyed</span><span class='period'>.</span><span class='id size'>size</span> <span class='op'>==</span> <span class='id children'>children</span><span class='period'>.</span><span class='id size'>size</span><span class='rparen'>)</span>
|
96
|
+
<span class='kw'>end</span>
|
97
|
+
|
98
|
+
<span class='kw'>def</span> <span class='id execute_generators'>execute_generators</span>
|
99
|
+
<span class='id generators'>generators</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id generator'>generator</span><span class='op'>|</span>
|
100
|
+
<span class='id generator'>generator</span><span class='period'>.</span><span class='id execute'>execute</span>
|
101
|
+
<span class='kw'>end</span>
|
102
|
+
<span class='kw'>end</span>
|
103
|
+
|
104
|
+
<span class='kw'>def</span> <span class='id unexecute_generators'>unexecute_generators</span>
|
105
|
+
<span class='id generators'>generators</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id generator'>generator</span><span class='op'>|</span>
|
106
|
+
<span class='id generator'>generator</span><span class='period'>.</span><span class='id unexecute'>unexecute</span>
|
107
|
+
<span class='kw'>end</span>
|
108
|
+
<span class='kw'>end</span>
|
109
|
+
|
110
|
+
<span class='kw'>end</span></pre>
|
111
|
+
|
112
|
+
<p>end</p>
|
113
|
+
</div></div>
|
114
|
+
|
115
|
+
<div id="footer">
|
116
|
+
Generated on Wed Dec 22 11:58:32 2010 by
|
117
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
118
|
+
0.6.3 (ruby-1.9.2).
|
119
|
+
</div>
|
120
|
+
|
121
|
+
</body>
|
122
|
+
</html>
|
@@ -0,0 +1,147 @@
|
|
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: errors</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: errors</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'># A module, below which, all errors should be found.
|
49
|
+
</span><span class='comment'>#
|
50
|
+
</span><span class='kw'>module</span> <span class='const'>Errors</span>
|
51
|
+
|
52
|
+
<span class='comment'>##
|
53
|
+
</span> <span class='comment'># A general Sprout Error was encountered.
|
54
|
+
</span> <span class='kw'>class</span> <span class='const'>SproutError</span> <span class='op'><</span> <span class='const'>StandardError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
55
|
+
|
56
|
+
<span class='comment'>##
|
57
|
+
</span> <span class='comment'># An error in the Executable was encountered.
|
58
|
+
</span> <span class='kw'>class</span> <span class='const'>ExecutableError</span> <span class='op'><</span> <span class='const'>SproutError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
59
|
+
|
60
|
+
<span class='comment'>##
|
61
|
+
</span> <span class='comment'># An error in a Generator was encountered.
|
62
|
+
</span> <span class='kw'>class</span> <span class='const'>GeneratorError</span> <span class='op'><</span> <span class='const'>SproutError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
63
|
+
|
64
|
+
<span class='comment'>##
|
65
|
+
</span> <span class='comment'># Unable to find the expected template for a Generator.
|
66
|
+
</span> <span class='kw'>class</span> <span class='const'>MissingGeneratorError</span> <span class='op'><</span> <span class='const'>GeneratorError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
67
|
+
|
68
|
+
<span class='comment'>##
|
69
|
+
</span> <span class='comment'># Unable to find the expected template for a Generator.
|
70
|
+
</span> <span class='kw'>class</span> <span class='const'>MissingTemplateError</span> <span class='op'><</span> <span class='const'>GeneratorError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
71
|
+
|
72
|
+
<span class='comment'>##
|
73
|
+
</span> <span class='comment'># There was a problem with the requested
|
74
|
+
</span> <span class='comment'># unpack operation.
|
75
|
+
</span> <span class='kw'>class</span> <span class='const'>ArchiveUnpackerError</span> <span class='op'><</span> <span class='const'>SproutError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
76
|
+
|
77
|
+
<span class='comment'>##
|
78
|
+
</span> <span class='comment'># The unpacked file was already found in the destination
|
79
|
+
</span> <span class='comment'># directory and the ArchiveUnpacker was not asked to clobber.
|
80
|
+
</span> <span class='kw'>class</span> <span class='const'>DestinationExistsError</span> <span class='op'><</span> <span class='const'>ArchiveUnpackerError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
81
|
+
|
82
|
+
<span class='comment'>##
|
83
|
+
</span> <span class='comment'># Sprouts was unable to accomplish the request.
|
84
|
+
</span> <span class='kw'>class</span> <span class='const'>ExecutionError</span> <span class='op'><</span> <span class='const'>SproutError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
85
|
+
|
86
|
+
<span class='comment'>##
|
87
|
+
</span> <span class='comment'># Requested parameter or accessor already exists.
|
88
|
+
</span> <span class='kw'>class</span> <span class='const'>DuplicateMemberError</span> <span class='op'><</span> <span class='const'>ExecutableError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
89
|
+
|
90
|
+
<span class='comment'>##
|
91
|
+
</span> <span class='comment'># Error when registering executables.
|
92
|
+
</span> <span class='kw'>class</span> <span class='const'>ExecutableRegistrationError</span> <span class='op'><</span> <span class='const'>ExecutableError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
93
|
+
|
94
|
+
<span class='comment'>##
|
95
|
+
</span> <span class='comment'># Could not find requested ExecutableTarget
|
96
|
+
</span> <span class='kw'>class</span> <span class='const'>MissingExecutableError</span> <span class='op'><</span> <span class='const'>ExecutableError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
97
|
+
|
98
|
+
<span class='comment'>##
|
99
|
+
</span> <span class='comment'># Required argument was not provided
|
100
|
+
</span> <span class='kw'>class</span> <span class='const'>MissingArgumentError</span> <span class='op'><</span> <span class='const'>ExecutableError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
101
|
+
|
102
|
+
<span class='comment'>##
|
103
|
+
</span> <span class='comment'># An argument was provided that was not valid
|
104
|
+
</span> <span class='kw'>class</span> <span class='const'>InvalidArgumentError</span> <span class='op'><</span> <span class='const'>ExecutableError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
105
|
+
|
106
|
+
<span class='comment'>##
|
107
|
+
</span> <span class='comment'># There was an error in ProcessRunner
|
108
|
+
</span> <span class='kw'>class</span> <span class='const'>ProcessRunnerError</span> <span class='op'><</span> <span class='const'>SproutError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
109
|
+
|
110
|
+
<span class='comment'>##
|
111
|
+
</span> <span class='comment'># There was a problem requiring a requested file
|
112
|
+
</span> <span class='kw'>class</span> <span class='const'>LoadError</span> <span class='op'><</span> <span class='const'>SproutError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
113
|
+
|
114
|
+
<span class='comment'>##
|
115
|
+
</span> <span class='comment'># Error on remote file download
|
116
|
+
</span> <span class='kw'>class</span> <span class='const'>RemoteFileLoaderError</span> <span class='op'><</span> <span class='const'>StandardError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
117
|
+
|
118
|
+
<span class='comment'>##
|
119
|
+
</span> <span class='comment'># An unexpected input was used or method was called.
|
120
|
+
</span> <span class='kw'>class</span> <span class='const'>UsageError</span> <span class='op'><</span> <span class='const'>SproutError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
121
|
+
|
122
|
+
<span class='comment'>##
|
123
|
+
</span> <span class='comment'># Can't figure out how to unpack this type of file.
|
124
|
+
</span> <span class='comment'># Try again with a .zip, .tgz, or .tar.gz
|
125
|
+
</span> <span class='kw'>class</span> <span class='const'>UnknownArchiveType</span> <span class='op'><</span> <span class='const'>SproutError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
126
|
+
|
127
|
+
<span class='comment'>##
|
128
|
+
</span> <span class='comment'># Error when a feature is not in a valid state
|
129
|
+
</span> <span class='kw'>class</span> <span class='const'>ValidationError</span> <span class='op'><</span> <span class='const'>SproutError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
130
|
+
|
131
|
+
<span class='comment'>##
|
132
|
+
</span> <span class='comment'># Could not meet the requested version requirement.
|
133
|
+
</span> <span class='kw'>class</span> <span class='const'>VersionRequirementNotMetError</span> <span class='op'><</span> <span class='const'>SproutError</span><span class='semicolon'>;</span> <span class='kw'>end</span>
|
134
|
+
|
135
|
+
<span class='kw'>end</span></pre>
|
136
|
+
|
137
|
+
<p>end</p>
|
138
|
+
</div></div>
|
139
|
+
|
140
|
+
<div id="footer">
|
141
|
+
Generated on Wed Dec 22 11:58:31 2010 by
|
142
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
143
|
+
0.6.3 (ruby-1.9.2).
|
144
|
+
</div>
|
145
|
+
|
146
|
+
</body>
|
147
|
+
</html>
|
@@ -0,0 +1,638 @@
|
|
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: executable</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: executable</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>require ‘sprout/executable/param’ require
|
46
|
+
‘sprout/executable/collection_param’ require ‘sprout/executable/boolean’
|
47
|
+
require ‘sprout/executable/number’ require ‘sprout/executable/string_param’
|
48
|
+
require ‘sprout/executable/strings’ require ‘sprout/executable/file_param’
|
49
|
+
require ‘sprout/executable/files’ require ‘sprout/executable/path’ require
|
50
|
+
‘sprout/executable/paths’ require ‘sprout/executable/url’ require
|
51
|
+
‘sprout/executable/urls’ require ‘sprout/executable/parameter_factory’
|
52
|
+
require ‘rake/clean’</p>
|
53
|
+
|
54
|
+
<p>module Sprout</p>
|
55
|
+
|
56
|
+
<pre class="code"><span class='comment'>##
|
57
|
+
</span><span class='comment'># The Sprout::Executable module exposes a Domain Specific Language
|
58
|
+
</span><span class='comment'># for describing Command Line Interface (CLI) applications.
|
59
|
+
</span><span class='comment'>#
|
60
|
+
</span><span class='comment'># This module can be included by any class, and depending on how that class
|
61
|
+
</span><span class='comment'># is used, one can either parse command line arguments into meaningful,
|
62
|
+
</span><span class='comment'># structured data, or delegate ruby code and configuration to an existing,
|
63
|
+
</span><span class='comment'># external command line process.
|
64
|
+
</span><span class='comment'>#
|
65
|
+
</span><span class='comment'># Following is an example of how one could define an executable Ruby
|
66
|
+
</span><span class='comment'># application using this module:
|
67
|
+
</span><span class='comment'>#
|
68
|
+
</span><span class='comment'># :include: ../../test/fixtures/examples/echo_inputs.rb
|
69
|
+
</span><span class='comment'>#
|
70
|
+
</span><span class='kw'>module</span> <span class='const'>Executable</span>
|
71
|
+
<span class='id include'>include</span> <span class='const'>RubyFeature</span>
|
72
|
+
|
73
|
+
<span class='const'>DEFAULT_FILE_EXPRESSION</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>/**/**/*</span><span class='tstring_end'>'</span></span>
|
74
|
+
<span class='const'>DEFAULT_PREFIX</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>--</span><span class='tstring_end'>'</span></span>
|
75
|
+
<span class='const'>DEFAULT_SHORT_PREFIX</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>-</span><span class='tstring_end'>'</span></span>
|
76
|
+
|
77
|
+
<span class='id extend'>extend</span> <span class='const'>Concern</span>
|
78
|
+
|
79
|
+
<span class='kw'>module</span> <span class='const'>ClassMethods</span>
|
80
|
+
<span class='comment'>##
|
81
|
+
</span> <span class='comment'># +add_param+ is the workhorse of the Task.
|
82
|
+
</span> <span class='comment'># This method is used to add new shell parameters to the executable interface.
|
83
|
+
</span> <span class='comment'>#
|
84
|
+
</span> <span class='comment'># +name+ is a symbol or string that represents the parameter that you would like to add
|
85
|
+
</span> <span class='comment'># such as :debug or :source_path.
|
86
|
+
</span> <span class='comment'>#
|
87
|
+
</span> <span class='comment'># +type+ is a class reference of the Executable::Param that you'd like to use.
|
88
|
+
</span> <span class='comment'># At the time of this writing, add_param will accept 2 class references that
|
89
|
+
</span> <span class='comment'># do not extend Param - String and File. The ParameterFactory will automatically
|
90
|
+
</span> <span class='comment'># resolve these to the correct data type when they are created.
|
91
|
+
</span> <span class='comment'>#
|
92
|
+
</span> <span class='comment'># Boolean true or false
|
93
|
+
</span> <span class='comment'># File Path to a file
|
94
|
+
</span> <span class='comment'># Number Any number
|
95
|
+
</span> <span class='comment'># Path Path to a directory
|
96
|
+
</span> <span class='comment'># String Any string value
|
97
|
+
</span> <span class='comment'># Url Basic URL
|
98
|
+
</span> <span class='comment'>#
|
99
|
+
</span> <span class='comment'># Files Collection of files
|
100
|
+
</span> <span class='comment'># Paths Collection of directories
|
101
|
+
</span> <span class='comment'># Strings Collection of arbitrary strings
|
102
|
+
</span> <span class='comment'># Urls Collection of URLs
|
103
|
+
</span> <span class='comment'>#
|
104
|
+
</span> <span class='comment'># Be sure to check out the Sprout::Executable::Param class to learn more about
|
105
|
+
</span> <span class='comment'># working with executable parameters.
|
106
|
+
</span> <span class='comment'>#
|
107
|
+
</span> <span class='comment'># Once parameters have been added using the +add_param+ method, clients
|
108
|
+
</span> <span class='comment'># can set and get those parameters from any newly created executable instance,
|
109
|
+
</span> <span class='comment'># or from the command line.
|
110
|
+
</span> <span class='comment'>#
|
111
|
+
</span> <span class='comment'># In the case of an executable delegate, parameter values will be sent to the
|
112
|
+
</span> <span class='comment'># command line executable in the order they are added using +add_param+.
|
113
|
+
</span> <span class='comment'>#
|
114
|
+
</span> <span class='comment'># In the case of a Ruby executable, command line parameters will be interpreted
|
115
|
+
</span> <span class='comment'># in the order they are defined using +add_param+.
|
116
|
+
</span> <span class='comment'>#
|
117
|
+
</span> <span class='kw'>def</span> <span class='id add_param'>add_param</span><span class='lparen'>(</span><span class='id name'>name</span><span class='comma'>,</span> <span class='id type'>type</span><span class='comma'>,</span> <span class='id options'>options</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span> <span class='comment'># :yields: Sprout::Executable::Param
|
118
|
+
</span> <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'>UsageError</span><span class='period'>.</span><span class='id new'>new</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>[DEPRECATED] add_param no longer uses closures, you can provide the same values as a hash in the optional last argument.</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id block_given?'>block_given?</span>
|
119
|
+
<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'>UsageError</span><span class='period'>.</span><span class='id new'>new</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>The first parameter (name:SymbolOrString) is required</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>
|
120
|
+
<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'>UsageError</span><span class='period'>.</span><span class='id new'>new</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>The second parameter (type:Class) is required</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id type'>type</span><span class='period'>.</span><span class='id nil?'>nil?</span>
|
121
|
+
<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'>UsageError</span><span class='period'>.</span><span class='id new'>new</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>The type parameter must be a Class by reference</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='op'>!</span><span class='id type'>type</span><span class='period'>.</span><span class='id is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Class</span><span class='rparen'>)</span>
|
122
|
+
|
123
|
+
<span class='id options'>options</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
124
|
+
<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>
|
125
|
+
<span class='id options'>options</span><span class='lbracket'>[</span><span class='symbol'>:type</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id type'>type</span>
|
126
|
+
<span class='comment'># TODO: Integrate the RDOC-parsed parameter description here:
|
127
|
+
</span> <span class='comment'>#options[:description] ||= Sprout::RDocParser.description_for_caller caller.shift
|
128
|
+
</span>
|
129
|
+
<span class='id create_param_accessors'>create_param_accessors</span> <span class='id options'>options</span>
|
130
|
+
<span class='id static_parameter_collection'>static_parameter_collection</span> <span class='op'><<</span> <span class='id options'>options</span>
|
131
|
+
<span class='id options'>options</span>
|
132
|
+
<span class='kw'>end</span>
|
133
|
+
|
134
|
+
<span class='kw'>def</span> <span class='id add_param_alias'>add_param_alias</span> <span class='id new_name'>new_name</span><span class='comma'>,</span> <span class='id old_name'>old_name</span>
|
135
|
+
<span class='id create_param_accessors'>create_param_accessors</span> <span class='symbol'>:name</span> <span class='op'>=></span> <span class='id new_name'>new_name</span><span class='comma'>,</span> <span class='symbol'>:real_name</span> <span class='op'>=></span> <span class='id old_name'>old_name</span>
|
136
|
+
<span class='kw'>end</span>
|
137
|
+
|
138
|
+
<span class='kw'>def</span> <span class='id static_parameter_collection'>static_parameter_collection</span>
|
139
|
+
<span class='ivar'>@static_parameter_collection</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
140
|
+
<span class='kw'>end</span>
|
141
|
+
|
142
|
+
<span class='kw'>def</span> <span class='id static_default_value_collection'>static_default_value_collection</span>
|
143
|
+
<span class='ivar'>@static_default_value_collection</span> <span class='op'>||=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
144
|
+
<span class='kw'>end</span>
|
145
|
+
|
146
|
+
<span class='kw'>def</span> <span class='id set'>set</span> <span class='id key'>key</span><span class='comma'>,</span> <span class='id value'>value</span>
|
147
|
+
<span class='id set_default_value'>set_default_value</span> <span class='id key'>key</span><span class='comma'>,</span> <span class='id value'>value</span>
|
148
|
+
<span class='kw'>end</span>
|
149
|
+
|
150
|
+
<span class='id private'>private</span>
|
151
|
+
|
152
|
+
<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>
|
153
|
+
<span class='kw'>if</span><span class='lparen'>(</span><span class='id instance_defines?'>instance_defines?</span> <span class='id name'>name</span><span class='rparen'>)</span>
|
154
|
+
<span class='id message'>message</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>add_param called with a name that is already in use (</span><span class='embexpr_beg'>#{</span><span class='id name'>name</span><span class='rbrace'>}</span><span class='tstring_content'>=) on (</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='rbrace'>}</span><span class='tstring_content'>)</span><span class='tstring_end'>"</span></span>
|
155
|
+
<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'>DuplicateMemberError</span><span class='period'>.</span><span class='id new'>new</span><span class='lparen'>(</span><span class='id message'>message</span><span class='rparen'>)</span>
|
156
|
+
<span class='kw'>end</span>
|
157
|
+
<span class='kw'>end</span>
|
158
|
+
|
159
|
+
<span class='kw'>def</span> <span class='id create_param_accessors'>create_param_accessors</span> <span class='id options'>options</span>
|
160
|
+
<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>
|
161
|
+
<span class='id real_name'>real_name</span> <span class='op'>=</span> <span class='id options'>options</span><span class='lbracket'>[</span><span class='symbol'>:real_name</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='id name'>name</span>
|
162
|
+
<span class='id accessor_can_be_defined_at'>accessor_can_be_defined_at</span> <span class='id name'>name</span>
|
163
|
+
|
164
|
+
<span class='comment'># define the writer:
|
165
|
+
</span> <span class='id define_method'>define_method</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id name'>name</span><span class='rbrace'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id value'>value</span><span class='op'>|</span>
|
166
|
+
<span class='kw'>if</span><span class='lparen'>(</span><span class='op'>!</span><span class='id options'>options</span><span class='lbracket'>[</span><span class='symbol'>:writer</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id nil?'>nil?</span><span class='rparen'>)</span>
|
167
|
+
<span class='id value'>value</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id send'>send</span><span class='lparen'>(</span><span class='id options'>options</span><span class='lbracket'>[</span><span class='symbol'>:writer</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id value'>value</span><span class='rparen'>)</span>
|
168
|
+
<span class='kw'>end</span>
|
169
|
+
<span class='id param_hash'>param_hash</span><span class='lbracket'>[</span><span class='id real_name'>real_name</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id value'>value</span> <span class='op'>=</span> <span class='id value'>value</span>
|
170
|
+
<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'>@</span><span class='embexpr_beg'>#{</span><span class='id name'>name</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id value'>value</span><span class='rparen'>)</span>
|
171
|
+
<span class='kw'>end</span>
|
172
|
+
|
173
|
+
<span class='comment'># define the reader:
|
174
|
+
</span> <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>
|
175
|
+
<span class='kw'>if</span><span class='lparen'>(</span><span class='id options'>options</span><span class='lbracket'>[</span><span class='symbol'>:reader</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id nil?'>nil?</span><span class='rparen'>)</span>
|
176
|
+
<span class='kw'>if</span><span class='lparen'>(</span><span class='id param_hash'>param_hash</span><span class='lbracket'>[</span><span class='id real_name'>real_name</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id nil?'>nil?</span><span class='rparen'>)</span>
|
177
|
+
<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'>UsageError</span><span class='period'>.</span><span class='id new'>new</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Unable to use requested parameter (</span><span class='embexpr_beg'>#{</span><span class='id real_name'>real_name</span><span class='rbrace'>}</span><span class='tstring_content'>) try adding it using:\n\n add_param :</span><span class='embexpr_beg'>#{</span><span class='id real_name'>real_name</span><span class='rbrace'>}</span><span class='tstring_content'>, String\n\n</span><span class='tstring_end'>"</span></span>
|
178
|
+
<span class='kw'>end</span>
|
179
|
+
<span class='id param_hash'>param_hash</span><span class='lbracket'>[</span><span class='id real_name'>real_name</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id value'>value</span>
|
180
|
+
<span class='kw'>else</span>
|
181
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id send'>send</span><span class='lparen'>(</span><span class='id options'>options</span><span class='lbracket'>[</span><span class='symbol'>:reader</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
182
|
+
<span class='kw'>end</span>
|
183
|
+
<span class='kw'>end</span>
|
184
|
+
<span class='kw'>end</span>
|
185
|
+
|
186
|
+
<span class='kw'>def</span> <span class='id instance_defines?'>instance_defines?</span> <span class='id name'>name</span>
|
187
|
+
<span class='comment'># In Ruby 1.9.1 instance_methods are symbols,
|
188
|
+
</span> <span class='comment'># In Ruby 1.8.7 instance_methods are strings.
|
189
|
+
</span> <span class='comment'># Boo.
|
190
|
+
</span> <span class='kw'>self</span><span class='period'>.</span><span class='id instance_methods'>instance_methods</span><span class='period'>.</span><span class='id include?'>include?</span><span class='lparen'>(</span><span class='id name'>name</span><span class='period'>.</span><span class='id to_s'>to_s</span><span class='rparen'>)</span> <span class='op'>||</span>
|
191
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id instance_methods'>instance_methods</span><span class='period'>.</span><span class='id include?'>include?</span><span class='lparen'>(</span><span class='id name'>name</span><span class='rparen'>)</span>
|
192
|
+
<span class='kw'>end</span>
|
193
|
+
|
194
|
+
<span class='kw'>def</span> <span class='id set_default_value'>set_default_value</span> <span class='id key'>key</span><span class='comma'>,</span> <span class='id value'>value</span>
|
195
|
+
<span class='kw'>if</span><span class='lparen'>(</span><span class='op'>!</span><span class='kw'>defined?</span> <span class='id key'>key</span><span class='rparen'>)</span>
|
196
|
+
<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'>UsageError</span><span class='period'>.</span><span class='id new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Cannot set default value (</span><span class='embexpr_beg'>#{</span><span class='id value'>value</span><span class='rbrace'>}</span><span class='tstring_content'>) for unknown parameter (</span><span class='embexpr_beg'>#{</span><span class='id key'>key</span><span class='rbrace'>}</span><span class='tstring_content'>)</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
197
|
+
<span class='kw'>end</span>
|
198
|
+
<span class='id static_default_value_collection'>static_default_value_collection</span> <span class='op'><<</span> <span class='lbrace'>{</span> <span class='symbol'>:name</span> <span class='op'>=></span> <span class='id key'>key</span><span class='comma'>,</span> <span class='symbol'>:value</span> <span class='op'>=></span> <span class='id value'>value</span> <span class='rbrace'>}</span>
|
199
|
+
<span class='kw'>end</span>
|
200
|
+
<span class='kw'>end</span>
|
201
|
+
|
202
|
+
<span class='kw'>module</span> <span class='const'>InstanceMethods</span>
|
203
|
+
<span class='comment'>##
|
204
|
+
</span> <span class='comment'># The default RubyGem that we will use when requesting our executable.
|
205
|
+
</span> <span class='comment'>#
|
206
|
+
</span> <span class='comment'># Classes that include the Executable can set the default value for this property
|
207
|
+
</span> <span class='comment'># at the class level with:
|
208
|
+
</span> <span class='comment'>#
|
209
|
+
</span> <span class='comment'># set :pkg_name, 'sprout-sometoolname'
|
210
|
+
</span> <span class='comment'>#
|
211
|
+
</span> <span class='comment'># But that value can be overridden on each instance like:
|
212
|
+
</span> <span class='comment'>#
|
213
|
+
</span> <span class='comment'># executable = SomeToolTask.new
|
214
|
+
</span> <span class='comment'># executable.pkg_name = 'sprout-othertoolname'
|
215
|
+
</span> <span class='comment'>#
|
216
|
+
</span> <span class='comment'># This parameter is required - either from the including class or instance
|
217
|
+
</span> <span class='comment'># configuration.
|
218
|
+
</span> <span class='comment'>#
|
219
|
+
</span> <span class='id attr_accessor'>attr_accessor</span> <span class='symbol'>:pkg_name</span>
|
220
|
+
|
221
|
+
<span class='comment'>##
|
222
|
+
</span> <span class='comment'># The default RubyGem version that we will use when requesting our executable.
|
223
|
+
</span> <span class='comment'>#
|
224
|
+
</span> <span class='comment'># Classes that include the Task can set the default value for this property
|
225
|
+
</span> <span class='comment'># at the class level with:
|
226
|
+
</span> <span class='comment'>#
|
227
|
+
</span> <span class='comment'># set :pkg_version, '>= 1.0.3'
|
228
|
+
</span> <span class='comment'>#
|
229
|
+
</span> <span class='comment'># But that value can be overriden on each instance like:
|
230
|
+
</span> <span class='comment'>#
|
231
|
+
</span> <span class='comment'># executable = SomeToolTask.new
|
232
|
+
</span> <span class='comment'># too.pkg_version = '>= 2.0.0'
|
233
|
+
</span> <span class='comment'>#
|
234
|
+
</span> <span class='comment'># This parameter is required - either from the including class or instance
|
235
|
+
</span> <span class='comment'># configuration.
|
236
|
+
</span> <span class='comment'>#
|
237
|
+
</span> <span class='id attr_accessor'>attr_accessor</span> <span class='symbol'>:pkg_version</span>
|
238
|
+
|
239
|
+
<span class='comment'>##
|
240
|
+
</span> <span class='comment'># The default command line prefix that should be used in front of parameter
|
241
|
+
</span> <span class='comment'># names.
|
242
|
+
</span> <span class='comment'>#
|
243
|
+
</span> <span class='comment'># The default value for this parameter is '--', but some command line
|
244
|
+
</span> <span class='comment'># applications (like MXMLC) prefer '-'.
|
245
|
+
</span> <span class='comment'>#
|
246
|
+
</span> <span class='id attr_accessor'>attr_accessor</span> <span class='symbol'>:default_prefix</span>
|
247
|
+
|
248
|
+
<span class='comment'>##
|
249
|
+
</span> <span class='comment'># The default command line prefix for short name parameters.
|
250
|
+
</span> <span class='comment'>#
|
251
|
+
</span> <span class='comment'># This value defaults to '-', but can be changed to whatever a particular
|
252
|
+
</span> <span class='comment'># tool prefers.
|
253
|
+
</span> <span class='comment'>#
|
254
|
+
</span> <span class='id attr_accessor'>attr_accessor</span> <span class='symbol'>:default_short_prefix</span>
|
255
|
+
|
256
|
+
<span class='comment'>##
|
257
|
+
</span> <span class='comment'># The default Sprout executable that we will use for this executable.
|
258
|
+
</span> <span class='comment'>#
|
259
|
+
</span> <span class='comment'># Classes that include the Task can set the default value for this property
|
260
|
+
</span> <span class='comment'># at the class level with:
|
261
|
+
</span> <span class='comment'>#
|
262
|
+
</span> <span class='comment'># set :executable, :mxmlc
|
263
|
+
</span> <span class='comment'>#
|
264
|
+
</span> <span class='comment'># But that value can be overriden on each instance like:
|
265
|
+
</span> <span class='comment'>#
|
266
|
+
</span> <span class='comment'># executable = SomeToolTask.new
|
267
|
+
</span> <span class='comment'># too.executable :compc
|
268
|
+
</span> <span class='comment'>#
|
269
|
+
</span> <span class='comment'># This parameter is required - either from the including class or instance
|
270
|
+
</span> <span class='comment'># configuration.
|
271
|
+
</span> <span class='comment'>#
|
272
|
+
</span> <span class='id attr_accessor'>attr_accessor</span> <span class='symbol'>:executable</span>
|
273
|
+
|
274
|
+
<span class='comment'>##
|
275
|
+
</span> <span class='comment'># Configure the executable instance to output failure messages to
|
276
|
+
</span> <span class='comment'># stderr and abort with non-zero response.
|
277
|
+
</span> <span class='id attr_accessor'>attr_accessor</span> <span class='symbol'>:abort_on_failure</span>
|
278
|
+
|
279
|
+
<span class='comment'>##
|
280
|
+
</span> <span class='comment'># If the executable is configured as a Rake::Task, it will extract the
|
281
|
+
</span> <span class='comment'># Rake::Task[:name] property and apply it to this field.
|
282
|
+
</span> <span class='comment'>#
|
283
|
+
</span> <span class='comment'># Concrete parameters can pull this value from their +belongs_to+
|
284
|
+
</span> <span class='comment'># parameter.
|
285
|
+
</span> <span class='id attr_accessor'>attr_accessor</span> <span class='symbol'>:rake_task_name</span>
|
286
|
+
|
287
|
+
<span class='id attr_reader'>attr_reader</span> <span class='symbol'>:param_hash</span>
|
288
|
+
<span class='id attr_reader'>attr_reader</span> <span class='symbol'>:params</span>
|
289
|
+
<span class='id attr_reader'>attr_reader</span> <span class='symbol'>:prerequisites</span>
|
290
|
+
|
291
|
+
<span class='kw'>def</span> <span class='id initialize'>initialize</span>
|
292
|
+
<span class='kw'>super</span>
|
293
|
+
<span class='ivar'>@abort_on_failure</span> <span class='op'>=</span> <span class='kw'>true</span>
|
294
|
+
<span class='ivar'>@appended_args</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
295
|
+
<span class='ivar'>@prepended_args</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
296
|
+
<span class='ivar'>@param_hash</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
297
|
+
<span class='ivar'>@params</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
298
|
+
<span class='ivar'>@prerequisites</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
299
|
+
<span class='ivar'>@option_parser</span> <span class='op'>=</span> <span class='const'>OptionParser</span><span class='period'>.</span><span class='id new'>new</span>
|
300
|
+
<span class='ivar'>@default_prefix</span> <span class='op'>=</span> <span class='const'>DEFAULT_PREFIX</span>
|
301
|
+
<span class='ivar'>@default_short_prefix</span> <span class='op'>=</span> <span class='const'>DEFAULT_SHORT_PREFIX</span>
|
302
|
+
<span class='id initialize_defaults'>initialize_defaults</span>
|
303
|
+
<span class='id initialize_parameters'>initialize_parameters</span>
|
304
|
+
<span class='kw'>end</span>
|
305
|
+
|
306
|
+
<span class='kw'>def</span> <span class='id parse!'>parse!</span> <span class='id commandline_options'>commandline_options</span>
|
307
|
+
<span class='kw'>begin</span>
|
308
|
+
<span class='id option_parser'>option_parser</span><span class='period'>.</span><span class='id parse!'>parse!</span> <span class='id commandline_options'>commandline_options</span>
|
309
|
+
<span class='id parse_extra_options!'>parse_extra_options!</span> <span class='id commandline_options'>commandline_options</span>
|
310
|
+
<span class='id validate'>validate</span> <span class='kw'>unless</span> <span class='id help_requested?'>help_requested?</span> <span class='id commandline_options'>commandline_options</span>
|
311
|
+
<span class='kw'>rescue</span> <span class='const'>StandardError</span> <span class='op'>=></span> <span class='id e'>e</span>
|
312
|
+
<span class='id handle_parse_error'>handle_parse_error</span> <span class='id e'>e</span>
|
313
|
+
<span class='kw'>end</span>
|
314
|
+
<span class='kw'>end</span>
|
315
|
+
|
316
|
+
<span class='comment'>##
|
317
|
+
</span> <span class='comment'># Execute the feature after calling parse
|
318
|
+
</span> <span class='comment'># with command line arguments.
|
319
|
+
</span> <span class='comment'>#
|
320
|
+
</span> <span class='comment'># Subclasses will generally override this method
|
321
|
+
</span> <span class='comment'># if they are a Ruby executable, but if you're
|
322
|
+
</span> <span class='comment'># just delegating to an external CLI application,
|
323
|
+
</span> <span class='comment'># calling execute will wind up executing the
|
324
|
+
</span> <span class='comment'># external process.
|
325
|
+
</span> <span class='kw'>def</span> <span class='id execute'>execute</span>
|
326
|
+
<span class='id execute_delegate'>execute_delegate</span>
|
327
|
+
<span class='kw'>end</span>
|
328
|
+
|
329
|
+
<span class='comment'>##
|
330
|
+
</span> <span class='comment'># Call the provided executable delegate.
|
331
|
+
</span> <span class='comment'>#
|
332
|
+
</span> <span class='comment'># This method is generally called from Rake task wrappers.
|
333
|
+
</span> <span class='comment'>#
|
334
|
+
</span> <span class='kw'>def</span> <span class='id execute_delegate'>execute_delegate</span>
|
335
|
+
<span class='id system_execute'>system_execute</span> <span class='id binary_path'>binary_path</span><span class='comma'>,</span> <span class='id to_shell'>to_shell</span>
|
336
|
+
<span class='kw'>end</span>
|
337
|
+
|
338
|
+
<span class='kw'>def</span> <span class='id prepare'>prepare</span>
|
339
|
+
<span class='id params'>params</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id param'>param</span><span class='op'>|</span>
|
340
|
+
<span class='id param'>param</span><span class='period'>.</span><span class='id prepare'>prepare</span>
|
341
|
+
<span class='kw'>end</span>
|
342
|
+
<span class='kw'>end</span>
|
343
|
+
|
344
|
+
<span class='kw'>def</span> <span class='id to_rake'>to_rake</span> <span class='op'>*</span><span class='id args'>args</span>
|
345
|
+
<span class='comment'># Define the file task first - so that
|
346
|
+
</span> <span class='comment'># desc blocks hook up to it...
|
347
|
+
</span> <span class='id outer_task'>outer_task</span> <span class='op'>=</span> <span class='id create_outer_task'>create_outer_task</span> <span class='op'>*</span><span class='id args'>args</span>
|
348
|
+
<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>
|
349
|
+
<span class='kw'>yield</span> <span class='kw'>self</span> <span class='kw'>if</span> <span class='id block_given?'>block_given?</span>
|
350
|
+
<span class='id prepare'>prepare</span>
|
351
|
+
|
352
|
+
<span class='comment'># TODO: Tried auto-updating with library
|
353
|
+
</span> <span class='comment'># prerequisites, but this led to strange
|
354
|
+
</span> <span class='comment'># behavior with multiple registrations.
|
355
|
+
</span> <span class='id handle_library_prerequisites'>handle_library_prerequisites</span> <span class='id outer_task'>outer_task</span><span class='period'>.</span><span class='id prerequisites'>prerequisites</span>
|
356
|
+
|
357
|
+
<span class='comment'># Add the library resolution rake task
|
358
|
+
</span> <span class='comment'># as a prerequisite
|
359
|
+
</span> <span class='id outer_task'>outer_task</span><span class='period'>.</span><span class='id prerequisites'>prerequisites</span> <span class='op'><<</span> <span class='id task'>task</span><span class='lparen'>(</span><span class='const'>Sprout</span><span class='op'>::</span><span class='const'>Library</span><span class='op'>::</span><span class='const'>TASK_NAME</span><span class='rparen'>)</span>
|
360
|
+
<span class='id prerequisites'>prerequisites</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id prereq'>prereq</span><span class='op'>|</span>
|
361
|
+
<span class='id outer_task'>outer_task</span><span class='period'>.</span><span class='id prerequisites'>prerequisites</span> <span class='op'><<</span> <span class='id prereq'>prereq</span>
|
362
|
+
<span class='kw'>end</span>
|
363
|
+
<span class='id outer_task'>outer_task</span>
|
364
|
+
<span class='kw'>end</span>
|
365
|
+
|
366
|
+
<span class='comment'>##
|
367
|
+
</span> <span class='comment'># This will create a hash of ONLY values that are created
|
368
|
+
</span> <span class='comment'># using +add_param+, properties that are created with
|
369
|
+
</span> <span class='comment'># attr_accessor must be handled manually, or patches are welcome!
|
370
|
+
</span> <span class='kw'>def</span> <span class='id to_hash'>to_hash</span>
|
371
|
+
<span class='id result'>result</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
372
|
+
<span class='id params'>params</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id param'>param</span><span class='op'>|</span>
|
373
|
+
<span class='id result'>result</span><span class='lbracket'>[</span><span class='id param'>param</span><span class='period'>.</span><span class='id name'>name</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id send'>send</span><span class='lparen'>(</span><span class='id param'>param</span><span class='period'>.</span><span class='id name'>name</span><span class='rparen'>)</span>
|
374
|
+
<span class='kw'>end</span>
|
375
|
+
<span class='id result'>result</span>
|
376
|
+
<span class='kw'>end</span>
|
377
|
+
|
378
|
+
<span class='comment'>##
|
379
|
+
</span> <span class='comment'># This will ignore unknown parameters, because our very
|
380
|
+
</span> <span class='comment'># first use case, is when generators call other generators
|
381
|
+
</span> <span class='comment'># and generator A might have different parameters than
|
382
|
+
</span> <span class='comment'># generator B.
|
383
|
+
</span> <span class='kw'>def</span> <span class='id from_hash'>from_hash</span> <span class='id hash'>hash</span>
|
384
|
+
<span class='id hash'>hash</span><span class='period'>.</span><span class='id each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id key'>key</span><span class='comma'>,</span> <span class='id value'>value</span><span class='op'>|</span>
|
385
|
+
<span class='kw'>if</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='id key'>key</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
386
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id send'>send</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id key'>key</span><span class='rbrace'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id value'>value</span>
|
387
|
+
<span class='kw'>end</span>
|
388
|
+
<span class='kw'>end</span>
|
389
|
+
<span class='kw'>end</span>
|
390
|
+
|
391
|
+
<span class='kw'>def</span> <span class='id to_help'>to_help</span>
|
392
|
+
<span class='id option_parser'>option_parser</span><span class='period'>.</span><span class='id to_s'>to_s</span>
|
393
|
+
<span class='kw'>end</span>
|
394
|
+
|
395
|
+
<span class='comment'># Create a string that represents this configured executable for shell execution
|
396
|
+
</span> <span class='kw'>def</span> <span class='id to_shell'>to_shell</span>
|
397
|
+
<span class='kw'>return</span> <span class='ivar'>@to_shell_proc</span><span class='period'>.</span><span class='id call'>call</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='ivar'>@to_shell_proc</span><span class='period'>.</span><span class='id nil?'>nil?</span>
|
398
|
+
|
399
|
+
<span class='id result'>result</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
400
|
+
<span class='id result'>result</span> <span class='op'><<</span> <span class='ivar'>@prepended_args</span> <span class='kw'>unless</span> <span class='ivar'>@prepended_args</span><span class='period'>.</span><span class='id nil?'>nil?</span>
|
401
|
+
<span class='id params'>params</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id param'>param</span><span class='op'>|</span>
|
402
|
+
<span class='kw'>if</span><span class='lparen'>(</span><span class='id param'>param</span><span class='period'>.</span><span class='id visible?'>visible?</span><span class='rparen'>)</span>
|
403
|
+
<span class='id result'>result</span> <span class='op'><<</span> <span class='id param'>param</span><span class='period'>.</span><span class='id to_shell'>to_shell</span>
|
404
|
+
<span class='kw'>end</span>
|
405
|
+
<span class='kw'>end</span>
|
406
|
+
<span class='id result'>result</span> <span class='op'><<</span> <span class='ivar'>@appended_args</span> <span class='kw'>unless</span> <span class='ivar'>@appended_args</span><span class='period'>.</span><span class='id nil?'>nil?</span>
|
407
|
+
<span class='kw'>return</span> <span class='id result'>result</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>
|
408
|
+
<span class='kw'>end</span>
|
409
|
+
|
410
|
+
<span class='comment'>##
|
411
|
+
</span> <span class='comment'># Called by Parameters like :path and :paths
|
412
|
+
</span> <span class='comment'>#
|
413
|
+
</span> <span class='kw'>def</span> <span class='id default_file_expression'>default_file_expression</span>
|
414
|
+
<span class='ivar'>@default_file_expression</span> <span class='op'>||=</span> <span class='const'>Sprout</span><span class='op'>::</span><span class='const'>Executable</span><span class='op'>::</span><span class='const'>DEFAULT_FILE_EXPRESSION</span>
|
415
|
+
<span class='kw'>end</span>
|
416
|
+
|
417
|
+
<span class='id protected'>protected</span>
|
418
|
+
|
419
|
+
<span class='comment'>##
|
420
|
+
</span> <span class='comment'># Create the outer rake task.
|
421
|
+
</span> <span class='comment'># For most executables, this will be a Rake::File task,
|
422
|
+
</span> <span class='comment'># This is a template method that should be overridden
|
423
|
+
</span> <span class='comment'># for executables that do not result in the creation of
|
424
|
+
</span> <span class='comment'># a file.
|
425
|
+
</span> <span class='comment'>#
|
426
|
+
</span> <span class='comment'># @see update_rake_task_name_from_args
|
427
|
+
</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>
|
428
|
+
<span class='id file'>file</span> <span class='op'>*</span><span class='id args'>args</span> <span class='kw'>do</span>
|
429
|
+
<span class='id execute'>execute</span>
|
430
|
+
<span class='kw'>end</span>
|
431
|
+
<span class='kw'>end</span>
|
432
|
+
|
433
|
+
<span class='comment'>##
|
434
|
+
</span> <span class='comment'># This method will add the current task to the Rake CLEAN
|
435
|
+
</span> <span class='comment'># collection.
|
436
|
+
</span> <span class='comment'>#
|
437
|
+
</span> <span class='comment'># Any Executable that does not create a Rake::File task
|
438
|
+
</span> <span class='comment'># should also override this method and prevent it from
|
439
|
+
</span> <span class='comment'># calling +CLEAN.add+.
|
440
|
+
</span> <span class='comment'>#
|
441
|
+
</span> <span class='comment'># @see create_outer_task
|
442
|
+
</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>
|
443
|
+
<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>
|
444
|
+
<span class='const'>CLEAN</span><span class='period'>.</span><span class='id add'>add</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id rake_task_name'>rake_task_name</span><span class='rparen'>)</span>
|
445
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id rake_task_name'>rake_task_name</span>
|
446
|
+
<span class='kw'>end</span>
|
447
|
+
|
448
|
+
<span class='kw'>def</span> <span class='id parse_rake_task_arg'>parse_rake_task_arg</span> <span class='id arg'>arg</span>
|
449
|
+
<span class='kw'>return</span> <span class='id arg'>arg</span> <span class='kw'>if</span> <span class='id arg'>arg</span><span class='period'>.</span><span class='id is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Symbol</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id arg'>arg</span><span class='period'>.</span><span class='id is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>String</span><span class='rparen'>)</span>
|
450
|
+
<span class='id arg'>arg</span><span class='period'>.</span><span class='id each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id key'>key</span><span class='comma'>,</span> <span class='id value'>value</span><span class='op'>|</span>
|
451
|
+
<span class='kw'>return</span> <span class='id key'>key</span>
|
452
|
+
<span class='kw'>end</span>
|
453
|
+
<span class='kw'>nil</span>
|
454
|
+
<span class='kw'>end</span>
|
455
|
+
|
456
|
+
<span class='kw'>def</span> <span class='id parse_extra_options!'>parse_extra_options!</span> <span class='id options'>options</span>
|
457
|
+
<span class='id options'>options</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id value'>value</span><span class='op'>|</span>
|
458
|
+
<span class='id params'>params</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id param'>param</span><span class='op'>|</span>
|
459
|
+
<span class='kw'>if</span> <span class='id param'>param</span><span class='period'>.</span><span class='id hidden_name?'>hidden_name?</span>
|
460
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id send'>send</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id param'>param</span><span class='period'>.</span><span class='id name'>name</span><span class='rbrace'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id value'>value</span>
|
461
|
+
<span class='kw'>break</span>
|
462
|
+
<span class='kw'>end</span>
|
463
|
+
<span class='kw'>end</span>
|
464
|
+
<span class='kw'>end</span>
|
465
|
+
<span class='kw'>end</span>
|
466
|
+
|
467
|
+
<span class='comment'>##
|
468
|
+
</span> <span class='comment'># This method will generally be overridden
|
469
|
+
</span> <span class='comment'># by subclasses and they can do whatever customization
|
470
|
+
</span> <span class='comment'># is necessary for a particular library type.
|
471
|
+
</span> <span class='comment'>#
|
472
|
+
</span> <span class='comment'># It's important to note that this value can be
|
473
|
+
</span> <span class='comment'># a String path to a file (or folder), or it can
|
474
|
+
</span> <span class='comment'># be an Array of paths to files (or folders).
|
475
|
+
</span> <span class='kw'>def</span> <span class='id library_added'>library_added</span> <span class='id path_or_paths'>path_or_paths</span>
|
476
|
+
<span class='kw'>end</span>
|
477
|
+
|
478
|
+
<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>
|
479
|
+
<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'>execute</span> <span class='id binary'>binary</span><span class='comma'>,</span> <span class='id params'>params</span>
|
480
|
+
<span class='kw'>end</span>
|
481
|
+
|
482
|
+
<span class='id private'>private</span>
|
483
|
+
|
484
|
+
<span class='kw'>def</span> <span class='id binary_path'>binary_path</span>
|
485
|
+
<span class='const'>Sprout</span><span class='op'>::</span><span class='const'>Executable</span><span class='period'>.</span><span class='id load'>load</span><span class='lparen'>(</span><span class='id executable'>executable</span><span class='comma'>,</span> <span class='id pkg_name'>pkg_name</span><span class='comma'>,</span> <span class='id pkg_version'>pkg_version</span><span class='rparen'>)</span><span class='period'>.</span><span class='id path'>path</span>
|
486
|
+
<span class='kw'>end</span>
|
487
|
+
|
488
|
+
<span class='kw'>def</span> <span class='id handle_library_prerequisites'>handle_library_prerequisites</span> <span class='id items'>items</span>
|
489
|
+
<span class='id items'>items</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id task_name'>task_name</span><span class='op'>|</span>
|
490
|
+
<span class='id t'>t</span> <span class='op'>=</span> <span class='const'>Rake</span><span class='period'>.</span><span class='id application'>application</span><span class='lbracket'>[</span><span class='id task_name'>task_name</span><span class='rbracket'>]</span>
|
491
|
+
<span class='kw'>if</span><span class='lparen'>(</span><span class='op'>!</span><span class='id t'>t</span><span class='period'>.</span><span class='id sprout_entity'>sprout_entity</span><span class='period'>.</span><span class='id nil?'>nil?</span><span class='rparen'>)</span>
|
492
|
+
<span class='id library_added'>library_added</span> <span class='id t'>t</span><span class='period'>.</span><span class='id sprout_entity'>sprout_entity</span><span class='period'>.</span><span class='id installed_project_path'>installed_project_path</span>
|
493
|
+
<span class='kw'>end</span>
|
494
|
+
<span class='kw'>end</span>
|
495
|
+
<span class='kw'>end</span>
|
496
|
+
|
497
|
+
<span class='kw'>def</span> <span class='id help_requested?'>help_requested?</span> <span class='id options'>options</span>
|
498
|
+
<span class='id options'>options</span><span class='period'>.</span><span class='id include?'>include?</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>--help</span><span class='tstring_end'>'</span></span>
|
499
|
+
<span class='kw'>end</span>
|
500
|
+
|
501
|
+
<span class='kw'>def</span> <span class='id handle_parse_error'>handle_parse_error</span> <span class='id error'>error</span>
|
502
|
+
<span class='kw'>if</span><span class='lparen'>(</span><span class='id abort_on_failure'>abort_on_failure</span><span class='rparen'>)</span>
|
503
|
+
<span class='id parts'>parts</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
504
|
+
<span class='id parts'>parts</span> <span class='op'><<</span> <span class='kw'>nil</span>
|
505
|
+
<span class='id parts'>parts</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>[ERROR - </span><span class='embexpr_beg'>#{</span><span class='id error'>error</span><span class='period'>.</span><span class='id class'>class</span><span class='period'>.</span><span class='id name'>name</span><span class='rbrace'>}</span><span class='tstring_content'>] </span><span class='embexpr_beg'>#{</span><span class='id error'>error</span><span class='period'>.</span><span class='id message'>message</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
506
|
+
<span class='id parts'>parts</span> <span class='op'><<</span> <span class='kw'>nil</span>
|
507
|
+
<span class='id parts'>parts</span> <span class='op'><<</span> <span class='id option_parser'>option_parser</span><span class='period'>.</span><span class='id to_s'>to_s</span>
|
508
|
+
<span class='id parts'>parts</span> <span class='op'><<</span> <span class='kw'>nil</span>
|
509
|
+
<span class='id abort'>abort</span> <span class='id parts'>parts</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'>\n</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
510
|
+
<span class='kw'>else</span>
|
511
|
+
<span class='id raise'>raise</span> <span class='id error'>error</span>
|
512
|
+
<span class='kw'>end</span>
|
513
|
+
<span class='kw'>end</span>
|
514
|
+
|
515
|
+
<span class='kw'>def</span> <span class='id initialize_parameters'>initialize_parameters</span>
|
516
|
+
<span class='id add_help_param'>add_help_param</span>
|
517
|
+
<span class='id assembled_parameter_collection'>assembled_parameter_collection</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id declaration'>declaration</span><span class='op'>|</span>
|
518
|
+
<span class='id param'>param</span> <span class='op'>=</span> <span class='id initialize_parameter'>initialize_parameter</span> <span class='id declaration'>declaration</span>
|
519
|
+
<span class='id short'>short</span> <span class='op'>=</span> <span class='id param'>param</span><span class='period'>.</span><span class='id option_parser_short_name'>option_parser_short_name</span>
|
520
|
+
|
521
|
+
<span class='id option_parser'>option_parser</span><span class='period'>.</span><span class='id on'>on</span> <span class='id short'>short</span><span class='comma'>,</span>
|
522
|
+
<span class='id param'>param</span><span class='period'>.</span><span class='id option_parser_declaration'>option_parser_declaration</span><span class='comma'>,</span>
|
523
|
+
<span class='id param'>param</span><span class='period'>.</span><span class='id description'>description</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id value'>value</span><span class='op'>|</span>
|
524
|
+
<span class='kw'>if</span><span class='lparen'>(</span><span class='id param'>param</span><span class='period'>.</span><span class='id is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>CollectionParam</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id param'>param</span><span class='period'>.</span><span class='id delimiter'>delimiter</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>+=</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
525
|
+
<span class='id eval'>eval</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>self.</span><span class='embexpr_beg'>#{</span><span class='id param'>param</span><span class='period'>.</span><span class='id name'>name</span><span class='rbrace'>}</span><span class='tstring_content'> << '</span><span class='embexpr_beg'>#{</span><span class='id value'>value</span><span class='rbrace'>}</span><span class='tstring_content'>'</span><span class='tstring_end'>"</span></span>
|
526
|
+
<span class='kw'>else</span>
|
527
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id send'>send</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id param'>param</span><span class='period'>.</span><span class='id name'>name</span><span class='rbrace'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id value'>value</span>
|
528
|
+
<span class='kw'>end</span>
|
529
|
+
<span class='kw'>end</span>
|
530
|
+
<span class='kw'>end</span>
|
531
|
+
<span class='kw'>end</span>
|
532
|
+
|
533
|
+
<span class='kw'>def</span> <span class='id initialize_defaults'>initialize_defaults</span>
|
534
|
+
<span class='id assembled_default_parameter_collection'>assembled_default_parameter_collection</span><span class='period'>.</span><span class='id reverse'>reverse</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id option'>option</span><span class='op'>|</span>
|
535
|
+
<span class='comment'>#puts ">> updating default on: #{self} for: #{option[:name]} with: #{option[:value]}"
|
536
|
+
</span> <span class='kw'>self</span><span class='period'>.</span><span class='id send'>send</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id option'>option</span><span class='lbracket'>[</span><span class='symbol'>:name</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id option'>option</span><span class='lbracket'>[</span><span class='symbol'>:value</span><span class='rbracket'>]</span>
|
537
|
+
<span class='kw'>end</span>
|
538
|
+
<span class='kw'>end</span>
|
539
|
+
|
540
|
+
<span class='kw'>def</span> <span class='id assembled_parameter_collection'>assembled_parameter_collection</span>
|
541
|
+
<span class='id assembled_static_collection'>assembled_static_collection</span> <span class='symbol'>:static_parameter_collection</span>
|
542
|
+
<span class='kw'>end</span>
|
543
|
+
|
544
|
+
<span class='kw'>def</span> <span class='id assembled_default_parameter_collection'>assembled_default_parameter_collection</span>
|
545
|
+
<span class='id assembled_static_collection'>assembled_static_collection</span> <span class='symbol'>:static_default_value_collection</span>
|
546
|
+
<span class='kw'>end</span>
|
547
|
+
|
548
|
+
<span class='kw'>def</span> <span class='id assembled_static_collection'>assembled_static_collection</span> <span class='id collection_name'>collection_name</span>
|
549
|
+
<span class='id collection'>collection</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
550
|
+
<span class='id inheritance_chain'>inheritance_chain</span><span class='period'>.</span><span class='id reverse'>reverse</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id clazz'>clazz</span><span class='op'>|</span>
|
551
|
+
<span class='kw'>if</span><span class='lparen'>(</span><span class='id clazz'>clazz</span><span class='period'>.</span><span class='id respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='id collection_name'>collection_name</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
552
|
+
<span class='id collection'>collection</span><span class='period'>.</span><span class='id concat'>concat</span> <span class='id clazz'>clazz</span><span class='period'>.</span><span class='id send'>send</span><span class='lparen'>(</span><span class='id collection_name'>collection_name</span><span class='rparen'>)</span>
|
553
|
+
<span class='kw'>end</span>
|
554
|
+
<span class='kw'>end</span>
|
555
|
+
<span class='id collection'>collection</span>
|
556
|
+
<span class='kw'>end</span>
|
557
|
+
|
558
|
+
<span class='kw'>def</span> <span class='id inheritance_chain'>inheritance_chain</span>
|
559
|
+
<span class='id chain'>chain</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
560
|
+
<span class='id clazz'>clazz</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id class'>class</span>
|
561
|
+
<span class='kw'>while</span> <span class='id clazz'>clazz</span> <span class='kw'>do</span>
|
562
|
+
<span class='id chain'>chain</span> <span class='op'><<</span> <span class='id clazz'>clazz</span>
|
563
|
+
<span class='id clazz'>clazz</span> <span class='op'>=</span> <span class='id clazz'>clazz</span><span class='period'>.</span><span class='id superclass'>superclass</span>
|
564
|
+
<span class='kw'>end</span>
|
565
|
+
<span class='id chain'>chain</span>
|
566
|
+
<span class='kw'>end</span>
|
567
|
+
|
568
|
+
<span class='kw'>def</span> <span class='id add_help_param'>add_help_param</span>
|
569
|
+
<span class='id option_parser'>option_parser</span><span class='period'>.</span><span class='id on'>on</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>--help</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Display this help message</span><span class='tstring_end'>'</span></span> <span class='kw'>do</span>
|
570
|
+
<span class='id puts'>puts</span> <span class='id option_parser'>option_parser</span><span class='period'>.</span><span class='id to_s'>to_s</span>
|
571
|
+
<span class='id exit'>exit</span>
|
572
|
+
<span class='kw'>end</span>
|
573
|
+
<span class='kw'>end</span>
|
574
|
+
|
575
|
+
<span class='kw'>def</span> <span class='id initialize_parameter'>initialize_parameter</span> <span class='id declaration'>declaration</span>
|
576
|
+
<span class='id name'>name</span> <span class='op'>=</span> <span class='id declaration'>declaration</span><span class='lbracket'>[</span><span class='symbol'>:name</span><span class='rbracket'>]</span>
|
577
|
+
<span class='id name_s'>name_s</span> <span class='op'>=</span> <span class='id name'>name</span><span class='period'>.</span><span class='id to_s'>to_s</span>
|
578
|
+
<span class='id type'>type</span> <span class='op'>=</span> <span class='id declaration'>declaration</span><span class='lbracket'>[</span><span class='symbol'>:type</span><span class='rbracket'>]</span>
|
579
|
+
|
580
|
+
<span class='comment'># First ensure the named accessor doesn't yet exist...
|
581
|
+
</span> <span class='kw'>if</span><span class='lparen'>(</span><span class='id parameter_hash_includes?'>parameter_hash_includes?</span> <span class='id name'>name</span><span class='rparen'>)</span>
|
582
|
+
<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'>ExecutableError</span><span class='period'>.</span><span class='id new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>ToolTask.add_param called with existing parameter name: </span><span class='embexpr_beg'>#{</span><span class='id name_s'>name_s</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
583
|
+
<span class='kw'>end</span>
|
584
|
+
|
585
|
+
<span class='id create_parameter'>create_parameter</span> <span class='id declaration'>declaration</span>
|
586
|
+
<span class='kw'>end</span>
|
587
|
+
|
588
|
+
<span class='kw'>def</span> <span class='id create_parameter'>create_parameter</span> <span class='id declaration'>declaration</span>
|
589
|
+
<span class='id param'>param</span> <span class='op'>=</span> <span class='const'>ParameterFactory</span><span class='period'>.</span><span class='id create'>create</span> <span class='id declaration'>declaration</span><span class='lbracket'>[</span><span class='symbol'>:type</span><span class='rbracket'>]</span>
|
590
|
+
<span class='id param'>param</span><span class='period'>.</span><span class='id belongs_to'>belongs_to</span> <span class='op'>=</span> <span class='kw'>self</span>
|
591
|
+
|
592
|
+
<span class='kw'>begin</span>
|
593
|
+
<span class='id declaration'>declaration</span><span class='period'>.</span><span class='id each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id key'>key</span><span class='comma'>,</span> <span class='id value'>value</span><span class='op'>|</span>
|
594
|
+
<span class='id param'>param</span><span class='period'>.</span><span class='id send'>send</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id key'>key</span><span class='rbrace'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id value'>value</span>
|
595
|
+
<span class='kw'>end</span>
|
596
|
+
<span class='kw'>rescue</span> <span class='const'>ArgumentError</span>
|
597
|
+
<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'>UsageError</span><span class='period'>.</span><span class='id new'>new</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Unexpected parameter option encountered with: </span><span class='embexpr_beg'>#{</span><span class='id key'>key</span><span class='rbrace'>}</span><span class='tstring_content'> and value: </span><span class='embexpr_beg'>#{</span><span class='id value'>value</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
598
|
+
<span class='kw'>end</span>
|
599
|
+
|
600
|
+
<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'>UsageError</span><span class='period'>.</span><span class='id new'>new</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Parameter name is required</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span><span class='lparen'>(</span><span class='id param'>param</span><span class='period'>.</span><span class='id name'>name</span><span class='period'>.</span><span class='id nil?'>nil?</span><span class='rparen'>)</span>
|
601
|
+
|
602
|
+
<span class='id param_hash'>param_hash</span><span class='lbracket'>[</span><span class='id param'>param</span><span class='period'>.</span><span class='id name'>name</span><span class='period'>.</span><span class='id to_sym'>to_sym</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id param'>param</span>
|
603
|
+
<span class='id params'>params</span> <span class='op'><<</span> <span class='id param'>param</span>
|
604
|
+
|
605
|
+
<span class='comment'># Expose this parameter to command line arguments:
|
606
|
+
</span> <span class='comment'>#add_commandline_param param
|
607
|
+
</span>
|
608
|
+
<span class='id param'>param</span>
|
609
|
+
<span class='kw'>end</span>
|
610
|
+
|
611
|
+
<span class='kw'>def</span> <span class='id parameter_hash_includes?'>parameter_hash_includes?</span> <span class='id name'>name</span>
|
612
|
+
<span class='id param_hash'>param_hash</span><span class='period'>.</span><span class='id has_key?'>has_key?</span> <span class='id name'>name</span><span class='period'>.</span><span class='id to_sym'>to_sym</span>
|
613
|
+
<span class='kw'>end</span>
|
614
|
+
|
615
|
+
<span class='kw'>def</span> <span class='id validate'>validate</span>
|
616
|
+
<span class='id params'>params</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id param'>param</span><span class='op'>|</span>
|
617
|
+
<span class='id param'>param</span><span class='period'>.</span><span class='id validate'>validate</span>
|
618
|
+
<span class='kw'>end</span>
|
619
|
+
<span class='kw'>end</span>
|
620
|
+
|
621
|
+
<span class='kw'>def</span> <span class='id option_parser'>option_parser</span>
|
622
|
+
<span class='ivar'>@option_parser</span>
|
623
|
+
<span class='kw'>end</span>
|
624
|
+
|
625
|
+
<span class='kw'>end</span>
|
626
|
+
<span class='kw'>end</span></pre>
|
627
|
+
|
628
|
+
<p>end</p>
|
629
|
+
</div></div>
|
630
|
+
|
631
|
+
<div id="footer">
|
632
|
+
Generated on Wed Dec 22 11:58:32 2010 by
|
633
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
634
|
+
0.6.3 (ruby-1.9.2).
|
635
|
+
</div>
|
636
|
+
|
637
|
+
</body>
|
638
|
+
</html>
|