summaryrefslogtreecommitdiff
path: root/new/lib/crys/processors
diff options
context:
space:
mode:
Diffstat (limited to 'new/lib/crys/processors')
-rw-r--r--new/lib/crys/processors/html_processor.rb4
-rw-r--r--new/lib/crys/processors/processed_page.rb4
-rw-r--r--new/lib/crys/processors/rss_processor.rb4
-rw-r--r--new/lib/crys/processors/yaml_batch_processor.rb45
4 files changed, 54 insertions, 3 deletions
diff --git a/new/lib/crys/processors/html_processor.rb b/new/lib/crys/processors/html_processor.rb
index 5dd1387f..eccc748b 100644
--- a/new/lib/crys/processors/html_processor.rb
+++ b/new/lib/crys/processors/html_processor.rb
@@ -18,7 +18,9 @@ module Crys
[
ProcessedPage.new(
filename: filename,
- content: html_content
+ content: html_content,
+ source: file_path,
+ last_updated_at: Time.now
)
]
end
diff --git a/new/lib/crys/processors/processed_page.rb b/new/lib/crys/processors/processed_page.rb
index 5bab3566..8627c10e 100644
--- a/new/lib/crys/processors/processed_page.rb
+++ b/new/lib/crys/processors/processed_page.rb
@@ -1,6 +1,8 @@
module Crys
ProcessedPage = Struct.new(
:filename,
- :content
+ :content,
+ :source,
+ :last_updated_at
)
end
diff --git a/new/lib/crys/processors/rss_processor.rb b/new/lib/crys/processors/rss_processor.rb
index 4806c594..8254bf4a 100644
--- a/new/lib/crys/processors/rss_processor.rb
+++ b/new/lib/crys/processors/rss_processor.rb
@@ -17,7 +17,9 @@ module Crys
[
ProcessedPage.new(
filename: rss.filename,
- content: rss.content
+ content: rss.content,
+ source: file_path,
+ last_updated_at: Time.now
)
]
end
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