diff options
Diffstat (limited to 'new/lib/crys/batch_builder.rb')
-rw-r--r-- | new/lib/crys/batch_builder.rb | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/new/lib/crys/batch_builder.rb b/new/lib/crys/batch_builder.rb index 61fdcf22..d8f1d7b6 100644 --- a/new/lib/crys/batch_builder.rb +++ b/new/lib/crys/batch_builder.rb @@ -1,34 +1,30 @@ +# frozen_string_literal: true + module Crys class BatchBuilder - def db_path - output_dir = "#{File.dirname(File.dirname(File.dirname(__FILE__)))}/db/pages.yaml" - end - - def output_dir - "#{File.dirname(File.dirname(__FILE__))}/output" - end - - def image_dir - "#{File.dirname(File.dirname(File.expand_path(__FILE__)))}/assets/images" - end + 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 - def builder_class - Crys::Builder end - def db - Crys::PagesDbManager.new - end - def build - db.pages.each do |page| + pages_db_manager.pages.each do |page| builder_class.new( - file_path: page.file_path, + file_path: page.source, output_dir: output_dir, image_dir: image_dir, + pages_db_manager: pages_db_manager ).build - puts "processed: " + page.filename + puts "processed: #{page.filename}" end end + + private + + attr_reader :pages_db_manager, :output_dir, :image_dir, :builder_class + end end |