diff options
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 |