Skip to content

Commit 244a826

Browse files
committed
Refactor: change variable name in Rakefile
Signed-off-by: Jiang Xin <[email protected]>
1 parent bdda5f3 commit 244a826

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

Rakefile

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,28 @@ CMD_IMGMAGICK='convert'
1717
desc "export images, default: rake convert[../images,600]"
1818
task :convert, :target, :width do |t, args|
1919
args.with_defaults(:target => TARGET, :width => RESIZE)
20-
FileList["**/*.svg", "**/*.xcf", "**/*.jpg", "**/*.png", "**/*.gif"].each do |t|
20+
FileList["**/*.svg", "**/*.xcf", "**/*.jpg", "**/*.png", "**/*.gif"].each do |source|
2121
[".svg", ".png", ".gif", ".xcf"].each do |prefer|
22-
if File.exists?(t.sub(/\.[^.]+$/, prefer))
23-
t = t.sub(/\.[^.]+$/, prefer)
22+
if File.exists?(source.sub(/\.[^.]+$/, prefer))
23+
source = source.sub(/\.[^.]+$/, prefer)
2424
break
2525
end
2626
end
27-
if t =~ /\.svg/
28-
f = args[:target] + '/' + t.sub(/\.[^.]+$/, '.png')
29-
command = "#{CMD_INKSCAPE} -w #{args[:width]} -f #{t} -e #{f}"
30-
elsif t =~ /\.xcf/
31-
f = args[:target] + '/' + t.sub(/\.[^.]+$/, '.png')
32-
command = "#{CMD_IMGMAGICK} -auto-level -flatten -resize '#{args[:width]}>' #{t} #{f}"
33-
elsif t =~ /\.(jpg|png|gif)/
34-
f = args[:target] + '/' + t
35-
command = "#{CMD_IMGMAGICK} -auto-level -resize '#{args[:width]}>' #{t} #{f}"
27+
if source =~ /\.svg/
28+
output = args[:target] + '/' + source.sub(/\.[^.]+$/, '.png')
29+
command = "#{CMD_INKSCAPE} -w #{args[:width]} -f #{source} -e #{output}"
30+
elsif source =~ /\.xcf/
31+
output = args[:target] + '/' + source.sub(/\.[^.]+$/, '.png')
32+
command = "#{CMD_IMGMAGICK} -auto-level -flatten -resize '#{args[:width]}>' #{source} #{output}"
33+
elsif source =~ /\.(jpg|png|gif)/
34+
output = args[:target] + '/' + source
35+
command = "#{CMD_IMGMAGICK} -auto-level -resize '#{args[:width]}>' #{source} #{output}"
3636
end
3737

38-
unless uptodate?(f, t)
39-
Dir.mkdir(File.dirname(f)) unless File.exists?(File.dirname(f))
38+
unless uptodate?(output, source)
39+
Dir.mkdir(File.dirname(output)) unless File.exists?(File.dirname(output))
4040
sh command
41-
File.utime(0, Time.now, f)
41+
File.utime(0, Time.now, output)
4242
end
4343
end
4444
end

0 commit comments

Comments
 (0)