summaryrefslogtreecommitdiff
path: root/new/lib/crys/batch_builder.rb
diff options
context:
space:
mode:
Diffstat (limited to 'new/lib/crys/batch_builder.rb')
-rw-r--r--new/lib/crys/batch_builder.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/new/lib/crys/batch_builder.rb b/new/lib/crys/batch_builder.rb
new file mode 100644
index 0000000..43dbec6
--- /dev/null
+++ b/new/lib/crys/batch_builder.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+module Crys
+ class BatchBuilder
+ def initialize(pages_db:, output_dir:, image_dir:, builder_class:)
+ @pages_db = pages_db
+ @output_dir = output_dir
+ @image_dir = image_dir
+ @builder_class = builder_class
+ end
+
+ def build
+ db.pages.each do |page|
+ builder_class.new(
+ file_path: page.file_path,
+ output_dir: output_dir,
+ image_dir: image_dir
+ ).build
+ puts "processed: #{page.filename}"
+ end
+ end
+
+ private
+
+ attr_reader :pages_db, :output_dir, :image_dir, :builder_class
+
+ def db
+ pages_db.new
+ end
+ end
+end