kaki-utils 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kaki/utils.rb +8 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16fea2419ebb00da4bc378e0cd9c3705779de1e4eec1d45405ec267b7ec636fb
|
4
|
+
data.tar.gz: 3d546ec7c87375c76ef64d92144256b7beb53804c98555deea7e2e98892e8234
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d3b4ec15bd9e862941ba42c697649660115fb7fd6962eff6cd6f9619d03ae70b7a2e0cec2a80567685170baf72ecb35a0e5eacf2471492ecaf48ee5222d8156
|
7
|
+
data.tar.gz: ad26e0231664d5a83530496c98ebc206f37b6e1c66df7d26675dea19d996aa19fa3c42f8e38f10ce6cf2b1dfe1f1b2fa1a0bf94a7b539b32b2c89e5dd1b5551e
|
data/lib/kaki/utils.rb
CHANGED
@@ -168,13 +168,18 @@ module Utils
|
|
168
168
|
def modify_serial_numbers(dir = Dir.pwd)
|
169
169
|
Dir.chdir(dir)
|
170
170
|
files = Dir.glob("*").select {|fn| File.file?(fn)}
|
171
|
+
data1 = []
|
171
172
|
data = files.map do |fn|
|
172
173
|
m = /^(.*?\D*?)(\d+)(\..+)$/.match(fn)
|
173
|
-
|
174
|
-
|
174
|
+
if m
|
175
|
+
[fn, m[1], m[2].to_i, m[3]]
|
176
|
+
else
|
177
|
+
data1 << [fn, fn]
|
178
|
+
nil
|
179
|
+
end
|
175
180
|
end.compact
|
176
181
|
num_length = data.map {|d| d[2].to_s.length}.max
|
177
|
-
data1
|
182
|
+
data1 += data.map {|d| [d[0], d[1] + ("%0#{num_length}d" % d[2]) + d[3]]}
|
178
183
|
|
179
184
|
Dir.mkdir("new_folder")
|
180
185
|
data1.each {|be, af| FileUtils.cp(be, "new_folder/#{af}")}
|