summaryrefslogtreecommitdiff
path: root/new/splash/lib
diff options
context:
space:
mode:
authormms <git@sapka.me>2025-01-08 21:24:33 +0100
committermms <git@sapka.me>2025-01-08 21:24:33 +0100
commit4004a55b0e324c35cbc7d58b831e49efd484ab93 (patch)
tree3ff4c68c28165b6d08c1a49532e8421193433d65 /new/splash/lib
parent2781360c7c25404c5a1fd03ed3472d43367ed8c6 (diff)
feat: rubocop
Diffstat (limited to 'new/splash/lib')
-rw-r--r--new/splash/lib/splash/batch_builder.rb23
-rw-r--r--new/splash/lib/splash/builder.rb3
-rw-r--r--new/splash/lib/splash/pages_db_manager.rb2
-rw-r--r--new/splash/lib/splash/processors/splash_processor.rb78
4 files changed, 46 insertions, 60 deletions
diff --git a/new/splash/lib/splash/batch_builder.rb b/new/splash/lib/splash/batch_builder.rb
index 1502a80a..71f5594b 100644
--- a/new/splash/lib/splash/batch_builder.rb
+++ b/new/splash/lib/splash/batch_builder.rb
@@ -1,25 +1,8 @@
+# frozen_string_literal: true
+
module Crys
module Splash
class BatchBuilder < Crys::BatchBuilder
- def db_path
- "#{File.dirname(File.dirname(File.dirname(__FILE__)))}/db/pages.yaml"
- end
-
- def output_dir
- "#{File.dirname(File.dirname(File.dirname(__FILE__)))}/output"
- end
-
- def image_dir
- "#{File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__))))}/assets/images"
- end
-
- def db
- Crys::Splash::PagesDbManager.new
- end
-
- def builder_class
- Crys::Splash::Builder
- end
- end
+ end
end
end
diff --git a/new/splash/lib/splash/builder.rb b/new/splash/lib/splash/builder.rb
index dc52d646..f886a0ec 100644
--- a/new/splash/lib/splash/builder.rb
+++ b/new/splash/lib/splash/builder.rb
@@ -1,11 +1,10 @@
# frozen_string_literal: true
-require_relative "processors/splash_processor"
+require_relative 'processors/splash_processor'
module Crys
module Splash
class Builder < Crys::Builder
-
def html_processor
Crys::Splash::SplashProcessor
end
diff --git a/new/splash/lib/splash/pages_db_manager.rb b/new/splash/lib/splash/pages_db_manager.rb
index 11a8d6fa..17658ea1 100644
--- a/new/splash/lib/splash/pages_db_manager.rb
+++ b/new/splash/lib/splash/pages_db_manager.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
module Crys
module Splash
class PagesDbManager < Crys::PagesDbManager
diff --git a/new/splash/lib/splash/processors/splash_processor.rb b/new/splash/lib/splash/processors/splash_processor.rb
index eec2bab4..1a1f2f2e 100644
--- a/new/splash/lib/splash/processors/splash_processor.rb
+++ b/new/splash/lib/splash/processors/splash_processor.rb
@@ -1,70 +1,72 @@
-require "yaml"
+# frozen_string_literal: true
+
+require 'yaml'
module Crys
module Splash
class SplashProcessor < Crys::HtmlProcessor
def not_real
[
- "doctor",
- "starfleet officer",
- "magician",
- "hacker",
- "emperor of an evil galaxy",
- "replicant",
- "computer",
- "evil genius",
- "monster from another dimension",
- "Grim Ripper",
- "computer virus",
- "Leader of the Free World",
- "living legend",
- "sentient AI",
- "teenage pilot of a purple mech",
- "android",
- "last man on Earth",
- "time traveler",
- "pirate",
- "mayor of a vitual town",
+ 'doctor',
+ 'starfleet officer',
+ 'magician',
+ 'hacker',
+ 'emperor of an evil galaxy',
+ 'replicant',
+ 'computer',
+ 'evil genius',
+ 'monster from another dimension',
+ 'Grim Ripper',
+ 'computer virus',
+ 'Leader of the Free World',
+ 'living legend',
+ 'sentient AI',
+ 'teenage pilot of a purple mech',
+ 'android',
+ 'last man on Earth',
+ 'time traveler',
+ 'pirate',
+ 'mayor of a vitual town'
]
end
def update_badge(url_part)
@main_rss = fetch_rss(name: :main)
- if @main_rss.items.first(20).any? { |it| it.link.include? url_part }
- updated_badge
- end
+ return unless @main_rss.items.first(20).any? { |it| it.link.include? url_part }
+
+ updated_badge
end
def more_update_badge(name:)
path = case name
when :bookmarks
- "/assets/more/bookmarks.yml"
+ '/assets/more/bookmarks.yml'
when :links
- "/assets/more/links.yml"
+ '/assets/more/links.yml'
end
yaml = YAML.load_file(project_root + path)
_, vals = yaml.first
- last_added = Time.parse(vals.last.fetch("date"))
+ last_added = Time.parse(vals.last.fetch('date'))
+
+ return unless (Time.now - last_added) / (24 * 60 * 60) < 30
- if (Time.now - last_added) / (24 * 60* 60) < 30
- updated_badge
- end
+ updated_badge
end
def new_badge
- image = process_image(file: "new.gif")
- code = ERB.new <<-EOF
-<img src="<%=image.relative_path%>" width="32" height="22" class="new-badge" alt="NEW">
-EOF
+ image = process_image(file: 'new.gif')
+ code = ERB.new <<~EOF
+ <img src="<%=image.relative_path%>" width="32" height="22" class="new-badge" alt="NEW">
+ EOF
code.result(binding)
end
def updated_badge
- image = process_image(file: "updated.gif")
- code = ERB.new <<-EOF
-<img src="<%=image.relative_path%>" width="54" height="12" class="new-badge" alt="UPDATED">
-EOF
+ image = process_image(file: 'updated.gif')
+ code = ERB.new <<~EOF
+ <img src="<%=image.relative_path%>" width="54" height="12" class="new-badge" alt="UPDATED">
+ EOF
code.result(binding)
end
end