summaryrefslogtreecommitdiff
path: root/new/lib/crys/pages_db_manager.rb
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/lib/crys/pages_db_manager.rb
parent2781360c7c25404c5a1fd03ed3472d43367ed8c6 (diff)
feat: rubocopHEADmaster
Diffstat (limited to 'new/lib/crys/pages_db_manager.rb')
-rw-r--r--new/lib/crys/pages_db_manager.rb26
1 files changed, 9 insertions, 17 deletions
diff --git a/new/lib/crys/pages_db_manager.rb b/new/lib/crys/pages_db_manager.rb
index 6a5e71c..029b035 100644
--- a/new/lib/crys/pages_db_manager.rb
+++ b/new/lib/crys/pages_db_manager.rb
@@ -1,10 +1,11 @@
+# frozen_string_literal: true
+
module Crys
class PagesDbManager
PAGES_KEY = :pages
- PAGE = Struct.new(:filename, :file_path, :last_update, :in_rss, keyword_init: true)
+ PAGE = Struct.new(:filename, :file_path, :last_update, :in_rss, keyword_init: true)
- def db_path
- end
+ def db_path; end
def add_page(processor)
@processor = processor
@@ -16,7 +17,7 @@ module Crys
end
def pages
- db.fetch(:pages).map do | _, data|
+ db.fetch(:pages).map do |_, data|
PAGE.new(data)
end
end
@@ -25,7 +26,6 @@ module Crys
attr_reader :hash, :processor
-
def db
@db ||= YAML.load_file(
db_path,
@@ -34,15 +34,9 @@ module Crys
end
def upsert_db(hash, known_page)
- if known_page
- record = PAGE.new(known_page)
- else
- record = PAGE.new(
- filename: processor.filename,
- file_path: processor.file_path,
- in_rss: true
- )
- end
+ record = PAGE.new(known_page || { filename: processor.filename,
+ file_path: processor.file_path,
+ in_rss: true })
record.last_update = Time.now
@@ -50,9 +44,7 @@ module Crys
end
def save_db
- File.open(db_path, 'w') do |f|
- f.write db.to_yaml
- end
+ File.write(db_path, db.to_yaml)
end
def known_page(hash)