diff --git a/Gemfile b/Gemfile index 1abe236..66de8a1 100644 --- a/Gemfile +++ b/Gemfile @@ -4,12 +4,13 @@ source "https://rubygems.org" ruby "3.3.0" -gem "hanami", "2.1.0" -gem "hanami-router", "2.1.0" -gem "hanami-controller", "2.1.0" -gem "hanami-validations", "2.1.0" -gem "hanami-assets", "2.1.0" -gem "hanami-view", "2.1.0" +gem "hanami", "~> 2.2.0.beta" +gem "hanami-router", "~> 2.2.0.beta" +gem "hanami-controller", "~> 2.2.0.beta" +gem "hanami-validations", "~> 2.2.0.beta" +gem "hanami-assets", "~> 2.2.0.beta" +gem "hanami-view", "~> 2.2.0.beta" +gem "hanami-db", "~> 2.2.0.beta" # gem "hanami-view", file: "~/Documents/projects/hanami/view" gem "csv" @@ -20,7 +21,7 @@ gem "dotenv" gem "whenever", require: false gem "warning" -gem "dry-types" +gem "dry-types", "~> 1.0", ">= 1.6.1" gem "dry-matcher" gem "dry-monads" gem "puma" @@ -69,7 +70,7 @@ gem "steam-api" group :cli, :development do gem "irb" - gem "hanami-reloader", "~> 2.1.0.rc" + gem "hanami-reloader", "~> 2.2.0.beta" gem "rubocop", require: false end @@ -80,7 +81,8 @@ end group :development do gem "ed25519" gem "bcrypt_pbkdf" - gem "guard-puma", "~> 0.8" + gem "hanami-webconsole", "~> 2.2.0.beta" + gem "guard-puma" gem "standardrb" gem "capistrano", "~> 3.7", require: false gem "capistrano-bundler" diff --git a/Gemfile.lock b/Gemfile.lock index c71fa91..6a0db4d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -36,7 +36,7 @@ GIT GEM remote: https://rubygems.org/ specs: - activesupport (7.1.3.3) + activesupport (7.1.3.4) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -46,8 +46,8 @@ GEM minitest (>= 5.1) mutex_m tzinfo (~> 2.0) - addressable (2.8.6) - public_suffix (>= 2.0.2, < 6.0) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) airbrussh (1.5.2) sshkit (>= 1.6.1, != 1.7.0) ast (2.4.2) @@ -56,14 +56,20 @@ GEM bcrypt_pbkdf (1.1.1) bcrypt_pbkdf (1.1.1-arm64-darwin) bcrypt_pbkdf (1.1.1-x86_64-darwin) + better_errors (2.10.1) + erubi (>= 1.0.0) + rack (>= 0.9.0) + rouge (>= 1.0.0) bigdecimal (3.1.8) + binding_of_caller (1.0.1) + debug_inspector (>= 1.2.0) bskyrb (0.5.3) date (>= 3.3.3) httparty (>= 0.21.0) json (>= 2.0) xrpc (>= 0.0.4) - builder (3.2.4) - capistrano (3.18.1) + builder (3.3.0) + capistrano (3.19.1) airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) @@ -75,10 +81,10 @@ GEM sshkit (~> 1.3) capistrano-systemd-multiservice (0.1.0.beta13) capistrano (~> 3.7) - charlock_holmes (0.7.7) + charlock_holmes (0.7.9) chronic (0.10.2) coderay (1.1.3) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.3) connection_pool (2.4.1) crass (1.0.6) csv (3.3.0) @@ -87,6 +93,7 @@ GEM database_cleaner-core (~> 2.0.0) sequel date (3.3.4) + debug_inspector (1.2.0) diff-lcs (1.5.1) domain_name (0.6.20240107) dotenv (3.1.2) @@ -96,8 +103,8 @@ GEM dry-auto_inject (1.0.1) dry-core (~> 1.0) zeitwerk (~> 2.6) - dry-cli (1.0.0) - dry-configurable (1.1.0) + dry-cli (1.1.0) + dry-configurable (1.2.0) dry-core (~> 1.0, < 2) zeitwerk (~> 2.6) dry-core (1.0.1) @@ -107,7 +114,7 @@ GEM concurrent-ruby (~> 1.0) dry-core (~> 1.0, < 2) dry-files (1.1.0) - dry-inflector (1.0.0) + dry-inflector (1.1.0) dry-initializer (3.1.1) dry-logger (1.0.4) dry-logic (1.5.0) @@ -137,11 +144,11 @@ GEM dry-types (>= 1.7, < 2) ice_nine (~> 0.11) zeitwerk (~> 2.6) - dry-system (1.0.1) - dry-auto_inject (~> 1.0, < 2) - dry-configurable (~> 1.0, < 2) - dry-core (~> 1.0, < 2) - dry-inflector (~> 1.0, < 2) + dry-system (1.1.0.beta1) + dry-auto_inject (~> 1.0) + dry-configurable (~> 1.0) + dry-core (~> 1.0) + dry-inflector (~> 1.0) dry-transformer (1.0.1) zeitwerk (~> 2.6) dry-types (1.7.2) @@ -158,7 +165,8 @@ GEM dry-schema (>= 1.12, < 2) zeitwerk (~> 2.6) ed25519 (1.3.0) - faker (3.3.1) + erubi (1.13.0) + faker (3.4.2) i18n (>= 1.8.11, < 2) faraday (1.10.3) faraday-em_http (~> 1.0) @@ -178,16 +186,18 @@ GEM faraday-httpclient (1.0.1) faraday-multipart (1.0.4) multipart-post (~> 2) - faraday-net_http (1.0.1) + faraday-net_http (1.0.2) faraday-net_http_persistent (1.2.0) faraday-patron (1.0.0) faraday-rack (1.0.0) faraday-retry (1.0.3) - ffi (1.16.3) + ffi (1.17.0-arm64-darwin) + ffi (1.17.0-x86_64-darwin) + ffi (1.17.0-x86_64-linux-gnu) formatador (1.1.0) georuby (2.5.2) gnuplot (2.6.2) - gpx (1.1.1) + gpx (1.2.0) nokogiri (~> 1.7) rake guard (2.18.1) @@ -205,36 +215,40 @@ GEM guard-compat (~> 1.2) puma (>= 4.0, < 7) guess_html_encoding (0.0.11) - hanami (2.1.0) + hanami (2.2.0.beta1) bundler (>= 1.16, < 3) - dry-configurable (~> 1.0, < 2) + dry-configurable (~> 1.0, >= 1.2.0, < 2) dry-core (~> 1.0, < 2) - dry-inflector (~> 1.0, < 2) + dry-inflector (~> 1.0, >= 1.1.0, < 2) dry-logger (~> 1.0, < 2) dry-monitor (~> 1.0, >= 1.0.1, < 2) - dry-system (~> 1.0, < 2) - hanami-cli (~> 2.1) - hanami-utils (~> 2.1) + dry-system (= 1.1.0.beta1) + hanami-cli (= 2.2.0.beta1) + hanami-utils (~> 2.2.beta) zeitwerk (~> 2.6) - hanami-assets (2.1.0) + hanami-assets (2.2.0.beta1) zeitwerk (~> 2.6) - hanami-cli (2.1.1) + hanami-cli (2.2.0.beta1) bundler (~> 2.1) - dry-cli (~> 1.0, < 2) + dry-cli (~> 1.0, >= 1.1.0) dry-files (~> 1.0, >= 1.0.2, < 2) dry-inflector (~> 1.0, < 2) rake (~> 13.0) zeitwerk (~> 2.6) - hanami-controller (2.1.0) + hanami-controller (2.2.0.beta1) dry-configurable (~> 1.0, < 2) dry-core (~> 1.0) - hanami-utils (~> 2.1) + hanami-utils (~> 2.2.beta) rack (~> 2.0) zeitwerk (~> 2.6) - hanami-reloader (2.1.0) - hanami-cli (~> 2.1) + hanami-db (2.2.0.beta1) + rom (~> 5.3) + rom-sql (~> 3.6, >= 3.6.4) zeitwerk (~> 2.6) - hanami-router (2.1.0) + hanami-reloader (2.2.0.beta1) + hanami-cli (~> 2.2.beta) + zeitwerk (~> 2.6) + hanami-router (2.2.0.beta1) mustermann (~> 3.0) mustermann-contrib (~> 3.0) rack (~> 2.0) @@ -243,24 +257,27 @@ GEM rake (~> 13.0) rspec (~> 3.12) zeitwerk (~> 2.6) - hanami-utils (2.1.0) + hanami-utils (2.2.0.beta1) concurrent-ruby (~> 1.0) dry-core (~> 1.0, < 2) dry-transformer (~> 1.0, < 2) - hanami-validations (2.1.0) + hanami-validations (2.2.0.beta1) dry-validation (>= 1.10, < 2) zeitwerk (~> 2.6.0) - hanami-view (2.1.0) + hanami-view (2.2.0.beta1) dry-configurable (~> 1.0) dry-core (~> 1.0) dry-inflector (~> 1.0, < 2) temple (~> 0.10.0, >= 0.10.2) tilt (~> 2.3) zeitwerk (~> 2.6) + hanami-webconsole (2.2.0.beta1) + better_errors (~> 2.10, >= 2.10.1) + binding_of_caller (~> 1.0) hansi (0.2.1) hashie (2.1.2) http-accept (1.7.0) - http-cookie (1.0.5) + http-cookie (1.0.6) domain_name (~> 0.5) httparty (0.22.0) csv @@ -269,15 +286,15 @@ GEM i18n (1.14.5) concurrent-ruby (~> 1.0) ice_nine (0.11.2) - image_processing (1.12.2) + image_processing (1.13.0) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) io-console (0.7.2) - irb (1.13.1) + irb (1.14.0) rdoc (>= 4.0.0) reline (>= 0.4.2) json (2.7.2) - jwt (2.8.1) + jwt (2.8.2) base64 language_server-protocol (3.17.0.3) lastfm (1.27.4) @@ -287,6 +304,7 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) + logger (1.6.0) lumberjack (1.2.10) mail (2.8.1) mini_mime (>= 0.1.1) @@ -297,21 +315,21 @@ GEM method_source (1.1.0) mime-types (3.5.2) mime-types-data (~> 3.2015) - mime-types-data (3.2024.0507) - mini_magick (4.12.0) + mime-types-data (3.2024.0702) + mini_magick (4.13.2) mini_mime (1.1.5) - minitest (5.23.1) + minitest (5.24.1) multi_xml (0.7.1) bigdecimal (~> 3.1) multipart-post (2.4.1) - mustermann (3.0.0) + mustermann (3.0.1) ruby2_keywords (~> 0.0.1) - mustermann-contrib (3.0.0) + mustermann-contrib (3.0.1) hansi (~> 0.2.0) - mustermann (= 3.0.0) + mustermann (= 3.0.1) mutex_m (0.2.0) nenv (0.3.0) - net-imap (0.4.11) + net-imap (0.4.14) date net-protocol net-pop (0.1.2) @@ -327,11 +345,11 @@ GEM net-ssh (7.2.3) netrc (0.11.0) nio4r (2.7.3) - nokogiri (1.16.5-arm64-darwin) + nokogiri (1.16.7-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.5-x86_64-darwin) + nokogiri (1.16.7-x86_64-darwin) racc (~> 1.4) - nokogiri (1.16.5-x86_64-linux) + nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) notiffany (0.1.3) nenv (~> 0.1) @@ -349,21 +367,21 @@ GEM omdb-api (1.4.3) activesupport httparty - parallel (1.24.0) - parser (3.3.1.0) + parallel (1.25.1) + parser (3.3.4.0) ast (~> 2.4.1) racc - pg (1.5.6) + pg (1.5.7) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) psych (5.1.2) stringio - public_suffix (5.0.5) + public_suffix (6.0.1) puma (6.4.2) nio4r (~> 2.0) que (2.3.0) - racc (1.8.0) + racc (1.8.1) rack (2.2.9) rack-attack (6.7.0) rack (>= 1.0, < 4) @@ -387,7 +405,7 @@ GEM redis-client (0.22.2) connection_pool regexp_parser (2.9.2) - reline (0.5.7) + reline (0.5.9) io-console (~> 0.5) rest-client (2.1.0) http-accept (>= 1.7.0, < 2.0) @@ -396,7 +414,7 @@ GEM netrc (~> 0.8) reverse_markdown (2.1.1) nokogiri - rexml (3.3.2) + rexml (3.3.4) strscan rom (5.3.2) rom-changeset (~> 5.3, >= 5.3.0) @@ -425,25 +443,26 @@ GEM dry-core (~> 1.0) dry-initializer (~> 3.0, >= 3.0.1) rom-core (~> 5.3, >= 5.3.0) - rom-sql (3.6.3) + rom-sql (3.6.4) dry-core (~> 1.0) dry-types (~> 1.0) rom (~> 5.2, >= 5.2.1) sequel (>= 4.49) + rouge (4.3.0) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) rspec-core (3.13.0) rspec-support (~> 3.13.0) - rspec-expectations (3.13.0) + rspec-expectations (3.13.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-support (3.13.1) - rubocop (1.63.5) + rubocop (1.64.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -456,20 +475,21 @@ GEM unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.31.3) parser (>= 3.3.1.0) - rubocop-performance (1.21.0) + rubocop-performance (1.21.1) rubocop (>= 1.48.1, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (1.13.0) - ruby-readability (0.7.0) + ruby-readability (0.7.1) guess_html_encoding (>= 0.0.4) nokogiri (>= 1.6.0) - ruby-vips (2.2.1) + ruby-vips (2.2.2) ffi (~> 1.12) + logger ruby2_keywords (0.0.5) - sanitize (6.1.0) + sanitize (6.1.2) crass (~> 1.0.2) nokogiri (>= 1.12.0) - sequel (5.80.0) + sequel (5.83.0) bigdecimal shellany (0.0.1) simple-rss (1.3.3) @@ -479,16 +499,15 @@ GEM snaky_hash (2.0.1) hashie version_gem (~> 1.1, >= 1.1.1) - sshkit (1.22.2) + sshkit (1.23.0) base64 - mutex_m net-scp (>= 1.1.2) net-sftp (>= 2.1.2) net-ssh (>= 2.8.0) - standard (1.36.0) + standard (1.39.2) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.0) - rubocop (~> 1.63.0) + rubocop (~> 1.64.0) standard-custom (~> 1.0.0) standard-performance (~> 1.4) standard-custom (1.0.2) @@ -501,13 +520,13 @@ GEM standard steam-api (1.2.0) faraday (~> 1.0) - stringio (3.1.0) + stringio (3.1.1) strscan (3.1.0) temple (0.10.3) thor (1.3.1) - tilt (2.3.0) + tilt (2.4.0) time_math2 (0.1.1) - timecop (0.9.8) + timecop (0.9.10) timeout (0.4.1) transproc (1.1.1) tzinfo (2.0.6) @@ -516,7 +535,7 @@ GEM unicode-emoji (3.4.0) unicode-version (~> 1.0) unicode-version (1.4.0) - vernier (1.0.1) + vernier (1.1.1) version_gem (1.1.4) warning (1.4.0) whenever (1.0.0) @@ -527,7 +546,7 @@ GEM date httparty json (>= 2.0) - zeitwerk (2.6.15) + zeitwerk (2.6.17) PLATFORMS arm64-darwin-23 @@ -553,20 +572,22 @@ DEPENDENCIES down dry-matcher dry-monads - dry-types + dry-types (~> 1.0, >= 1.6.1) ed25519 georuby gnuplot gpx - guard-puma (~> 0.8) - hanami (= 2.1.0) - hanami-assets (= 2.1.0) - hanami-controller (= 2.1.0) - hanami-reloader (~> 2.1.0.rc) - hanami-router (= 2.1.0) + guard-puma + hanami (~> 2.2.0.beta) + hanami-assets (~> 2.2.0.beta) + hanami-controller (~> 2.2.0.beta) + hanami-db (~> 2.2.0.beta) + hanami-reloader (~> 2.2.0.beta) + hanami-router (~> 2.2.0.beta) hanami-rspec (~> 2.1.0.rc) - hanami-validations (= 2.1.0) - hanami-view (= 2.1.0) + hanami-validations (~> 2.2.0.beta) + hanami-view (~> 2.2.0.beta) + hanami-webconsole (~> 2.2.0.beta) httparty image_processing (~> 1.0) irb diff --git a/Rakefile b/Rakefile index 88f3bd7..dee2dae 100644 --- a/Rakefile +++ b/Rakefile @@ -85,7 +85,7 @@ namespace :blog do require "hanami/prepare" require "que" - Que.connection = Adamantium::Container["persistence.db"] + Que.connection = Adamantium::Container["db.gateway"].connection Adamantium::Jobs::ArchiveDeletedWebmentions.enqueue end diff --git a/app/db/relation.rb b/app/db/relation.rb new file mode 100644 index 0000000..0362e54 --- /dev/null +++ b/app/db/relation.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +require "hanami/db/relation" + +module Adamantium + module DB + class Relation < Hanami::DB::Relation + end + end +end diff --git a/app/db/repo.rb b/app/db/repo.rb new file mode 100644 index 0000000..a874b12 --- /dev/null +++ b/app/db/repo.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +require "hanami/db/repo" + +module Adamantium + module DB + class Repo < Hanami::DB::Repo + end + end +end diff --git a/app/relations/auto_taggings.rb b/app/relations/auto_taggings.rb index 9234047..7bd604f 100644 --- a/app/relations/auto_taggings.rb +++ b/app/relations/auto_taggings.rb @@ -2,7 +2,7 @@ module Adamantium module Relations - class AutoTaggings < ROM::Relation[:sql] + class AutoTaggings < Adamantium::DB::Relation schema :auto_taggings, infer: true do associations do belongs_to :tag diff --git a/app/relations/highlights.rb b/app/relations/highlights.rb index eb8f035..3f29c21 100644 --- a/app/relations/highlights.rb +++ b/app/relations/highlights.rb @@ -2,7 +2,7 @@ module Adamantium module Relations - class Highlights < ROM::Relation[:sql] + class Highlights < Adamantium::DB::Relation schema :highlights, infer: true do associations do belongs_to :post diff --git a/app/relations/login_tokens.rb b/app/relations/login_tokens.rb index 3b14146..7f57651 100644 --- a/app/relations/login_tokens.rb +++ b/app/relations/login_tokens.rb @@ -2,7 +2,7 @@ module Adamantium module Relations - class LoginTokens < ROM::Relation[:sql] + class LoginTokens < Adamantium::DB::Relation schema :login_tokens, infer: true auto_struct(true) diff --git a/app/relations/movies.rb b/app/relations/movies.rb index 5a443b3..fa09cc4 100644 --- a/app/relations/movies.rb +++ b/app/relations/movies.rb @@ -2,7 +2,7 @@ module Adamantium module Relations - class Movies < ROM::Relation[:sql] + class Movies < Adamantium::DB::Relation schema :movies, infer: true auto_struct(true) diff --git a/app/relations/pages.rb b/app/relations/pages.rb index dee595d..49b07cc 100644 --- a/app/relations/pages.rb +++ b/app/relations/pages.rb @@ -2,7 +2,7 @@ module Adamantium module Relations - class Pages < ROM::Relation[:sql] + class Pages < Adamantium::DB::Relation schema :pages, infer: true auto_struct(true) diff --git a/app/relations/podcast_scrobbles.rb b/app/relations/podcast_scrobbles.rb index 0404a4b..99edf4c 100644 --- a/app/relations/podcast_scrobbles.rb +++ b/app/relations/podcast_scrobbles.rb @@ -2,7 +2,7 @@ module Adamantium module Relations - class PodcastScrobbles < ROM::Relation[:sql] + class PodcastScrobbles < Adamantium::DB::Relation schema :podcast_scrobbles, infer: true auto_struct(true) diff --git a/app/relations/podcasts.rb b/app/relations/podcasts.rb index ba96774..f686579 100644 --- a/app/relations/podcasts.rb +++ b/app/relations/podcasts.rb @@ -2,7 +2,7 @@ module Adamantium module Relations - class Podcasts < ROM::Relation[:sql] + class Podcasts < Adamantium::DB::Relation schema :podcasts, infer: true auto_struct(true) diff --git a/app/relations/post_tags.rb b/app/relations/post_tags.rb index 23a1bb2..45bb905 100644 --- a/app/relations/post_tags.rb +++ b/app/relations/post_tags.rb @@ -2,7 +2,7 @@ module Adamantium module Relations - class PostTags < ROM::Relation[:sql] + class PostTags < Adamantium::DB::Relation schema :post_tags, infer: true do associations do belongs_to :post diff --git a/app/relations/post_trips.rb b/app/relations/post_trips.rb index 85cb19a..641c60d 100644 --- a/app/relations/post_trips.rb +++ b/app/relations/post_trips.rb @@ -2,7 +2,7 @@ module Adamantium module Relations - class PostTrips < ROM::Relation[:sql] + class PostTrips < Adamantium::DB::Relation schema :post_trips, infer: true do associations do belongs_to :post diff --git a/app/relations/posts.rb b/app/relations/posts.rb index 73012c5..91bdd9c 100644 --- a/app/relations/posts.rb +++ b/app/relations/posts.rb @@ -2,7 +2,7 @@ module Adamantium module Relations - class Posts < ROM::Relation[:sql] + class Posts < Adamantium::DB::Relation schema :posts, infer: true do associations do has_many :post_tags diff --git a/app/relations/reactions.rb b/app/relations/reactions.rb index 106f300..2fbf71a 100644 --- a/app/relations/reactions.rb +++ b/app/relations/reactions.rb @@ -2,7 +2,7 @@ module Adamantium module Relations - class Reactions < ROM::Relation[:sql] + class Reactions < Adamantium::DB::Relation schema :reactions, infer: true do associations do belongs_to :post diff --git a/app/relations/tags.rb b/app/relations/tags.rb index 367f05d..51a879b 100644 --- a/app/relations/tags.rb +++ b/app/relations/tags.rb @@ -2,7 +2,7 @@ module Adamantium module Relations - class Tags < ROM::Relation[:sql] + class Tags < Adamantium::DB::Relation schema :tags, infer: true do associations do has_many :post_tags diff --git a/app/relations/top_tracks.rb b/app/relations/top_tracks.rb index ce09983..fdb8918 100644 --- a/app/relations/top_tracks.rb +++ b/app/relations/top_tracks.rb @@ -2,7 +2,7 @@ module Adamantium module Relations - class TopTracks < ROM::Relation[:sql] + class TopTracks < Adamantium::DB::Relation schema :top_tracks, infer: true auto_struct(true) diff --git a/app/relations/trips.rb b/app/relations/trips.rb index f400e6b..bb33802 100644 --- a/app/relations/trips.rb +++ b/app/relations/trips.rb @@ -2,7 +2,7 @@ module Adamantium module Relations - class Trips < ROM::Relation[:sql] + class Trips < Adamantium::DB::Relation schema :trips, infer: true do associations do has_many :post_trips diff --git a/app/relations/users.rb b/app/relations/users.rb index 34d9257..4a00145 100644 --- a/app/relations/users.rb +++ b/app/relations/users.rb @@ -2,7 +2,7 @@ module Adamantium module Relations - class Users < ROM::Relation[:sql] + class Users < Adamantium::DB::Relation schema :users, infer: true auto_struct(true) diff --git a/app/relations/webmentions.rb b/app/relations/webmentions.rb index 6a691b6..0465e98 100644 --- a/app/relations/webmentions.rb +++ b/app/relations/webmentions.rb @@ -2,7 +2,7 @@ module Adamantium module Relations - class Webmentions < ROM::Relation[:sql] + class Webmentions < Adamantium::DB::Relation schema :webmentions, infer: true do associations do belongs_to :post diff --git a/app/relations/workouts.rb b/app/relations/workouts.rb index 0f39d4d..1c40d0b 100644 --- a/app/relations/workouts.rb +++ b/app/relations/workouts.rb @@ -2,7 +2,7 @@ module Adamantium module Relations - class Workouts < ROM::Relation[:sql] + class Workouts < Adamantium::DB::Relation schema :workouts, infer: true auto_struct(true) diff --git a/app/repos/page_repo.rb b/app/repos/page_repo.rb index 61f7933..b9d679d 100644 --- a/app/repos/page_repo.rb +++ b/app/repos/page_repo.rb @@ -1,6 +1,6 @@ module Adamantium module Repos - class PageRepo < Adamantium::Repo[:pages] + class PageRepo < Adamantium::DB::Repo[:pages] def fetch!(slug:) pages .published diff --git a/app/repos/podcast_scrobble_repo.rb b/app/repos/podcast_scrobble_repo.rb index 08d93e0..7929d04 100644 --- a/app/repos/podcast_scrobble_repo.rb +++ b/app/repos/podcast_scrobble_repo.rb @@ -1,6 +1,6 @@ module Adamantium module Repos - class PodcastScrobbleRepo < Adamantium::Repo[:podcast_scrobbles] + class PodcastScrobbleRepo < Adamantium::DB::Repo[:podcast_scrobbles] commands :create def exists?(id:) diff --git a/app/repos/post_repo.rb b/app/repos/post_repo.rb index 13ccfcc..e60c196 100644 --- a/app/repos/post_repo.rb +++ b/app/repos/post_repo.rb @@ -2,7 +2,7 @@ require "time_math" module Adamantium module Repos - class PostRepo < Adamantium::Repo[:posts] + class PostRepo < Adamantium::DB::Repo[:posts] def recent(limit:) date = Time.now diff --git a/config/app.rb b/config/app.rb index a1ed989..b10992c 100644 --- a/config/app.rb +++ b/config/app.rb @@ -29,6 +29,7 @@ module Adamantium "clients.blue_sky", "clients.mastodon", "clients.steam", + "db.rom", "geo.gpx_parser", "param_parser.micropub_post", "param_parser.webmention", diff --git a/config/providers/persistence.rb b/config/providers/persistence.rb deleted file mode 100644 index 0e03cf0..0000000 --- a/config/providers/persistence.rb +++ /dev/null @@ -1,45 +0,0 @@ -# frozen_string_literal: true - -Hanami.app.register_provider :persistence, namespace: true do - prepare do - require "rom-changeset" - require "rom/core" - require "rom/sql" - - # TODO(Hanami): As part of built-in rom setup, configure ROM with app inflector - silence_warnings { ROM::Inflector = Hanami.app["inflector"] } - - rom_config = ROM::Configuration.new(:sql, target["settings"].database_url) - - rom_config.plugin(:sql, relations: :instrumentation) do |plugin_config| - plugin_config.notifications = target["notifications"] - end - - rom_config.plugin(:sql, relations: :auto_restrictions) - - register "config", rom_config - register "db", rom_config.gateways[:default].connection - end - - start do - rom_config = target["persistence.config"] - rom_config.auto_registration( - target.root.join("app"), - namespace: Hanami.app.namespace.to_s - ) - - register "rom", ROM.container(rom_config) - end - - stop do - target["persistence.rom"].disconnect - end - - define_method(:silence_warnings) do |&block| - orig_verbose = $VERBOSE - $VERBOSE = nil - result = block.call - $VERBOSE = orig_verbose - result - end -end diff --git a/lib/adamantium/repo.rb b/lib/adamantium/repo.rb deleted file mode 100644 index d77c095..0000000 --- a/lib/adamantium/repo.rb +++ /dev/null @@ -1,10 +0,0 @@ -# auto_register: false -# frozen_string_literal: true - -require "rom-repository" - -module Adamantium - class Repo < ROM::Repository::Root - include Deps[container: "persistence.rom"] - end -end diff --git a/slices/admin/actions/bookmarks/clean.rb b/slices/admin/actions/bookmarks/clean.rb index d5813cd..cce8e5e 100644 --- a/slices/admin/actions/bookmarks/clean.rb +++ b/slices/admin/actions/bookmarks/clean.rb @@ -5,7 +5,7 @@ module Admin module Bookmarks class Clean < Action def handle(req, res) - Que.connection = Adamantium::Container["persistence.db"] + Que.connection = Adamantium::Container["db.gateway"].connection res.status = 200 if Que.job_stats.any? { |job| job[:job_class] == Adamantium::Jobs::ArchiveDeadBookmarks.name } diff --git a/slices/admin/repos/auto_tagging_repo.rb b/slices/admin/repos/auto_tagging_repo.rb index 858e707..b2a58a7 100644 --- a/slices/admin/repos/auto_tagging_repo.rb +++ b/slices/admin/repos/auto_tagging_repo.rb @@ -1,6 +1,6 @@ module Admin module Repos - class AutoTaggingRepo < Adamantium::Repo[:auto_taggings] + class AutoTaggingRepo < Adamantium::DB::Repo[:auto_taggings] commands :create def find(id) diff --git a/slices/admin/repos/book_repo.rb b/slices/admin/repos/book_repo.rb index fe02755..5ef44c9 100644 --- a/slices/admin/repos/book_repo.rb +++ b/slices/admin/repos/book_repo.rb @@ -1,6 +1,6 @@ module Admin module Repos - class BookRepo < Adamantium::Repo[:posts] + class BookRepo < Adamantium::DB::Repo[:posts] commands :create, update: :by_pk def list_all diff --git a/slices/admin/repos/bookmark_repo.rb b/slices/admin/repos/bookmark_repo.rb index 9472086..3ed4cee 100644 --- a/slices/admin/repos/bookmark_repo.rb +++ b/slices/admin/repos/bookmark_repo.rb @@ -1,6 +1,6 @@ module Admin module Repos - class BookmarkRepo < Adamantium::Repo[:posts] + class BookmarkRepo < Adamantium::DB::Repo[:posts] def list posts .where(post_type: "bookmark") diff --git a/slices/admin/repos/highlight_repo.rb b/slices/admin/repos/highlight_repo.rb index 1e13a47..2ce87d2 100644 --- a/slices/admin/repos/highlight_repo.rb +++ b/slices/admin/repos/highlight_repo.rb @@ -1,6 +1,6 @@ module Admin module Repos - class HighlightRepo < Adamantium::Repo[:highlights] + class HighlightRepo < Adamantium::DB::Repo[:highlights] commands :create, delete: :by_pk def list_all diff --git a/slices/admin/repos/login_tokens_repo.rb b/slices/admin/repos/login_tokens_repo.rb index 3f19701..2fb8d4f 100644 --- a/slices/admin/repos/login_tokens_repo.rb +++ b/slices/admin/repos/login_tokens_repo.rb @@ -1,6 +1,6 @@ module Admin module Repos - class LoginTokensRepo < Adamantium::Repo[:login_tokens] + class LoginTokensRepo < Adamantium::DB::Repo[:login_tokens] commands :create def by_token(token:) diff --git a/slices/admin/repos/movie_repo.rb b/slices/admin/repos/movie_repo.rb index 16c7506..63c55a5 100644 --- a/slices/admin/repos/movie_repo.rb +++ b/slices/admin/repos/movie_repo.rb @@ -1,6 +1,6 @@ module Admin module Repos - class MovieRepo < Adamantium::Repo[:movies] + class MovieRepo < Adamantium::DB::Repo[:movies] commands :create def by_title_and_year(title:, year:) diff --git a/slices/admin/repos/page_repo.rb b/slices/admin/repos/page_repo.rb index eea6131..be0e141 100644 --- a/slices/admin/repos/page_repo.rb +++ b/slices/admin/repos/page_repo.rb @@ -2,7 +2,7 @@ require "time_math" module Admin module Repos - class PageRepo < Adamantium::Repo[:pages] + class PageRepo < Adamantium::DB::Repo[:pages] commands :create, update: :by_pk def list diff --git a/slices/admin/repos/post_repo.rb b/slices/admin/repos/post_repo.rb index 350ca11..d05cd37 100644 --- a/slices/admin/repos/post_repo.rb +++ b/slices/admin/repos/post_repo.rb @@ -2,7 +2,7 @@ require "time_math" module Admin module Repos - class PostRepo < Adamantium::Repo[:posts] + class PostRepo < Adamantium::DB::Repo[:posts] commands update: :by_pk def tag_post(post_id:, tags:) diff --git a/slices/admin/repos/post_tag_repo.rb b/slices/admin/repos/post_tag_repo.rb index 5f13038..90d75dc 100644 --- a/slices/admin/repos/post_tag_repo.rb +++ b/slices/admin/repos/post_tag_repo.rb @@ -1,6 +1,6 @@ module Admin module Repos - class PostTagRepo < Adamantium::Repo[:post_tags] + class PostTagRepo < Adamantium::DB::Repo[:post_tags] def merge_tags(target_id:, source_id:) post_tags.where(tag_id: source_id).update(tag_id: target_id) end diff --git a/slices/admin/repos/post_trip_repo.rb b/slices/admin/repos/post_trip_repo.rb index 1fabb8f..8725480 100644 --- a/slices/admin/repos/post_trip_repo.rb +++ b/slices/admin/repos/post_trip_repo.rb @@ -1,6 +1,6 @@ module Admin module Repos - class PostTripRepo < Adamantium::Repo[:post_trips] + class PostTripRepo < Adamantium::DB::Repo[:post_trips] commands :create def remove(trip_id:, post_id:) diff --git a/slices/admin/repos/tag_repo.rb b/slices/admin/repos/tag_repo.rb index 5c6a5c9..ab10ca2 100644 --- a/slices/admin/repos/tag_repo.rb +++ b/slices/admin/repos/tag_repo.rb @@ -1,6 +1,6 @@ module Admin module Repos - class TagRepo < Adamantium::Repo[:tags] + class TagRepo < Adamantium::DB::Repo[:tags] def list tags .order(Sequel.function(:lower, :label)) diff --git a/slices/admin/repos/trip_repo.rb b/slices/admin/repos/trip_repo.rb index 2a832ed..30a13b0 100644 --- a/slices/admin/repos/trip_repo.rb +++ b/slices/admin/repos/trip_repo.rb @@ -1,6 +1,6 @@ module Admin module Repos - class TripRepo < Adamantium::Repo[:trips] + class TripRepo < Adamantium::DB::Repo[:trips] commands :create def list diff --git a/slices/admin/repos/user_repo.rb b/slices/admin/repos/user_repo.rb index e6ef38b..b8ffe2f 100644 --- a/slices/admin/repos/user_repo.rb +++ b/slices/admin/repos/user_repo.rb @@ -1,6 +1,6 @@ module Admin module Repos - class UserRepo < Adamantium::Repo[:users] + class UserRepo < Adamantium::DB::Repo[:users] commands :create def exists(id) diff --git a/slices/admin/repos/webmention_repo.rb b/slices/admin/repos/webmention_repo.rb index 5a1f768..f8207ad 100644 --- a/slices/admin/repos/webmention_repo.rb +++ b/slices/admin/repos/webmention_repo.rb @@ -1,6 +1,6 @@ module Admin module Repos - class WebmentionRepo < Adamantium::Repo[:webmentions] + class WebmentionRepo < Adamantium::DB::Repo[:webmentions] commands update: :by_pk def list_all_for_check diff --git a/slices/admin/views/bookmarks/index.rb b/slices/admin/views/bookmarks/index.rb index ff5883a..4b5da37 100644 --- a/slices/admin/views/bookmarks/index.rb +++ b/slices/admin/views/bookmarks/index.rb @@ -19,7 +19,7 @@ module Admin end expose :running_jobs do - Que.connection = Adamantium::Container["persistence.db"] + Que.connection = Adamantium::Container["db.gateway"].connection Que.job_stats.any? { |job| job[:job_class] == Adamantium::Jobs::ArchiveDeadBookmarks.name } end end diff --git a/slices/main/repos/movie_repo.rb b/slices/main/repos/movie_repo.rb index 5fcac8c..faeeb52 100644 --- a/slices/main/repos/movie_repo.rb +++ b/slices/main/repos/movie_repo.rb @@ -1,6 +1,6 @@ module Main module Repos - class MovieRepo < Adamantium::Repo[:movies] + class MovieRepo < Adamantium::DB::Repo[:movies] def listing movies.order(Sequel.lit("year desc")).to_a end diff --git a/slices/main/repos/page_repo.rb b/slices/main/repos/page_repo.rb index 362b91d..21ec4ec 100644 --- a/slices/main/repos/page_repo.rb +++ b/slices/main/repos/page_repo.rb @@ -1,6 +1,6 @@ module Main module Repos - class PageRepo < Adamantium::Repo[:pages] + class PageRepo < Adamantium::DB::Repo[:pages] def fetch!(slug:) pages .published diff --git a/slices/main/repos/podcast_repo.rb b/slices/main/repos/podcast_repo.rb index 2f55acd..11ba2ce 100644 --- a/slices/main/repos/podcast_repo.rb +++ b/slices/main/repos/podcast_repo.rb @@ -1,6 +1,6 @@ module Main module Repos - class PodcastRepo < Adamantium::Repo[:podcasts] + class PodcastRepo < Adamantium::DB::Repo[:podcasts] def listing podcasts.order(:name).to_a end diff --git a/slices/main/repos/podcast_scrobble_repo.rb b/slices/main/repos/podcast_scrobble_repo.rb index 58c98f3..ef66f8b 100644 --- a/slices/main/repos/podcast_scrobble_repo.rb +++ b/slices/main/repos/podcast_scrobble_repo.rb @@ -1,6 +1,6 @@ module Main module Repos - class PodcastScrobbleRepo < Adamantium::Repo[:podcast_scrobbles] + class PodcastScrobbleRepo < Adamantium::DB::Repo[:podcast_scrobbles] def exists?(id:) !!podcast_scrobbles .where(overcast_id: id) diff --git a/slices/main/repos/post_repo.rb b/slices/main/repos/post_repo.rb index 29925fc..4d8f38e 100644 --- a/slices/main/repos/post_repo.rb +++ b/slices/main/repos/post_repo.rb @@ -1,6 +1,6 @@ module Main module Repos - class PostRepo < Adamantium::Repo[:posts] + class PostRepo < Adamantium::DB::Repo[:posts] Sequel.extension :pg_json Sequel.extension :pg_json_ops diff --git a/slices/main/repos/post_tag_repo.rb b/slices/main/repos/post_tag_repo.rb index 83d3d5f..614bcf7 100644 --- a/slices/main/repos/post_tag_repo.rb +++ b/slices/main/repos/post_tag_repo.rb @@ -1,6 +1,6 @@ module Main module Repos - class PostTagRepo < Adamantium::Repo[:post_tags] + class PostTagRepo < Adamantium::DB::Repo[:post_tags] def posts_tagged(tag:) tag_id = post_tags .tags diff --git a/slices/main/repos/reaction_repo.rb b/slices/main/repos/reaction_repo.rb index e4eba5e..9531606 100644 --- a/slices/main/repos/reaction_repo.rb +++ b/slices/main/repos/reaction_repo.rb @@ -1,6 +1,6 @@ module Main module Repos - class ReactionRepo < Adamantium::Repo[:reactions] + class ReactionRepo < Adamantium::DB::Repo[:reactions] commands :create def count(post_id:) diff --git a/slices/main/repos/tag_repo.rb b/slices/main/repos/tag_repo.rb index 0626e74..bb00704 100644 --- a/slices/main/repos/tag_repo.rb +++ b/slices/main/repos/tag_repo.rb @@ -1,6 +1,6 @@ module Main module Repos - class TagRepo < Adamantium::Repo[:tags] + class TagRepo < Adamantium::DB::Repo[:tags] def fetch!(slug) tags.where(slug: slug).one! end diff --git a/slices/main/repos/top_track_repo.rb b/slices/main/repos/top_track_repo.rb index d7c952b..0e1d483 100644 --- a/slices/main/repos/top_track_repo.rb +++ b/slices/main/repos/top_track_repo.rb @@ -1,6 +1,6 @@ module Main module Repos - class TopTrackRepo < Adamantium::Repo[:top_tracks] + class TopTrackRepo < Adamantium::DB::Repo[:top_tracks] def for_post(id:) top_tracks .where(post_id: id) diff --git a/slices/main/repos/trip_repo.rb b/slices/main/repos/trip_repo.rb index 8b0a1f8..d62c315 100644 --- a/slices/main/repos/trip_repo.rb +++ b/slices/main/repos/trip_repo.rb @@ -1,6 +1,6 @@ module Main module Repos - class TripRepo < Adamantium::Repo[:trips] + class TripRepo < Adamantium::DB::Repo[:trips] def fetch!(id) trips .where(id: id) diff --git a/slices/main/repos/workout_repo.rb b/slices/main/repos/workout_repo.rb index 30cab78..900b59c 100644 --- a/slices/main/repos/workout_repo.rb +++ b/slices/main/repos/workout_repo.rb @@ -1,6 +1,6 @@ module Main module Repos - class WorkoutRepo < Adamantium::Repo[:workouts] + class WorkoutRepo < Adamantium::DB::Repo[:workouts] def list workouts.order(:published_at).to_a end diff --git a/slices/micropub/commands/posts/send_webmentions.rb b/slices/micropub/commands/posts/send_webmentions.rb index bc6b3ba..bcec5b0 100644 --- a/slices/micropub/commands/posts/send_webmentions.rb +++ b/slices/micropub/commands/posts/send_webmentions.rb @@ -8,7 +8,7 @@ module Micropub include Deps["settings", "post_utilities.link_finder"] def call(post_content:, post_url:, in_reply_to:) - Que.connection = Adamantium::Container["persistence.db"] + Que.connection = Adamantium::Container["db.gateway"].connection Adamantium::Jobs::SendWebMentions.enqueue(post_content: post_content, post_url: post_url, in_reply_to: in_reply_to) end diff --git a/slices/micropub/repos/auto_tagging_repo.rb b/slices/micropub/repos/auto_tagging_repo.rb index ea13d6b..294ce45 100644 --- a/slices/micropub/repos/auto_tagging_repo.rb +++ b/slices/micropub/repos/auto_tagging_repo.rb @@ -1,6 +1,6 @@ module Micropub module Repos - class AutoTaggingRepo < Adamantium::Repo[:auto_taggings] + class AutoTaggingRepo < Adamantium::DB::Repo[:auto_taggings] def find(id) auto_taggings .where(id: id) diff --git a/slices/micropub/repos/movie_repo.rb b/slices/micropub/repos/movie_repo.rb index 204d757..78df32f 100644 --- a/slices/micropub/repos/movie_repo.rb +++ b/slices/micropub/repos/movie_repo.rb @@ -1,6 +1,6 @@ module Micropub module Repos - class MovieRepo < Adamantium::Repo[:movies] + class MovieRepo < Adamantium::DB::Repo[:movies] commands :create end end diff --git a/slices/micropub/repos/podcast_repo.rb b/slices/micropub/repos/podcast_repo.rb index e9d7fba..e54c6c2 100644 --- a/slices/micropub/repos/podcast_repo.rb +++ b/slices/micropub/repos/podcast_repo.rb @@ -1,6 +1,6 @@ module Micropub module Repos - class PodcastRepo < Adamantium::Repo[:podcasts] + class PodcastRepo < Adamantium::DB::Repo[:podcasts] commands :create def listing diff --git a/slices/micropub/repos/post_repo.rb b/slices/micropub/repos/post_repo.rb index 7d820cd..ae19388 100644 --- a/slices/micropub/repos/post_repo.rb +++ b/slices/micropub/repos/post_repo.rb @@ -1,6 +1,6 @@ module Micropub module Repos - class PostRepo < Adamantium::Repo[:posts] + class PostRepo < Adamantium::DB::Repo[:posts] commands update: :by_pk def remove_tag(post_id:, tag:) diff --git a/slices/micropub/repos/webmentions_repo.rb b/slices/micropub/repos/webmentions_repo.rb index 1d78cb2..74c5f8e 100644 --- a/slices/micropub/repos/webmentions_repo.rb +++ b/slices/micropub/repos/webmentions_repo.rb @@ -1,6 +1,6 @@ module Micropub module Repos - class WebmentionsRepo < Adamantium::Repo[:webmentions] + class WebmentionsRepo < Adamantium::DB::Repo[:webmentions] commands :create end end diff --git a/slices/micropub/repos/workout_repo.rb b/slices/micropub/repos/workout_repo.rb index 734eefd..a332ad7 100644 --- a/slices/micropub/repos/workout_repo.rb +++ b/slices/micropub/repos/workout_repo.rb @@ -1,6 +1,6 @@ module Micropub module Repos - class WorkoutRepo < Adamantium::Repo[:workouts] + class WorkoutRepo < Adamantium::DB::Repo[:workouts] commands :create, update: :by_pk end end diff --git a/spec/requests/create_webmention_spec.rb b/spec/requests/create_webmention_spec.rb index 36a87fe..2899346 100644 --- a/spec/requests/create_webmention_spec.rb +++ b/spec/requests/create_webmention_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true RSpec.describe "Webmention creation", :db, :requests do - let(:post_repo) { Adamantium::Repos::PostRepo.new } + let(:post_repo) { Adamantium::DB::Repos::PostRepo.new } let(:post_record) { Test::Factory[:post] } context "reply" do diff --git a/spec/support/db.rb b/spec/support/db.rb index 234be96..7e6a7de 100644 --- a/spec/support/db.rb +++ b/spec/support/db.rb @@ -6,10 +6,6 @@ require_relative "db/database_cleaner" require_relative "db/factory" RSpec.configure do |config| - config.before :suite do - Hanami.app.start :persistence - end - config.include Test::DB::Helpers, :db config.include(Test::DB::FactoryHelper.new, factory: nil) diff --git a/spec/support/db/helpers.rb b/spec/support/db/helpers.rb index c2eb130..cf5944c 100644 --- a/spec/support/db/helpers.rb +++ b/spec/support/db/helpers.rb @@ -8,11 +8,11 @@ module Test end def rom - Hanami.app["persistence.rom"] + Hanami.app["db.rom"] end def db - Hanami.app["persistence.db"] + Hanami.app["db.gateway"].connection end end end