script/worker_analysis in image_optim-0.26.2 vs script/worker_analysis in image_optim-0.26.3
- old
+ new
@@ -116,12 +116,14 @@
private
def get!(key, etag)
raw = DB[Marshal.dump(key)]
return unless raw
+
entry = Marshal.load(raw)
return unless entry[1] == etag
+
entry[0]
end
def set!(key, etag, &_block)
value = yield
@@ -173,10 +175,11 @@
end
end
def options_string(options)
return '' if options.empty?
+
"(#{options.sort.map{ |k, v| "#{k}:#{v.inspect}" }.join(', ')})"
end
end
# One worker result
@@ -282,10 +285,11 @@
def run_workers(src, workers, last_result = nil, &block)
required_workers = workers.select(&:required)
with_progress(workers, last_result) do |worker|
next if required_workers.any?{ |w| w.run_order < worker.run_order }
+
worker_result, result_image = run_worker(src, worker)
steps = (last_result ? last_result.steps : []) + [worker_result]
chain_result = ChainResult.new(src.image_format, steps)
chain_result.difference = difference_with(result_image)
@@ -327,10 +331,11 @@
info:
].shelljoin).to_f
unless $CHILD_STATUS.success?
fail "failed comparison of #{@path} with #{other}"
end
+
nrmse
end
end
def for_compare(*images)
@@ -480,9 +485,10 @@
@workers_by_format = Hash.new{ |h, k| h[k] = [] }
ImageOptim::Worker.klasses.each do |klass|
worker_config = config.delete(klass.bin_sym)
next if worker_config == false
+
worker_config ||= {}
option_variants = worker_config.delete(:variants) || [{}]
option_variants = case option_variants
when Array then option_variants