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