From 9d9d8ccf6dc0e91684e3c0afa5a8a42a043f9459 Mon Sep 17 00:00:00 2001 From: Daniel Nitsikopoulos Date: Thu, 8 Jun 2023 21:57:54 +1000 Subject: [PATCH] Run rubocop on all files --- Rakefile | 19 ++++++++-------- app/action.rb | 8 +++---- app/actions/trips/show.rb | 1 - app/actions/workouts/create.rb | 5 ++--- app/commands/auto_tagging/tag.rb | 10 ++++----- app/commands/workouts/create.rb | 1 - app/decorators/movies/decorator.rb | 1 - app/repos/movie_repo.rb | 2 +- app/repos/post_repo.rb | 11 +++++----- app/repos/workout_repo.rb | 2 +- app/views/movies/index.rb | 1 - config/environment.rb | 12 +++++----- lib/adamantium/client/mastodon.rb | 2 ++ lib/adamantium/client/omdb.rb | 2 +- lib/adamantium/jobs/remove_dead_bookmarks.rb | 2 +- lib/adamantium/middleware/basic_auth.rb | 2 +- slices/admin/actions/auto_tagging/create.rb | 23 ++++++++++---------- slices/admin/actions/auto_tagging/delete.rb | 3 +-- slices/admin/actions/auto_tagging/index.rb | 3 +-- slices/admin/actions/auto_tagging/new.rb | 3 +-- slices/admin/actions/bookmarks/archive.rb | 3 +-- slices/admin/actions/bookmarks/cache.rb | 9 ++++---- slices/admin/actions/bookmarks/clean.rb | 3 +-- slices/admin/actions/bookmarks/delete.rb | 3 +-- slices/admin/actions/bookmarks/index.rb | 3 +-- slices/admin/actions/index.rb | 5 ++--- slices/admin/actions/merge_tags/index.rb | 3 +-- slices/admin/actions/merge_tags/merge.rb | 5 ++--- slices/admin/actions/merge_tags/new.rb | 3 +-- slices/admin/actions/photos/index.rb | 3 +-- slices/admin/actions/posts/archive.rb | 3 +-- slices/admin/actions/posts/delete.rb | 3 +-- slices/admin/actions/posts/index.rb | 3 +-- slices/admin/actions/posts/publish.rb | 3 +-- slices/admin/actions/tags/delete.rb | 3 +-- slices/admin/actions/tags/index.rb | 3 +-- slices/admin/actions/trips/add_post.rb | 1 - slices/admin/actions/trips/create.rb | 1 - slices/admin/actions/trips/show.rb | 1 - slices/admin/actions/trips/update.rb | 1 - slices/admin/commands/auto_tagging/create.rb | 4 ++-- slices/admin/commands/auto_tagging/tag.rb | 10 ++++----- slices/admin/commands/bookmarks/cache.rb | 2 +- slices/admin/commands/movies/create.rb | 4 +--- slices/admin/repos/bookmark_repo.rb | 2 +- slices/admin/repos/movie_repo.rb | 2 +- slices/admin/repos/post_repo.rb | 13 +++++------ slices/admin/repos/post_tag_repo.rb | 1 - slices/admin/repos/tag_repo.rb | 1 + slices/admin/types.rb | 2 +- slices/admin/view.rb | 2 +- slices/admin/views/auto_tagging/index.rb | 3 +-- slices/admin/views/auto_tagging/new.rb | 3 +-- slices/admin/views/bookmarks/index.rb | 5 ++--- slices/admin/views/index.rb | 3 +-- slices/admin/views/merge_tags/index.rb | 3 +-- slices/admin/views/merge_tags/new.rb | 3 +-- slices/admin/views/photos/index.rb | 3 +-- slices/admin/views/posts/index.rb | 5 ++--- slices/admin/views/tags/index.rb | 7 +++--- slices/admin/views/trips/index.rb | 3 +-- slices/admin/views/trips/new.rb | 2 +- slices/admin/views/trips/show.rb | 3 +-- spec/adamantium/unit/geo/gpx_parser_spec.rb | 9 ++++---- version_assets.rb | 2 +- 65 files changed, 114 insertions(+), 158 deletions(-) diff --git a/Rakefile b/Rakefile index 9b83d5f..6aab91c 100644 --- a/Rakefile +++ b/Rakefile @@ -9,25 +9,24 @@ namespace :blog do Dotenv.load("/home/blog/current/.env.production") end - task :load_from_letterboxd => ["blog:load_environment"] do + task load_from_letterboxd: ["blog:load_environment"] do require "hanami/prepare" require "scraperd" client = Scraperd::Base.new - activities = client.fetch('dnitza') + activities = client.fetch("dnitza") create_command = Admin::Container["commands.movies.create"] activities.each do |activity| - title = CGI.unescapeHTML(activity.title) - create_command.({ - title: title, - year: activity.year, - url: activity.film_link, - watched_at: activity.watched_at - }) + create_command.call({ + title: title, + year: activity.year, + url: activity.film_link, + watched_at: activity.watched_at + }) end end -end \ No newline at end of file +end diff --git a/app/action.rb b/app/action.rb index 3461082..502a579 100644 --- a/app/action.rb +++ b/app/action.rb @@ -10,10 +10,10 @@ require "dry/matcher/result_matcher" module Adamantium class Action < Hanami::Action include Deps["logger", - "settings", - not_found_view: "views.not_found", - error_view: "views.error", - sentry: "sentry.client"] + "settings", + not_found_view: "views.not_found", + error_view: "views.error", + sentry: "sentry.client"] include Dry::Matcher.for(:handle, with: Dry::Matcher::ResultMatcher) include Dry::Monads[:result] diff --git a/app/actions/trips/show.rb b/app/actions/trips/show.rb index fc51a53..65b848b 100644 --- a/app/actions/trips/show.rb +++ b/app/actions/trips/show.rb @@ -4,7 +4,6 @@ module Adamantium module Actions module Trips class Show < Adamantium::Action - include Deps["views.trips.show"] def handle(req, res) diff --git a/app/actions/workouts/create.rb b/app/actions/workouts/create.rb index 6847919..289f998 100644 --- a/app/actions/workouts/create.rb +++ b/app/actions/workouts/create.rb @@ -5,9 +5,9 @@ module Adamantium include Deps["geo.gpx_parser", "commands.workouts.create"] def handle(req, res) - tempfile = Tempfile.new(%w/path .gpx/) + tempfile = Tempfile.new(%w[path .gpx]) - if req.params.to_h.dig(:file, :tempfile) != nil + if !req.params.to_h.dig(:file, :tempfile).nil? tempfile.write req.params[:file][:tempfile].read else tempfile.write req.params[:file] @@ -15,7 +15,6 @@ module Adamantium tempfile.rewind - gpxfile = gpx_parser.call(path: tempfile.path) if gpxfile.success? diff --git a/app/commands/auto_tagging/tag.rb b/app/commands/auto_tagging/tag.rb index 23fca6f..adab784 100644 --- a/app/commands/auto_tagging/tag.rb +++ b/app/commands/auto_tagging/tag.rb @@ -7,10 +7,10 @@ module Adamantium def call(auto_tag_id: nil) auto_taggings = if auto_tag_id - auto_tagging_repo.find(auto_tag_id) - else - auto_tagging_repo.all - end + auto_tagging_repo.find(auto_tag_id) + else + auto_tagging_repo.all + end auto_taggings.each do |auto_tagging| posts = auto_tagging.title_only? ? @@ -19,7 +19,7 @@ module Adamantium posts.each do |post| post_repo.auto_tag_post(post_id: post.id, - tag_id: auto_tagging.tag_id) + tag_id: auto_tagging.tag_id) end end diff --git a/app/commands/workouts/create.rb b/app/commands/workouts/create.rb index 1d7ac3e..d795d44 100644 --- a/app/commands/workouts/create.rb +++ b/app/commands/workouts/create.rb @@ -1,4 +1,3 @@ - require "securerandom" require "dry/monads" require "filemagic" diff --git a/app/decorators/movies/decorator.rb b/app/decorators/movies/decorator.rb index 662e5b1..96b8a3a 100644 --- a/app/decorators/movies/decorator.rb +++ b/app/decorators/movies/decorator.rb @@ -6,7 +6,6 @@ module Adamantium module Decorators module Movies class Decorator < SimpleDelegator - include Deps["clients.omdb"] def poster diff --git a/app/repos/movie_repo.rb b/app/repos/movie_repo.rb index 709e240..01c90a8 100644 --- a/app/repos/movie_repo.rb +++ b/app/repos/movie_repo.rb @@ -30,4 +30,4 @@ module Adamantium end end end -end \ No newline at end of file +end diff --git a/app/repos/post_repo.rb b/app/repos/post_repo.rb index 488b5d6..4eb79c3 100644 --- a/app/repos/post_repo.rb +++ b/app/repos/post_repo.rb @@ -48,13 +48,12 @@ module Adamantium end def auto_tag_post(post_id:, tag_id:) - return if posts - .post_tags - .where( - post_id: post_id, - tag_id: tag_id - ).count > 0 + .post_tags + .where( + post_id: post_id, + tag_id: tag_id + ).count > 0 posts .post_tags diff --git a/app/repos/workout_repo.rb b/app/repos/workout_repo.rb index 4d7346d..faeec70 100644 --- a/app/repos/workout_repo.rb +++ b/app/repos/workout_repo.rb @@ -8,4 +8,4 @@ module Adamantium end end end -end \ No newline at end of file +end diff --git a/app/views/movies/index.rb b/app/views/movies/index.rb index e3409bd..a870b33 100644 --- a/app/views/movies/index.rb +++ b/app/views/movies/index.rb @@ -2,7 +2,6 @@ module Adamantium module Views module Movies class Index < View - include Deps["repos.movie_repo"] expose :movies do diff --git a/config/environment.rb b/config/environment.rb index 7bcd9b1..cf44425 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -4,14 +4,14 @@ require "connection_pool" require "que" require "hanami/boot" -uri = URI.parse(ENV['DATABASE_URL']) +uri = URI.parse(ENV["DATABASE_URL"]) Que.connection = ConnectionPool.new(size: 10) do PG::Connection.open( - host: uri.host, - user: uri.user, + host: uri.host, + user: uri.user, password: uri.password, - port: uri.port || 5432, - dbname: uri.path[1..-1] + port: uri.port || 5432, + dbname: uri.path[1..] ) -end \ No newline at end of file +end diff --git a/lib/adamantium/client/mastodon.rb b/lib/adamantium/client/mastodon.rb index 7613c7e..92cc519 100644 --- a/lib/adamantium/client/mastodon.rb +++ b/lib/adamantium/client/mastodon.rb @@ -52,8 +52,10 @@ module Adamantium mastodon_token = settings.mastodon_token file = Tempfile.new(SecureRandom.uuid) + # rubocop:disable Security/Open file.write(URI.open(photo["value"]).read) file.rewind + # rubocop:enable Security/Open file_size = file.size.to_f / 2**20 formatted_file_size = "%.2f" % file_size diff --git a/lib/adamantium/client/omdb.rb b/lib/adamantium/client/omdb.rb index 3d398aa..970da32 100644 --- a/lib/adamantium/client/omdb.rb +++ b/lib/adamantium/client/omdb.rb @@ -12,4 +12,4 @@ module Adamantium end end end -end \ No newline at end of file +end diff --git a/lib/adamantium/jobs/remove_dead_bookmarks.rb b/lib/adamantium/jobs/remove_dead_bookmarks.rb index 0c775e2..5e54705 100644 --- a/lib/adamantium/jobs/remove_dead_bookmarks.rb +++ b/lib/adamantium/jobs/remove_dead_bookmarks.rb @@ -18,4 +18,4 @@ module Adamantium end end end -end \ No newline at end of file +end diff --git a/lib/adamantium/middleware/basic_auth.rb b/lib/adamantium/middleware/basic_auth.rb index 9cbc178..1338b21 100644 --- a/lib/adamantium/middleware/basic_auth.rb +++ b/lib/adamantium/middleware/basic_auth.rb @@ -3,7 +3,7 @@ module Adamantium class BasicAuth < Rack::Auth::Basic def call(env) request = Rack::Request.new(env) - if request.path.match(/^\/admin*/) + if /^\/admin*/.match?(request.path) # Execute basic authentication super(env) else diff --git a/slices/admin/actions/auto_tagging/create.rb b/slices/admin/actions/auto_tagging/create.rb index 6599524..28abee6 100644 --- a/slices/admin/actions/auto_tagging/create.rb +++ b/slices/admin/actions/auto_tagging/create.rb @@ -2,12 +2,11 @@ module Admin module Actions module AutoTagging class Create < Action - include Deps["commands.auto_tagging.create", - "views.auto_tagging.index", - "validation.contracts.auto_tagging_contract", - auto_tag: "commands.auto_tagging.tag", - new_view: "views.auto_tagging.new"] + "views.auto_tagging.index", + "validation.contracts.auto_tagging_contract", + auto_tag: "commands.auto_tagging.tag", + new_view: "views.auto_tagging.new"] def handle(req, res) title_contains = req.params[:title_contains] @@ -16,16 +15,16 @@ module Admin tag_now = req.params[:tag_now] validation = auto_tagging_contract.call(title_contains: title_contains, - body_contains: body_contains, - tag_id: tag_id) + body_contains: body_contains, + tag_id: tag_id) if validation.success? - result = create.(title_contains: title_contains, - body_contains: body_contains, - tag_id: tag_id) + result = create.call(title_contains: title_contains, + body_contains: body_contains, + tag_id: tag_id) if result.success? && tag_now - auto_tag.(auto_tag_id: result.value!) + auto_tag.call(auto_tag_id: result.value!) end res.render index @@ -36,4 +35,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/actions/auto_tagging/delete.rb b/slices/admin/actions/auto_tagging/delete.rb index ca3240a..3e9f4e3 100644 --- a/slices/admin/actions/auto_tagging/delete.rb +++ b/slices/admin/actions/auto_tagging/delete.rb @@ -2,7 +2,6 @@ module Admin module Actions module AutoTagging class Delete < Action - include Deps["repos.auto_tagging_repo"] def handle(req, res) @@ -11,4 +10,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/actions/auto_tagging/index.rb b/slices/admin/actions/auto_tagging/index.rb index d9efd8f..08adbfa 100644 --- a/slices/admin/actions/auto_tagging/index.rb +++ b/slices/admin/actions/auto_tagging/index.rb @@ -2,7 +2,6 @@ module Admin module Actions module AutoTagging class Index < Action - include Deps["views.auto_tagging.index"] def handle(req, res) @@ -11,4 +10,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/actions/auto_tagging/new.rb b/slices/admin/actions/auto_tagging/new.rb index dabf94d..d984548 100644 --- a/slices/admin/actions/auto_tagging/new.rb +++ b/slices/admin/actions/auto_tagging/new.rb @@ -2,7 +2,6 @@ module Admin module Actions module AutoTagging class New < Action - include Deps[new_view: "views.auto_tagging.new"] def handle(req, res) @@ -11,4 +10,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/actions/bookmarks/archive.rb b/slices/admin/actions/bookmarks/archive.rb index 1db2f51..6fc20ad 100644 --- a/slices/admin/actions/bookmarks/archive.rb +++ b/slices/admin/actions/bookmarks/archive.rb @@ -2,7 +2,6 @@ module Admin module Actions module Bookmarks class Archive < Action - include Deps["repos.bookmark_repo"] def handle(req, res) @@ -13,4 +12,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/actions/bookmarks/cache.rb b/slices/admin/actions/bookmarks/cache.rb index 7235779..aebc987 100644 --- a/slices/admin/actions/bookmarks/cache.rb +++ b/slices/admin/actions/bookmarks/cache.rb @@ -2,19 +2,18 @@ module Admin module Actions module Bookmarks class Cache < Action - include Deps["commands.bookmarks.cache"] def handle(req, res) bookmark_id = req.params[:id] - if cache.(bookmark_id: bookmark_id).success? - res.body = "Success" + res.body = if cache.call(bookmark_id: bookmark_id).success? + "Success" else - res.body = "Failed" + "Failed" end end end end end -end \ No newline at end of file +end diff --git a/slices/admin/actions/bookmarks/clean.rb b/slices/admin/actions/bookmarks/clean.rb index 2fd388c..f2abf36 100644 --- a/slices/admin/actions/bookmarks/clean.rb +++ b/slices/admin/actions/bookmarks/clean.rb @@ -4,7 +4,6 @@ module Admin module Actions module Bookmarks class Clean < Action - def handle(req, res) Que.connection = Adamantium::Container["persistence.db"] @@ -19,4 +18,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/actions/bookmarks/delete.rb b/slices/admin/actions/bookmarks/delete.rb index 1bdb93b..a30cf6a 100644 --- a/slices/admin/actions/bookmarks/delete.rb +++ b/slices/admin/actions/bookmarks/delete.rb @@ -2,7 +2,6 @@ module Admin module Actions module Bookmarks class Delete < Action - include Deps["repos.bookmark_repo", "repos.post_tag_repo"] def handle(req, res) @@ -14,4 +13,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/actions/bookmarks/index.rb b/slices/admin/actions/bookmarks/index.rb index c673080..c3205ad 100644 --- a/slices/admin/actions/bookmarks/index.rb +++ b/slices/admin/actions/bookmarks/index.rb @@ -2,7 +2,6 @@ module Admin module Actions module Bookmarks class Index < Action - include Deps["views.bookmarks.index"] def handle(req, res) @@ -11,4 +10,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/actions/index.rb b/slices/admin/actions/index.rb index deff24f..131ee99 100644 --- a/slices/admin/actions/index.rb +++ b/slices/admin/actions/index.rb @@ -1,12 +1,11 @@ module Admin module Actions class Index < Action - include Deps["views.index"] def handle(req, res) res.render index end + end end - end -end \ No newline at end of file +end diff --git a/slices/admin/actions/merge_tags/index.rb b/slices/admin/actions/merge_tags/index.rb index 7f0b014..26af061 100644 --- a/slices/admin/actions/merge_tags/index.rb +++ b/slices/admin/actions/merge_tags/index.rb @@ -2,7 +2,6 @@ module Admin module Actions module MergeTags class Index < Action - include Deps["views.merge_tags.index"] def handle(req, res) @@ -11,4 +10,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/actions/merge_tags/merge.rb b/slices/admin/actions/merge_tags/merge.rb index 3549724..3490e86 100644 --- a/slices/admin/actions/merge_tags/merge.rb +++ b/slices/admin/actions/merge_tags/merge.rb @@ -2,14 +2,13 @@ module Admin module Actions module MergeTags class Merge < Action - include Deps["commands.merge_tags.merge"] def handle(req, res) target_id = req.params[:target_id] source_id = req.params[:source_id] - result = merge.(target_id: target_id, source_id: source_id) + result = merge.call(target_id: target_id, source_id: source_id) if result.success? res.redirect_to "/admin/tags/merge" @@ -21,4 +20,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/actions/merge_tags/new.rb b/slices/admin/actions/merge_tags/new.rb index 5e0bcdc..af6dd0d 100644 --- a/slices/admin/actions/merge_tags/new.rb +++ b/slices/admin/actions/merge_tags/new.rb @@ -2,7 +2,6 @@ module Admin module Actions module MergeTags class New < Action - include Deps[new_view: "views.merge_tags.new"] def handle(req, res) @@ -11,4 +10,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/actions/photos/index.rb b/slices/admin/actions/photos/index.rb index 75cd3a6..363eb27 100644 --- a/slices/admin/actions/photos/index.rb +++ b/slices/admin/actions/photos/index.rb @@ -2,7 +2,6 @@ module Admin module Actions module Photos class Index < Action - include Deps["views.photos.index"] def handle(req, res) @@ -11,4 +10,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/actions/posts/archive.rb b/slices/admin/actions/posts/archive.rb index cb4fce0..907780e 100644 --- a/slices/admin/actions/posts/archive.rb +++ b/slices/admin/actions/posts/archive.rb @@ -2,7 +2,6 @@ module Admin module Actions module Posts class Archive < Action - include Deps["repos.post_repo"] def handle(req, res) @@ -13,4 +12,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/actions/posts/delete.rb b/slices/admin/actions/posts/delete.rb index a5b7c48..bbe84f6 100644 --- a/slices/admin/actions/posts/delete.rb +++ b/slices/admin/actions/posts/delete.rb @@ -2,7 +2,6 @@ module Admin module Actions module Posts class Delete < Action - include Deps["repos.post_repo", "repos.post_tag_repo"] def handle(req, res) @@ -14,4 +13,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/actions/posts/index.rb b/slices/admin/actions/posts/index.rb index 85fe279..5a4c8ff 100644 --- a/slices/admin/actions/posts/index.rb +++ b/slices/admin/actions/posts/index.rb @@ -2,7 +2,6 @@ module Admin module Actions module Posts class Index < Action - include Deps["views.posts.index"] def handle(req, res) @@ -11,4 +10,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/actions/posts/publish.rb b/slices/admin/actions/posts/publish.rb index 2e94563..79ba748 100644 --- a/slices/admin/actions/posts/publish.rb +++ b/slices/admin/actions/posts/publish.rb @@ -2,7 +2,6 @@ module Admin module Actions module Posts class Publish < Action - include Deps["repos.post_repo"] def handle(req, res) post_id = req.params[:id] @@ -12,4 +11,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/actions/tags/delete.rb b/slices/admin/actions/tags/delete.rb index 994f95c..50373a1 100644 --- a/slices/admin/actions/tags/delete.rb +++ b/slices/admin/actions/tags/delete.rb @@ -2,7 +2,6 @@ module Admin module Actions module Tags class Delete < Action - include Deps["repos.post_tag_repo", "repos.tag_repo"] def handle(req, res) @@ -14,4 +13,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/actions/tags/index.rb b/slices/admin/actions/tags/index.rb index f9f31a9..24a3609 100644 --- a/slices/admin/actions/tags/index.rb +++ b/slices/admin/actions/tags/index.rb @@ -2,7 +2,6 @@ module Admin module Actions module Tags class Index < Action - include Deps["views.tags.index"] def handle(req, res) @@ -11,4 +10,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/actions/trips/add_post.rb b/slices/admin/actions/trips/add_post.rb index 820e93e..921d2b1 100644 --- a/slices/admin/actions/trips/add_post.rb +++ b/slices/admin/actions/trips/add_post.rb @@ -4,7 +4,6 @@ module Admin module Actions module Trips class AddPost < Admin::Action - include Deps["commands.trips.add_post"] def handle(req, res) diff --git a/slices/admin/actions/trips/create.rb b/slices/admin/actions/trips/create.rb index 7115594..a9ec3a9 100644 --- a/slices/admin/actions/trips/create.rb +++ b/slices/admin/actions/trips/create.rb @@ -4,7 +4,6 @@ module Admin module Actions module Trips class Create < Admin::Action - include Deps["commands.trips.create"] def handle(req, res) diff --git a/slices/admin/actions/trips/show.rb b/slices/admin/actions/trips/show.rb index 4c1e6ee..716d800 100644 --- a/slices/admin/actions/trips/show.rb +++ b/slices/admin/actions/trips/show.rb @@ -4,7 +4,6 @@ module Admin module Actions module Trips class Show < Admin::Action - include Deps["views.trips.show"] def handle(req, res) diff --git a/slices/admin/actions/trips/update.rb b/slices/admin/actions/trips/update.rb index fc929fb..7639c25 100644 --- a/slices/admin/actions/trips/update.rb +++ b/slices/admin/actions/trips/update.rb @@ -4,7 +4,6 @@ module Admin module Actions module Trips class Update < Admin::Action - include Deps["commands.trips.update"] def handle(req, res) diff --git a/slices/admin/commands/auto_tagging/create.rb b/slices/admin/commands/auto_tagging/create.rb index eff337d..04d8a32 100644 --- a/slices/admin/commands/auto_tagging/create.rb +++ b/slices/admin/commands/auto_tagging/create.rb @@ -9,8 +9,8 @@ module Admin Failure() if !title_contains.empty? && !body_contains.empty? result = auto_tagging_repo.create(title_contains: title_contains, - body_contains: body_contains, - tag_id: tag_id) + body_contains: body_contains, + tag_id: tag_id) Success(result.id) end diff --git a/slices/admin/commands/auto_tagging/tag.rb b/slices/admin/commands/auto_tagging/tag.rb index f351e90..a44c289 100644 --- a/slices/admin/commands/auto_tagging/tag.rb +++ b/slices/admin/commands/auto_tagging/tag.rb @@ -7,10 +7,10 @@ module Admin def call(auto_tag_id: nil) auto_taggings = if auto_tag_id - auto_tagging_repo.find(auto_tag_id) - else - auto_tagging_repo.all - end + auto_tagging_repo.find(auto_tag_id) + else + auto_tagging_repo.all + end auto_taggings.each do |auto_tagging| posts = auto_tagging.title_only? ? @@ -19,7 +19,7 @@ module Admin posts.each do |post| post_repo.tag_post(post_id: post.id, - tag_id: auto_tagging.tag_id) + tag_id: auto_tagging.tag_id) end end diff --git a/slices/admin/commands/bookmarks/cache.rb b/slices/admin/commands/bookmarks/cache.rb index f517386..de07e0a 100644 --- a/slices/admin/commands/bookmarks/cache.rb +++ b/slices/admin/commands/bookmarks/cache.rb @@ -8,7 +8,7 @@ module Admin include Dry::Monads[:result] include Deps["repos.bookmark_repo"] - def call(bookmark_id: ) + def call(bookmark_id:) bookmark = bookmark_repo.fetch(id: bookmark_id) bookmark.url diff --git a/slices/admin/commands/movies/create.rb b/slices/admin/commands/movies/create.rb index d901826..55d51a6 100644 --- a/slices/admin/commands/movies/create.rb +++ b/slices/admin/commands/movies/create.rb @@ -4,7 +4,6 @@ module Admin module Commands module Movies class Create - include Deps["repos.movie_repo"] def call(movie) @@ -20,8 +19,7 @@ module Admin repo.create(movie) end - end end end end -end \ No newline at end of file +end diff --git a/slices/admin/repos/bookmark_repo.rb b/slices/admin/repos/bookmark_repo.rb index 8a9550b..099e80d 100644 --- a/slices/admin/repos/bookmark_repo.rb +++ b/slices/admin/repos/bookmark_repo.rb @@ -32,4 +32,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/repos/movie_repo.rb b/slices/admin/repos/movie_repo.rb index 599d287..16c7506 100644 --- a/slices/admin/repos/movie_repo.rb +++ b/slices/admin/repos/movie_repo.rb @@ -16,4 +16,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/repos/post_repo.rb b/slices/admin/repos/post_repo.rb index 2e22419..d168c7b 100644 --- a/slices/admin/repos/post_repo.rb +++ b/slices/admin/repos/post_repo.rb @@ -4,13 +4,12 @@ module Admin module Repos class PostRepo < Adamantium::Repo[:posts] def tag_post(post_id:, tag_id:) - return if posts - .post_tags - .where( - post_id: post_id, - tag_id: tag_id - ).count > 0 + .post_tags + .where( + post_id: post_id, + tag_id: tag_id + ).count > 0 posts .post_tags @@ -64,4 +63,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/repos/post_tag_repo.rb b/slices/admin/repos/post_tag_repo.rb index 0863910..5f13038 100644 --- a/slices/admin/repos/post_tag_repo.rb +++ b/slices/admin/repos/post_tag_repo.rb @@ -1,7 +1,6 @@ module Admin module Repos class PostTagRepo < Adamantium::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/tag_repo.rb b/slices/admin/repos/tag_repo.rb index 56b39a0..5c6a5c9 100644 --- a/slices/admin/repos/tag_repo.rb +++ b/slices/admin/repos/tag_repo.rb @@ -6,6 +6,7 @@ module Admin .order(Sequel.function(:lower, :label)) .to_a end + def list_with_posts tags .combine(:posts) diff --git a/slices/admin/types.rb b/slices/admin/types.rb index 6363428..c165e5c 100644 --- a/slices/admin/types.rb +++ b/slices/admin/types.rb @@ -10,4 +10,4 @@ module Admin attribute :label, Types::Coercible::String end end -end \ No newline at end of file +end diff --git a/slices/admin/view.rb b/slices/admin/view.rb index 7bba4e5..0b000ac 100644 --- a/slices/admin/view.rb +++ b/slices/admin/view.rb @@ -3,4 +3,4 @@ module Admin config.layouts_dir = "layouts" config.paths = "slices/admin/templates" end -end \ No newline at end of file +end diff --git a/slices/admin/views/auto_tagging/index.rb b/slices/admin/views/auto_tagging/index.rb index 6c374a3..4300d5a 100644 --- a/slices/admin/views/auto_tagging/index.rb +++ b/slices/admin/views/auto_tagging/index.rb @@ -2,7 +2,6 @@ module Admin module Views module AutoTagging class Index < Admin::View - include Deps["repos.auto_tagging_repo"] expose :auto_taggings do @@ -11,4 +10,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/views/auto_tagging/new.rb b/slices/admin/views/auto_tagging/new.rb index 757579d..b6b4cc5 100644 --- a/slices/admin/views/auto_tagging/new.rb +++ b/slices/admin/views/auto_tagging/new.rb @@ -2,7 +2,6 @@ module Admin module Views module AutoTagging class New < Admin::View - include Deps["repos.tag_repo"] expose :tags do @@ -15,4 +14,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/views/bookmarks/index.rb b/slices/admin/views/bookmarks/index.rb index fe10012..d85351b 100644 --- a/slices/admin/views/bookmarks/index.rb +++ b/slices/admin/views/bookmarks/index.rb @@ -4,7 +4,6 @@ module Admin module Views module Bookmarks class Index < Admin::View - include Deps["repos.bookmark_repo"] expose :published_bookmarks do |bookmarks| @@ -16,7 +15,7 @@ module Admin end expose :bookmarks do - bookmark_repo.list.partition{|p| p.published_at } + bookmark_repo.list.partition { |p| p.published_at } end expose :running_jobs do @@ -26,4 +25,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/views/index.rb b/slices/admin/views/index.rb index e0a49ac..188ddf5 100644 --- a/slices/admin/views/index.rb +++ b/slices/admin/views/index.rb @@ -1,7 +1,6 @@ module Admin module Views class Index < Admin::View - end end -end \ No newline at end of file +end diff --git a/slices/admin/views/merge_tags/index.rb b/slices/admin/views/merge_tags/index.rb index 0537824..706c2a0 100644 --- a/slices/admin/views/merge_tags/index.rb +++ b/slices/admin/views/merge_tags/index.rb @@ -2,7 +2,6 @@ module Admin module Views module MergeTags class Index < Admin::View - include Deps["repos.tag_repo"] expose :tags do @@ -11,4 +10,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/views/merge_tags/new.rb b/slices/admin/views/merge_tags/new.rb index b09c03b..3ea40ac 100644 --- a/slices/admin/views/merge_tags/new.rb +++ b/slices/admin/views/merge_tags/new.rb @@ -2,7 +2,6 @@ module Admin module Views module MergeTags class New < Admin::View - include Deps["repos.tag_repo"] expose :tag do |id:| @@ -15,4 +14,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/views/photos/index.rb b/slices/admin/views/photos/index.rb index c12eb5e..813d405 100644 --- a/slices/admin/views/photos/index.rb +++ b/slices/admin/views/photos/index.rb @@ -2,7 +2,6 @@ module Admin module Views module Photos class Index < Admin::View - MEDIA_DIR = "public/media/".freeze expose :photos_buckets do @@ -13,4 +12,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/views/posts/index.rb b/slices/admin/views/posts/index.rb index 7365040..3aa8e2f 100644 --- a/slices/admin/views/posts/index.rb +++ b/slices/admin/views/posts/index.rb @@ -2,7 +2,6 @@ module Admin module Views module Posts class Index < Admin::View - include Deps["repos.post_repo"] expose :published_posts do |posts| @@ -14,9 +13,9 @@ module Admin end expose :posts do - post_repo.list.partition{|p| p.published_at } + post_repo.list.partition { |p| p.published_at } end end end end -end \ No newline at end of file +end diff --git a/slices/admin/views/tags/index.rb b/slices/admin/views/tags/index.rb index 5c5f473..5760115 100644 --- a/slices/admin/views/tags/index.rb +++ b/slices/admin/views/tags/index.rb @@ -2,7 +2,6 @@ module Admin module Views module Tags class Index < Admin::View - include Deps["repos.tag_repo"] expose :tags do @@ -10,13 +9,13 @@ module Admin end expose :unused_tags do |tags| - tags.partition {|t| t.posts.count == 0}.first + tags.partition { |t| t.posts.count == 0 }.first end expose :used_tags do |tags| - tags.partition {|t| t.posts.count == 0}.last + tags.partition { |t| t.posts.count == 0 }.last end end end end -end \ No newline at end of file +end diff --git a/slices/admin/views/trips/index.rb b/slices/admin/views/trips/index.rb index ccc0e8e..03a4867 100644 --- a/slices/admin/views/trips/index.rb +++ b/slices/admin/views/trips/index.rb @@ -2,7 +2,6 @@ module Admin module Views module Trips class Index < Admin::View - include Deps["repos.trip_repo"] expose :trips do @@ -11,4 +10,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/views/trips/new.rb b/slices/admin/views/trips/new.rb index 94aa8bc..3dedffa 100644 --- a/slices/admin/views/trips/new.rb +++ b/slices/admin/views/trips/new.rb @@ -8,4 +8,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/slices/admin/views/trips/show.rb b/slices/admin/views/trips/show.rb index 55ccf65..6ab2453 100644 --- a/slices/admin/views/trips/show.rb +++ b/slices/admin/views/trips/show.rb @@ -2,7 +2,6 @@ module Admin module Views module Trips class Show < Admin::View - include Deps["repos.trip_repo", "repos.post_repo"] expose :trip do |id:| @@ -15,4 +14,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/spec/adamantium/unit/geo/gpx_parser_spec.rb b/spec/adamantium/unit/geo/gpx_parser_spec.rb index 21854a1..524df68 100644 --- a/spec/adamantium/unit/geo/gpx_parser_spec.rb +++ b/spec/adamantium/unit/geo/gpx_parser_spec.rb @@ -1,15 +1,14 @@ # frozen_string_literal: true + require "spec_helper" RSpec.describe Adamantium::Geo::GpxParser do - subject { described_class.new } - let(:gpx_file) { File.join(SPEC_ROOT, "support", "fixtures", "geo.gpx") } - let(:expected_svg) { File.read(File.join(SPEC_ROOT, "support", "fixtures", "geo.svg")) } + let(:gpx_file) { File.join(SPEC_ROOT, "support", "fixtures", "geo.gpx") } + let(:expected_svg) { File.read(File.join(SPEC_ROOT, "support", "fixtures", "geo.svg")) } it "parses a gpx file" do - # puts gpx_file.inspect result = subject.call(path: gpx_file).value! parsed_svg = Nokogiri::XML::Document.parse(result[:svg]) @@ -18,4 +17,4 @@ RSpec.describe Adamantium::Geo::GpxParser do expect(result[:distance]).to eq 3.0724966849262554 expect(result[:duration]).to eq 15237.0 end -end \ No newline at end of file +end diff --git a/version_assets.rb b/version_assets.rb index d711665..49474b7 100644 --- a/version_assets.rb +++ b/version_assets.rb @@ -24,4 +24,4 @@ Dir.glob(dist_path + "/*.{js,css}").each_with_object(filenames) do |f, memo| File.rename(f, dist_path + "/" + filename + "-" + hash + File.extname(f)) end -File.open(folder_path + "/asset-manifest.json", "wb") {|f| f.write(JSON.generate(filenames)) } +File.binwrite(folder_path + "/asset-manifest.json", JSON.generate(filenames))