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.rb37
1 files changed, 17 insertions, 20 deletions
diff --git a/new/lib/crys/batch_builder.rb b/new/lib/crys/batch_builder.rb
index 61fdcf22..43dbec62 100644
--- a/new/lib/crys/batch_builder.rb
+++ b/new/lib/crys/batch_builder.rb
@@ -1,34 +1,31 @@
+# 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"
+ 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 builder_class
- Crys::Builder
- end
-
- def db
- Crys::PagesDbManager.new
- end
-
def build
db.pages.each do |page|
builder_class.new(
file_path: page.file_path,
output_dir: output_dir,
- image_dir: image_dir,
+ image_dir: image_dir
).build
- puts "processed: " + page.filename
+ 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