summaryrefslogtreecommitdiff
path: root/new/lib/crys/processors/mixins/common_functions.rb
diff options
context:
space:
mode:
Diffstat (limited to 'new/lib/crys/processors/mixins/common_functions.rb')
-rw-r--r--new/lib/crys/processors/mixins/common_functions.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/new/lib/crys/processors/mixins/common_functions.rb b/new/lib/crys/processors/mixins/common_functions.rb
new file mode 100644
index 00000000..52ce65ac
--- /dev/null
+++ b/new/lib/crys/processors/mixins/common_functions.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+require 'rss'
+
+module Crys
+ module CommonFunctions
+ def project_root
+ 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)
+ full_path = "#{image_dir}/#{file}"
+
+ image = ::Crys::ImageProcessor.new(path: full_path, filename: file, width: width)
+ assets << image
+
+ image
+ end
+
+ def fetch_rss(url: nil, name: nil)
+ if name
+ path = case name
+ when :main
+ '/public/index.xml'
+ end
+
+ rss = File.read(project_root + path)
+ else
+ puts url
+
+ end
+
+ RSS::Parser.parse(rss)
+ end
+ end
+end