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,50 @@
|
|
1
|
+
##
|
2
|
+
## $Rev: 20 $
|
3
|
+
## $Release: 0.1.0 $
|
4
|
+
## copyright(c) 2006 kuwata-lab.com all rights reserved.
|
5
|
+
##
|
6
|
+
|
7
|
+
|
8
|
+
##
|
9
|
+
## extends File class
|
10
|
+
##
|
11
|
+
class File
|
12
|
+
|
13
|
+
|
14
|
+
##
|
15
|
+
## edit file content
|
16
|
+
##
|
17
|
+
## ex.
|
18
|
+
## File.edit('file.txt') do |content|
|
19
|
+
## content.gsub!(/\$Release\$/, '1.0.0')
|
20
|
+
## content.gsub!(/\$Copyright\$/, '(c)kuwata-lab')
|
21
|
+
## end
|
22
|
+
##
|
23
|
+
def self.edit(filename, &block)
|
24
|
+
File.open(filename, 'r+') do |f|
|
25
|
+
content = f.read()
|
26
|
+
#yield(content)
|
27
|
+
block.arity == 1 ? yield(content) : yield(content, filename)
|
28
|
+
f.rewind()
|
29
|
+
f.truncate(0)
|
30
|
+
f.write(content)
|
31
|
+
end if test(?f, filename)
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
##
|
36
|
+
## write file
|
37
|
+
##
|
38
|
+
## ex.
|
39
|
+
## content = <<END
|
40
|
+
## foo
|
41
|
+
## bar
|
42
|
+
## END
|
43
|
+
## File.write('file.txt', content)
|
44
|
+
##
|
45
|
+
def self.write(filename, content)
|
46
|
+
File.open(filename, 'w') { |f| f.write(content) }
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,340 @@
|
|
1
|
+
##
|
2
|
+
## $Rev: 26 $
|
3
|
+
## $Release: 0.1.0 $
|
4
|
+
## copyright(c) 2006 kuwata-lab.com all rights reserved.
|
5
|
+
##
|
6
|
+
|
7
|
+
|
8
|
+
require 'fileutils'
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
##
|
13
|
+
## extends FileUtils
|
14
|
+
##
|
15
|
+
## requires 'rubyzip', 'bz2', and 'minitar' library.
|
16
|
+
## * rubyzip - http://raa.ruby-lang.org/project/rubyzip/
|
17
|
+
## * bz2 - http://raa.ruby-lang.org/project/bz2/
|
18
|
+
## * minitar - http://raa.ruby-lang.org/project/minitar/
|
19
|
+
##
|
20
|
+
module FileUtils
|
21
|
+
|
22
|
+
|
23
|
+
##
|
24
|
+
## copy files into dest with timestamp preserved
|
25
|
+
##
|
26
|
+
## ex1.
|
27
|
+
## cp_p('file1', 'file2')
|
28
|
+
## ex2.
|
29
|
+
## cp_p(['file1', 'file2', 'file3'], 'dir')
|
30
|
+
##
|
31
|
+
def cp_p(src, dest, options={})
|
32
|
+
(options ||= {})[:preserve] = true
|
33
|
+
cp(src, dest, options)
|
34
|
+
end
|
35
|
+
module_function :cp_p
|
36
|
+
|
37
|
+
|
38
|
+
##
|
39
|
+
## copy files into dest recursively with timestamp preserved
|
40
|
+
##
|
41
|
+
## ex1.
|
42
|
+
## cp_pr('file1', 'file2')
|
43
|
+
## ex2.
|
44
|
+
## cp_pr(['file1', 'file2', 'file3'], 'dir')
|
45
|
+
##
|
46
|
+
def cp_pr(src, dest, options={})
|
47
|
+
(options ||= {})[:preserve] = true
|
48
|
+
cp_r(src, dest, options)
|
49
|
+
end
|
50
|
+
module_function :cp_pr
|
51
|
+
|
52
|
+
|
53
|
+
##
|
54
|
+
## copy files into dest keeping file type (symbolic link, device file, etc)
|
55
|
+
##
|
56
|
+
## ex1.
|
57
|
+
## cp_a('file1', 'file2')
|
58
|
+
## ex2.
|
59
|
+
## cp_a(['file1', 'file2', 'file3'], 'dir')
|
60
|
+
##
|
61
|
+
def cp_a(src, dest, options={})
|
62
|
+
fu_check_options(options, :preserve, :verbose, :noop)
|
63
|
+
if options[:verbose]
|
64
|
+
opt_str = options[:preserve] ? ' -ap' : ' -p'
|
65
|
+
arg_str = [src, dest].flatten.join(' ')
|
66
|
+
fu_output_message("cp#{opt_str} #{arg_str}")
|
67
|
+
end
|
68
|
+
return if options[:noop]
|
69
|
+
dereference_root = false #options[:dereference_root]
|
70
|
+
(src.is_a?(Array) ? src : [src]).each do |item|
|
71
|
+
Dir.glob(item).each do |filename|
|
72
|
+
copy_entry(item, dest, options[:preserve], dereference_root)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
module_function :cp_a
|
77
|
+
|
78
|
+
|
79
|
+
##
|
80
|
+
## copy files to dest with keeping it's filepath
|
81
|
+
##
|
82
|
+
## ex1. copy 'lib/rook/rook.rb' into 'tmp/lib/rook/rook.rb'
|
83
|
+
## store('lib/rook/rook.rb', 'tmp')
|
84
|
+
## ex2. copy all 'lib/**/*.rb' into 'tmp/lib/**/*.rb'
|
85
|
+
## cp_a(Dir.glob('lib/**/*.rb'), 'tmp')
|
86
|
+
##
|
87
|
+
def store(src, dest, options={})
|
88
|
+
_store(:cp, src, dest, options)
|
89
|
+
end
|
90
|
+
module_function :store
|
91
|
+
|
92
|
+
|
93
|
+
##
|
94
|
+
## copy files to dest with keeping it's filepath and timestamp
|
95
|
+
##
|
96
|
+
def store_p(src, dest, options={})
|
97
|
+
_store(:cp_p, src, dest, options)
|
98
|
+
end
|
99
|
+
module_function :store_p
|
100
|
+
|
101
|
+
|
102
|
+
##
|
103
|
+
## copy files to dest with keeping it's filepath and file type
|
104
|
+
##
|
105
|
+
def store_a(src, dest, options={})
|
106
|
+
_store(:cp_a, src, dest, options)
|
107
|
+
end
|
108
|
+
module_function :store_a
|
109
|
+
|
110
|
+
|
111
|
+
def _store(cp_cmd, src, dest, options={}) # :nodoc:
|
112
|
+
fu_check_options(options, :preserve, :verbose, :noop)
|
113
|
+
if options[:verbose]
|
114
|
+
opt_str = options[:preserve] ? ' -p' : ''
|
115
|
+
arg_str = [src, dest].flatten.join(' ')
|
116
|
+
fu_output_message("store#{opt_str} #{arg_str}")
|
117
|
+
end
|
118
|
+
return if options[:noop]
|
119
|
+
options.delete(:verbose)
|
120
|
+
options.delete(:noop)
|
121
|
+
mkdir_options = options.dup
|
122
|
+
cp_options = options.dup
|
123
|
+
(src.is_a?(Array) ? src : [ src ]).each do |filename|
|
124
|
+
if test(?d, filename)
|
125
|
+
path = "#{dest}/#{filename}"
|
126
|
+
mkdir_p(path, mkdir_options) unless test(?d, path)
|
127
|
+
else
|
128
|
+
dir = File.dirname(filename)
|
129
|
+
base = File.basename(filename)
|
130
|
+
path = "#{dest}/#{dir}"
|
131
|
+
mkdir_p(path, mkdir_options) unless test(?d, path)
|
132
|
+
__send__(cp_cmd, filename, path, cp_options)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
module_function :_store
|
137
|
+
|
138
|
+
|
139
|
+
##
|
140
|
+
## create *.zip file
|
141
|
+
##
|
142
|
+
## requires 'rubyzip' library.
|
143
|
+
##
|
144
|
+
## ex1.
|
145
|
+
## zip 'file.zip', Dir.glob('*.txt')
|
146
|
+
## ex2.
|
147
|
+
## zip 'file.zip', Dir.glob('*.txt'), :basedir=>'path'
|
148
|
+
##
|
149
|
+
def zip(zipfilename, filenames, options={})
|
150
|
+
require 'zip/zip'
|
151
|
+
basedir = options[:basedir]
|
152
|
+
filenames = [ filenames ] unless filenames.is_a?(Array)
|
153
|
+
if options[:verbose]
|
154
|
+
opt_str = ''
|
155
|
+
opt_str << 'r' if options[:recursive]
|
156
|
+
opt_str = ' -' + opt_str unless opt_str.empty?
|
157
|
+
fu_output_message("zip#{opt_str} #{zipfilename} #{filenames.join(' ')}")
|
158
|
+
end
|
159
|
+
return if options[:noop]
|
160
|
+
::Zip::ZipFile.open(zipfilename, true) do |zipfile|
|
161
|
+
filenames.each do |fname|
|
162
|
+
list = test(?d, fname) && options[:recursive] ? Dir.glob("#{fname}/**/*") : [fname]
|
163
|
+
list.each do |filename|
|
164
|
+
entry = basedir ? "#{basedir}/#{fname}" : filename
|
165
|
+
zipfile.add(entry, filename)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
module_function :zip
|
171
|
+
|
172
|
+
|
173
|
+
##
|
174
|
+
## create *.zip file with keeping filepath
|
175
|
+
##
|
176
|
+
## requires 'rubyzip' library.
|
177
|
+
##
|
178
|
+
def zip_r(zipfilename, filenames, options={})
|
179
|
+
(options ||= {})[:recursive] = true
|
180
|
+
zip(zipfilename, filenames, options)
|
181
|
+
end
|
182
|
+
module_function :zip_r
|
183
|
+
|
184
|
+
|
185
|
+
##
|
186
|
+
## unzip *.zip file
|
187
|
+
##
|
188
|
+
## requires 'rubyzip' library.
|
189
|
+
##
|
190
|
+
## ex1.
|
191
|
+
## unzip 'foo-1.1.zip', :basedir=>'foo'
|
192
|
+
## ex2.
|
193
|
+
## unzip 'foo-1.1.zip', ['foo1.txt', 'foo2.txt']
|
194
|
+
##
|
195
|
+
def unzip(zipfilename, filenames=nil, options={})
|
196
|
+
require 'zip/zip'
|
197
|
+
basedir = options[:basedir]
|
198
|
+
filenames = [ filenames ] if filenames && !filenames.is_a?(Array)
|
199
|
+
if options[:verbose]
|
200
|
+
opt_str = ''
|
201
|
+
opt_str << " -r #{basedir}" if options[:basedir]
|
202
|
+
fu_output_message("unzip#{opt_str} #{zipfilename} #{filenames ? filenames.join(' ') : ''}")
|
203
|
+
end
|
204
|
+
return if options[:noop]
|
205
|
+
::Zip::ZipFile.open(zipfilename) do |zipfile|
|
206
|
+
zipfile.each do |entry| # entry.class == Zip::ZipEntry
|
207
|
+
next unless filenames.nil? || filenames.include?(entry.name)
|
208
|
+
filename = basedir ? "#{basedir}/#{entry}" : "#{entry}"
|
209
|
+
if test(?e, filename)
|
210
|
+
FileUtils.rm_rf(filename) # if entry.file? || !test(?d, filename)
|
211
|
+
else
|
212
|
+
FileUtils.mkdir_p(File.dirname(filename))
|
213
|
+
end
|
214
|
+
zipfile.extract(entry, filename)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
module_function :unzip
|
219
|
+
|
220
|
+
|
221
|
+
##
|
222
|
+
## create *.tar file
|
223
|
+
##
|
224
|
+
## requires 'minitar' library.
|
225
|
+
##
|
226
|
+
## ex1.
|
227
|
+
## tar_cf 'foo.tar', Dir.glob('*.txt')
|
228
|
+
##
|
229
|
+
def tar_cf(tarfilename, filenames, options={})
|
230
|
+
_tar_cf(tarfilename, filenames, options, '-cf', null)
|
231
|
+
end
|
232
|
+
module_function :tar_cf
|
233
|
+
|
234
|
+
|
235
|
+
##
|
236
|
+
## extract *.tar file
|
237
|
+
##
|
238
|
+
## requires 'minitar' library.
|
239
|
+
##
|
240
|
+
## ex1.
|
241
|
+
## tar_xf 'foo.tar'
|
242
|
+
## ex2.
|
243
|
+
## tar_xf 'foo.tar', ['file1.txt', 'file2.txt']
|
244
|
+
##
|
245
|
+
def tar_xf(tarfilename, filenames=[], options={})
|
246
|
+
_tar_xf(tarfilename, filenames, options, '-xf', null)
|
247
|
+
end
|
248
|
+
module_function :tar_xf
|
249
|
+
|
250
|
+
|
251
|
+
##
|
252
|
+
## create *.tar.gz file
|
253
|
+
##
|
254
|
+
## requires 'minitar' library.
|
255
|
+
##
|
256
|
+
## ex1.
|
257
|
+
## tar_czf 'foo.tar.gz', Dir.glob('*.txt')
|
258
|
+
##
|
259
|
+
def tar_czf(tarfilename, filenames, options={})
|
260
|
+
require 'zlib'
|
261
|
+
_tar_cf(tarfilename, filenames, options, '-czf', ::Zlib::GzipWriter)
|
262
|
+
end
|
263
|
+
module_function :tar_czf
|
264
|
+
|
265
|
+
|
266
|
+
##
|
267
|
+
## extract *.tar.gz file
|
268
|
+
##
|
269
|
+
## requires 'minitar' library.
|
270
|
+
##
|
271
|
+
## ex1.
|
272
|
+
## tar_xzf 'foo.tar.gz'
|
273
|
+
## ex2.
|
274
|
+
## tar_xzf 'foo.tar', ['file1.txt', 'file2.txt']
|
275
|
+
##
|
276
|
+
def tar_xzf(tarfilename, filenames=[], options={})
|
277
|
+
require 'zlib'
|
278
|
+
_tar_xf(tarfilename, filenames, options, "-xzf", ::Zlib::GzipReader)
|
279
|
+
end
|
280
|
+
module_function :tar_xzf
|
281
|
+
|
282
|
+
|
283
|
+
##
|
284
|
+
## create *.tar.bz2 file
|
285
|
+
##
|
286
|
+
## requires 'bz2' and 'minitar' library.
|
287
|
+
##
|
288
|
+
## ex1.
|
289
|
+
## tar_cjf 'foo.tar.bz2', Dir.glob('*.txt')
|
290
|
+
##
|
291
|
+
def tar_cjf(tarfilename, filenames, options={})
|
292
|
+
require 'bz2'
|
293
|
+
require 'rook/helper/bz2'
|
294
|
+
_tar_cf(tarfilename, filenames, options, '-cjf', ::BZ2::Writer)
|
295
|
+
end
|
296
|
+
module_function :tar_cjf
|
297
|
+
|
298
|
+
|
299
|
+
##
|
300
|
+
## extract *.tar.bz2 file
|
301
|
+
##
|
302
|
+
## requires 'bz2' and 'minitar' library.
|
303
|
+
##
|
304
|
+
## ex1.
|
305
|
+
## tar_xjf 'foo.tar.bz2'
|
306
|
+
## ex2.
|
307
|
+
## tar_xjf 'foo.tar.bz2', ['file1.txt', 'file2.txt']
|
308
|
+
##
|
309
|
+
def tar_xjf(tarfilename, filenames=[], options={})
|
310
|
+
require 'bz2'
|
311
|
+
require 'rook/bz2-helper'
|
312
|
+
_tar_xf(tarfilename, filenames, options, "-xjf", ::BZ2::Writer)
|
313
|
+
end
|
314
|
+
module_function :tar_xjf
|
315
|
+
|
316
|
+
|
317
|
+
def _tar_cf(tarfilename, filenames, options, taropt, writer_class) # :nodoc:
|
318
|
+
require 'archive/tar/minitar'
|
319
|
+
puts "tar #{taropt} #{tarfilename} #{filenames.to_a.join(' ')}" if options[:verbose]
|
320
|
+
return if options[:noop]
|
321
|
+
f = File.open(tarfilename, 'wb')
|
322
|
+
writer = writer_class ? writer_class.new(f) : f
|
323
|
+
::Archive::Tar::Minitar.pack(filenames, writer) # Warning: writer will be closed!
|
324
|
+
end
|
325
|
+
module_function :_tar_cf
|
326
|
+
|
327
|
+
|
328
|
+
def _tar_xf(tarfilename, filenames, options, taropt, reader_class) #:nodoc:
|
329
|
+
require 'archive/tar/minitar'
|
330
|
+
puts "tar #{taropt} #{tarfilename} #{filenames.to_a.join(' ')}" if options[:verbose]
|
331
|
+
return if options[:noop]
|
332
|
+
basedir = options[:basedir] || '.'
|
333
|
+
f = File.open(tarfilename, 'rb')
|
334
|
+
reader = reader_class ? reader_class.new(f) : f
|
335
|
+
::Archive::Tar::Minitar.unpack(reader, basedir) # Warning: reader will be closed!
|
336
|
+
end
|
337
|
+
module_function :_tar_xf
|
338
|
+
|
339
|
+
|
340
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
##
|
2
|
+
## $Rev: 20 $
|
3
|
+
## $Release: 0.1.0 $
|
4
|
+
## copyright(c) 2006 kuwata-lab.com all rights reserved.
|
5
|
+
##
|
6
|
+
|
7
|
+
|
8
|
+
##
|
9
|
+
## add several global functions.
|
10
|
+
##
|
11
|
+
## these are convenience for non-ruby user and compatibility with Kook.
|
12
|
+
##
|
13
|
+
module Kernel
|
14
|
+
|
15
|
+
|
16
|
+
module_function
|
17
|
+
|
18
|
+
|
19
|
+
def array_prefix(array, prefix)
|
20
|
+
return array.collect { |item| "#{prefix}#{item}" }
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
#--
|
25
|
+
#def array_prefix!(array, prefix)
|
26
|
+
# return array.collect! { |item| "#{prefix}#{item}" }
|
27
|
+
#end
|
28
|
+
#++
|
29
|
+
|
30
|
+
|
31
|
+
def array_suffix(array, suffix)
|
32
|
+
return array.collect { |item| "#{item}#{suffix}" }
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
#--
|
37
|
+
#def array_prefix!(array, prefix)
|
38
|
+
# return array.collect! { |item| "#{item}#{suffix}" }
|
39
|
+
#end
|
40
|
+
#++
|
41
|
+
|
42
|
+
|
43
|
+
def array_sandwich(array, prefix, suffix)
|
44
|
+
return array.collect { |item| "#{prefix}#{item}#{suffix}" }
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
#--
|
49
|
+
#def array_sandwich!(array, prefix, suffix)
|
50
|
+
# return array.collect! { |item| "#{prefix}#{item}#{suffix}" }
|
51
|
+
#end
|
52
|
+
#++
|
53
|
+
|
54
|
+
|
55
|
+
def array_delete_suffix(array, suffix=/\.\w+\z/)
|
56
|
+
return array.collect { |item| item.sub(suffix, '') }
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
#--
|
61
|
+
#def array_delete_suffix!(array, suffix=/\.\w+\z/)
|
62
|
+
# return array.collect { |item| item.sub(suffix, '') }
|
63
|
+
#end
|
64
|
+
#++
|
65
|
+
|
66
|
+
|
67
|
+
def array_delete_prefix(array, prefix)
|
68
|
+
return array.collect { |item| item.sub(prefix, '') }
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
#--
|
73
|
+
#def array_delete_prefix!(array, prefix)
|
74
|
+
# return array.collect! { |item| item.sub(prefix, '') }
|
75
|
+
#end
|
76
|
+
#++
|
77
|
+
|
78
|
+
|
79
|
+
def array_join(array, separator)
|
80
|
+
return array.join(separator)
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
def array_basenames(array)
|
85
|
+
return array.collect { |item| File.basename(item) }
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
#--
|
90
|
+
#def array_basenames!(array)
|
91
|
+
# return array.collect { |item| File.basename(item) }
|
92
|
+
#end
|
93
|
+
#++
|
94
|
+
|
95
|
+
|
96
|
+
def array_dirnames(array)
|
97
|
+
return array.collect { |item| File.dirname(item) }
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
#--
|
102
|
+
#def array_dirnames!(array)
|
103
|
+
# return array.collect { |item| File.dirname(item) }
|
104
|
+
#end
|
105
|
+
#++
|
106
|
+
|
107
|
+
|
108
|
+
end
|