summaryrefslogtreecommitdiff
path: root/new/lib/crys/batch_builder.rb
blob: d8f1d7b63eae0208ea89731d82bdb72d76455c19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

module Crys
  class BatchBuilder
    def initialize(pages_db_manager:, output_dir:, image_dir:, builder_class:)
      @pages_db_manager = pages_db_manager
      @output_dir = output_dir
      @image_dir = image_dir
      @builder_class = builder_class

    end

    def build
      pages_db_manager.pages.each do |page|
        builder_class.new(
          file_path: page.source,
          output_dir: output_dir,
          image_dir: image_dir,
          pages_db_manager: pages_db_manager
        ).build
      puts "processed: #{page.filename}"
      end
    end

    private

    attr_reader :pages_db_manager, :output_dir, :image_dir, :builder_class

  end
end