sprout 1.0.32.pre → 1.0.35.pre
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sprout might be problematic. Click here for more details.
- data/Gemfile +2 -1
- data/Gemfile.lock +4 -2
- data/README.textile +12 -13
- data/VERSION +1 -0
- data/doc/Dir.html +288 -0
- data/doc/Rake/Task.html +184 -0
- data/doc/Sprout.html +144 -0
- data/doc/Sprout/ArchiveUnpacker.html +1246 -0
- data/doc/Sprout/Base.html +126 -0
- data/doc/Sprout/Base/ClassMethods.html +434 -0
- data/doc/Sprout/Concern.html +353 -0
- data/doc/Sprout/Daemon.html +166 -0
- data/doc/Sprout/Daemon/ClassMethods.html +244 -0
- data/doc/Sprout/Daemon/InstanceMethods.html +601 -0
- data/doc/Sprout/Errors.html +101 -0
- data/doc/Sprout/Errors/ArchiveUnpackerError.html +125 -0
- data/doc/Sprout/Errors/DestinationExistsError.html +133 -0
- data/doc/Sprout/Errors/DuplicateMemberError.html +132 -0
- data/doc/Sprout/Errors/ExecutableError.html +125 -0
- data/doc/Sprout/Errors/ExecutableRegistrationError.html +132 -0
- data/doc/Sprout/Errors/ExecutionError.html +121 -0
- data/doc/Sprout/Errors/GeneratorError.html +125 -0
- data/doc/Sprout/Errors/InvalidArgumentError.html +132 -0
- data/doc/Sprout/Errors/LoadError.html +121 -0
- data/doc/Sprout/Errors/MissingArgumentError.html +132 -0
- data/doc/Sprout/Errors/MissingExecutableError.html +132 -0
- data/doc/Sprout/Errors/MissingGeneratorError.html +132 -0
- data/doc/Sprout/Errors/MissingTemplateError.html +132 -0
- data/doc/Sprout/Errors/ProcessRunnerError.html +121 -0
- data/doc/Sprout/Errors/RemoteFileLoaderError.html +110 -0
- data/doc/Sprout/Errors/SproutError.html +114 -0
- data/doc/Sprout/Errors/UnknownArchiveType.html +122 -0
- data/doc/Sprout/Errors/UsageError.html +121 -0
- data/doc/Sprout/Errors/ValidationError.html +121 -0
- data/doc/Sprout/Errors/VersionRequirementNotMetError.html +121 -0
- data/doc/Sprout/Executable.html +173 -0
- data/doc/Sprout/Executable/Boolean.html +483 -0
- data/doc/Sprout/Executable/ClassMethods.html +417 -0
- data/doc/Sprout/Executable/CollectionParam.html +483 -0
- data/doc/Sprout/Executable/FileParam.html +484 -0
- data/doc/Sprout/Executable/Files.html +292 -0
- data/doc/Sprout/Executable/InstanceMethods.html +2006 -0
- data/doc/Sprout/Executable/Number.html +141 -0
- data/doc/Sprout/Executable/Param.html +2818 -0
- data/doc/Sprout/Executable/ParameterFactory.html +232 -0
- data/doc/Sprout/Executable/Path.html +223 -0
- data/doc/Sprout/Executable/Paths.html +253 -0
- data/doc/Sprout/Executable/StringParam.html +213 -0
- data/doc/Sprout/Executable/Strings.html +167 -0
- data/doc/Sprout/Executable/Url.html +160 -0
- data/doc/Sprout/Executable/Urls.html +170 -0
- data/doc/Sprout/FileTarget.html +1109 -0
- data/doc/Sprout/Generator.html +689 -0
- data/doc/Sprout/Generator/Base.html +1626 -0
- data/doc/Sprout/Generator/Command.html +690 -0
- data/doc/Sprout/Generator/DirectoryManifest.html +476 -0
- data/doc/Sprout/Generator/FileManifest.html +572 -0
- data/doc/Sprout/Generator/Manifest.html +377 -0
- data/doc/Sprout/Generator/TemplateManifest.html +196 -0
- data/doc/Sprout/GeneratorGenerator.html +1018 -0
- data/doc/Sprout/Library.html +1141 -0
- data/doc/Sprout/LibraryGenerator.html +309 -0
- data/doc/Sprout/Log.html +496 -0
- data/doc/Sprout/MXMLC.html +6373 -0
- data/doc/Sprout/Platform.html +714 -0
- data/doc/Sprout/ProcessRunner.html +1352 -0
- data/doc/Sprout/ProgressBar.html +376 -0
- data/doc/Sprout/ProgressBarImpl.html +2119 -0
- data/doc/Sprout/ProgressBarManager.html +434 -0
- data/doc/Sprout/ProgressBarOutputStream.html +416 -0
- data/doc/Sprout/RDocParser.html +211 -0
- data/doc/Sprout/RemoteFileLoader.html +172 -0
- data/doc/Sprout/RemoteFileTarget.html +679 -0
- data/doc/Sprout/ReversedProgressBar.html +194 -0
- data/doc/Sprout/RubyFeature.html +155 -0
- data/doc/Sprout/RubyFeature/ClassMethods.html +1065 -0
- data/doc/Sprout/RubyGenerator.html +764 -0
- data/doc/Sprout/Specification.html +767 -0
- data/doc/Sprout/System.html +191 -0
- data/doc/Sprout/System/BaseSystem.html +1455 -0
- data/doc/Sprout/System/JavaSystem.html +122 -0
- data/doc/Sprout/System/OSXSystem.html +335 -0
- data/doc/Sprout/System/ThreadMock.html +193 -0
- data/doc/Sprout/System/UnixSystem.html +584 -0
- data/doc/Sprout/System/VistaSystem.html +251 -0
- data/doc/Sprout/System/WinNixSystem.html +325 -0
- data/doc/Sprout/System/WinSystem.html +571 -0
- data/doc/Sprout/ToolGenerator.html +931 -0
- data/doc/Sprout/VERSION.html +128 -0
- data/doc/SproutTestCase.html +1412 -0
- data/doc/String.html +286 -0
- data/doc/_index.html +1035 -0
- data/doc/class_list.html +36 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +53 -0
- data/doc/css/style.css +310 -0
- data/doc/file.README.html +96 -0
- data/doc/file.archive_unpacker.html +288 -0
- data/doc/file.base.html +208 -0
- data/doc/file.base_system.html +278 -0
- data/doc/file.boolean.html +135 -0
- data/doc/file.collection_param.html +139 -0
- data/doc/file.command.html +126 -0
- data/doc/file.concern.html +136 -0
- data/doc/file.daemon.html +309 -0
- data/doc/file.dir.html +76 -0
- data/doc/file.directory_manifest.html +122 -0
- data/doc/file.errors.html +147 -0
- data/doc/file.executable.html +638 -0
- data/doc/file.file_manifest.html +109 -0
- data/doc/file.file_param.html +120 -0
- data/doc/file.file_target.html +140 -0
- data/doc/file.files.html +85 -0
- data/doc/file.generator.html +296 -0
- data/doc/file.generator_class.html +72 -0
- data/doc/file.generator_generator.html +137 -0
- data/doc/file.generator_test.html +92 -0
- data/doc/file.generator_test_helper.html +67 -0
- data/doc/file.java_system.html +62 -0
- data/doc/file.library.html +291 -0
- data/doc/file.library_generator.html +74 -0
- data/doc/file.log.html +100 -0
- data/doc/file.manifest.html +67 -0
- data/doc/file.mxmlc.html +740 -0
- data/doc/file.number.html +67 -0
- data/doc/file.osx_system.html +79 -0
- data/doc/file.param.html +491 -0
- data/doc/file.parameter_factory.html +119 -0
- data/doc/file.path.html +81 -0
- data/doc/file.paths.html +80 -0
- data/doc/file.platform.html +124 -0
- data/doc/file.process_runner.html +224 -0
- data/doc/file.progress_bar.html +390 -0
- data/doc/file.rdoc_parser.html +145 -0
- data/doc/file.remote_file_loader.html +117 -0
- data/doc/file.remote_file_target.html +176 -0
- data/doc/file.ruby_base.html +64 -0
- data/doc/file.ruby_feature.html +244 -0
- data/doc/file.ruby_generator.html +118 -0
- data/doc/file.ruby_input.html +62 -0
- data/doc/file.ruby_test_case.html +78 -0
- data/doc/file.ruby_test_helper.html +61 -0
- data/doc/file.specification.html +248 -0
- data/doc/file.sprout.html +64 -0
- data/doc/file.sprout_test_case.html +280 -0
- data/doc/file.string.html +72 -0
- data/doc/file.string_param.html +76 -0
- data/doc/file.strings.html +71 -0
- data/doc/file.system.html +86 -0
- data/doc/file.template_manifest.html +67 -0
- data/doc/file.tool.html +92 -0
- data/doc/file.tool_generator.html +90 -0
- data/doc/file.unix_system.html +128 -0
- data/doc/file.url.html +71 -0
- data/doc/file.urls.html +70 -0
- data/doc/file.version.html +71 -0
- data/doc/file.vista_system.html +69 -0
- data/doc/file.win_nix_system.html +88 -0
- data/doc/file.win_system.html +129 -0
- data/doc/file_list.html +230 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +96 -0
- data/doc/js/app.js +202 -0
- data/doc/js/full_list.js +149 -0
- data/doc/js/jquery.js +154 -0
- data/doc/method_list.html +3355 -0
- data/doc/top-level-namespace.html +192 -0
- data/lib/sprout/archive_unpacker.rb +203 -137
- data/lib/sprout/base.rb +38 -11
- data/lib/sprout/concern.rb +51 -0
- data/lib/sprout/daemon.rb +256 -0
- data/lib/sprout/executable.rb +40 -11
- data/lib/sprout/executable/boolean.rb +47 -1
- data/lib/sprout/executable/collection_param.rb +33 -1
- data/lib/sprout/executable/file_param.rb +16 -3
- data/lib/sprout/executable/files.rb +5 -0
- data/lib/sprout/executable/number.rb +5 -1
- data/lib/sprout/executable/param.rb +232 -16
- data/lib/sprout/executable/parameter_factory.rb +39 -1
- data/lib/sprout/executable/path.rb +7 -1
- data/lib/sprout/executable/paths.rb +6 -1
- data/lib/sprout/executable/string_param.rb +8 -1
- data/lib/sprout/executable/strings.rb +7 -1
- data/lib/sprout/executable/url.rb +8 -1
- data/lib/sprout/executable/urls.rb +7 -1
- data/lib/sprout/file_target.rb +11 -11
- data/lib/sprout/generator.rb +244 -0
- data/lib/sprout/generator/base.rb +0 -94
- data/lib/sprout/generators/generator/generator_generator.rb +35 -1
- data/lib/sprout/generators/generator/templates/generator_class.rb +3 -3
- data/lib/sprout/library.rb +75 -0
- data/lib/sprout/log.rb +11 -12
- data/lib/sprout/process_runner.rb +29 -9
- data/lib/sprout/remote_file_target.rb +20 -9
- data/lib/sprout/system/base_system.rb +11 -3
- data/lib/sprout/test/sprout_test_case.rb +1 -0
- data/lib/sprout/version.rb +7 -11
- data/rakefile.rb +7 -12
- data/script/add_param_handler.rb +43 -0
- data/sprout.gemspec +2 -3
- data/test/fixtures/executable/fdb.rb +764 -0
- data/test/fixtures/executable/flex3sdk_gem/fdb +60 -0
- data/test/fixtures/executable/mxmlc.rb +9 -11
- data/test/unit/daemon_test.rb +61 -0
- data/test/unit/process_runner_test.rb +21 -0
- data/test/unit/remote_file_target_test.rb +45 -11
- data/test/unit/sprout_test_helper.rb +1 -1
- metadata +210 -29
@@ -0,0 +1,192 @@
|
|
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>Top Level Namespace</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">Index</a> »
|
27
|
+
|
28
|
+
|
29
|
+
<span class="title">Top Level Namespace</span>
|
30
|
+
|
31
|
+
|
32
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="search">
|
36
|
+
<a id="class_list_link" href="#">Class List</a>
|
37
|
+
<a id="method_list_link" href="#">Method List</a>
|
38
|
+
<a id ="file_list_link" href="#">File List</a>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div class="clear"></div>
|
42
|
+
</div>
|
43
|
+
|
44
|
+
<iframe id="search_frame"></iframe>
|
45
|
+
|
46
|
+
<div id="content"><h1>Top Level Namespace
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
</h1>
|
51
|
+
|
52
|
+
<dl class="box">
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
</dl>
|
62
|
+
<div class="clear"></div>
|
63
|
+
|
64
|
+
<h2>Defined Under Namespace</h2>
|
65
|
+
<p class="children">
|
66
|
+
|
67
|
+
|
68
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Sprout.html" title="Sprout (module)">Sprout</a></span>, <span class='object_link'><a href="SproutTestCase.html" title="SproutTestCase (module)">SproutTestCase</a></span>
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Dir.html" title="Dir (class)">Dir</a></span>, <span class='object_link'><a href="String.html" title="String (class)">String</a></span>
|
73
|
+
|
74
|
+
|
75
|
+
</p>
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
<h2>
|
81
|
+
Instance Method Summary
|
82
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
83
|
+
</h2>
|
84
|
+
|
85
|
+
<ul class="summary">
|
86
|
+
|
87
|
+
<li class="public ">
|
88
|
+
<span class="summary_signature">
|
89
|
+
|
90
|
+
<a href="#library-instance_method" title="#library (instance method)">- (Object) <strong>library</strong>(pkg_name, name = nil, version = nil) </a>
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
</span>
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
<span class="summary_desc"><div class='inline'>
|
104
|
+
<p>From within a Rakefile, you can load libraries by calling this method:.</p>
|
105
|
+
</div></span>
|
106
|
+
|
107
|
+
</li>
|
108
|
+
|
109
|
+
|
110
|
+
</ul>
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
<div id="instance_method_details" class="method_details_list">
|
116
|
+
<h2>Instance Method Details</h2>
|
117
|
+
|
118
|
+
|
119
|
+
<div class="method_details first">
|
120
|
+
<p class="signature first" id="library-instance_method">
|
121
|
+
|
122
|
+
- (<tt>Object</tt>) <strong>library</strong>(pkg_name, name = nil, version = nil)
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
</p><div class="docstring">
|
127
|
+
<div class="discussion">
|
128
|
+
|
129
|
+
<p>From within a Rakefile, you can load libraries by calling this method:</p>
|
130
|
+
|
131
|
+
<pre class="code"><span class='id library'>library</span> <span class='symbol'>:asunit4</span></pre>
|
132
|
+
|
133
|
+
<p>Or, if you would like to specify which registered library to pull from the
|
134
|
+
identified package (by name):</p>
|
135
|
+
|
136
|
+
<pre class="code"><span class='id library'>library</span> <span class='symbol'>:asunit4</span><span class='comma'>,</span> <span class='symbol'>:src</span></pre>
|
137
|
+
|
138
|
+
<p>Or, if you'd like to specify version requirements:</p>
|
139
|
+
|
140
|
+
<pre class="code"><span class='id library'>library</span> <span class='symbol'>:asunit4</span><span class='comma'>,</span> <span class='symbol'>:swc</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>>= 4.2.pre</span><span class='tstring_end'>'</span></span></pre>
|
141
|
+
|
142
|
+
<p>It's important to note that libraries must also be defined in your Gemfile
|
143
|
+
like:</p>
|
144
|
+
|
145
|
+
<pre class="code"><span class='id gem'>gem</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>asunit4</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>>= 4.2.pre</span><span class='tstring_end'>"</span></span></pre>
|
146
|
+
|
147
|
+
<p>Libraries are generally then added to compiler tasks as Rake dependencies
|
148
|
+
like:</p>
|
149
|
+
|
150
|
+
<pre class="code"><span class='id mxmlc'>mxmlc</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>bin/SomeRunner.swf</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='lbracket'>[</span><span class='symbol'>:asunit4</span><span class='rbracket'>]</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id t'>t</span><span class='op'>|</span>
|
151
|
+
<span class='id t'>t</span><span class='period'>.</span><span class='id input'>input</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>src/SomeRunner.as</span><span class='tstring_end'>'</span></span>
|
152
|
+
<span class='id t'>t</span><span class='period'>.</span><span class='id source_path'>source_path</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>test</span><span class='tstring_end'>'</span></span>
|
153
|
+
<span class='kw'>end</span></pre>
|
154
|
+
|
155
|
+
|
156
|
+
</div>
|
157
|
+
</div>
|
158
|
+
<div class="tags">
|
159
|
+
|
160
|
+
</div><table class="source_code">
|
161
|
+
<tr>
|
162
|
+
<td>
|
163
|
+
<pre class="lines">
|
164
|
+
|
165
|
+
|
166
|
+
251
|
167
|
+
252
|
168
|
+
253</pre>
|
169
|
+
</td>
|
170
|
+
<td>
|
171
|
+
<pre class="code"><span class="info file"># File 'lib/sprout/library.rb', line 251</span>
|
172
|
+
|
173
|
+
<span class='kw'>def</span> <span class='id library'>library</span> <span class='id pkg_name'>pkg_name</span><span class='comma'>,</span> <span class='id name'>name</span><span class='op'>=</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='id version'>version</span><span class='op'>=</span><span class='kw'>nil</span>
|
174
|
+
<span class='const'>Sprout</span><span class='op'>::</span><span class='const'>Library</span><span class='period'>.</span><span class='id define_task'>define_task</span> <span class='id name'>name</span><span class='comma'>,</span> <span class='id pkg_name'>pkg_name</span><span class='comma'>,</span> <span class='id version'>version</span>
|
175
|
+
<span class='kw'>end</span></pre>
|
176
|
+
</td>
|
177
|
+
</tr>
|
178
|
+
</table>
|
179
|
+
</div>
|
180
|
+
|
181
|
+
</div>
|
182
|
+
|
183
|
+
</div>
|
184
|
+
|
185
|
+
<div id="footer">
|
186
|
+
Generated on Wed Dec 22 11:58:37 2010 by
|
187
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
188
|
+
0.6.3 (ruby-1.9.2).
|
189
|
+
</div>
|
190
|
+
|
191
|
+
</body>
|
192
|
+
</html>
|
@@ -1,175 +1,241 @@
|
|
1
1
|
require 'zip/zip'
|
2
|
+
require 'sprout/version'
|
2
3
|
require 'archive/tar/minitar'
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
5
|
+
##
|
6
|
+
# Given a source, destination and archive type (or ability to infer it),
|
7
|
+
# unpack the provided archive.
|
8
|
+
#
|
9
|
+
# unpacker = Sprout::ArchiveUnpacker.new
|
10
|
+
# unpacker.unpack "Foo.zip", "unpacked/"
|
11
|
+
#
|
12
|
+
class Sprout::ArchiveUnpacker
|
13
|
+
|
14
|
+
##
|
15
|
+
# Unpack the provided +archive+ into the provided +destination+.
|
16
|
+
#
|
17
|
+
# If a +type+ is not provided, a type will be inferred from the file name suffix.
|
18
|
+
#
|
19
|
+
# @param archive [File] Path to the archive that will be unpacked (or copied)
|
20
|
+
# @param destination [Path] Path to the folder where unpacked files should be placed (or copied).
|
21
|
+
# @param type [Symbol] The type of the archive in cases where it can't be inferred
|
22
|
+
# from the name. Acceptable values are: :zip, :tgz, :swc, :exe or :rb
|
23
|
+
# @param clobber [Boolean] If the destination already contains the expected file(s),
|
24
|
+
# the unpacker will not run unless +clobber+ is true.
|
25
|
+
# @return [String] path to the unpacked files (usually same as destination).
|
26
|
+
# @raise Sprout::Errors::UnknownArchiveType If the archive type cannot be inferred and a valid type is not provided.
|
27
|
+
def unpack archive, destination, type=nil, clobber=nil
|
28
|
+
return unpack_zip(archive, destination, clobber) if is_zip?(archive, type)
|
29
|
+
return unpack_tgz(archive, destination, clobber) if is_tgz?(archive, type)
|
30
|
+
|
31
|
+
# This is definitely debatable, should we copy the file even if it's
|
32
|
+
# not an archive that we're about to unpack?
|
33
|
+
# If so, why would we only do this with some subset of file types?
|
34
|
+
# Opinions welcome here...
|
35
|
+
return copy_file(archive, destination, clobber) if is_copyable?(archive)
|
36
|
+
|
37
|
+
raise Sprout::Errors::UnknownArchiveType.new("Unsupported or unknown archive type encountered with: #{archive}")
|
38
|
+
end
|
24
39
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
40
|
+
##
|
41
|
+
# Unpack zip archives on any platform using whatever strategy is most
|
42
|
+
# efficient and reliable.
|
43
|
+
#
|
44
|
+
# @param archive [File] Path to the archive that will be unpacked.
|
45
|
+
# @param destination [Path] Path to the folder where unpacked files should be placed.
|
46
|
+
# @param clobber [Boolean] If the destination already contains the expected file(s),
|
47
|
+
# the unpacker will not run unless +clobber+ is true.
|
48
|
+
# @return [File] the file or directory that was created.
|
49
|
+
def unpack_zip archive, destination, clobber=nil
|
50
|
+
validate archive, destination
|
51
|
+
|
52
|
+
##
|
53
|
+
# As it turns out, the Rubyzip library corrupts
|
54
|
+
# binary files (like the Flash Player) on OSX and is also
|
55
|
+
# horribly slow for large archives (like the ~120MB Flex SDK)
|
56
|
+
# on all platforms.
|
57
|
+
if is_darwin?
|
58
|
+
unpack_zip_on_darwin archive, destination, clobber
|
59
|
+
else
|
60
|
+
Zip::ZipFile.open archive do |zipfile|
|
61
|
+
zipfile.each do |entry|
|
62
|
+
next if entry.name =~ /__MACOSX/ or entry.name =~ /\.DS_Store/
|
41
63
|
unpack_zip_entry entry, destination, clobber
|
42
|
-
end
|
43
64
|
end
|
44
65
|
end
|
45
66
|
end
|
67
|
+
end
|
46
68
|
|
47
|
-
|
48
|
-
|
49
|
-
|
69
|
+
##
|
70
|
+
# Return true if we're on a Darwin native system (OSX).
|
71
|
+
# @return [Boolean]
|
72
|
+
def is_darwin?
|
73
|
+
Sprout.current_system.is_a?(Sprout::System::OSXSystem)
|
74
|
+
end
|
50
75
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
76
|
+
##
|
77
|
+
# Optimization for zip files on OSX. Uses the native
|
78
|
+
# 'unzip' utility which is much faster (and more reliable)
|
79
|
+
# than Ruby for large archives (like the Flex SDK) and
|
80
|
+
# binaries that Ruby corrupts (like the Flash Player).
|
81
|
+
#
|
82
|
+
# @return [File] the file or directory that was created.
|
83
|
+
def unpack_zip_on_darwin archive, destination, clobber
|
84
|
+
# Unzipping on OS X
|
85
|
+
FileUtils.makedirs destination
|
86
|
+
zip_dir = File.expand_path File.dirname(archive)
|
87
|
+
zip_name = File.basename archive
|
88
|
+
output = File.expand_path destination
|
89
|
+
# puts ">> zip_dir: #{zip_dir} zip_name: #{zip_name} output: #{output}"
|
90
|
+
%x(cd #{zip_dir};unzip #{zip_name} -d #{output})
|
91
|
+
end
|
60
92
|
|
61
|
-
|
62
|
-
|
63
|
-
|
93
|
+
##
|
94
|
+
# Unpack tar.gz or .tgz files on any platform.
|
95
|
+
#
|
96
|
+
# @return [File] the file or directory that was created.
|
97
|
+
def unpack_tgz archive, destination, clobber=nil
|
98
|
+
validate archive, destination
|
64
99
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
100
|
+
tar = Zlib::GzipReader.new(File.open(archive, 'rb'))
|
101
|
+
if(!should_unpack_tgz?(destination, clobber))
|
102
|
+
raise Sprout::Errors::DestinationExistsError.new "Unable to unpack #{archive} into #{destination} without explicit :clobber argument"
|
103
|
+
end
|
69
104
|
|
70
|
-
|
105
|
+
Archive::Tar::Minitar.unpack(tar, destination)
|
71
106
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
107
|
+
# Recurse and unpack gzipped children (Adobe did this double
|
108
|
+
# gzip with the Linux FlashPlayer for some weird reason)
|
109
|
+
["#{destination}/**/*.tgz", "#{destination}/**/*.tar.gz"].each do |pattern|
|
110
|
+
Dir.glob(pattern).each do |child|
|
111
|
+
if(child != archive && dir != File.dirname(child))
|
112
|
+
unpack_tgz(child, File.dirname(child))
|
79
113
|
end
|
80
114
|
end
|
81
115
|
end
|
116
|
+
end
|
82
117
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
end
|
118
|
+
##
|
119
|
+
# Rather than unpacking, safely copy the file from one location
|
120
|
+
# to another.
|
121
|
+
# This method is generally used when .exe files are downloaded
|
122
|
+
# directly.
|
123
|
+
#
|
124
|
+
# @return [File] the file or directory that was created.
|
125
|
+
def copy_file file, destination, clobber=nil
|
126
|
+
validate file, destination
|
127
|
+
target = File.expand_path( File.join(destination, File.basename(file)) )
|
128
|
+
if(File.exists?(target) && clobber != :clobber)
|
129
|
+
raise Sprout::Errors::DestinationExistsError.new "Unable to copy #{file} to #{target} because target already exists and we were not asked to :clobber it"
|
130
|
+
end
|
131
|
+
FileUtils.mkdir_p destination
|
132
|
+
FileUtils.cp_r file, destination
|
133
|
+
|
134
|
+
destination
|
135
|
+
end
|
96
136
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
137
|
+
##
|
138
|
+
# Returns true if the provided file name looks like a zip file or the +type+ argument is +:zip+.
|
139
|
+
# @return [Boolean]
|
140
|
+
def is_zip? archive, type=nil
|
141
|
+
type == :zip || !archive.match(/\.zip$/).nil?
|
142
|
+
end
|
101
143
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
144
|
+
##
|
145
|
+
# Return true if the provided file name looks like a tar.gz file or the +type+ argument is +:tgz+.
|
146
|
+
# @return [Boolean]
|
147
|
+
def is_tgz? archive, type=nil
|
148
|
+
type == :tgz || !archive.match(/\.tgz$/).nil? || !archive.match(/\.tar.gz$/).nil?
|
149
|
+
end
|
106
150
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
end
|
151
|
+
##
|
152
|
+
# Return true if the downloaded archive is a .exe file or the +type+ argument is +:exe+.
|
153
|
+
# @return [Boolean]
|
154
|
+
def is_exe? archive, type=nil
|
155
|
+
type == :exe || !archive.match(/\.exe$/).nil?
|
156
|
+
end
|
114
157
|
|
115
|
-
|
116
|
-
|
117
|
-
|
158
|
+
##
|
159
|
+
# Return true if the downloaded archive is a .swc file or the +type+ argument is +:swc+.
|
160
|
+
# @return [Boolean]
|
161
|
+
def is_swc? archive, type=nil
|
162
|
+
type == :swc || !archive.match(/\.swc$/).nil?
|
163
|
+
end
|
118
164
|
|
119
|
-
|
165
|
+
##
|
166
|
+
# Return true if the downloaded archive is a .rb file or the +type+ argument is +:rb+.
|
167
|
+
# @return [Boolean]
|
168
|
+
def is_rb? archive, type=nil
|
169
|
+
type == :rb || !archive.match(/\.rb$/).nil?
|
170
|
+
end
|
120
171
|
|
121
|
-
|
122
|
-
(is_exe?(archive) || is_swc?(archive) || is_rb?(archive))
|
123
|
-
end
|
172
|
+
private
|
124
173
|
|
125
|
-
|
126
|
-
|
174
|
+
##
|
175
|
+
# Return true if the provided archive should be copied as-is, rather
|
176
|
+
# than being unpacked first.
|
177
|
+
# @return [Boolean]
|
178
|
+
def is_copyable? archive
|
179
|
+
(is_exe?(archive) || is_swc?(archive) || is_rb?(archive))
|
180
|
+
end
|
127
181
|
|
128
|
-
|
182
|
+
##
|
183
|
+
# Return true if the tgz should be unpacked.
|
184
|
+
# @return [Boolean]
|
185
|
+
def should_unpack_tgz? dir, clobber=nil
|
186
|
+
return !directory_has_children?(dir) || clobber == :clobber
|
129
187
|
|
130
|
-
|
131
|
-
(Dir.entries(dir) - ['.', '..']).size > 0
|
132
|
-
end
|
188
|
+
end
|
133
189
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
190
|
+
##
|
191
|
+
# Return true if the provided directory has one or more chidren.
|
192
|
+
# @return [Boolean]
|
193
|
+
def directory_has_children? dir
|
194
|
+
(Dir.entries(dir) - ['.', '..']).size > 0
|
195
|
+
end
|
138
196
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
197
|
+
##
|
198
|
+
# @return [Boolean] true if the +archive+ and +destination+ exist.
|
199
|
+
# @raise Sprout::Errors::ArchiveUnpackerError if the +archive+ or +destination+ don't exist.
|
200
|
+
def validate archive, destination
|
201
|
+
archive_message = "Archive could not be found at: #{archive}"
|
202
|
+
raise Sprout::Errors::ArchiveUnpackerError.new(archive_message) unless valid_path?(archive)
|
203
|
+
destination_message = "Destination could not be found at: #{destination}"
|
204
|
+
raise Sprout::Errors::ArchiveUnpackerError.new(destination_message) unless valid_path?(destination)
|
205
|
+
true
|
206
|
+
end
|
143
207
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
208
|
+
##
|
209
|
+
# @return [Boolean] true if the provided +path+ is not nil and exists on disk.
|
210
|
+
def valid_path? path
|
211
|
+
!path.nil? && File.exists?(path)
|
212
|
+
end
|
148
213
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
214
|
+
##
|
215
|
+
# Unpack an entry from a zip archive. This is an _inconvenience_ method
|
216
|
+
# thanks to the way Ruby zip handles zip archives.
|
217
|
+
def unpack_zip_entry entry, destination, clobber
|
218
|
+
# Ensure hidden mac files don't get written to disk:
|
219
|
+
path = File.join destination, entry.name
|
220
|
+
|
221
|
+
if entry.directory?
|
222
|
+
# If an archive has empty directories:
|
223
|
+
FileUtils.mkdir_p path
|
224
|
+
elsif entry.file?
|
225
|
+
# On Windows, we don't get the entry for
|
226
|
+
# each parent directory:
|
227
|
+
FileUtils.mkdir_p File.dirname(path)
|
228
|
+
begin
|
229
|
+
entry.extract path
|
230
|
+
rescue Zip::ZipDestinationFileExistsError => zip_dest_error
|
231
|
+
if(clobber == :clobber)
|
232
|
+
FileUtils.rm_rf path
|
161
233
|
entry.extract path
|
162
|
-
|
163
|
-
|
164
|
-
FileUtils.rm_rf path
|
165
|
-
entry.extract path
|
166
|
-
else
|
167
|
-
raise Sprout::Errors::DestinationExistsError.new zip_dest_error.message
|
168
|
-
end
|
234
|
+
else
|
235
|
+
raise Sprout::Errors::DestinationExistsError.new zip_dest_error.message
|
169
236
|
end
|
170
237
|
end
|
171
238
|
end
|
172
|
-
|
173
239
|
end
|
174
240
|
end
|
175
241
|
|