Renamer 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/renamer +5 -88
- data/doc/ChangeLog.rdoc +5 -0
- data/lib/command_line.rb +99 -0
- data/lib/const.rb +3 -3
- data/lib/renamer.rb +230 -233
- data/po/fr/renamer.po +2 -4
- data/test/tc_renamer_procs.rb +347 -347
- data/test/ts_renamer.rb +5 -3
- metadata +2 -1
data/po/fr/renamer.po
CHANGED
@@ -90,14 +90,12 @@ msgid "to the NEW one"
|
|
90
90
|
msgstr "à la NOUVELLE"
|
91
91
|
|
92
92
|
#: bin/renamer:89
|
93
|
-
#, fuzzy
|
94
93
|
msgid "Rename FILENAMES by trimming first n characters"
|
95
|
-
msgstr "Renomme FICHIERS
|
94
|
+
msgstr "Renomme FICHIERS en enlevant les n premiers caractères"
|
96
95
|
|
97
96
|
#: bin/renamer:90
|
98
|
-
#, fuzzy
|
99
97
|
msgid "Rename FILENAMES by trimming last n characters"
|
100
|
-
msgstr "Renomme FICHIERS
|
98
|
+
msgstr "Renomme FICHIERS en enlevant les n derniers caractères"
|
101
99
|
|
102
100
|
#: bin/renamer:91
|
103
101
|
msgid "Run %s recursively across directories"
|
data/test/tc_renamer_procs.rb
CHANGED
@@ -20,351 +20,351 @@
|
|
20
20
|
|
21
21
|
# Testing procs
|
22
22
|
class TestRenamerProcs < Test::Unit::TestCase
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
23
|
+
def setup
|
24
|
+
$VERBOSE = nil
|
25
|
+
@files = Array.new
|
26
|
+
Dir.mkdir("tmp_files")
|
27
|
+
Dir.chdir("tmp_files")
|
28
|
+
end
|
29
|
+
|
30
|
+
def teardown
|
31
|
+
Dir.chdir("..")
|
32
|
+
FileUtils.rm_rf("tmp_files")
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_mv
|
36
|
+
@files << File.new("PLOP", "w").path
|
37
|
+
@files << File.new("TesT.Hop", "w").path
|
38
|
+
|
39
|
+
r = Renamer.new(@files)
|
40
|
+
r.downcase
|
41
|
+
|
42
|
+
assert(!File.exist?("PLOP"))
|
43
|
+
assert(!File.exist?("TesT.Hop"))
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_subdirectory
|
47
|
+
Dir.mkdir("test1")
|
48
|
+
Dir.mkdir("test2")
|
49
|
+
@files << File.new("test1/PLOP.txt", "w").path
|
50
|
+
@files << File.new("test2/PLOP.txt", "w").path
|
51
|
+
|
52
|
+
r = Renamer.new(@files)
|
53
|
+
r.downcase
|
54
|
+
|
55
|
+
assert(File.exist?("test1/plop.txt"))
|
56
|
+
assert(File.exist?("test2/plop.txt"))
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_recursivity
|
60
|
+
Dir.mkdir("test1")
|
61
|
+
Dir.mkdir("test1/test3")
|
62
|
+
Dir.mkdir("test1/test3/test4")
|
63
|
+
Dir.mkdir("test2")
|
64
|
+
@files << File.new("test1/PLOP.txt", "w").path
|
65
|
+
@files << File.new("test1/test3/PLOP.txt", "w").path
|
66
|
+
@files << File.new("test1/test3/test4/PLOP.txt", "w").path
|
67
|
+
@files << File.new("test2/PLOP.txt", "w").path
|
68
|
+
|
69
|
+
r = Renamer.new(@files, true)
|
70
|
+
r.downcase
|
71
|
+
|
72
|
+
assert(File.exist?("test1/plop.txt"))
|
73
|
+
assert(File.exist?("test1/test3/plop.txt"))
|
74
|
+
assert(File.exist?("test1/test3/test4/plop.txt"))
|
75
|
+
assert(File.exist?("test2/plop.txt"))
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_overwrite
|
79
|
+
# First we test that it doesn't overwrite when overwrite is false
|
80
|
+
@files << File.new("plop_plop", "w").path
|
81
|
+
@files << File.new("plop plop", "w").path
|
82
|
+
|
83
|
+
r = Renamer.new(@files, false, false)
|
84
|
+
r.underscore_to_space
|
85
|
+
|
86
|
+
assert(File.exist?("plop_plop"))
|
87
|
+
assert(File.exist?("plop plop"))
|
88
|
+
|
89
|
+
# Now we test that files are overwrited when overwrite is true
|
90
|
+
@files.clear
|
91
|
+
@files << File.new("test_test", "w").path
|
92
|
+
@files << File.new("test test", "w").path
|
93
|
+
|
94
|
+
r = Renamer.new(@files, false, true)
|
95
|
+
r.underscore_to_space
|
96
|
+
|
97
|
+
assert(!File.exist?("test_test"))
|
98
|
+
assert(File.exist?("test test"))
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_downcase
|
102
|
+
@files << File.new("PLOP", "w").path
|
103
|
+
@files << File.new("PLOP.txt", "w").path
|
104
|
+
@files << File.new("PLOP.JPG", "w").path
|
105
|
+
@files << File.new("TesT.Hop", "w").path
|
106
|
+
@files << File.new("test.txt", "w").path
|
107
|
+
@files << File.new("teST.jpg.txt", "w").path
|
108
|
+
|
109
|
+
r = Renamer.new(@files)
|
110
|
+
r.downcase
|
111
|
+
|
112
|
+
assert(File.exist?("plop"))
|
113
|
+
assert(File.exist?("plop.txt"))
|
114
|
+
assert(File.exist?("plop.jpg"))
|
115
|
+
assert(File.exist?("test.hop"))
|
116
|
+
assert(File.exist?("test.txt"))
|
117
|
+
assert(File.exist?("test.jpg.txt"))
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_upcase
|
121
|
+
@files << File.new("plop", "w").path
|
122
|
+
@files << File.new("PLOP.txt", "w").path
|
123
|
+
@files << File.new("PLOP.JPG", "w").path
|
124
|
+
@files << File.new("TesT.Hop", "w").path
|
125
|
+
@files << File.new("test.txt", "w").path
|
126
|
+
@files << File.new("teST.jpg.txt", "w").path
|
127
|
+
|
128
|
+
r = Renamer.new(@files)
|
129
|
+
r.upcase
|
130
|
+
|
131
|
+
assert(File.exist?("PLOP"))
|
132
|
+
assert(File.exist?("PLOP.TXT"))
|
133
|
+
assert(File.exist?("PLOP.JPG"))
|
134
|
+
assert(File.exist?("TEST.HOP"))
|
135
|
+
assert(File.exist?("TEST.TXT"))
|
136
|
+
assert(File.exist?("TEST.JPG.TXT"))
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_space_to_underscore
|
140
|
+
@files << File.new("plop plop", "w").path
|
141
|
+
@files << File.new("PLOP.txt", "w").path
|
142
|
+
@files << File.new("PLOP PLOP PLOP.avi", "w").path
|
143
|
+
@files << File.new("TesT .Hop", "w").path
|
144
|
+
@files << File.new("test. txt", "w").path
|
145
|
+
@files << File.new("teST.jpg.txt", "w").path
|
146
|
+
|
147
|
+
r = Renamer.new(@files)
|
148
|
+
r.space_to_underscore
|
149
|
+
|
150
|
+
assert(File.exist?("plop_plop"))
|
151
|
+
assert(File.exist?("PLOP.txt"))
|
152
|
+
assert(File.exist?("PLOP_PLOP_PLOP.avi"))
|
153
|
+
assert(File.exist?("TesT_.Hop"))
|
154
|
+
assert(File.exist?("test._txt"))
|
155
|
+
assert(File.exist?("teST.jpg.txt"))
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_underscore_to_space
|
159
|
+
@files << File.new("plop_plop", "w").path
|
160
|
+
@files << File.new("PLOP.txt", "w").path
|
161
|
+
@files << File.new("PLOP_PLOP_PLOP.avi", "w").path
|
162
|
+
@files << File.new("TesT_.Hop", "w").path
|
163
|
+
@files << File.new("test._txt", "w").path
|
164
|
+
@files << File.new("teST.jpg.txt", "w").path
|
165
|
+
|
166
|
+
r = Renamer.new(@files)
|
167
|
+
r.underscore_to_space
|
168
|
+
|
169
|
+
assert(File.exist?("plop plop"))
|
170
|
+
assert(File.exist?("PLOP.txt"))
|
171
|
+
assert(File.exist?("PLOP PLOP PLOP.avi"))
|
172
|
+
assert(File.exist?("TesT .Hop"))
|
173
|
+
assert(File.exist?("test. txt"))
|
174
|
+
assert(File.exist?("teST.jpg.txt"))
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_capitalize
|
178
|
+
@files << File.new("plop_plop", "w").path
|
179
|
+
@files << File.new("PLOP.txt", "w").path
|
180
|
+
@files << File.new("Plop.avi", "w").path
|
181
|
+
@files << File.new("TesT_.Hop", "w").path
|
182
|
+
@files << File.new("test test.TXT", "w").path
|
183
|
+
@files << File.new("teST.jpg.txt", "w").path
|
184
|
+
|
185
|
+
r = Renamer.new(@files)
|
186
|
+
r.capitalize
|
187
|
+
|
188
|
+
assert(File.exist?("Plop_plop"))
|
189
|
+
assert(File.exist?("Plop.txt"))
|
190
|
+
assert(File.exist?("Plop.avi"))
|
191
|
+
assert(File.exist?("Test_.hop"))
|
192
|
+
assert(File.exist?("Test test.txt"))
|
193
|
+
assert(File.exist?("Test.jpg.txt"))
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_capitalize_words
|
197
|
+
@files << File.new("plop_plop", "w").path
|
198
|
+
@files << File.new("PLOP.txt", "w").path
|
199
|
+
@files << File.new("Plop.avi", "w").path
|
200
|
+
@files << File.new("TesT_.Hop", "w").path
|
201
|
+
@files << File.new("test test.txt", "w").path
|
202
|
+
@files << File.new("test test_test.txt", "w").path
|
203
|
+
@files << File.new("teST.jpg.txt", "w").path
|
204
|
+
@files << File.new(".dotfile", "w").path
|
205
|
+
|
206
|
+
r = Renamer.new(@files)
|
207
|
+
r.capitalize_words
|
208
|
+
|
209
|
+
assert(File.exist?("Plop_Plop"))
|
210
|
+
assert(File.exist?("Plop.txt"))
|
211
|
+
assert(File.exist?("Plop.avi"))
|
212
|
+
assert(File.exist?("Test_.hop"))
|
213
|
+
assert(File.exist?("Test Test.txt"))
|
214
|
+
assert(File.exist?("Test Test_Test.txt"))
|
215
|
+
assert(File.exist?("Test.Jpg.txt"))
|
216
|
+
assert(File.exist?(".dotfile"))
|
217
|
+
end
|
218
|
+
|
219
|
+
def test_basename
|
220
|
+
@files << File.new("plop_plop.txt", "w").path
|
221
|
+
@files << File.new("PLOP.txt", "w").path
|
222
|
+
@files << File.new("TesT_.txt", "w").path
|
223
|
+
@files << File.new("test test.txt", "w").path
|
224
|
+
@files << File.new("test test_test.txt", "w").path
|
225
|
+
@files << File.new("teST.jpg.txt", "w").path
|
226
|
+
@files << File.new("Plop", "w").path
|
227
|
+
@files << File.new("test0004.txt", "w").path
|
228
|
+
|
229
|
+
r = Renamer.new(@files)
|
230
|
+
r.basename("test")
|
231
|
+
|
232
|
+
assert(File.exist?("test0000.txt"))
|
233
|
+
assert(File.exist?("test0001.txt"))
|
234
|
+
assert(File.exist?("test0002.txt"))
|
235
|
+
assert(File.exist?("test0003.txt"))
|
236
|
+
assert(File.exist?("test0005.txt"))
|
237
|
+
assert(File.exist?("test0006.txt"))
|
238
|
+
assert(File.exist?("test0000"))
|
239
|
+
end
|
240
|
+
|
241
|
+
def test_ext
|
242
|
+
@files << File.new("plop_plop", "w").path
|
243
|
+
@files << File.new("PLOP.txt", "w").path
|
244
|
+
@files << File.new("Plop.avi", "w").path
|
245
|
+
@files << File.new("TesT_.Hop", "w").path
|
246
|
+
@files << File.new("test test.txt", "w").path
|
247
|
+
@files << File.new("test test_test.txt", "w").path
|
248
|
+
@files << File.new("teST.jpg.txt", "w").path
|
249
|
+
@files << File.new(".dotfile", "w").path
|
250
|
+
Dir.mkdir("tmp_files2")
|
251
|
+
@files << File.new("tmp_files2/.dotfile", "w").path
|
252
|
+
|
253
|
+
r = Renamer.new(@files)
|
254
|
+
r.ext("rnm")
|
255
|
+
|
256
|
+
assert(File.exist?("plop_plop.rnm"))
|
257
|
+
assert(File.exist?("PLOP.rnm"))
|
258
|
+
assert(File.exist?("Plop.rnm"))
|
259
|
+
assert(File.exist?("TesT_.rnm"))
|
260
|
+
assert(File.exist?("test test.rnm"))
|
261
|
+
assert(File.exist?("test test_test.rnm"))
|
262
|
+
assert(File.exist?("teST.jpg.rnm"))
|
263
|
+
assert(File.exist?(".dotfile"))
|
264
|
+
assert(File.exist?("tmp_files2/.dotfile"))
|
265
|
+
end
|
266
|
+
|
267
|
+
def test_downcase_ext
|
268
|
+
@files << File.new("plop_plop", "w").path
|
269
|
+
@files << File.new("PLOP.txt", "w").path
|
270
|
+
@files << File.new("Plop.AvI", "w").path
|
271
|
+
@files << File.new("TesT_.Hop", "w").path
|
272
|
+
@files << File.new("test test.TXT", "w").path
|
273
|
+
@files << File.new("test test_test.TXT", "w").path
|
274
|
+
@files << File.new("teST.jpg.TXT", "w").path
|
275
|
+
@files << File.new(".DotFile", "w").path
|
276
|
+
Dir.mkdir("tmp_files2")
|
277
|
+
@files << File.new("tmp_files2/.DotFile", "w").path
|
278
|
+
|
279
|
+
r = Renamer.new(@files)
|
280
|
+
r.downcase_ext
|
281
|
+
|
282
|
+
assert(File.exist?("plop_plop"))
|
283
|
+
assert(File.exist?("PLOP.txt"))
|
284
|
+
assert(File.exist?("Plop.avi"))
|
285
|
+
assert(File.exist?("TesT_.hop"))
|
286
|
+
assert(File.exist?("test test.txt"))
|
287
|
+
assert(File.exist?("test test_test.txt"))
|
288
|
+
assert(File.exist?("teST.jpg.txt"))
|
289
|
+
assert(File.exist?(".DotFile"))
|
290
|
+
assert(File.exist?("tmp_files2/.DotFile"))
|
291
|
+
end
|
292
|
+
|
293
|
+
def test_upcase_ext
|
294
|
+
@files << File.new("plop_plop", "w").path
|
295
|
+
@files << File.new("PLOP.txt", "w").path
|
296
|
+
@files << File.new("Plop.AvI", "w").path
|
297
|
+
@files << File.new("TesT_.Hop", "w").path
|
298
|
+
@files << File.new("test test.TXT", "w").path
|
299
|
+
@files << File.new("test test_test.TXT", "w").path
|
300
|
+
@files << File.new("teST.jpg.TXT", "w").path
|
301
|
+
@files << File.new(".DotFile", "w").path
|
302
|
+
Dir.mkdir("tmp_files2")
|
303
|
+
@files << File.new("tmp_files2/.DotFile", "w").path
|
304
|
+
|
305
|
+
r = Renamer.new(@files)
|
306
|
+
r.upcase_ext
|
307
|
+
|
308
|
+
assert(File.exist?("plop_plop"))
|
309
|
+
assert(File.exist?("PLOP.TXT"))
|
310
|
+
assert(File.exist?("Plop.AVI"))
|
311
|
+
assert(File.exist?("TesT_.HOP"))
|
312
|
+
assert(File.exist?("test test.TXT"))
|
313
|
+
assert(File.exist?("test test_test.TXT"))
|
314
|
+
assert(File.exist?("teST.jpg.TXT"))
|
315
|
+
assert(File.exist?(".DotFile"))
|
316
|
+
assert(File.exist?("tmp_files2/.DotFile"))
|
317
|
+
end
|
318
|
+
|
319
|
+
def test_trim_first_characters
|
320
|
+
@files << File.new("plop_plop", "w").path
|
321
|
+
@files << File.new("abracadabra.txt", "w").path
|
322
|
+
@files << File.new("abcdefij.klm.txt", "w").path
|
323
|
+
|
324
|
+
r = Renamer.new(@files)
|
325
|
+
r.trim_first(5)
|
326
|
+
|
327
|
+
assert(File.exist?("plop"))
|
328
|
+
assert(File.exist?("adabra.txt"))
|
329
|
+
assert(File.exist?("fij.klm.txt"))
|
330
|
+
end
|
331
|
+
|
332
|
+
def test_trim_last_characters
|
333
|
+
@files << File.new("plop_plouf", "w").path
|
334
|
+
@files << File.new("abracadabra.txt", "w").path
|
335
|
+
@files << File.new("abcdefij.klm.txt", "w").path
|
336
|
+
|
337
|
+
r = Renamer.new(@files)
|
338
|
+
r.trim_last(4)
|
339
|
+
|
340
|
+
assert(File.exist?("plop_p"))
|
341
|
+
assert(File.exist?("abracad.txt"))
|
342
|
+
assert(File.exist?("abcdefij.txt"))
|
343
|
+
end
|
344
|
+
|
345
|
+
def test_date
|
346
|
+
@files << File.new("plop_plouf", "w").path
|
347
|
+
@files << File.new("abracadabra.txt", "w").path
|
348
|
+
|
349
|
+
time = Time.now
|
350
|
+
|
351
|
+
r = Renamer.new(@files)
|
352
|
+
r.current_date(time)
|
353
|
+
|
354
|
+
assert(File.exist?([time.strftime("%Y-%m-%d"), "plop_plouf"].join('_')))
|
355
|
+
assert(File.exist?([time.strftime("%Y-%m-%d"), "abracadabra.txt"].join('_')))
|
356
|
+
end
|
357
|
+
|
358
|
+
def test_datetime
|
359
|
+
@files << File.new("plop_plouf", "w").path
|
360
|
+
@files << File.new("abracadabra.txt", "w").path
|
361
|
+
|
362
|
+
time = Time.now
|
363
|
+
|
364
|
+
r = Renamer.new(@files)
|
365
|
+
r.current_datetime(time)
|
366
|
+
|
367
|
+
assert(File.exist?([time.strftime("%Y-%m-%d_%H-%M"), "plop_plouf"].join('_')))
|
368
|
+
assert(File.exist?([time.strftime("%Y-%m-%d_%H-%M"), "abracadabra.txt"].join('_')))
|
369
|
+
end
|
370
370
|
end
|