sprout 1.0.35.pre → 1.1.2.pre

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sprout might be problematic. Click here for more details.

Files changed (234) hide show
  1. data/Gemfile +1 -1
  2. data/Gemfile.lock +0 -2
  3. data/README.textile +1 -1
  4. data/VERSION +1 -1
  5. data/lib/sprout/concern.rb +5 -7
  6. data/lib/sprout/daemon.rb +183 -143
  7. data/lib/sprout/executable/base.rb +564 -0
  8. data/lib/sprout/executable.rb +1 -550
  9. data/lib/sprout/generator/base.rb +2 -3
  10. data/lib/sprout/generator.rb +2 -1
  11. data/lib/sprout/generators/ruby/templates/ruby_base.rb +1 -2
  12. data/lib/sprout/library.rb +3 -3
  13. data/lib/sprout/output_buffer.rb +35 -0
  14. data/lib/sprout/process_runner.rb +68 -17
  15. data/lib/sprout/progress_bar.rb +5 -5
  16. data/lib/sprout/remote_file_target.rb +1 -1
  17. data/lib/sprout/system/base_system.rb +3 -3
  18. data/lib/sprout/system/unix_system.rb +1 -1
  19. data/lib/sprout/{test/sprout_test_case.rb → test_helper.rb} +214 -14
  20. data/lib/sprout/version.rb +1 -1
  21. data/lib/sprout.rb +133 -2
  22. data/rakefile.rb +2 -0
  23. data/test/fixtures/examples/echo_inputs.rb +1 -2
  24. data/test/fixtures/executable/fdb.rb +7 -9
  25. data/test/fixtures/executable/flex3sdk_gem/fdb +49 -18
  26. data/test/fixtures/executable/mxmlc.rb +1 -2
  27. data/test/fixtures/executable/subclass/executable_subclass.rb +0 -1
  28. data/test/fixtures/executable/subclass/executable_superclass.rb +1 -2
  29. data/test/fixtures/specification/flex4sdk.rb +35 -24
  30. data/test/unit/archive_unpacker_test.rb +1 -1
  31. data/test/unit/boolean_param_test.rb +1 -1
  32. data/test/unit/daemon_test.rb +35 -3
  33. data/test/unit/executable_option_parser_test.rb +2 -3
  34. data/test/unit/executable_param_test.rb +1 -1
  35. data/test/unit/executable_test.rb +8 -15
  36. data/test/unit/fake_other_executable.rb +1 -2
  37. data/test/unit/file_param_test.rb +1 -1
  38. data/test/unit/file_target_test.rb +1 -1
  39. data/test/unit/files_param_test.rb +1 -1
  40. data/test/unit/generator_generator_test.rb +1 -1
  41. data/test/unit/generator_test.rb +1 -1
  42. data/test/unit/library_generator_test.rb +1 -1
  43. data/test/unit/library_test.rb +1 -1
  44. data/test/unit/osx_system_test.rb +1 -1
  45. data/test/unit/path_param_test.rb +1 -1
  46. data/test/unit/paths_param_test.rb +1 -1
  47. data/test/unit/platform_test.rb +1 -1
  48. data/test/unit/process_runner_test.rb +1 -1
  49. data/test/unit/rdoc_parser_test.rb +1 -1
  50. data/test/unit/remote_file_loader_test.rb +1 -1
  51. data/test/unit/remote_file_target_test.rb +1 -1
  52. data/test/unit/ruby_feature_test.rb +1 -1
  53. data/test/unit/ruby_generator_test.rb +1 -1
  54. data/test/unit/specification_test.rb +8 -1
  55. data/test/unit/sprout_test.rb +2 -2
  56. data/test/unit/string_param_test.rb +1 -1
  57. data/test/unit/string_test.rb +1 -1
  58. data/test/unit/strings_param_test.rb +1 -1
  59. data/test/unit/test_helper.rb +33 -1
  60. data/test/unit/tool_generator_test.rb +1 -1
  61. data/test/unit/unix_system_test.rb +1 -1
  62. data/test/unit/user_test.rb +1 -1
  63. data/test/unit/vista_system_test.rb +1 -1
  64. data/test/unit/win_nix_system_test.rb +1 -1
  65. data/test/unit/win_system_test.rb +1 -1
  66. data/test-stderr.log +1 -0
  67. data/test-stdout.log +237 -0
  68. metadata +15 -190
  69. data/doc/Dir.html +0 -288
  70. data/doc/Rake/Task.html +0 -184
  71. data/doc/Sprout/ArchiveUnpacker.html +0 -1246
  72. data/doc/Sprout/Base/ClassMethods.html +0 -434
  73. data/doc/Sprout/Base.html +0 -126
  74. data/doc/Sprout/Concern.html +0 -353
  75. data/doc/Sprout/Daemon/ClassMethods.html +0 -244
  76. data/doc/Sprout/Daemon/InstanceMethods.html +0 -601
  77. data/doc/Sprout/Daemon.html +0 -166
  78. data/doc/Sprout/Errors/ArchiveUnpackerError.html +0 -125
  79. data/doc/Sprout/Errors/DestinationExistsError.html +0 -133
  80. data/doc/Sprout/Errors/DuplicateMemberError.html +0 -132
  81. data/doc/Sprout/Errors/ExecutableError.html +0 -125
  82. data/doc/Sprout/Errors/ExecutableRegistrationError.html +0 -132
  83. data/doc/Sprout/Errors/ExecutionError.html +0 -121
  84. data/doc/Sprout/Errors/GeneratorError.html +0 -125
  85. data/doc/Sprout/Errors/InvalidArgumentError.html +0 -132
  86. data/doc/Sprout/Errors/LoadError.html +0 -121
  87. data/doc/Sprout/Errors/MissingArgumentError.html +0 -132
  88. data/doc/Sprout/Errors/MissingExecutableError.html +0 -132
  89. data/doc/Sprout/Errors/MissingGeneratorError.html +0 -132
  90. data/doc/Sprout/Errors/MissingTemplateError.html +0 -132
  91. data/doc/Sprout/Errors/ProcessRunnerError.html +0 -121
  92. data/doc/Sprout/Errors/RemoteFileLoaderError.html +0 -110
  93. data/doc/Sprout/Errors/SproutError.html +0 -114
  94. data/doc/Sprout/Errors/UnknownArchiveType.html +0 -122
  95. data/doc/Sprout/Errors/UsageError.html +0 -121
  96. data/doc/Sprout/Errors/ValidationError.html +0 -121
  97. data/doc/Sprout/Errors/VersionRequirementNotMetError.html +0 -121
  98. data/doc/Sprout/Errors.html +0 -101
  99. data/doc/Sprout/Executable/Boolean.html +0 -483
  100. data/doc/Sprout/Executable/ClassMethods.html +0 -417
  101. data/doc/Sprout/Executable/CollectionParam.html +0 -483
  102. data/doc/Sprout/Executable/FileParam.html +0 -484
  103. data/doc/Sprout/Executable/Files.html +0 -292
  104. data/doc/Sprout/Executable/InstanceMethods.html +0 -2006
  105. data/doc/Sprout/Executable/Number.html +0 -141
  106. data/doc/Sprout/Executable/Param.html +0 -2818
  107. data/doc/Sprout/Executable/ParameterFactory.html +0 -232
  108. data/doc/Sprout/Executable/Path.html +0 -223
  109. data/doc/Sprout/Executable/Paths.html +0 -253
  110. data/doc/Sprout/Executable/StringParam.html +0 -213
  111. data/doc/Sprout/Executable/Strings.html +0 -167
  112. data/doc/Sprout/Executable/Url.html +0 -160
  113. data/doc/Sprout/Executable/Urls.html +0 -170
  114. data/doc/Sprout/Executable.html +0 -173
  115. data/doc/Sprout/FileTarget.html +0 -1109
  116. data/doc/Sprout/Generator/Base.html +0 -1626
  117. data/doc/Sprout/Generator/Command.html +0 -690
  118. data/doc/Sprout/Generator/DirectoryManifest.html +0 -476
  119. data/doc/Sprout/Generator/FileManifest.html +0 -572
  120. data/doc/Sprout/Generator/Manifest.html +0 -377
  121. data/doc/Sprout/Generator/TemplateManifest.html +0 -196
  122. data/doc/Sprout/Generator.html +0 -689
  123. data/doc/Sprout/GeneratorGenerator.html +0 -1018
  124. data/doc/Sprout/Library.html +0 -1141
  125. data/doc/Sprout/LibraryGenerator.html +0 -309
  126. data/doc/Sprout/Log.html +0 -496
  127. data/doc/Sprout/MXMLC.html +0 -6373
  128. data/doc/Sprout/Platform.html +0 -714
  129. data/doc/Sprout/ProcessRunner.html +0 -1352
  130. data/doc/Sprout/ProgressBar.html +0 -376
  131. data/doc/Sprout/ProgressBarImpl.html +0 -2119
  132. data/doc/Sprout/ProgressBarManager.html +0 -434
  133. data/doc/Sprout/ProgressBarOutputStream.html +0 -416
  134. data/doc/Sprout/RDocParser.html +0 -211
  135. data/doc/Sprout/RemoteFileLoader.html +0 -172
  136. data/doc/Sprout/RemoteFileTarget.html +0 -679
  137. data/doc/Sprout/ReversedProgressBar.html +0 -194
  138. data/doc/Sprout/RubyFeature/ClassMethods.html +0 -1065
  139. data/doc/Sprout/RubyFeature.html +0 -155
  140. data/doc/Sprout/RubyGenerator.html +0 -764
  141. data/doc/Sprout/Specification.html +0 -767
  142. data/doc/Sprout/System/BaseSystem.html +0 -1455
  143. data/doc/Sprout/System/JavaSystem.html +0 -122
  144. data/doc/Sprout/System/OSXSystem.html +0 -335
  145. data/doc/Sprout/System/ThreadMock.html +0 -193
  146. data/doc/Sprout/System/UnixSystem.html +0 -584
  147. data/doc/Sprout/System/VistaSystem.html +0 -251
  148. data/doc/Sprout/System/WinNixSystem.html +0 -325
  149. data/doc/Sprout/System/WinSystem.html +0 -571
  150. data/doc/Sprout/System.html +0 -191
  151. data/doc/Sprout/ToolGenerator.html +0 -931
  152. data/doc/Sprout/VERSION.html +0 -128
  153. data/doc/Sprout.html +0 -144
  154. data/doc/SproutTestCase.html +0 -1412
  155. data/doc/String.html +0 -286
  156. data/doc/_index.html +0 -1035
  157. data/doc/class_list.html +0 -36
  158. data/doc/css/common.css +0 -1
  159. data/doc/css/full_list.css +0 -53
  160. data/doc/css/style.css +0 -310
  161. data/doc/file.README.html +0 -96
  162. data/doc/file.archive_unpacker.html +0 -288
  163. data/doc/file.base.html +0 -208
  164. data/doc/file.base_system.html +0 -278
  165. data/doc/file.boolean.html +0 -135
  166. data/doc/file.collection_param.html +0 -139
  167. data/doc/file.command.html +0 -126
  168. data/doc/file.concern.html +0 -136
  169. data/doc/file.daemon.html +0 -309
  170. data/doc/file.dir.html +0 -76
  171. data/doc/file.directory_manifest.html +0 -122
  172. data/doc/file.errors.html +0 -147
  173. data/doc/file.executable.html +0 -638
  174. data/doc/file.file_manifest.html +0 -109
  175. data/doc/file.file_param.html +0 -120
  176. data/doc/file.file_target.html +0 -140
  177. data/doc/file.files.html +0 -85
  178. data/doc/file.generator.html +0 -296
  179. data/doc/file.generator_class.html +0 -72
  180. data/doc/file.generator_generator.html +0 -137
  181. data/doc/file.generator_test.html +0 -92
  182. data/doc/file.generator_test_helper.html +0 -67
  183. data/doc/file.java_system.html +0 -62
  184. data/doc/file.library.html +0 -291
  185. data/doc/file.library_generator.html +0 -74
  186. data/doc/file.log.html +0 -100
  187. data/doc/file.manifest.html +0 -67
  188. data/doc/file.mxmlc.html +0 -740
  189. data/doc/file.number.html +0 -67
  190. data/doc/file.osx_system.html +0 -79
  191. data/doc/file.param.html +0 -491
  192. data/doc/file.parameter_factory.html +0 -119
  193. data/doc/file.path.html +0 -81
  194. data/doc/file.paths.html +0 -80
  195. data/doc/file.platform.html +0 -124
  196. data/doc/file.process_runner.html +0 -224
  197. data/doc/file.progress_bar.html +0 -390
  198. data/doc/file.rdoc_parser.html +0 -145
  199. data/doc/file.remote_file_loader.html +0 -117
  200. data/doc/file.remote_file_target.html +0 -176
  201. data/doc/file.ruby_base.html +0 -64
  202. data/doc/file.ruby_feature.html +0 -244
  203. data/doc/file.ruby_generator.html +0 -118
  204. data/doc/file.ruby_input.html +0 -62
  205. data/doc/file.ruby_test_case.html +0 -78
  206. data/doc/file.ruby_test_helper.html +0 -61
  207. data/doc/file.specification.html +0 -248
  208. data/doc/file.sprout.html +0 -64
  209. data/doc/file.sprout_test_case.html +0 -280
  210. data/doc/file.string.html +0 -72
  211. data/doc/file.string_param.html +0 -76
  212. data/doc/file.strings.html +0 -71
  213. data/doc/file.system.html +0 -86
  214. data/doc/file.template_manifest.html +0 -67
  215. data/doc/file.tool.html +0 -92
  216. data/doc/file.tool_generator.html +0 -90
  217. data/doc/file.unix_system.html +0 -128
  218. data/doc/file.url.html +0 -71
  219. data/doc/file.urls.html +0 -70
  220. data/doc/file.version.html +0 -71
  221. data/doc/file.vista_system.html +0 -69
  222. data/doc/file.win_nix_system.html +0 -88
  223. data/doc/file.win_system.html +0 -129
  224. data/doc/file_list.html +0 -230
  225. data/doc/frames.html +0 -13
  226. data/doc/index.html +0 -96
  227. data/doc/js/app.js +0 -202
  228. data/doc/js/full_list.js +0 -149
  229. data/doc/js/jquery.js +0 -154
  230. data/doc/method_list.html +0 -3355
  231. data/doc/top-level-namespace.html +0 -192
  232. data/lib/sprout/base.rb +0 -121
  233. data/lib/sprout/log.rb +0 -46
  234. data/test/unit/sprout_test_helper.rb +0 -33
