summaryrefslogtreecommitdiff
path: root/new/lib/crys/processors/common_functions.rb
blob: f33c76816083499fb2da0dd1a4a917a778cb7d45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'rss'

module Crys
  module CommonFunctions
    def project_root
      "#{File.dirname(File.dirname(File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__))))))}"
    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)
      end

      RSS::Parser.parse(rss)
    end
  end
end