rook 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +124 -37
- data/bin/rook +8 -902
- data/doc-api/classes/BZ2.html +111 -0
- data/doc-api/classes/BZ2/Reader.html +234 -0
- data/doc-api/classes/Digest.html +107 -0
- data/doc-api/classes/Digest/Base.html +254 -0
- data/doc-api/classes/Enumerable.html +430 -0
- data/doc-api/classes/File.html +208 -0
- data/doc-api/classes/FileUtils.html +758 -0
- data/doc-api/classes/Kernel.html +317 -0
- data/doc-api/classes/Rook.html +148 -0
- data/doc-api/classes/Rook/Assertion.html +164 -0
- data/doc-api/classes/Rook/AssertionError.html +111 -0
- data/doc-api/classes/Rook/CommandOptionError.html +113 -0
- data/doc-api/classes/Rook/Commands.html +1158 -0
- data/doc-api/classes/Rook/Cookbook.html +357 -0
- data/doc-api/classes/Rook/CookbookError.html +161 -0
- data/doc-api/classes/Rook/CookbookValidator.html +215 -0
- data/doc-api/classes/Rook/Kitchen.html +875 -0
- data/doc-api/classes/Rook/KitchenHelper.html +386 -0
- data/doc-api/classes/Rook/Main.html +325 -0
- data/doc-api/classes/Rook/Parameters.html +443 -0
- data/doc-api/classes/Rook/Recipe.html +546 -0
- data/doc-api/classes/Rook/RookError.html +111 -0
- data/doc-api/classes/Rook/Util.html +408 -0
- data/doc-api/classes/Rook/Util/UndefinedPropertyError.html +160 -0
- data/doc-api/created.rid +1 -0
- data/doc-api/files/__/README_txt.html +313 -0
- data/doc-api/files/rook/commands_rb.html +115 -0
- data/doc-api/files/rook/cookbook_rb.html +115 -0
- data/doc-api/files/rook/helper/bz2_rb.html +114 -0
- data/doc-api/files/rook/helper/digest_rb.html +114 -0
- data/doc-api/files/rook/helper/enumerable_rb.html +107 -0
- data/doc-api/files/rook/helper/file_rb.html +107 -0
- data/doc-api/files/rook/helper/fileutils_rb.html +124 -0
- data/doc-api/files/rook/helper/kernel_rb.html +107 -0
- data/doc-api/files/rook/kitchen_rb.html +117 -0
- data/doc-api/files/rook/main_rb.html +117 -0
- data/doc-api/files/rook/recipe_rb.html +114 -0
- data/doc-api/files/rook/util_rb.html +115 -0
- data/doc-api/files/rook_rb.html +122 -0
- data/doc-api/fr_class_index.html +50 -0
- data/doc-api/fr_file_index.html +40 -0
- data/doc-api/fr_method_index.html +181 -0
- data/doc-api/index.html +24 -0
- data/doc-api/rdoc-style.css +208 -0
- data/examples/hello_c/Rookbook.rb +37 -0
- data/examples/hello_c/Rookbook.yaml +45 -0
- data/examples/hello_c/hello.c +6 -3
- data/examples/project/README.txt +8 -0
- data/examples/project/Rookbook.props +1 -0
- data/examples/project/Rookbook.rb +120 -0
- data/examples/project/Rookbook.yaml +117 -0
- data/examples/project/bin/example +12 -0
- data/examples/project/example.gemspec +29 -0
- data/examples/project/lib/example.rb +36 -0
- data/examples/{archive → project}/lib/example/bar.rb +0 -0
- data/examples/{archive → project}/lib/example/baz.rb +0 -0
- data/examples/{archive → project}/lib/example/foo.rb +0 -0
- data/examples/project/setup.rb +1331 -0
- data/examples/project/test/test.rb +27 -0
- data/lib/rook.rb +50 -0
- data/lib/rook/commands.rb +426 -0
- data/lib/rook/cookbook.rb +237 -0
- data/lib/rook/helper/bz2.rb +39 -0
- data/lib/rook/helper/digest.rb +76 -0
- data/lib/rook/helper/enumerable.rb +121 -0
- data/lib/rook/helper/file.rb +50 -0
- data/lib/rook/helper/fileutils.rb +340 -0
- data/lib/rook/helper/kernel.rb +108 -0
- data/lib/rook/kitchen.rb +668 -0
- data/lib/rook/main.rb +280 -0
- data/lib/rook/recipe.rb +259 -0
- data/lib/rook/rookbook.schema.yaml +156 -0
- data/lib/rook/util.rb +172 -0
- data/rook.gemspec +56 -0
- metadata +139 -45
- data/examples/archive/COPYING +0 -340
- data/examples/archive/README.txt +0 -1
- data/examples/archive/Rookbook +0 -56
- data/examples/archive/bin/example +0 -0
- data/examples/archive/doc/index.html +0 -0
- data/examples/archive/doc/index.txt +0 -0
- data/examples/archive/lib/example.rb +0 -0
- data/examples/archive/test/test1.rb +0 -0
- data/examples/archive/test/test2.rb +0 -0
- data/examples/hello_c/Rookbook +0 -24
@@ -0,0 +1,208 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: File</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">File</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../files/rook/helper/file_rb.html">
|
59
|
+
rook/helper/file.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
<div id="description">
|
82
|
+
<p>
|
83
|
+
extends <a href="File.html">File</a> class
|
84
|
+
</p>
|
85
|
+
|
86
|
+
</div>
|
87
|
+
|
88
|
+
|
89
|
+
</div>
|
90
|
+
|
91
|
+
<div id="method-list">
|
92
|
+
<h3 class="section-bar">Methods</h3>
|
93
|
+
|
94
|
+
<div class="name-list">
|
95
|
+
<a href="#M000001">edit</a>
|
96
|
+
<a href="#M000002">write</a>
|
97
|
+
</div>
|
98
|
+
</div>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
|
103
|
+
<!-- if includes -->
|
104
|
+
|
105
|
+
<div id="section">
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
<!-- if method_list -->
|
115
|
+
<div id="methods">
|
116
|
+
<h3 class="section-bar">Public Class methods</h3>
|
117
|
+
|
118
|
+
<div id="method-M000001" class="method-detail">
|
119
|
+
<a name="M000001"></a>
|
120
|
+
|
121
|
+
<div class="method-heading">
|
122
|
+
<a href="#M000001" class="method-signature">
|
123
|
+
<span class="method-name">edit</span><span class="method-args">(filename) {|content| ...}</span>
|
124
|
+
</a>
|
125
|
+
</div>
|
126
|
+
|
127
|
+
<div class="method-description">
|
128
|
+
<p>
|
129
|
+
edit file content
|
130
|
+
</p>
|
131
|
+
<p>
|
132
|
+
ex.
|
133
|
+
</p>
|
134
|
+
<pre>
|
135
|
+
File.edit('file.txt') do |content|
|
136
|
+
content.gsub!(/\$Release\$/, '1.0.0')
|
137
|
+
content.gsub!(/\$Copyright\$/, '(c)kuwata-lab')
|
138
|
+
end
|
139
|
+
</pre>
|
140
|
+
<p><a class="source-toggle" href="#"
|
141
|
+
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
142
|
+
<div class="method-source-code" id="M000001-source">
|
143
|
+
<pre>
|
144
|
+
<span class="ruby-comment cmt"># File rook/helper/file.rb, line 23</span>
|
145
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">edit</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
146
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-value str">'r+'</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
147
|
+
<span class="ruby-identifier">content</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">read</span>()
|
148
|
+
<span class="ruby-comment cmt">#yield(content)</span>
|
149
|
+
<span class="ruby-identifier">block</span>.<span class="ruby-identifier">arity</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-operator">?</span> <span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">content</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">content</span>, <span class="ruby-identifier">filename</span>)
|
150
|
+
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">rewind</span>()
|
151
|
+
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">truncate</span>(<span class="ruby-value">0</span>)
|
152
|
+
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">content</span>)
|
153
|
+
<span class="ruby-keyword kw">end</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">test</span>(<span class="ruby-value">?f</span>, <span class="ruby-identifier">filename</span>)
|
154
|
+
<span class="ruby-keyword kw">end</span>
|
155
|
+
</pre>
|
156
|
+
</div>
|
157
|
+
</div>
|
158
|
+
</div>
|
159
|
+
|
160
|
+
<div id="method-M000002" class="method-detail">
|
161
|
+
<a name="M000002"></a>
|
162
|
+
|
163
|
+
<div class="method-heading">
|
164
|
+
<a href="#M000002" class="method-signature">
|
165
|
+
<span class="method-name">write</span><span class="method-args">(filename, content)</span>
|
166
|
+
</a>
|
167
|
+
</div>
|
168
|
+
|
169
|
+
<div class="method-description">
|
170
|
+
<p>
|
171
|
+
write file
|
172
|
+
</p>
|
173
|
+
<p>
|
174
|
+
ex.
|
175
|
+
</p>
|
176
|
+
<pre>
|
177
|
+
content = <<END
|
178
|
+
foo
|
179
|
+
bar
|
180
|
+
END
|
181
|
+
File.write('file.txt', content)
|
182
|
+
</pre>
|
183
|
+
<p><a class="source-toggle" href="#"
|
184
|
+
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
185
|
+
<div class="method-source-code" id="M000002-source">
|
186
|
+
<pre>
|
187
|
+
<span class="ruby-comment cmt"># File rook/helper/file.rb, line 45</span>
|
188
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">content</span>)
|
189
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-value str">'w'</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">content</span>) }
|
190
|
+
<span class="ruby-keyword kw">end</span>
|
191
|
+
</pre>
|
192
|
+
</div>
|
193
|
+
</div>
|
194
|
+
</div>
|
195
|
+
|
196
|
+
|
197
|
+
</div>
|
198
|
+
|
199
|
+
|
200
|
+
</div>
|
201
|
+
|
202
|
+
|
203
|
+
<div id="validator-badges">
|
204
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
205
|
+
</div>
|
206
|
+
|
207
|
+
</body>
|
208
|
+
</html>
|
@@ -0,0 +1,758 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Module: FileUtils</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Module</strong></td>
|
53
|
+
<td class="class-name-in-header">FileUtils</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../files/rook/helper/fileutils_rb.html">
|
59
|
+
rook/helper/fileutils.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
</table>
|
66
|
+
</div>
|
67
|
+
<!-- banner header -->
|
68
|
+
|
69
|
+
<div id="bodyContent">
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
<div id="contextContent">
|
74
|
+
|
75
|
+
<div id="description">
|
76
|
+
<p>
|
77
|
+
extends <a href="FileUtils.html">FileUtils</a>
|
78
|
+
</p>
|
79
|
+
<p>
|
80
|
+
requires ‘rubyzip’, ‘bz2’, and
|
81
|
+
‘minitar’ library.
|
82
|
+
</p>
|
83
|
+
<ul>
|
84
|
+
<li>rubyzip - <a
|
85
|
+
href="http://raa.ruby-lang.org/project/rubyzip">raa.ruby-lang.org/project/rubyzip</a>/
|
86
|
+
|
87
|
+
</li>
|
88
|
+
<li>bz2 - <a
|
89
|
+
href="http://raa.ruby-lang.org/project/bz2">raa.ruby-lang.org/project/bz2</a>/
|
90
|
+
|
91
|
+
</li>
|
92
|
+
<li>minitar - <a
|
93
|
+
href="http://raa.ruby-lang.org/project/minitar">raa.ruby-lang.org/project/minitar</a>/
|
94
|
+
|
95
|
+
</li>
|
96
|
+
</ul>
|
97
|
+
|
98
|
+
</div>
|
99
|
+
|
100
|
+
|
101
|
+
</div>
|
102
|
+
|
103
|
+
<div id="method-list">
|
104
|
+
<h3 class="section-bar">Methods</h3>
|
105
|
+
|
106
|
+
<div class="name-list">
|
107
|
+
<a href="#M000005">cp_a</a>
|
108
|
+
<a href="#M000003">cp_p</a>
|
109
|
+
<a href="#M000004">cp_pr</a>
|
110
|
+
<a href="#M000006">store</a>
|
111
|
+
<a href="#M000008">store_a</a>
|
112
|
+
<a href="#M000007">store_p</a>
|
113
|
+
<a href="#M000012">tar_cf</a>
|
114
|
+
<a href="#M000016">tar_cjf</a>
|
115
|
+
<a href="#M000014">tar_czf</a>
|
116
|
+
<a href="#M000013">tar_xf</a>
|
117
|
+
<a href="#M000017">tar_xjf</a>
|
118
|
+
<a href="#M000015">tar_xzf</a>
|
119
|
+
<a href="#M000011">unzip</a>
|
120
|
+
<a href="#M000009">zip</a>
|
121
|
+
<a href="#M000010">zip_r</a>
|
122
|
+
</div>
|
123
|
+
</div>
|
124
|
+
|
125
|
+
</div>
|
126
|
+
|
127
|
+
|
128
|
+
<!-- if includes -->
|
129
|
+
|
130
|
+
<div id="section">
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
<!-- if method_list -->
|
140
|
+
<div id="methods">
|
141
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
142
|
+
|
143
|
+
<div id="method-M000005" class="method-detail">
|
144
|
+
<a name="M000005"></a>
|
145
|
+
|
146
|
+
<div class="method-heading">
|
147
|
+
<a href="#M000005" class="method-signature">
|
148
|
+
<span class="method-name">cp_a</span><span class="method-args">(src, dest, options={})</span>
|
149
|
+
</a>
|
150
|
+
</div>
|
151
|
+
|
152
|
+
<div class="method-description">
|
153
|
+
<p>
|
154
|
+
copy files into dest keeping file type (symbolic link, device file, etc)
|
155
|
+
</p>
|
156
|
+
<p>
|
157
|
+
ex1.
|
158
|
+
</p>
|
159
|
+
<pre>
|
160
|
+
cp_a('file1', 'file2')
|
161
|
+
</pre>
|
162
|
+
<p>
|
163
|
+
ex2.
|
164
|
+
</p>
|
165
|
+
<pre>
|
166
|
+
cp_a(['file1', 'file2', 'file3'], 'dir')
|
167
|
+
</pre>
|
168
|
+
<p><a class="source-toggle" href="#"
|
169
|
+
onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
|
170
|
+
<div class="method-source-code" id="M000005-source">
|
171
|
+
<pre>
|
172
|
+
<span class="ruby-comment cmt"># File rook/helper/fileutils.rb, line 61</span>
|
173
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cp_a</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">options</span>={})
|
174
|
+
<span class="ruby-identifier">fu_check_options</span>(<span class="ruby-identifier">options</span>, <span class="ruby-identifier">:preserve</span>, <span class="ruby-identifier">:verbose</span>, <span class="ruby-identifier">:noop</span>)
|
175
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:verbose</span>]
|
176
|
+
<span class="ruby-identifier">opt_str</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:preserve</span>] <span class="ruby-operator">?</span> <span class="ruby-value str">' -ap'</span> <span class="ruby-operator">:</span> <span class="ruby-value str">' -p'</span>
|
177
|
+
<span class="ruby-identifier">arg_str</span> = [<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>].<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">' '</span>)
|
178
|
+
<span class="ruby-identifier">fu_output_message</span>(<span class="ruby-node">"cp#{opt_str} #{arg_str}"</span>)
|
179
|
+
<span class="ruby-keyword kw">end</span>
|
180
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:noop</span>]
|
181
|
+
<span class="ruby-identifier">dereference_root</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-comment cmt">#options[:dereference_root]</span>
|
182
|
+
(<span class="ruby-identifier">src</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">src</span> <span class="ruby-operator">:</span> [<span class="ruby-identifier">src</span>]).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span>
|
183
|
+
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-identifier">item</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">filename</span><span class="ruby-operator">|</span>
|
184
|
+
<span class="ruby-identifier">copy_entry</span>(<span class="ruby-identifier">item</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:preserve</span>], <span class="ruby-identifier">dereference_root</span>)
|
185
|
+
<span class="ruby-keyword kw">end</span>
|
186
|
+
<span class="ruby-keyword kw">end</span>
|
187
|
+
<span class="ruby-keyword kw">end</span>
|
188
|
+
</pre>
|
189
|
+
</div>
|
190
|
+
</div>
|
191
|
+
</div>
|
192
|
+
|
193
|
+
<div id="method-M000003" class="method-detail">
|
194
|
+
<a name="M000003"></a>
|
195
|
+
|
196
|
+
<div class="method-heading">
|
197
|
+
<a href="#M000003" class="method-signature">
|
198
|
+
<span class="method-name">cp_p</span><span class="method-args">(src, dest, options={})</span>
|
199
|
+
</a>
|
200
|
+
</div>
|
201
|
+
|
202
|
+
<div class="method-description">
|
203
|
+
<p>
|
204
|
+
copy files into dest with timestamp preserved
|
205
|
+
</p>
|
206
|
+
<p>
|
207
|
+
ex1.
|
208
|
+
</p>
|
209
|
+
<pre>
|
210
|
+
cp_p('file1', 'file2')
|
211
|
+
</pre>
|
212
|
+
<p>
|
213
|
+
ex2.
|
214
|
+
</p>
|
215
|
+
<pre>
|
216
|
+
cp_p(['file1', 'file2', 'file3'], 'dir')
|
217
|
+
</pre>
|
218
|
+
<p><a class="source-toggle" href="#"
|
219
|
+
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
220
|
+
<div class="method-source-code" id="M000003-source">
|
221
|
+
<pre>
|
222
|
+
<span class="ruby-comment cmt"># File rook/helper/fileutils.rb, line 31</span>
|
223
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cp_p</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">options</span>={})
|
224
|
+
(<span class="ruby-identifier">options</span> <span class="ruby-operator">||=</span> {})[<span class="ruby-identifier">:preserve</span>] = <span class="ruby-keyword kw">true</span>
|
225
|
+
<span class="ruby-identifier">cp</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">options</span>)
|
226
|
+
<span class="ruby-keyword kw">end</span>
|
227
|
+
</pre>
|
228
|
+
</div>
|
229
|
+
</div>
|
230
|
+
</div>
|
231
|
+
|
232
|
+
<div id="method-M000004" class="method-detail">
|
233
|
+
<a name="M000004"></a>
|
234
|
+
|
235
|
+
<div class="method-heading">
|
236
|
+
<a href="#M000004" class="method-signature">
|
237
|
+
<span class="method-name">cp_pr</span><span class="method-args">(src, dest, options={})</span>
|
238
|
+
</a>
|
239
|
+
</div>
|
240
|
+
|
241
|
+
<div class="method-description">
|
242
|
+
<p>
|
243
|
+
copy files into dest recursively with timestamp preserved
|
244
|
+
</p>
|
245
|
+
<p>
|
246
|
+
ex1.
|
247
|
+
</p>
|
248
|
+
<pre>
|
249
|
+
cp_pr('file1', 'file2')
|
250
|
+
</pre>
|
251
|
+
<p>
|
252
|
+
ex2.
|
253
|
+
</p>
|
254
|
+
<pre>
|
255
|
+
cp_pr(['file1', 'file2', 'file3'], 'dir')
|
256
|
+
</pre>
|
257
|
+
<p><a class="source-toggle" href="#"
|
258
|
+
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
259
|
+
<div class="method-source-code" id="M000004-source">
|
260
|
+
<pre>
|
261
|
+
<span class="ruby-comment cmt"># File rook/helper/fileutils.rb, line 46</span>
|
262
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cp_pr</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">options</span>={})
|
263
|
+
(<span class="ruby-identifier">options</span> <span class="ruby-operator">||=</span> {})[<span class="ruby-identifier">:preserve</span>] = <span class="ruby-keyword kw">true</span>
|
264
|
+
<span class="ruby-identifier">cp_r</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">options</span>)
|
265
|
+
<span class="ruby-keyword kw">end</span>
|
266
|
+
</pre>
|
267
|
+
</div>
|
268
|
+
</div>
|
269
|
+
</div>
|
270
|
+
|
271
|
+
<div id="method-M000006" class="method-detail">
|
272
|
+
<a name="M000006"></a>
|
273
|
+
|
274
|
+
<div class="method-heading">
|
275
|
+
<a href="#M000006" class="method-signature">
|
276
|
+
<span class="method-name">store</span><span class="method-args">(src, dest, options={})</span>
|
277
|
+
</a>
|
278
|
+
</div>
|
279
|
+
|
280
|
+
<div class="method-description">
|
281
|
+
<p>
|
282
|
+
copy files to dest with keeping it’s filepath
|
283
|
+
</p>
|
284
|
+
<p>
|
285
|
+
ex1. copy ‘lib/rook/rook.rb’ into
|
286
|
+
‘tmp/lib/rook/rook.rb‘
|
287
|
+
</p>
|
288
|
+
<pre>
|
289
|
+
store('lib/rook/rook.rb', 'tmp')
|
290
|
+
</pre>
|
291
|
+
<p>
|
292
|
+
ex2. copy all ‘lib/**/*.rb’ into ‘tmp/lib/**/*.rb’
|
293
|
+
</p>
|
294
|
+
<pre>
|
295
|
+
cp_a(Dir.glob('lib/**/*.rb'), 'tmp')
|
296
|
+
</pre>
|
297
|
+
<p><a class="source-toggle" href="#"
|
298
|
+
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
299
|
+
<div class="method-source-code" id="M000006-source">
|
300
|
+
<pre>
|
301
|
+
<span class="ruby-comment cmt"># File rook/helper/fileutils.rb, line 87</span>
|
302
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">store</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">options</span>={})
|
303
|
+
<span class="ruby-identifier">_store</span>(<span class="ruby-identifier">:cp</span>, <span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">options</span>)
|
304
|
+
<span class="ruby-keyword kw">end</span>
|
305
|
+
</pre>
|
306
|
+
</div>
|
307
|
+
</div>
|
308
|
+
</div>
|
309
|
+
|
310
|
+
<div id="method-M000008" class="method-detail">
|
311
|
+
<a name="M000008"></a>
|
312
|
+
|
313
|
+
<div class="method-heading">
|
314
|
+
<a href="#M000008" class="method-signature">
|
315
|
+
<span class="method-name">store_a</span><span class="method-args">(src, dest, options={})</span>
|
316
|
+
</a>
|
317
|
+
</div>
|
318
|
+
|
319
|
+
<div class="method-description">
|
320
|
+
<p>
|
321
|
+
copy files to dest with keeping it’s filepath and file type
|
322
|
+
</p>
|
323
|
+
<p><a class="source-toggle" href="#"
|
324
|
+
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
325
|
+
<div class="method-source-code" id="M000008-source">
|
326
|
+
<pre>
|
327
|
+
<span class="ruby-comment cmt"># File rook/helper/fileutils.rb, line 105</span>
|
328
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">store_a</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">options</span>={})
|
329
|
+
<span class="ruby-identifier">_store</span>(<span class="ruby-identifier">:cp_a</span>, <span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">options</span>)
|
330
|
+
<span class="ruby-keyword kw">end</span>
|
331
|
+
</pre>
|
332
|
+
</div>
|
333
|
+
</div>
|
334
|
+
</div>
|
335
|
+
|
336
|
+
<div id="method-M000007" class="method-detail">
|
337
|
+
<a name="M000007"></a>
|
338
|
+
|
339
|
+
<div class="method-heading">
|
340
|
+
<a href="#M000007" class="method-signature">
|
341
|
+
<span class="method-name">store_p</span><span class="method-args">(src, dest, options={})</span>
|
342
|
+
</a>
|
343
|
+
</div>
|
344
|
+
|
345
|
+
<div class="method-description">
|
346
|
+
<p>
|
347
|
+
copy files to dest with keeping it’s filepath and timestamp
|
348
|
+
</p>
|
349
|
+
<p><a class="source-toggle" href="#"
|
350
|
+
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
351
|
+
<div class="method-source-code" id="M000007-source">
|
352
|
+
<pre>
|
353
|
+
<span class="ruby-comment cmt"># File rook/helper/fileutils.rb, line 96</span>
|
354
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">store_p</span>(<span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">options</span>={})
|
355
|
+
<span class="ruby-identifier">_store</span>(<span class="ruby-identifier">:cp_p</span>, <span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>, <span class="ruby-identifier">options</span>)
|
356
|
+
<span class="ruby-keyword kw">end</span>
|
357
|
+
</pre>
|
358
|
+
</div>
|
359
|
+
</div>
|
360
|
+
</div>
|
361
|
+
|
362
|
+
<div id="method-M000012" class="method-detail">
|
363
|
+
<a name="M000012"></a>
|
364
|
+
|
365
|
+
<div class="method-heading">
|
366
|
+
<a href="#M000012" class="method-signature">
|
367
|
+
<span class="method-name">tar_cf</span><span class="method-args">(tarfilename, filenames, options={})</span>
|
368
|
+
</a>
|
369
|
+
</div>
|
370
|
+
|
371
|
+
<div class="method-description">
|
372
|
+
<p>
|
373
|
+
create *.tar file
|
374
|
+
</p>
|
375
|
+
<p>
|
376
|
+
requires ‘minitar’ library.
|
377
|
+
</p>
|
378
|
+
<p>
|
379
|
+
ex1.
|
380
|
+
</p>
|
381
|
+
<pre>
|
382
|
+
tar_cf 'foo.tar', Dir.glob('*.txt')
|
383
|
+
</pre>
|
384
|
+
<p><a class="source-toggle" href="#"
|
385
|
+
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
386
|
+
<div class="method-source-code" id="M000012-source">
|
387
|
+
<pre>
|
388
|
+
<span class="ruby-comment cmt"># File rook/helper/fileutils.rb, line 229</span>
|
389
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tar_cf</span>(<span class="ruby-identifier">tarfilename</span>, <span class="ruby-identifier">filenames</span>, <span class="ruby-identifier">options</span>={})
|
390
|
+
<span class="ruby-identifier">_tar_cf</span>(<span class="ruby-identifier">tarfilename</span>, <span class="ruby-identifier">filenames</span>, <span class="ruby-identifier">options</span>, <span class="ruby-value str">'-cf'</span>, <span class="ruby-identifier">null</span>)
|
391
|
+
<span class="ruby-keyword kw">end</span>
|
392
|
+
</pre>
|
393
|
+
</div>
|
394
|
+
</div>
|
395
|
+
</div>
|
396
|
+
|
397
|
+
<div id="method-M000016" class="method-detail">
|
398
|
+
<a name="M000016"></a>
|
399
|
+
|
400
|
+
<div class="method-heading">
|
401
|
+
<a href="#M000016" class="method-signature">
|
402
|
+
<span class="method-name">tar_cjf</span><span class="method-args">(tarfilename, filenames, options={})</span>
|
403
|
+
</a>
|
404
|
+
</div>
|
405
|
+
|
406
|
+
<div class="method-description">
|
407
|
+
<p>
|
408
|
+
create *.tar.bz2 file
|
409
|
+
</p>
|
410
|
+
<p>
|
411
|
+
requires ‘bz2’ and ‘minitar’ library.
|
412
|
+
</p>
|
413
|
+
<p>
|
414
|
+
ex1.
|
415
|
+
</p>
|
416
|
+
<pre>
|
417
|
+
tar_cjf 'foo.tar.bz2', Dir.glob('*.txt')
|
418
|
+
</pre>
|
419
|
+
<p><a class="source-toggle" href="#"
|
420
|
+
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
|
421
|
+
<div class="method-source-code" id="M000016-source">
|
422
|
+
<pre>
|
423
|
+
<span class="ruby-comment cmt"># File rook/helper/fileutils.rb, line 291</span>
|
424
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tar_cjf</span>(<span class="ruby-identifier">tarfilename</span>, <span class="ruby-identifier">filenames</span>, <span class="ruby-identifier">options</span>={})
|
425
|
+
<span class="ruby-identifier">require</span> <span class="ruby-value str">'bz2'</span>
|
426
|
+
<span class="ruby-identifier">require</span> <span class="ruby-value str">'rook/helper/bz2'</span>
|
427
|
+
<span class="ruby-identifier">_tar_cf</span>(<span class="ruby-identifier">tarfilename</span>, <span class="ruby-identifier">filenames</span>, <span class="ruby-identifier">options</span>, <span class="ruby-value str">'-cjf'</span>, <span class="ruby-operator">::</span><span class="ruby-constant">BZ2</span><span class="ruby-operator">::</span><span class="ruby-constant">Writer</span>)
|
428
|
+
<span class="ruby-keyword kw">end</span>
|
429
|
+
</pre>
|
430
|
+
</div>
|
431
|
+
</div>
|
432
|
+
</div>
|
433
|
+
|
434
|
+
<div id="method-M000014" class="method-detail">
|
435
|
+
<a name="M000014"></a>
|
436
|
+
|
437
|
+
<div class="method-heading">
|
438
|
+
<a href="#M000014" class="method-signature">
|
439
|
+
<span class="method-name">tar_czf</span><span class="method-args">(tarfilename, filenames, options={})</span>
|
440
|
+
</a>
|
441
|
+
</div>
|
442
|
+
|
443
|
+
<div class="method-description">
|
444
|
+
<p>
|
445
|
+
create *.tar.gz file
|
446
|
+
</p>
|
447
|
+
<p>
|
448
|
+
requires ‘minitar’ library.
|
449
|
+
</p>
|
450
|
+
<p>
|
451
|
+
ex1.
|
452
|
+
</p>
|
453
|
+
<pre>
|
454
|
+
tar_czf 'foo.tar.gz', Dir.glob('*.txt')
|
455
|
+
</pre>
|
456
|
+
<p><a class="source-toggle" href="#"
|
457
|
+
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
458
|
+
<div class="method-source-code" id="M000014-source">
|
459
|
+
<pre>
|
460
|
+
<span class="ruby-comment cmt"># File rook/helper/fileutils.rb, line 259</span>
|
461
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tar_czf</span>(<span class="ruby-identifier">tarfilename</span>, <span class="ruby-identifier">filenames</span>, <span class="ruby-identifier">options</span>={})
|
462
|
+
<span class="ruby-identifier">require</span> <span class="ruby-value str">'zlib'</span>
|
463
|
+
<span class="ruby-identifier">_tar_cf</span>(<span class="ruby-identifier">tarfilename</span>, <span class="ruby-identifier">filenames</span>, <span class="ruby-identifier">options</span>, <span class="ruby-value str">'-czf'</span>, <span class="ruby-operator">::</span><span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">GzipWriter</span>)
|
464
|
+
<span class="ruby-keyword kw">end</span>
|
465
|
+
</pre>
|
466
|
+
</div>
|
467
|
+
</div>
|
468
|
+
</div>
|
469
|
+
|
470
|
+
<div id="method-M000013" class="method-detail">
|
471
|
+
<a name="M000013"></a>
|
472
|
+
|
473
|
+
<div class="method-heading">
|
474
|
+
<a href="#M000013" class="method-signature">
|
475
|
+
<span class="method-name">tar_xf</span><span class="method-args">(tarfilename, filenames=[], options={})</span>
|
476
|
+
</a>
|
477
|
+
</div>
|
478
|
+
|
479
|
+
<div class="method-description">
|
480
|
+
<p>
|
481
|
+
extract *.tar file
|
482
|
+
</p>
|
483
|
+
<p>
|
484
|
+
requires ‘minitar’ library.
|
485
|
+
</p>
|
486
|
+
<p>
|
487
|
+
ex1.
|
488
|
+
</p>
|
489
|
+
<pre>
|
490
|
+
tar_xf 'foo.tar'
|
491
|
+
</pre>
|
492
|
+
<p>
|
493
|
+
ex2.
|
494
|
+
</p>
|
495
|
+
<pre>
|
496
|
+
tar_xf 'foo.tar', ['file1.txt', 'file2.txt']
|
497
|
+
</pre>
|
498
|
+
<p><a class="source-toggle" href="#"
|
499
|
+
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
500
|
+
<div class="method-source-code" id="M000013-source">
|
501
|
+
<pre>
|
502
|
+
<span class="ruby-comment cmt"># File rook/helper/fileutils.rb, line 245</span>
|
503
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tar_xf</span>(<span class="ruby-identifier">tarfilename</span>, <span class="ruby-identifier">filenames</span>=[], <span class="ruby-identifier">options</span>={})
|
504
|
+
<span class="ruby-identifier">_tar_xf</span>(<span class="ruby-identifier">tarfilename</span>, <span class="ruby-identifier">filenames</span>, <span class="ruby-identifier">options</span>, <span class="ruby-value str">'-xf'</span>, <span class="ruby-identifier">null</span>)
|
505
|
+
<span class="ruby-keyword kw">end</span>
|
506
|
+
</pre>
|
507
|
+
</div>
|
508
|
+
</div>
|
509
|
+
</div>
|
510
|
+
|
511
|
+
<div id="method-M000017" class="method-detail">
|
512
|
+
<a name="M000017"></a>
|
513
|
+
|
514
|
+
<div class="method-heading">
|
515
|
+
<a href="#M000017" class="method-signature">
|
516
|
+
<span class="method-name">tar_xjf</span><span class="method-args">(tarfilename, filenames=[], options={})</span>
|
517
|
+
</a>
|
518
|
+
</div>
|
519
|
+
|
520
|
+
<div class="method-description">
|
521
|
+
<p>
|
522
|
+
extract *.tar.bz2 file
|
523
|
+
</p>
|
524
|
+
<p>
|
525
|
+
requires ‘bz2’ and ‘minitar’ library.
|
526
|
+
</p>
|
527
|
+
<p>
|
528
|
+
ex1.
|
529
|
+
</p>
|
530
|
+
<pre>
|
531
|
+
tar_xjf 'foo.tar.bz2'
|
532
|
+
</pre>
|
533
|
+
<p>
|
534
|
+
ex2.
|
535
|
+
</p>
|
536
|
+
<pre>
|
537
|
+
tar_xjf 'foo.tar.bz2', ['file1.txt', 'file2.txt']
|
538
|
+
</pre>
|
539
|
+
<p><a class="source-toggle" href="#"
|
540
|
+
onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
|
541
|
+
<div class="method-source-code" id="M000017-source">
|
542
|
+
<pre>
|
543
|
+
<span class="ruby-comment cmt"># File rook/helper/fileutils.rb, line 309</span>
|
544
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tar_xjf</span>(<span class="ruby-identifier">tarfilename</span>, <span class="ruby-identifier">filenames</span>=[], <span class="ruby-identifier">options</span>={})
|
545
|
+
<span class="ruby-identifier">require</span> <span class="ruby-value str">'bz2'</span>
|
546
|
+
<span class="ruby-identifier">require</span> <span class="ruby-value str">'rook/bz2-helper'</span>
|
547
|
+
<span class="ruby-identifier">_tar_xf</span>(<span class="ruby-identifier">tarfilename</span>, <span class="ruby-identifier">filenames</span>, <span class="ruby-identifier">options</span>, <span class="ruby-value str">"-xjf"</span>, <span class="ruby-operator">::</span><span class="ruby-constant">BZ2</span><span class="ruby-operator">::</span><span class="ruby-constant">Writer</span>)
|
548
|
+
<span class="ruby-keyword kw">end</span>
|
549
|
+
</pre>
|
550
|
+
</div>
|
551
|
+
</div>
|
552
|
+
</div>
|
553
|
+
|
554
|
+
<div id="method-M000015" class="method-detail">
|
555
|
+
<a name="M000015"></a>
|
556
|
+
|
557
|
+
<div class="method-heading">
|
558
|
+
<a href="#M000015" class="method-signature">
|
559
|
+
<span class="method-name">tar_xzf</span><span class="method-args">(tarfilename, filenames=[], options={})</span>
|
560
|
+
</a>
|
561
|
+
</div>
|
562
|
+
|
563
|
+
<div class="method-description">
|
564
|
+
<p>
|
565
|
+
extract *.tar.gz file
|
566
|
+
</p>
|
567
|
+
<p>
|
568
|
+
requires ‘minitar’ library.
|
569
|
+
</p>
|
570
|
+
<p>
|
571
|
+
ex1.
|
572
|
+
</p>
|
573
|
+
<pre>
|
574
|
+
tar_xzf 'foo.tar.gz'
|
575
|
+
</pre>
|
576
|
+
<p>
|
577
|
+
ex2.
|
578
|
+
</p>
|
579
|
+
<pre>
|
580
|
+
tar_xzf 'foo.tar', ['file1.txt', 'file2.txt']
|
581
|
+
</pre>
|
582
|
+
<p><a class="source-toggle" href="#"
|
583
|
+
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
584
|
+
<div class="method-source-code" id="M000015-source">
|
585
|
+
<pre>
|
586
|
+
<span class="ruby-comment cmt"># File rook/helper/fileutils.rb, line 276</span>
|
587
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tar_xzf</span>(<span class="ruby-identifier">tarfilename</span>, <span class="ruby-identifier">filenames</span>=[], <span class="ruby-identifier">options</span>={})
|
588
|
+
<span class="ruby-identifier">require</span> <span class="ruby-value str">'zlib'</span>
|
589
|
+
<span class="ruby-identifier">_tar_xf</span>(<span class="ruby-identifier">tarfilename</span>, <span class="ruby-identifier">filenames</span>, <span class="ruby-identifier">options</span>, <span class="ruby-value str">"-xzf"</span>, <span class="ruby-operator">::</span><span class="ruby-constant">Zlib</span><span class="ruby-operator">::</span><span class="ruby-constant">GzipReader</span>)
|
590
|
+
<span class="ruby-keyword kw">end</span>
|
591
|
+
</pre>
|
592
|
+
</div>
|
593
|
+
</div>
|
594
|
+
</div>
|
595
|
+
|
596
|
+
<div id="method-M000011" class="method-detail">
|
597
|
+
<a name="M000011"></a>
|
598
|
+
|
599
|
+
<div class="method-heading">
|
600
|
+
<a href="#M000011" class="method-signature">
|
601
|
+
<span class="method-name">unzip</span><span class="method-args">(zipfilename, filenames=nil, options={})</span>
|
602
|
+
</a>
|
603
|
+
</div>
|
604
|
+
|
605
|
+
<div class="method-description">
|
606
|
+
<p>
|
607
|
+
unzip *.zip file
|
608
|
+
</p>
|
609
|
+
<p>
|
610
|
+
requires ‘rubyzip’ library.
|
611
|
+
</p>
|
612
|
+
<p>
|
613
|
+
ex1.
|
614
|
+
</p>
|
615
|
+
<pre>
|
616
|
+
unzip 'foo-1.1.zip', :basedir=>'foo'
|
617
|
+
</pre>
|
618
|
+
<p>
|
619
|
+
ex2.
|
620
|
+
</p>
|
621
|
+
<pre>
|
622
|
+
unzip 'foo-1.1.zip', ['foo1.txt', 'foo2.txt']
|
623
|
+
</pre>
|
624
|
+
<p><a class="source-toggle" href="#"
|
625
|
+
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
626
|
+
<div class="method-source-code" id="M000011-source">
|
627
|
+
<pre>
|
628
|
+
<span class="ruby-comment cmt"># File rook/helper/fileutils.rb, line 195</span>
|
629
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unzip</span>(<span class="ruby-identifier">zipfilename</span>, <span class="ruby-identifier">filenames</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">options</span>={})
|
630
|
+
<span class="ruby-identifier">require</span> <span class="ruby-value str">'zip/zip'</span>
|
631
|
+
<span class="ruby-identifier">basedir</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:basedir</span>]
|
632
|
+
<span class="ruby-identifier">filenames</span> = [ <span class="ruby-identifier">filenames</span> ] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">filenames</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">filenames</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
|
633
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:verbose</span>]
|
634
|
+
<span class="ruby-identifier">opt_str</span> = <span class="ruby-value str">''</span>
|
635
|
+
<span class="ruby-identifier">opt_str</span> <span class="ruby-operator"><<</span> <span class="ruby-node">" -r #{basedir}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:basedir</span>]
|
636
|
+
<span class="ruby-identifier">fu_output_message</span>(<span class="ruby-node">"unzip#{opt_str} #{zipfilename} #{filenames ? filenames.join(' ') : ''}"</span>)
|
637
|
+
<span class="ruby-keyword kw">end</span>
|
638
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:noop</span>]
|
639
|
+
<span class="ruby-operator">::</span><span class="ruby-constant">Zip</span><span class="ruby-operator">::</span><span class="ruby-constant">ZipFile</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">zipfilename</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">zipfile</span><span class="ruby-operator">|</span>
|
640
|
+
<span class="ruby-identifier">zipfile</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">entry</span><span class="ruby-operator">|</span> <span class="ruby-comment cmt"># entry.class == Zip::ZipEntry</span>
|
641
|
+
<span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">filenames</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">filenames</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">entry</span>.<span class="ruby-identifier">name</span>)
|
642
|
+
<span class="ruby-identifier">filename</span> = <span class="ruby-identifier">basedir</span> <span class="ruby-value">? </span><span class="ruby-node">"#{basedir}/#{entry}"</span> <span class="ruby-operator">:</span> <span class="ruby-node">"#{entry}"</span>
|
643
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">test</span>(<span class="ruby-value">?e</span>, <span class="ruby-identifier">filename</span>)
|
644
|
+
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm_rf</span>(<span class="ruby-identifier">filename</span>) <span class="ruby-comment cmt"># if entry.file? || !test(?d, filename)</span>
|
645
|
+
<span class="ruby-keyword kw">else</span>
|
646
|
+
<span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">mkdir_p</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">filename</span>))
|
647
|
+
<span class="ruby-keyword kw">end</span>
|
648
|
+
<span class="ruby-identifier">zipfile</span>.<span class="ruby-identifier">extract</span>(<span class="ruby-identifier">entry</span>, <span class="ruby-identifier">filename</span>)
|
649
|
+
<span class="ruby-keyword kw">end</span>
|
650
|
+
<span class="ruby-keyword kw">end</span>
|
651
|
+
<span class="ruby-keyword kw">end</span>
|
652
|
+
</pre>
|
653
|
+
</div>
|
654
|
+
</div>
|
655
|
+
</div>
|
656
|
+
|
657
|
+
<div id="method-M000009" class="method-detail">
|
658
|
+
<a name="M000009"></a>
|
659
|
+
|
660
|
+
<div class="method-heading">
|
661
|
+
<a href="#M000009" class="method-signature">
|
662
|
+
<span class="method-name">zip</span><span class="method-args">(zipfilename, filenames, options={})</span>
|
663
|
+
</a>
|
664
|
+
</div>
|
665
|
+
|
666
|
+
<div class="method-description">
|
667
|
+
<p>
|
668
|
+
create *.zip file
|
669
|
+
</p>
|
670
|
+
<p>
|
671
|
+
requires ‘rubyzip’ library.
|
672
|
+
</p>
|
673
|
+
<p>
|
674
|
+
ex1.
|
675
|
+
</p>
|
676
|
+
<pre>
|
677
|
+
zip 'file.zip', Dir.glob('*.txt')
|
678
|
+
</pre>
|
679
|
+
<p>
|
680
|
+
ex2.
|
681
|
+
</p>
|
682
|
+
<pre>
|
683
|
+
zip 'file.zip', Dir.glob('*.txt'), :basedir=>'path'
|
684
|
+
</pre>
|
685
|
+
<p><a class="source-toggle" href="#"
|
686
|
+
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
687
|
+
<div class="method-source-code" id="M000009-source">
|
688
|
+
<pre>
|
689
|
+
<span class="ruby-comment cmt"># File rook/helper/fileutils.rb, line 149</span>
|
690
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">zip</span>(<span class="ruby-identifier">zipfilename</span>, <span class="ruby-identifier">filenames</span>, <span class="ruby-identifier">options</span>={})
|
691
|
+
<span class="ruby-identifier">require</span> <span class="ruby-value str">'zip/zip'</span>
|
692
|
+
<span class="ruby-identifier">basedir</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:basedir</span>]
|
693
|
+
<span class="ruby-identifier">filenames</span> = [ <span class="ruby-identifier">filenames</span> ] <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">filenames</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
|
694
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:verbose</span>]
|
695
|
+
<span class="ruby-identifier">opt_str</span> = <span class="ruby-value str">''</span>
|
696
|
+
<span class="ruby-identifier">opt_str</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">'r'</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:recursive</span>]
|
697
|
+
<span class="ruby-identifier">opt_str</span> = <span class="ruby-value str">' -'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">opt_str</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">opt_str</span>.<span class="ruby-identifier">empty?</span>
|
698
|
+
<span class="ruby-identifier">fu_output_message</span>(<span class="ruby-node">"zip#{opt_str} #{zipfilename} #{filenames.join(' ')}"</span>)
|
699
|
+
<span class="ruby-keyword kw">end</span>
|
700
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:noop</span>]
|
701
|
+
<span class="ruby-operator">::</span><span class="ruby-constant">Zip</span><span class="ruby-operator">::</span><span class="ruby-constant">ZipFile</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">zipfilename</span>, <span class="ruby-keyword kw">true</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">zipfile</span><span class="ruby-operator">|</span>
|
702
|
+
<span class="ruby-identifier">filenames</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">fname</span><span class="ruby-operator">|</span>
|
703
|
+
<span class="ruby-identifier">list</span> = <span class="ruby-identifier">test</span>(<span class="ruby-value">?d</span>, <span class="ruby-identifier">fname</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:recursive</span>] <span class="ruby-operator">?</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-node">"#{fname}/**/*"</span>) <span class="ruby-operator">:</span> [<span class="ruby-identifier">fname</span>]
|
704
|
+
<span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">filename</span><span class="ruby-operator">|</span>
|
705
|
+
<span class="ruby-identifier">entry</span> = <span class="ruby-identifier">basedir</span> <span class="ruby-value">? </span><span class="ruby-node">"#{basedir}/#{fname}"</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">filename</span>
|
706
|
+
<span class="ruby-identifier">zipfile</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">entry</span>, <span class="ruby-identifier">filename</span>)
|
707
|
+
<span class="ruby-keyword kw">end</span>
|
708
|
+
<span class="ruby-keyword kw">end</span>
|
709
|
+
<span class="ruby-keyword kw">end</span>
|
710
|
+
<span class="ruby-keyword kw">end</span>
|
711
|
+
</pre>
|
712
|
+
</div>
|
713
|
+
</div>
|
714
|
+
</div>
|
715
|
+
|
716
|
+
<div id="method-M000010" class="method-detail">
|
717
|
+
<a name="M000010"></a>
|
718
|
+
|
719
|
+
<div class="method-heading">
|
720
|
+
<a href="#M000010" class="method-signature">
|
721
|
+
<span class="method-name">zip_r</span><span class="method-args">(zipfilename, filenames, options={})</span>
|
722
|
+
</a>
|
723
|
+
</div>
|
724
|
+
|
725
|
+
<div class="method-description">
|
726
|
+
<p>
|
727
|
+
create *.zip file with keeping filepath
|
728
|
+
</p>
|
729
|
+
<p>
|
730
|
+
requires ‘rubyzip’ library.
|
731
|
+
</p>
|
732
|
+
<p><a class="source-toggle" href="#"
|
733
|
+
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
734
|
+
<div class="method-source-code" id="M000010-source">
|
735
|
+
<pre>
|
736
|
+
<span class="ruby-comment cmt"># File rook/helper/fileutils.rb, line 178</span>
|
737
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">zip_r</span>(<span class="ruby-identifier">zipfilename</span>, <span class="ruby-identifier">filenames</span>, <span class="ruby-identifier">options</span>={})
|
738
|
+
(<span class="ruby-identifier">options</span> <span class="ruby-operator">||=</span> {})[<span class="ruby-identifier">:recursive</span>] = <span class="ruby-keyword kw">true</span>
|
739
|
+
<span class="ruby-identifier">zip</span>(<span class="ruby-identifier">zipfilename</span>, <span class="ruby-identifier">filenames</span>, <span class="ruby-identifier">options</span>)
|
740
|
+
<span class="ruby-keyword kw">end</span>
|
741
|
+
</pre>
|
742
|
+
</div>
|
743
|
+
</div>
|
744
|
+
</div>
|
745
|
+
|
746
|
+
|
747
|
+
</div>
|
748
|
+
|
749
|
+
|
750
|
+
</div>
|
751
|
+
|
752
|
+
|
753
|
+
<div id="validator-badges">
|
754
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
755
|
+
</div>
|
756
|
+
|
757
|
+
</body>
|
758
|
+
</html>
|