parallelize the heck out of what i can

This commit is contained in:
John Bintz 2013-11-17 13:56:58 -05:00
parent 7c7f50515f
commit 6f78aac0b5
3 changed files with 10 additions and 10 deletions

View File

@ -2,6 +2,7 @@
require 'thor'
require 'digest/md5'
require 'parallel'
require_relative '../lib/svggvs'
@ -35,15 +36,13 @@ module SVGGVS
write_svgs
ensure_tmp
@exported_pngs = []
context.individual_files.each_with_index do |svg_file, index|
@exported_pngs = Parallel.map(context.individual_files.each_with_index) do |svg_file, index|
target = Pathname(context.session.png_files_path % index)
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}"}
target
end
end
@ -51,7 +50,7 @@ module SVGGVS
def pdf
pngs
trimmed_pngs = @exported_pngs.collect do |png|
trimmed_pngs = Parallel.map(@exported_pngs) do |png|
tmp_target = tmp_target_for(png)
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")
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)
files += Array.new(9 - files.length, placeholder)

View File

@ -1,3 +1,3 @@
module Svggvs
VERSION = "0.0.2"
module SVGGVS
VERSION = "0.0.3"
end

View File

@ -5,7 +5,7 @@ require 'svggvs/version'
Gem::Specification.new do |gem|
gem.name = "svggvs"
gem.version = Svggvs::VERSION
gem.version = SVGGVS::VERSION
gem.authors = ["John Bintz"]
gem.email = ["john@coswellproductions.com"]
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 'thor'
gem.add_dependency 'parallel'
end