summaryrefslogtreecommitdiff
path: root/new/lib/crys/builder.rb
diff options
context:
space:
mode:
authormms <git@sapka.me>2025-01-06 22:17:43 +0100
committermms <git@sapka.me>2025-01-06 22:17:43 +0100
commitb50e4a5f40bc64fa1893d249d83c05ecd217de1d (patch)
treed98b5c3a378975d095aa3dad8d1a642c3cf0f3d2 /new/lib/crys/builder.rb
parentbfd8209ad0d80b5027bea8a1a095dadc8bffdc61 (diff)
feat(new): rss + batch
Diffstat (limited to 'new/lib/crys/builder.rb')
-rw-r--r--new/lib/crys/builder.rb40
1 files changed, 26 insertions, 14 deletions
diff --git a/new/lib/crys/builder.rb b/new/lib/crys/builder.rb
index a3f55b15..b8135c77 100644
--- a/new/lib/crys/builder.rb
+++ b/new/lib/crys/builder.rb
@@ -1,24 +1,26 @@
-
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_content
process_assets
+
+ upsert_pages_db
end
private
- attr_reader :file_path, :output_dir, :processor
+ attr_reader :file_path, :output_dir, :processor, :db
+ def pages_db_manager
+ Crys::PagesDbManager.new
+ end
+
def process_assets
processor.assets.each do |asset|
output_path = output_dir + "/" + asset.relative_path
@@ -26,19 +28,21 @@ module Crys
end
end
- def process_html
- html = processor.to_html
+ def process_content
+ content = processor.parsed_content
filename = processor.filename
output_path = output_dir + "/" + filename
- File.open(output_path, 'w') { |file| file.write(html) }
+ File.open(output_path, 'w') { |file| file.write(content) }
end
- def processor_class
- case file_path
- when /html.erb$/
- html_processor
- else
+ def processor_class
+ case file_path
+ when /html.erb$/
+ html_processor
+ when /xml.rb$/
+ rss_processor
+ else
raise StandardError.new("No processor for #{file_path}")
end
end
@@ -46,5 +50,13 @@ module Crys
def html_processor
Crys::HtmlProcessor
end
+
+ def rss_processor
+ Crys::RssProcessor
+ end
+
+ def upsert_pages_db
+ pages_db_manager.add_page(processor)
+ end
end
end