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.rb20
-rw-r--r--new/lib/crys/processors/mixins/common_functions.rb (renamed from new/lib/crys/processors/common_functions.rb)4
-rw-r--r--new/lib/crys/processors/mixins/common_parts.rb (renamed from new/lib/crys/processors/common_parts.rb)0
-rw-r--r--new/lib/crys/processors/processed_page.rb6
-rw-r--r--new/lib/crys/processors/rss_processor.rb13
5 files changed, 31 insertions, 12 deletions
diff --git a/new/lib/crys/processors/html_processor.rb b/new/lib/crys/processors/html_processor.rb
index 33116cef..5dd1387f 100644
--- a/new/lib/crys/processors/html_processor.rb
+++ b/new/lib/crys/processors/html_processor.rb
@@ -1,8 +1,7 @@
# frozen_string_literal: true
-require 'erb'
-require_relative 'common_functions'
-require_relative 'common_parts'
+require_relative 'mixins/common_functions'
+require_relative 'mixins/common_parts'
module Crys
class HtmlProcessor
@@ -15,15 +14,24 @@ module Crys
@assets = []
end
- def parsed_content
- html_file = ERB.new(File.read(file_path))
- html_file.result(local_binding)
+ def parsed_pages
+ [
+ ProcessedPage.new(
+ filename: filename,
+ content: html_content
+ )
+ ]
end
def filename
file_path.scan(%r{.*/(.*)\.erb}).flatten.first
end
+ def html_content
+ html_file = ERB.new(File.read(file_path))
+ html_file.result(local_binding)
+ end
+
attr_reader :assets, :file_path
private
diff --git a/new/lib/crys/processors/common_functions.rb b/new/lib/crys/processors/mixins/common_functions.rb
index 9cf56692..52ce65ac 100644
--- a/new/lib/crys/processors/common_functions.rb
+++ b/new/lib/crys/processors/mixins/common_functions.rb
@@ -5,10 +5,10 @@ require 'rss'
module Crys
module CommonFunctions
def project_root
- File.dirname(File.dirname(File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__)))))).to_s
+ File.dirname(File.dirname(File.dirname(File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__))))))).to_s
end
- def process_image(file:, width: :auto)
+ def process_image(file:, width: :auto)
full_path = "#{image_dir}/#{file}"
image = ::Crys::ImageProcessor.new(path: full_path, filename: file, width: width)
diff --git a/new/lib/crys/processors/common_parts.rb b/new/lib/crys/processors/mixins/common_parts.rb
index a6c2dc16..a6c2dc16 100644
--- a/new/lib/crys/processors/common_parts.rb
+++ b/new/lib/crys/processors/mixins/common_parts.rb
diff --git a/new/lib/crys/processors/processed_page.rb b/new/lib/crys/processors/processed_page.rb
new file mode 100644
index 00000000..5bab3566
--- /dev/null
+++ b/new/lib/crys/processors/processed_page.rb
@@ -0,0 +1,6 @@
+module Crys
+ ProcessedPage = Struct.new(
+ :filename,
+ :content
+ )
+end
diff --git a/new/lib/crys/processors/rss_processor.rb b/new/lib/crys/processors/rss_processor.rb
index de79f11b..4806c594 100644
--- a/new/lib/crys/processors/rss_processor.rb
+++ b/new/lib/crys/processors/rss_processor.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require_relative 'common_functions'
-require_relative 'common_parts'
+require_relative 'mixins/common_functions'
+require_relative 'mixins/common_parts'
module Crys
class RssProcessor
@@ -13,8 +13,13 @@ module Crys
@image_dir = image_dir # just for api consistency
end
- def parsed_content
- rss.content
+ def parsed_pages
+ [
+ ProcessedPage.new(
+ filename: rss.filename,
+ content: rss.content
+ )
+ ]
end
def filename