parallelize the heck out of what i can
This commit is contained in:
parent
7c7f50515f
commit
6f78aac0b5
13
bin/svggvs
13
bin/svggvs
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
require 'thor'
|
require 'thor'
|
||||||
require 'digest/md5'
|
require 'digest/md5'
|
||||||
|
require 'parallel'
|
||||||
|
|
||||||
require_relative '../lib/svggvs'
|
require_relative '../lib/svggvs'
|
||||||
|
|
||||||
@ -35,15 +36,13 @@ module SVGGVS
|
|||||||
write_svgs
|
write_svgs
|
||||||
ensure_tmp
|
ensure_tmp
|
||||||
|
|
||||||
@exported_pngs = []
|
@exported_pngs = Parallel.map(context.individual_files.each_with_index) do |svg_file, index|
|
||||||
|
|
||||||
context.individual_files.each_with_index do |svg_file, index|
|
|
||||||
target = Pathname(context.session.png_files_path % index)
|
target = Pathname(context.session.png_files_path % index)
|
||||||
target.parent.mkpath
|
target.parent.mkpath
|
||||||
|
|
||||||
@exported_pngs << target
|
|
||||||
|
|
||||||
system %{inkscape --export-area-page --export-png "#{target.expand_path}" --export-width #{context.session.png_export_width} --export-background="#ffffffff" "#{svg_file.expand_path}"}
|
system %{inkscape --export-area-page --export-png "#{target.expand_path}" --export-width #{context.session.png_export_width} --export-background="#ffffffff" "#{svg_file.expand_path}"}
|
||||||
|
|
||||||
|
target
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -51,7 +50,7 @@ module SVGGVS
|
|||||||
def pdf
|
def pdf
|
||||||
pngs
|
pngs
|
||||||
|
|
||||||
trimmed_pngs = @exported_pngs.collect do |png|
|
trimmed_pngs = Parallel.map(@exported_pngs) do |png|
|
||||||
tmp_target = tmp_target_for(png)
|
tmp_target = tmp_target_for(png)
|
||||||
|
|
||||||
system %{convert #{png} -gravity Center -crop #{context.session.pdf_card_size}+0+0 +repage #{tmp_target}}
|
system %{convert #{png} -gravity Center -crop #{context.session.pdf_card_size}+0+0 +repage #{tmp_target}}
|
||||||
@ -66,7 +65,7 @@ module SVGGVS
|
|||||||
placeholder = tmp_target_for("placeholder.png")
|
placeholder = tmp_target_for("placeholder.png")
|
||||||
system %{convert -size #{context.session.pdf_card_size} xc:white #{placeholder}}
|
system %{convert -size #{context.session.pdf_card_size} xc:white #{placeholder}}
|
||||||
|
|
||||||
pages = png_slices.each_with_index.collect do |files, page_index|
|
pages = Parallel.map(png_slices.each_with_index) do |files, page_index|
|
||||||
tmp_pdf_target = tmp_path.join("page%05d.pdf" % page_index)
|
tmp_pdf_target = tmp_path.join("page%05d.pdf" % page_index)
|
||||||
|
|
||||||
files += Array.new(9 - files.length, placeholder)
|
files += Array.new(9 - files.length, placeholder)
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
module Svggvs
|
module SVGGVS
|
||||||
VERSION = "0.0.2"
|
VERSION = "0.0.3"
|
||||||
end
|
end
|
||||||
|
@ -5,7 +5,7 @@ require 'svggvs/version'
|
|||||||
|
|
||||||
Gem::Specification.new do |gem|
|
Gem::Specification.new do |gem|
|
||||||
gem.name = "svggvs"
|
gem.name = "svggvs"
|
||||||
gem.version = Svggvs::VERSION
|
gem.version = SVGGVS::VERSION
|
||||||
gem.authors = ["John Bintz"]
|
gem.authors = ["John Bintz"]
|
||||||
gem.email = ["john@coswellproductions.com"]
|
gem.email = ["john@coswellproductions.com"]
|
||||||
gem.description = %q{Generate sets of card game cards using Inkscape templates and Ruby}
|
gem.description = %q{Generate sets of card game cards using Inkscape templates and Ruby}
|
||||||
@ -19,4 +19,5 @@ Gem::Specification.new do |gem|
|
|||||||
|
|
||||||
gem.add_dependency 'nokogiri'
|
gem.add_dependency 'nokogiri'
|
||||||
gem.add_dependency 'thor'
|
gem.add_dependency 'thor'
|
||||||
|
gem.add_dependency 'parallel'
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user