diff options
author | mms <git@sapka.me> | 2025-01-09 22:53:46 +0100 |
---|---|---|
committer | mms <git@sapka.me> | 2025-01-09 22:53:46 +0100 |
commit | 27a14097e6705f6665e8fe5a7a4ca078799f3647 (patch) | |
tree | e6e7063071d8b369b829cb2461e9aa1ef84204e4 /new/lib/crys/processors/yaml_batch_processor.rb | |
parent | edb8b8b15c2c7963daa453b0fa1753aad37ee1f4 (diff) |
Diffstat (limited to 'new/lib/crys/processors/yaml_batch_processor.rb')
-rw-r--r-- | new/lib/crys/processors/yaml_batch_processor.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/new/lib/crys/processors/yaml_batch_processor.rb b/new/lib/crys/processors/yaml_batch_processor.rb new file mode 100644 index 00000000..ef0257b8 --- /dev/null +++ b/new/lib/crys/processors/yaml_batch_processor.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require "yaml" + +require_relative 'mixins/common_functions' +require_relative 'mixins/common_parts' + +module Crys + class YamlBatchProcessor + def initialize(file_path:, image_dir:) + @file_path = file_path + rss_file = File.read(file_path) + + @assets = [] + @image_dir = image_dir # just for api consistency + end + + def parsed_pages + pages.map do |page| + ProcessedPage.new( + filename: page[:filename], + content: "all your base are belong to us", + source: file_path + "#" + page[:uid].to_s , + last_updated_at: page[:last_updated_at] + ) + end + end + + def filename + rss.filename + end + + attr_reader :assets, :file_path + + private + + def pages + @pages ||= YAML.load_file(file_path, + permitted_classes: [Time, Symbol] + ) + end + + attr_reader :rss + end +end |