summaryrefslogtreecommitdiff
path: root/new/lib/crys/builder.rb
diff options
context:
space:
mode:
authormms <git@sapka.me>2025-01-05 22:34:55 +0100
committermms <git@sapka.me>2025-01-05 22:34:55 +0100
commitbfd8209ad0d80b5027bea8a1a095dadc8bffdc61 (patch)
tree1d4ec6d63dd3b4a1f788ec340a0fba3cd48b3dea /new/lib/crys/builder.rb
parent628fcf941c322dd0ed24a643c58394392484740e (diff)
feat(new): splash page in progress
Diffstat (limited to 'new/lib/crys/builder.rb')
-rw-r--r--new/lib/crys/builder.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/new/lib/crys/builder.rb b/new/lib/crys/builder.rb
new file mode 100644
index 0000000..a3f55b1
--- /dev/null
+++ b/new/lib/crys/builder.rb
@@ -0,0 +1,50 @@
+
+module Crys
+ class Builder
+
+
+ def initialize(file_path:, output_dir:, image_dir:)
+ @file_path = file_path
+ @output_dir = output_dir
+ @processor = processor_class.new(file_path: file_path, image_dir: image_dir)
+
+ end
+
+ def build
+ process_html
+ process_assets
+ end
+
+ private
+
+ attr_reader :file_path, :output_dir, :processor
+
+ def process_assets
+ processor.assets.each do |asset|
+ output_path = output_dir + "/" + asset.relative_path
+ File.open(output_path, 'w') { |file| file.write(asset.processed_asset) }
+ end
+ end
+
+ def process_html
+ html = processor.to_html
+ filename = processor.filename
+ output_path = output_dir + "/" + filename
+
+ File.open(output_path, 'w') { |file| file.write(html) }
+ end
+
+ def processor_class
+ case file_path
+ when /html.erb$/
+ html_processor
+ else
+ raise StandardError.new("No processor for #{file_path}")
+ end
+ end
+
+ def html_processor
+ Crys::HtmlProcessor
+ end
+ end
+end