@@ -1,1246 +0,0 @@
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>Class: Sprout::ArchiveUnpacker</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)</a> &raquo;
27
- <span class='title'><span class='object_link'><a href="../Sprout.html" title="Sprout (module)">Sprout</a></span></span>
28
- &raquo;
29
- <span class="title">ArchiveUnpacker</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>Class: Sprout::ArchiveUnpacker
47
-
48
-
49
-
50
- </h1>
51
-
52
- <dl class="box">
53
-
54
- <dt class="r1">Inherits:</dt>
55
- <dd class="r1">
56
- <span class="inheritName">Object</span>
57
-
58
- <ul class="fullTree">
59
- <li>Object</li>
60
-
61
- <li class="next">Sprout::ArchiveUnpacker</li>
62
-
63
- </ul>
64
- <a href="#" class="inheritanceTree">show all</a>
65
-
66
- </dd>
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
- <dt class="r2 last">Defined in:</dt>
77
- <dd class="r2 last">lib/sprout/archive_unpacker.rb</dd>
78
-
79
- </dl>
80
- <div class="clear"></div>
81
-
82
- <h2>Overview</h2><div class="docstring">
83
- <div class="discussion">
84
-
85
- <p>Given a source, destination and archive type (or ability to infer it),
86
- unpack the provided archive.</p>
87
-
88
- <pre class="code"><span class='id unpacker'>unpacker</span> <span class='op'>=</span> <span class='const'>Sprout</span><span class='op'>::</span><span class='const'>ArchiveUnpacker</span><span class='period'>.</span><span class='id new'>new</span>
89
- <span class='id unpacker'>unpacker</span><span class='period'>.</span><span class='id unpack'>unpack</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Foo.zip</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>unpacked/</span><span class='tstring_end'>&quot;</span></span></pre>
90
-
91
-
92
- </div>
93
- </div>
94
- <div class="tags">
95
-
96
- </div>
97
-
98
-
99
-
100
- <h2>
101
- Instance Method Summary
102
- <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
103
- </h2>
104
-
105
- <ul class="summary">
106
-
107
- <li class="public ">
108
- <span class="summary_signature">
109
-
110
- <a href="#copy_file-instance_method" title="#copy_file (instance method)">- (File) <strong>copy_file</strong>(file, destination, clobber = nil) </a>
111
-
112
-
113
-
114
- </span>
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
- <span class="summary_desc"><div class='inline'>
124
- <p>Rather than unpacking, safely copy the file from one location to another.</p>
125
- </div></span>
126
-
127
- </li>
128
-
129
-
130
- <li class="public ">
131
- <span class="summary_signature">
132
-
133
- <a href="#is_darwin%3F-instance_method" title="#is_darwin? (instance method)">- (Boolean) <strong>is_darwin?</strong> </a>
134
-
135
-
136
-
137
- </span>
138
-
139
-
140
-
141
-
142
-
143
-
144
-
145
-
146
- <span class="summary_desc"><div class='inline'>
147
- <p>Return true if we're on a Darwin native system (OSX).</p>
148
- </div></span>
149
-
150
- </li>
151
-
152
-
153
- <li class="public ">
154
- <span class="summary_signature">
155
-
156
- <a href="#is_exe%3F-instance_method" title="#is_exe? (instance method)">- (Boolean) <strong>is_exe?</strong>(archive, type = nil) </a>
157
-
158
-
159
-
160
- </span>
161
-
162
-
163
-
164
-
165
-
166
-
167
-
168
-
169
- <span class="summary_desc"><div class='inline'>
170
- <p>Return true if the downloaded archive is a .exe file or the <tt>type</tt>
171
- argument is <tt>:exe</tt>.</p>
172
- </div></span>
173
-
174
- </li>
175
-
176
-
177
- <li class="public ">
178
- <span class="summary_signature">
179
-
180
- <a href="#is_rb%3F-instance_method" title="#is_rb? (instance method)">- (Boolean) <strong>is_rb?</strong>(archive, type = nil) </a>
181
-
182
-
183
-
184
- </span>
185
-
186
-
187
-
188
-
189
-
190
-
191
-
192
-
193
- <span class="summary_desc"><div class='inline'>
194
- <p>Return true if the downloaded archive is a .rb file or the <tt>type</tt>
195
- argument is <tt>:rb</tt>.</p>
196
- </div></span>
197
-
198
- </li>
199
-
200
-
201
- <li class="public ">
202
- <span class="summary_signature">
203
-
204
- <a href="#is_swc%3F-instance_method" title="#is_swc? (instance method)">- (Boolean) <strong>is_swc?</strong>(archive, type = nil) </a>
205
-
206
-
207
-
208
- </span>
209
-
210
-
211
-
212
-
213
-
214
-
215
-
216
-
217
- <span class="summary_desc"><div class='inline'>
218
- <p>Return true if the downloaded archive is a .swc file or the <tt>type</tt>
219
- argument is <tt>:swc</tt>.</p>
220
- </div></span>
221
-
222
- </li>
223
-
224
-
225
- <li class="public ">
226
- <span class="summary_signature">
227
-
228
- <a href="#is_tgz%3F-instance_method" title="#is_tgz? (instance method)">- (Boolean) <strong>is_tgz?</strong>(archive, type = nil) </a>
229
-
230
-
231
-
232
- </span>
233
-
234
-
235
-
236
-
237
-
238
-
239
-
240
-
241
- <span class="summary_desc"><div class='inline'>
242
- <p>Return true if the provided file name looks like a tar.gz file or the
243
- <tt>type</tt> argument is <tt>:tgz</tt>.</p>
244
- </div></span>
245
-
246
- </li>
247
-
248
-
249
- <li class="public ">
250
- <span class="summary_signature">
251
-
252
- <a href="#is_zip%3F-instance_method" title="#is_zip? (instance method)">- (Boolean) <strong>is_zip?</strong>(archive, type = nil) </a>
253
-
254
-
255
-
256
- </span>
257
-
258
-
259
-
260
-
261
-
262
-
263
-
264
-
265
- <span class="summary_desc"><div class='inline'>
266
- <p>Returns true if the provided file name looks like a zip file or the
267
- <tt>type</tt> argument is <tt>:zip</tt>.</p>
268
- </div></span>
269
-
270
- </li>
271
-
272
-
273
- <li class="public ">
274
- <span class="summary_signature">
275
-
276
- <a href="#unpack-instance_method" title="#unpack (instance method)">- (String) <strong>unpack</strong>(archive, destination, type = nil, clobber = nil) </a>
277
-
278
-
279
-
280
- </span>
281
-
282
-
283
-
284
-
285
-
286
-
287
-
288
-
289
- <span class="summary_desc"><div class='inline'>
290
- <p>Unpack the provided <tt>archive</tt> into the provided
291
- <tt>destination</tt>.</p>
292
- </div></span>
293
-
294
- </li>
295
-
296
-
297
- <li class="public ">
298
- <span class="summary_signature">
299
-
300
- <a href="#unpack_tgz-instance_method" title="#unpack_tgz (instance method)">- (File) <strong>unpack_tgz</strong>(archive, destination, clobber = nil) </a>
301
-
302
-
303
-
304
- </span>
305
-
306
-
307
-
308
-
309
-
310
-
311
-
312
-
313
- <span class="summary_desc"><div class='inline'>
314
- <p>Unpack tar.gz or .tgz files on any platform.</p>
315
- </div></span>
316
-
317
- </li>
318
-
319
-
320
- <li class="public ">
321
- <span class="summary_signature">
322
-
323
- <a href="#unpack_zip-instance_method" title="#unpack_zip (instance method)">- (File) <strong>unpack_zip</strong>(archive, destination, clobber = nil) </a>
324
-
325
-
326
-
327
- </span>
328
-
329
-
330
-
331
-
332
-
333
-
334
-
335
-
336
- <span class="summary_desc"><div class='inline'>
337
- <p>Unpack zip archives on any platform using whatever strategy is most
338
- efficient and reliable.</p>
339
- </div></span>
340
-
341
- </li>
342
-
343
-
344
- <li class="public ">
345
- <span class="summary_signature">
346
-
347
- <a href="#unpack_zip_on_darwin-instance_method" title="#unpack_zip_on_darwin (instance method)">- (File) <strong>unpack_zip_on_darwin</strong>(archive, destination, clobber) </a>
348
-
349
-
350
-
351
- </span>
352
-
353
-
354
-
355
-
356
-
357
-
358
-
359
-
360
- <span class="summary_desc"><div class='inline'>
361
- <p>Optimization for zip files on OSX.</p>
362
- </div></span>
363
-
364
- </li>
365
-
366
-
367
- </ul>
368
-
369
-
370
-
371
-
372
- <div id="instance_method_details" class="method_details_list">
373
- <h2>Instance Method Details</h2>
374
-
375
-
376
- <div class="method_details first">
377
- <p class="signature first" id="copy_file-instance_method">
378
-
379
- - (<tt>File</tt>) <strong>copy_file</strong>(file, destination, clobber = nil)
380
-
381
-
382
-
383
- </p><div class="docstring">
384
- <div class="discussion">
385
-
386
- <p>Rather than unpacking, safely copy the file from one location to another.
387
- This method is generally used when .exe files are downloaded directly.</p>
388
-
389
-
390
- </div>
391
- </div>
392
- <div class="tags">
393
- <h3>Returns:</h3>
394
- <ul class="return">
395
-
396
- <li>
397
-
398
- <span class='type'>(<tt>File</tt>)</span>
399
-
400
-
401
-
402
-
403
- &mdash;
404
- <div class='inline'>
405
- <p>the file or directory that was created.</p>
406
- </div>
407
-
408
- </li>
409
-
410
- </ul>
411
-
412
- </div><table class="source_code">
413
- <tr>
414
- <td>
415
- <pre class="lines">
416
-
417
-
418
- 125
419
- 126
420
- 127
421
- 128
422
- 129
423
- 130
424
- 131
425
- 132
426
- 133
427
- 134
428
- 135</pre>
429
- </td>
430
- <td>
431
- <pre class="code"><span class="info file"># File 'lib/sprout/archive_unpacker.rb', line 125</span>
432
-
433
- <span class='kw'>def</span> <span class='id copy_file'>copy_file</span> <span class='id file'>file</span><span class='comma'>,</span> <span class='id destination'>destination</span><span class='comma'>,</span> <span class='id clobber'>clobber</span><span class='op'>=</span><span class='kw'>nil</span>
434
- <span class='id validate'>validate</span> <span class='id file'>file</span><span class='comma'>,</span> <span class='id destination'>destination</span>
435
- <span class='id target'>target</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id expand_path'>expand_path</span><span class='lparen'>(</span> <span class='const'>File</span><span class='period'>.</span><span class='id join'>join</span><span class='lparen'>(</span><span class='id destination'>destination</span><span class='comma'>,</span> <span class='const'>File</span><span class='period'>.</span><span class='id basename'>basename</span><span class='lparen'>(</span><span class='id file'>file</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='rparen'>)</span>
436
- <span class='kw'>if</span><span class='lparen'>(</span><span class='const'>File</span><span class='period'>.</span><span class='id exists?'>exists?</span><span class='lparen'>(</span><span class='id target'>target</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id clobber'>clobber</span> <span class='op'>!=</span> <span class='symbol'>:clobber</span><span class='rparen'>)</span>
437
- <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'>DestinationExistsError</span><span class='period'>.</span><span class='id new'>new</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Unable to copy </span><span class='embexpr_beg'>#{</span><span class='id file'>file</span><span class='rbrace'>}</span><span class='tstring_content'> to </span><span class='embexpr_beg'>#{</span><span class='id target'>target</span><span class='rbrace'>}</span><span class='tstring_content'> because target already exists and we were not asked to :clobber it</span><span class='tstring_end'>&quot;</span></span>
438
- <span class='kw'>end</span>
439
- <span class='const'>FileUtils</span><span class='period'>.</span><span class='id mkdir_p'>mkdir_p</span> <span class='id destination'>destination</span>
440
- <span class='const'>FileUtils</span><span class='period'>.</span><span class='id cp_r'>cp_r</span> <span class='id file'>file</span><span class='comma'>,</span> <span class='id destination'>destination</span>
441
-
442
- <span class='id destination'>destination</span>
443
- <span class='kw'>end</span></pre>
444
- </td>
445
- </tr>
446
- </table>
447
- </div>
448
-
449
- <div class="method_details ">
450
- <p class="signature " id="is_darwin?-instance_method">
451
-
452
- - (<tt>Boolean</tt>) <strong>is_darwin?</strong>
453
-
454
-
455
-
456
- </p><div class="docstring">
457
- <div class="discussion">
458
-
459
- <p>Return true if we're on a Darwin native system (OSX).</p>
460
-
461
-
462
- </div>
463
- </div>
464
- <div class="tags">
465
- <h3>Returns:</h3>
466
- <ul class="return">
467
-
468
- <li>
469
-
470
- <span class='type'>(<tt>Boolean</tt>)</span>
471
-
472
-
473
-
474
-
475
- </li>
476
-
477
- </ul>
478
-
479
- </div><table class="source_code">
480
- <tr>
481
- <td>
482
- <pre class="lines">
483
-
484
-
485
- 72
486
- 73
487
- 74</pre>
488
- </td>
489
- <td>
490
- <pre class="code"><span class="info file"># File 'lib/sprout/archive_unpacker.rb', line 72</span>
491
-
492
- <span class='kw'>def</span> <span class='id is_darwin?'>is_darwin?</span>
493
- <span class='const'>Sprout</span><span class='period'>.</span><span class='id current_system'>current_system</span><span class='period'>.</span><span class='id is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Sprout</span><span class='op'>::</span><span class='const'>System</span><span class='op'>::</span><span class='const'>OSXSystem</span><span class='rparen'>)</span>
494
- <span class='kw'>end</span></pre>
495
- </td>
496
- </tr>
497
- </table>
498
- </div>
499
-
500
- <div class="method_details ">
501
- <p class="signature " id="is_exe?-instance_method">
502
-
503
- - (<tt>Boolean</tt>) <strong>is_exe?</strong>(archive, type = nil)
504
-
505
-
506
-
507
- </p><div class="docstring">
508
- <div class="discussion">
509
-
510
- <p>Return true if the downloaded archive is a .exe file or the <tt>type</tt>
511
- argument is <tt>:exe</tt>.</p>
512
-
513
-
514
- </div>
515
- </div>
516
- <div class="tags">
517
- <h3>Returns:</h3>
518
- <ul class="return">
519
-
520
- <li>
521
-
522
- <span class='type'>(<tt>Boolean</tt>)</span>
523
-
524
-
525
-
526
-
527
- </li>
528
-
529
- </ul>
530
-
531
- </div><table class="source_code">
532
- <tr>
533
- <td>
534
- <pre class="lines">
535
-
536
-
537
- 154
538
- 155
539
- 156</pre>
540
- </td>
541
- <td>
542
- <pre class="code"><span class="info file"># File 'lib/sprout/archive_unpacker.rb', line 154</span>
543
-
544
- <span class='kw'>def</span> <span class='id is_exe?'>is_exe?</span> <span class='id archive'>archive</span><span class='comma'>,</span> <span class='id type'>type</span><span class='op'>=</span><span class='kw'>nil</span>
545
- <span class='id type'>type</span> <span class='op'>==</span> <span class='symbol'>:exe</span> <span class='op'>||</span> <span class='op'>!</span><span class='id archive'>archive</span><span class='period'>.</span><span class='id match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\.exe$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id nil?'>nil?</span>
546
- <span class='kw'>end</span></pre>
547
- </td>
548
- </tr>
549
- </table>
550
- </div>
551
-
552
- <div class="method_details ">
553
- <p class="signature " id="is_rb?-instance_method">
554
-
555
- - (<tt>Boolean</tt>) <strong>is_rb?</strong>(archive, type = nil)
556
-
557
-
558
-
559
- </p><div class="docstring">
560
- <div class="discussion">
561
-
562
- <p>Return true if the downloaded archive is a .rb file or the <tt>type</tt>
563
- argument is <tt>:rb</tt>.</p>
564
-
565
-
566
- </div>
567
- </div>
568
- <div class="tags">
569
- <h3>Returns:</h3>
570
- <ul class="return">
571
-
572
- <li>
573
-
574
- <span class='type'>(<tt>Boolean</tt>)</span>
575
-
576
-
577
-
578
-
579
- </li>
580
-
581
- </ul>
582
-
583
- </div><table class="source_code">
584
- <tr>
585
- <td>
586
- <pre class="lines">
587
-
588
-
589
- 168
590
- 169
591
- 170</pre>
592
- </td>
593
- <td>
594
- <pre class="code"><span class="info file"># File 'lib/sprout/archive_unpacker.rb', line 168</span>
595
-
596
- <span class='kw'>def</span> <span class='id is_rb?'>is_rb?</span> <span class='id archive'>archive</span><span class='comma'>,</span> <span class='id type'>type</span><span class='op'>=</span><span class='kw'>nil</span>
597
- <span class='id type'>type</span> <span class='op'>==</span> <span class='symbol'>:rb</span> <span class='op'>||</span> <span class='op'>!</span><span class='id archive'>archive</span><span class='period'>.</span><span class='id match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\.rb$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id nil?'>nil?</span>
598
- <span class='kw'>end</span></pre>
599
- </td>
600
- </tr>
601
- </table>
602
- </div>
603
-
604
- <div class="method_details ">
605
- <p class="signature " id="is_swc?-instance_method">
606
-
607
- - (<tt>Boolean</tt>) <strong>is_swc?</strong>(archive, type = nil)
608
-
609
-
610
-
611
- </p><div class="docstring">
612
- <div class="discussion">
613
-
614
- <p>Return true if the downloaded archive is a .swc file or the <tt>type</tt>
615
- argument is <tt>:swc</tt>.</p>
616
-
617
-
618
- </div>
619
- </div>
620
- <div class="tags">
621
- <h3>Returns:</h3>
622
- <ul class="return">
623
-
624
- <li>
625
-
626
- <span class='type'>(<tt>Boolean</tt>)</span>
627
-
628
-
629
-
630
-
631
- </li>
632
-
633
- </ul>
634
-
635
- </div><table class="source_code">
636
- <tr>
637
- <td>
638
- <pre class="lines">
639
-
640
-
641
- 161
642
- 162
643
- 163</pre>
644
- </td>
645
- <td>
646
- <pre class="code"><span class="info file"># File 'lib/sprout/archive_unpacker.rb', line 161</span>
647
-
648
- <span class='kw'>def</span> <span class='id is_swc?'>is_swc?</span> <span class='id archive'>archive</span><span class='comma'>,</span> <span class='id type'>type</span><span class='op'>=</span><span class='kw'>nil</span>
649
- <span class='id type'>type</span> <span class='op'>==</span> <span class='symbol'>:swc</span> <span class='op'>||</span> <span class='op'>!</span><span class='id archive'>archive</span><span class='period'>.</span><span class='id match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\.swc$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id nil?'>nil?</span>
650
- <span class='kw'>end</span></pre>
651
- </td>
652
- </tr>
653
- </table>
654
- </div>
655
-
656
- <div class="method_details ">
657
- <p class="signature " id="is_tgz?-instance_method">
658
-
659
- - (<tt>Boolean</tt>) <strong>is_tgz?</strong>(archive, type = nil)
660
-
661
-
662
-
663
- </p><div class="docstring">
664
- <div class="discussion">
665
-
666
- <p>Return true if the provided file name looks like a tar.gz file or the
667
- <tt>type</tt> argument is <tt>:tgz</tt>.</p>
668
-
669
-
670
- </div>
671
- </div>
672
- <div class="tags">
673
- <h3>Returns:</h3>
674
- <ul class="return">
675
-
676
- <li>
677
-
678
- <span class='type'>(<tt>Boolean</tt>)</span>
679
-
680
-
681
-
682
-
683
- </li>
684
-
685
- </ul>
686
-
687
- </div><table class="source_code">
688
- <tr>
689
- <td>
690
- <pre class="lines">
691
-
692
-
693
- 147
694
- 148
695
- 149</pre>
696
- </td>
697
- <td>
698
- <pre class="code"><span class="info file"># File 'lib/sprout/archive_unpacker.rb', line 147</span>
699
-
700
- <span class='kw'>def</span> <span class='id is_tgz?'>is_tgz?</span> <span class='id archive'>archive</span><span class='comma'>,</span> <span class='id type'>type</span><span class='op'>=</span><span class='kw'>nil</span>
701
- <span class='id type'>type</span> <span class='op'>==</span> <span class='symbol'>:tgz</span> <span class='op'>||</span> <span class='op'>!</span><span class='id archive'>archive</span><span class='period'>.</span><span class='id match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\.tgz$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id nil?'>nil?</span> <span class='op'>||</span> <span class='op'>!</span><span class='id archive'>archive</span><span class='period'>.</span><span class='id match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\.tar.gz$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id nil?'>nil?</span>
702
- <span class='kw'>end</span></pre>
703
- </td>
704
- </tr>
705
- </table>
706
- </div>
707
-
708
- <div class="method_details ">
709
- <p class="signature " id="is_zip?-instance_method">
710
-
711
- - (<tt>Boolean</tt>) <strong>is_zip?</strong>(archive, type = nil)
712
-
713
-
714
-
715
- </p><div class="docstring">
716
- <div class="discussion">
717
-
718
- <p>Returns true if the provided file name looks like a zip file or the
719
- <tt>type</tt> argument is <tt>:zip</tt>.</p>
720
-
721
-
722
- </div>
723
- </div>
724
- <div class="tags">
725
- <h3>Returns:</h3>
726
- <ul class="return">
727
-
728
- <li>
729
-
730
- <span class='type'>(<tt>Boolean</tt>)</span>
731
-
732
-
733
-
734
-
735
- </li>
736
-
737
- </ul>
738
-
739
- </div><table class="source_code">
740
- <tr>
741
- <td>
742
- <pre class="lines">
743
-
744
-
745
- 140
746
- 141
747
- 142</pre>
748
- </td>
749
- <td>
750
- <pre class="code"><span class="info file"># File 'lib/sprout/archive_unpacker.rb', line 140</span>
751
-
752
- <span class='kw'>def</span> <span class='id is_zip?'>is_zip?</span> <span class='id archive'>archive</span><span class='comma'>,</span> <span class='id type'>type</span><span class='op'>=</span><span class='kw'>nil</span>
753
- <span class='id type'>type</span> <span class='op'>==</span> <span class='symbol'>:zip</span> <span class='op'>||</span> <span class='op'>!</span><span class='id archive'>archive</span><span class='period'>.</span><span class='id match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\.zip$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id nil?'>nil?</span>
754
- <span class='kw'>end</span></pre>
755
- </td>
756
- </tr>
757
- </table>
758
- </div>
759
-
760
- <div class="method_details ">
761
- <p class="signature " id="unpack-instance_method">
762
-
763
- - (<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>) <strong>unpack</strong>(archive, destination, type = nil, clobber = nil)
764
-
765
-
766
-
767
- </p><div class="docstring">
768
- <div class="discussion">
769
-
770
- <p>Unpack the provided <tt>archive</tt> into the provided
771
- <tt>destination</tt>.</p>
772
-
773
- <p>If a <tt>type</tt> is not provided, a type will be inferred from the file
774
- name suffix.</p>
775
-
776
-
777
- </div>
778
- </div>
779
- <div class="tags">
780
- <h3>Parameters:</h3>
781
- <ul class="param">
782
-
783
- <li>
784
-
785
- <span class='type'>(<tt>File</tt>)</span>
786
-
787
-
788
- <span class='name'>archive</span>
789
-
790
-
791
-
792
- &mdash;
793
- <div class='inline'>
794
- <p>Path to the archive that will be unpacked (or copied)</p>
795
- </div>
796
-
797
- </li>
798
-
799
- <li>
800
-
801
- <span class='type'>(<tt>Path</tt>)</span>
802
-
803
-
804
- <span class='name'>destination</span>
805
-
806
-
807
-
808
- &mdash;
809
- <div class='inline'>
810
- <p>Path to the folder where unpacked files should be placed (or copied).</p>
811
- </div>
812
-
813
- </li>
814
-
815
- <li>
816
-
817
- <span class='type'>(<tt>Symbol</tt>)</span>
818
-
819
-
820
- <span class='name'>type</span>
821
-
822
-
823
- <em class="default">(defaults to: <tt>nil</tt>)</em>
824
-
825
-
826
- &mdash;
827
- <div class='inline'>
828
- <p>The type of the archive in cases where it can't be inferred from the name.
829
- Acceptable values are: :zip, :tgz, :swc, :exe or :rb</p>
830
- </div>
831
-
832
- </li>
833
-
834
- <li>
835
-
836
- <span class='type'>(<tt>Boolean</tt>)</span>
837
-
838
-
839
- <span class='name'>clobber</span>
840
-
841
-
842
- <em class="default">(defaults to: <tt>nil</tt>)</em>
843
-
844
-
845
- &mdash;
846
- <div class='inline'>
847
- <p>If the destination already contains the expected file(s), the unpacker
848
- will not run unless <tt>clobber</tt> is true.</p>
849
- </div>
850
-
851
- </li>
852
-
853
- </ul>
854
- <h3>Returns:</h3>
855
- <ul class="return">
856
-
857
- <li>
858
-
859
- <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>)</span>
860
-
861
-
862
-
863
-
864
- &mdash;
865
- <div class='inline'>
866
- <p>path to the unpacked files (usually same as destination).</p>
867
- </div>
868
-
869
- </li>
870
-
871
- </ul>
872
- <h3>Raises:</h3>
873
- <ul class="raise">
874
-
875
- <li>
876
-
877
- <span class='type'></span>
878
-
879
-
880
-
881
-
882
-
883
- <div class='inline'>
884
- <p>Sprout::Errors::UnknownArchiveType If the archive type cannot be inferred
885
- and a valid type is not provided.</p>
886
- </div>
887
-
888
- </li>
889
-
890
- </ul>
891
-
892
- </div><table class="source_code">
893
- <tr>
894
- <td>
895
- <pre class="lines">
896
-
897
-
898
- 27
899
- 28
900
- 29
901
- 30
902
- 31
903
- 32
904
- 33
905
- 34
906
- 35
907
- 36
908
- 37
909
- 38</pre>
910
- </td>
911
- <td>
912
- <pre class="code"><span class="info file"># File 'lib/sprout/archive_unpacker.rb', line 27</span>
913
-
914
- <span class='kw'>def</span> <span class='id unpack'>unpack</span> <span class='id archive'>archive</span><span class='comma'>,</span> <span class='id destination'>destination</span><span class='comma'>,</span> <span class='id type'>type</span><span class='op'>=</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='id clobber'>clobber</span><span class='op'>=</span><span class='kw'>nil</span>
915
- <span class='kw'>return</span> <span class='id unpack_zip'>unpack_zip</span><span class='lparen'>(</span><span class='id archive'>archive</span><span class='comma'>,</span> <span class='id destination'>destination</span><span class='comma'>,</span> <span class='id clobber'>clobber</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id is_zip?'>is_zip?</span><span class='lparen'>(</span><span class='id archive'>archive</span><span class='comma'>,</span> <span class='id type'>type</span><span class='rparen'>)</span>
916
- <span class='kw'>return</span> <span class='id unpack_tgz'>unpack_tgz</span><span class='lparen'>(</span><span class='id archive'>archive</span><span class='comma'>,</span> <span class='id destination'>destination</span><span class='comma'>,</span> <span class='id clobber'>clobber</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id is_tgz?'>is_tgz?</span><span class='lparen'>(</span><span class='id archive'>archive</span><span class='comma'>,</span> <span class='id type'>type</span><span class='rparen'>)</span>
917
-
918
- <span class='comment'># This is definitely debatable, should we copy the file even if it's
919
- </span> <span class='comment'># not an archive that we're about to unpack?
920
- </span> <span class='comment'># If so, why would we only do this with some subset of file types?
921
- </span> <span class='comment'># Opinions welcome here...
922
- </span> <span class='kw'>return</span> <span class='id copy_file'>copy_file</span><span class='lparen'>(</span><span class='id archive'>archive</span><span class='comma'>,</span> <span class='id destination'>destination</span><span class='comma'>,</span> <span class='id clobber'>clobber</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id is_copyable?'>is_copyable?</span><span class='lparen'>(</span><span class='id archive'>archive</span><span class='rparen'>)</span>
923
-
924
- <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'>UnknownArchiveType</span><span class='period'>.</span><span class='id new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Unsupported or unknown archive type encountered with: </span><span class='embexpr_beg'>#{</span><span class='id archive'>archive</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
925
- <span class='kw'>end</span></pre>
926
- </td>
927
- </tr>
928
- </table>
929
- </div>
930
-
931
- <div class="method_details ">
932
- <p class="signature " id="unpack_tgz-instance_method">
933
-
934
- - (<tt>File</tt>) <strong>unpack_tgz</strong>(archive, destination, clobber = nil)
935
-
936
-
937
-
938
- </p><div class="docstring">
939
- <div class="discussion">
940
-
941
- <p>Unpack tar.gz or .tgz files on any platform.</p>
942
-
943
-
944
- </div>
945
- </div>
946
- <div class="tags">
947
- <h3>Returns:</h3>
948
- <ul class="return">
949
-
950
- <li>
951
-
952
- <span class='type'>(<tt>File</tt>)</span>
953
-
954
-
955
-
956
-
957
- &mdash;
958
- <div class='inline'>
959
- <p>the file or directory that was created.</p>
960
- </div>
961
-
962
- </li>
963
-
964
- </ul>
965
-
966
- </div><table class="source_code">
967
- <tr>
968
- <td>
969
- <pre class="lines">
970
-
971
-
972
- 97
973
- 98
974
- 99
975
- 100
976
- 101
977
- 102
978
- 103
979
- 104
980
- 105
981
- 106
982
- 107
983
- 108
984
- 109
985
- 110
986
- 111
987
- 112
988
- 113
989
- 114
990
- 115
991
- 116</pre>
992
- </td>
993
- <td>
994
- <pre class="code"><span class="info file"># File 'lib/sprout/archive_unpacker.rb', line 97</span>
995
-
996
- <span class='kw'>def</span> <span class='id unpack_tgz'>unpack_tgz</span> <span class='id archive'>archive</span><span class='comma'>,</span> <span class='id destination'>destination</span><span class='comma'>,</span> <span class='id clobber'>clobber</span><span class='op'>=</span><span class='kw'>nil</span>
997
- <span class='id validate'>validate</span> <span class='id archive'>archive</span><span class='comma'>,</span> <span class='id destination'>destination</span>
998
-
999
- <span class='id tar'>tar</span> <span class='op'>=</span> <span class='const'>Zlib</span><span class='op'>::</span><span class='const'>GzipReader</span><span class='period'>.</span><span class='id new'>new</span><span class='lparen'>(</span><span class='const'>File</span><span class='period'>.</span><span class='id open'>open</span><span class='lparen'>(</span><span class='id archive'>archive</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>rb</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
1000
- <span class='kw'>if</span><span class='lparen'>(</span><span class='op'>!</span><span class='id should_unpack_tgz?'>should_unpack_tgz?</span><span class='lparen'>(</span><span class='id destination'>destination</span><span class='comma'>,</span> <span class='id clobber'>clobber</span><span class='rparen'>)</span><span class='rparen'>)</span>
1001
- <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'>DestinationExistsError</span><span class='period'>.</span><span class='id new'>new</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Unable to unpack </span><span class='embexpr_beg'>#{</span><span class='id archive'>archive</span><span class='rbrace'>}</span><span class='tstring_content'> into </span><span class='embexpr_beg'>#{</span><span class='id destination'>destination</span><span class='rbrace'>}</span><span class='tstring_content'> without explicit :clobber argument</span><span class='tstring_end'>&quot;</span></span>
1002
- <span class='kw'>end</span>
1003
-
1004
- <span class='const'>Archive</span><span class='op'>::</span><span class='const'>Tar</span><span class='op'>::</span><span class='const'>Minitar</span><span class='period'>.</span><span class='id unpack'>unpack</span><span class='lparen'>(</span><span class='id tar'>tar</span><span class='comma'>,</span> <span class='id destination'>destination</span><span class='rparen'>)</span>
1005
-
1006
- <span class='comment'># Recurse and unpack gzipped children (Adobe did this double
1007
- </span> <span class='comment'># gzip with the Linux FlashPlayer for some weird reason)
1008
- </span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id destination'>destination</span><span class='rbrace'>}</span><span class='tstring_content'>/**/*.tgz</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id destination'>destination</span><span class='rbrace'>}</span><span class='tstring_content'>/**/*.tar.gz</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id pattern'>pattern</span><span class='op'>|</span>
1009
- <span class='const'>Dir</span><span class='period'>.</span><span class='id glob'>glob</span><span class='lparen'>(</span><span class='id pattern'>pattern</span><span class='rparen'>)</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id child'>child</span><span class='op'>|</span>
1010
- <span class='kw'>if</span><span class='lparen'>(</span><span class='id child'>child</span> <span class='op'>!=</span> <span class='id archive'>archive</span> <span class='op'>&amp;&amp;</span> <span class='id dir'>dir</span> <span class='op'>!=</span> <span class='const'>File</span><span class='period'>.</span><span class='id dirname'>dirname</span><span class='lparen'>(</span><span class='id child'>child</span><span class='rparen'>)</span><span class='rparen'>)</span>
1011
- <span class='id unpack_tgz'>unpack_tgz</span><span class='lparen'>(</span><span class='id child'>child</span><span class='comma'>,</span> <span class='const'>File</span><span class='period'>.</span><span class='id dirname'>dirname</span><span class='lparen'>(</span><span class='id child'>child</span><span class='rparen'>)</span><span class='rparen'>)</span>
1012
- <span class='kw'>end</span>
1013
- <span class='kw'>end</span>
1014
- <span class='kw'>end</span>
1015
- <span class='kw'>end</span></pre>
1016
- </td>
1017
- </tr>
1018
- </table>
1019
- </div>
1020
-
1021
- <div class="method_details ">
1022
- <p class="signature " id="unpack_zip-instance_method">
1023
-
1024
- - (<tt>File</tt>) <strong>unpack_zip</strong>(archive, destination, clobber = nil)
1025
-
1026
-
1027
-
1028
- </p><div class="docstring">
1029
- <div class="discussion">
1030
-
1031
- <p>Unpack zip archives on any platform using whatever strategy is most
1032
- efficient and reliable.</p>
1033
-
1034
-
1035
- </div>
1036
- </div>
1037
- <div class="tags">
1038
- <h3>Parameters:</h3>
1039
- <ul class="param">
1040
-
1041
- <li>
1042
-
1043
- <span class='type'>(<tt>File</tt>)</span>
1044
-
1045
-
1046
- <span class='name'>archive</span>
1047
-
1048
-
1049
-
1050
- &mdash;
1051
- <div class='inline'>
1052
- <p>Path to the archive that will be unpacked.</p>
1053
- </div>
1054
-
1055
- </li>
1056
-
1057
- <li>
1058
-
1059
- <span class='type'>(<tt>Path</tt>)</span>
1060
-
1061
-
1062
- <span class='name'>destination</span>
1063
-
1064
-
1065
-
1066
- &mdash;
1067
- <div class='inline'>
1068
- <p>Path to the folder where unpacked files should be placed.</p>
1069
- </div>
1070
-
1071
- </li>
1072
-
1073
- <li>
1074
-
1075
- <span class='type'>(<tt>Boolean</tt>)</span>
1076
-
1077
-
1078
- <span class='name'>clobber</span>
1079
-
1080
-
1081
- <em class="default">(defaults to: <tt>nil</tt>)</em>
1082
-
1083
-
1084
- &mdash;
1085
- <div class='inline'>
1086
- <p>If the destination already contains the expected file(s), the unpacker
1087
- will not run unless <tt>clobber</tt> is true.</p>
1088
- </div>
1089
-
1090
- </li>
1091
-
1092
- </ul>
1093
- <h3>Returns:</h3>
1094
- <ul class="return">
1095
-
1096
- <li>
1097
-
1098
- <span class='type'>(<tt>File</tt>)</span>
1099
-
1100
-
1101
-
1102
-
1103
- &mdash;
1104
- <div class='inline'>
1105
- <p>the file or directory that was created.</p>
1106
- </div>
1107
-
1108
- </li>
1109
-
1110
- </ul>
1111
-
1112
- </div><table class="source_code">
1113
- <tr>
1114
- <td>
1115
- <pre class="lines">
1116
-
1117
-
1118
- 49
1119
- 50
1120
- 51
1121
- 52
1122
- 53
1123
- 54
1124
- 55
1125
- 56
1126
- 57
1127
- 58
1128
- 59
1129
- 60
1130
- 61
1131
- 62
1132
- 63
1133
- 64
1134
- 65
1135
- 66
1136
- 67</pre>
1137
- </td>
1138
- <td>
1139
- <pre class="code"><span class="info file"># File 'lib/sprout/archive_unpacker.rb', line 49</span>
1140
-
1141
- <span class='kw'>def</span> <span class='id unpack_zip'>unpack_zip</span> <span class='id archive'>archive</span><span class='comma'>,</span> <span class='id destination'>destination</span><span class='comma'>,</span> <span class='id clobber'>clobber</span><span class='op'>=</span><span class='kw'>nil</span>
1142
- <span class='id validate'>validate</span> <span class='id archive'>archive</span><span class='comma'>,</span> <span class='id destination'>destination</span>
1143
-
1144
- <span class='comment'>##
1145
- </span> <span class='comment'># As it turns out, the Rubyzip library corrupts
1146
- </span> <span class='comment'># binary files (like the Flash Player) on OSX and is also
1147
- </span> <span class='comment'># horribly slow for large archives (like the ~120MB Flex SDK)
1148
- </span> <span class='comment'># on all platforms.
1149
- </span> <span class='kw'>if</span> <span class='id is_darwin?'>is_darwin?</span>
1150
- <span class='id unpack_zip_on_darwin'>unpack_zip_on_darwin</span> <span class='id archive'>archive</span><span class='comma'>,</span> <span class='id destination'>destination</span><span class='comma'>,</span> <span class='id clobber'>clobber</span>
1151
- <span class='kw'>else</span>
1152
- <span class='const'>Zip</span><span class='op'>::</span><span class='const'>ZipFile</span><span class='period'>.</span><span class='id open'>open</span> <span class='id archive'>archive</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id zipfile'>zipfile</span><span class='op'>|</span>
1153
- <span class='id zipfile'>zipfile</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id entry'>entry</span><span class='op'>|</span>
1154
- <span class='kw'>next</span> <span class='kw'>if</span> <span class='id entry'>entry</span><span class='period'>.</span><span class='id name'>name</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>__MACOSX</span><span class='regexp_end'>/</span></span> <span class='kw'>or</span> <span class='id entry'>entry</span><span class='period'>.</span><span class='id name'>name</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\.DS_Store</span><span class='regexp_end'>/</span></span>
1155
- <span class='id unpack_zip_entry'>unpack_zip_entry</span> <span class='id entry'>entry</span><span class='comma'>,</span> <span class='id destination'>destination</span><span class='comma'>,</span> <span class='id clobber'>clobber</span>
1156
- <span class='kw'>end</span>
1157
- <span class='kw'>end</span>
1158
- <span class='kw'>end</span>
1159
- <span class='kw'>end</span></pre>
1160
- </td>
1161
- </tr>
1162
- </table>
1163
- </div>
1164
-
1165
- <div class="method_details ">
1166
- <p class="signature " id="unpack_zip_on_darwin-instance_method">
1167
-
1168
- - (<tt>File</tt>) <strong>unpack_zip_on_darwin</strong>(archive, destination, clobber)
1169
-
1170
-
1171
-
1172
- </p><div class="docstring">
1173
- <div class="discussion">
1174
-
1175
- <p>Optimization for zip files on OSX. Uses the native 'unzip' utility which is
1176
- much faster (and more reliable) than Ruby for large archives (like the
1177
- Flex SDK) and binaries that Ruby corrupts (like the Flash Player).</p>
1178
-
1179
-
1180
- </div>
1181
- </div>
1182
- <div class="tags">
1183
- <h3>Returns:</h3>
1184
- <ul class="return">
1185
-
1186
- <li>
1187
-
1188
- <span class='type'>(<tt>File</tt>)</span>
1189
-
1190
-
1191
-
1192
-
1193
- &mdash;
1194
- <div class='inline'>
1195
- <p>the file or directory that was created.</p>
1196
- </div>
1197
-
1198
- </li>
1199
-
1200
- </ul>
1201
-
1202
- </div><table class="source_code">
1203
- <tr>
1204
- <td>
1205
- <pre class="lines">
1206
-
1207
-
1208
- 83
1209
- 84
1210
- 85
1211
- 86
1212
- 87
1213
- 88
1214
- 89
1215
- 90
1216
- 91</pre>
1217
- </td>
1218
- <td>
1219
- <pre class="code"><span class="info file"># File 'lib/sprout/archive_unpacker.rb', line 83</span>
1220
-
1221
- <span class='kw'>def</span> <span class='id unpack_zip_on_darwin'>unpack_zip_on_darwin</span> <span class='id archive'>archive</span><span class='comma'>,</span> <span class='id destination'>destination</span><span class='comma'>,</span> <span class='id clobber'>clobber</span>
1222
- <span class='comment'># Unzipping on OS X
1223
- </span> <span class='const'>FileUtils</span><span class='period'>.</span><span class='id makedirs'>makedirs</span> <span class='id destination'>destination</span>
1224
- <span class='id zip_dir'>zip_dir</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id expand_path'>expand_path</span> <span class='const'>File</span><span class='period'>.</span><span class='id dirname'>dirname</span><span class='lparen'>(</span><span class='id archive'>archive</span><span class='rparen'>)</span>
1225
- <span class='id zip_name'>zip_name</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id basename'>basename</span> <span class='id archive'>archive</span>
1226
- <span class='id output'>output</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id expand_path'>expand_path</span> <span class='id destination'>destination</span>
1227
- <span class='comment'># puts &quot;&gt;&gt; zip_dir: #{zip_dir} zip_name: #{zip_name} output: #{output}&quot;
1228
- </span> <span class='backtick'>%x(</span><span class='tstring_content'>cd </span><span class='embexpr_beg'>#{</span><span class='id zip_dir'>zip_dir</span><span class='rbrace'>}</span><span class='tstring_content'>;unzip </span><span class='embexpr_beg'>#{</span><span class='id zip_name'>zip_name</span><span class='rbrace'>}</span><span class='tstring_content'> -d </span><span class='embexpr_beg'>#{</span><span class='id output'>output</span><span class='rbrace'>}</span><span class='tstring_end'>)</span></span>
1229
- <span class='kw'>end</span></pre>
1230
- </td>
1231
- </tr>
1232
- </table>
1233
- </div>
1234
-
1235
- </div>
1236
-
1237
- </div>
1238
-
1239
- <div id="footer">
1240
- Generated on Wed Dec 22 11:58:35 2010 by
1241
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1242
- 0.6.3 (ruby-1.9.2).
1243
- </div>
1244
-
1245
- </body>
1246
- </html>