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/common_functions.rb11
-rw-r--r--new/lib/crys/processors/common_parts.rb14
-rw-r--r--new/lib/crys/processors/html_processor.rb13
-rw-r--r--new/lib/crys/processors/rss_processor.rb8
4 files changed, 27 insertions, 19 deletions
diff --git a/new/lib/crys/processors/common_functions.rb b/new/lib/crys/processors/common_functions.rb
index f33c768..9cf5669 100644
--- a/new/lib/crys/processors/common_functions.rb
+++ b/new/lib/crys/processors/common_functions.rb
@@ -1,13 +1,15 @@
+# frozen_string_literal: true
+
require 'rss'
module Crys
module CommonFunctions
def project_root
- "#{File.dirname(File.dirname(File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__))))))}"
+ 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
+ full_path = "#{image_dir}/#{file}"
image = ::Crys::ImageProcessor.new(path: full_path, filename: file, width: width)
assets << image
@@ -19,10 +21,13 @@ module Crys
if name
path = case name
when :main
- "/public/index.xml"
+ '/public/index.xml'
end
rss = File.read(project_root + path)
+ else
+ puts url
+
end
RSS::Parser.parse(rss)
diff --git a/new/lib/crys/processors/common_parts.rb b/new/lib/crys/processors/common_parts.rb
index 4e1dae5..a6c2dc1 100644
--- a/new/lib/crys/processors/common_parts.rb
+++ b/new/lib/crys/processors/common_parts.rb
@@ -1,18 +1,18 @@
+# frozen_string_literal: true
+
module Crys
module CommonParts
def webbutton(file:, url:, alt:)
- full_path = image_dir + "/buttons/" + file
-
+ full_path = "#{image_dir}/buttons/#{file}"
+
image = ::Crys::ImageProcessor.new(path: full_path, filename: file, width: 88)
assets << image
- code = ERB.new <<-EOF
-<a href="<%=url%>"><img src="<%=image.relative_path%>" width="88" height="31" class="webbutton" alt="<%=alt%>"></a>
-EOF
+ code = ERB.new <<~EOF
+ <a href="<%=url%>"><img src="<%=image.relative_path%>" width="88" height="31" class="webbutton" alt="<%=alt%>"></a>
+ EOF
code.result(binding)
-
end
-
end
end
diff --git a/new/lib/crys/processors/html_processor.rb b/new/lib/crys/processors/html_processor.rb
index bcc9768..33116ce 100644
--- a/new/lib/crys/processors/html_processor.rb
+++ b/new/lib/crys/processors/html_processor.rb
@@ -1,13 +1,14 @@
+# frozen_string_literal: true
+
require 'erb'
-require_relative "common_functions"
-require_relative "common_parts"
+require_relative 'common_functions'
+require_relative 'common_parts'
module Crys
class HtmlProcessor
-
include CommonFunctions
include CommonParts
-
+
def initialize(file_path:, image_dir:)
@file_path = file_path
@image_dir = image_dir
@@ -20,7 +21,7 @@ module Crys
end
def filename
- file_path.scan(/.*\/(.*)\.erb/).flatten.first
+ file_path.scan(%r{.*/(.*)\.erb}).flatten.first
end
attr_reader :assets, :file_path
@@ -31,7 +32,7 @@ module Crys
attr_writer :assets
def local_binding
- local_binding ||= binding.clone
+ @local_binding ||= binding.clone
end
end
end
diff --git a/new/lib/crys/processors/rss_processor.rb b/new/lib/crys/processors/rss_processor.rb
index bce48ad..de79f11 100644
--- a/new/lib/crys/processors/rss_processor.rb
+++ b/new/lib/crys/processors/rss_processor.rb
@@ -1,5 +1,7 @@
-require_relative "common_functions"
-require_relative "common_parts"
+# frozen_string_literal: true
+
+require_relative 'common_functions'
+require_relative 'common_parts'
module Crys
class RssProcessor
@@ -8,6 +10,7 @@ module Crys
rss_file = File.read(file_path)
instance_eval(rss_file)
@assets = []
+ @image_dir = image_dir # just for api consistency
end
def parsed_content
@@ -23,6 +26,5 @@ module Crys
private
attr_reader :rss
-
end
end