style: rubocop

This commit is contained in:
Neetpone 2024-04-04 04:21:23 -04:00 committed by Neetpone
parent 7349fba52f
commit 902e2d422b
66 changed files with 430 additions and 154 deletions

58
.rubocop.yml Normal file
View file

@ -0,0 +1,58 @@
inherit_from: .rubocop_todo.yml
AllCops:
SuggestExtensions: false
NewCops: enable
Exclude:
- db/migrate/*.rb
- db/schema.rb
- vendor/**/*
- public/**/*
- tmp/**/*
- spec/rails_helper.rb
- lib/tasks/auto_annotate_models.rake
Style/FetchEnvVar:
Enabled: false
# I just don't like it
Layout/EmptyLineAfterMagicComment:
Enabled: false
# These next two are stylistic choices I don't agree with
Style/MultilineIfModifier:
Enabled: false
Style/IfUnlessModifier:
Enabled: false
# It just feels wrong
Style/HashSyntax:
EnforcedShorthandSyntax: never
# This is too convenient not to
Style/GlobalVars:
AllowedVariables:
- $redis
Style/FrozenStringLiteralComment:
Enabled: true
# Don't like it
Style/EmptyMethod:
Enabled: false
Style/ClassVars:
Enabled: false
Style/ClassAndModuleChildren:
EnforcedStyle: compact
# This does the oppposite of what I want to do.
Layout/HashAlignment:
Enabled: false
Layout/CaseIndentation:
IndentOneStep: true
Style/NumericPredicate:
Enabled: false

124
.rubocop_todo.yml Normal file
View file

@ -0,0 +1,124 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-04-04 07:59:52 UTC using RuboCop version 1.62.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, no_empty_lines
Layout/EmptyLinesAroundBlockBody:
Exclude:
- 'db/schema.rb'
# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_braces
Layout/FirstHashElementIndentation:
EnforcedStyle: consistent
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
# SupportedStyles: space, no_space, compact
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceInsideHashLiteralBraces:
Exclude:
- 'app/controllers/search_controller.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: space, compact, no_space
Layout/SpaceInsideParens:
Exclude:
- 'app/controllers/search_controller.rb'
# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
Layout/SpaceInsidePercentLiteralDelimiters:
Exclude:
- 'Gemfile'
# Offense count: 6
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 48
# Offense count: 3
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 53
# Offense count: 3
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/CyclomaticComplexity:
Max: 16
# Offense count: 12
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 50
# Offense count: 2
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/PerceivedComplexity:
Max: 17
# Offense count: 2
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
Naming/MethodParameterName:
Exclude:
- 'app/helpers/search_helper.rb'
# Offense count: 22
# Configuration parameters: AllowedConstants.
Style/Documentation:
Enabled: false
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/GlobalStdStream:
Exclude:
- 'config/environments/production.rb'
# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: literals, strict
Style/MutableConstant:
Exclude:
- 'app/controllers/search_controller.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/PerlBackrefs:
Exclude:
- 'bin/bundle'
# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SafeForConstants.
Style/RedundantFetchBlock:
Exclude:
- 'config/puma.rb'
-
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: RequireEnglish.
# SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names
Style/SpecialGlobalVars:
EnforcedStyle: use_perl_names
# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 198

28
Gemfile
View file

@ -1,43 +1,45 @@
source "https://rubygems.org"
# frozen_string_literal: true
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby "3.2.2"
ruby '3.2.2'
gem "rails", "~> 7.0.8", ">= 7.0.8.1"
gem "sprockets-rails"
gem "pg", "~> 1.1"
gem "puma", "~> 5.0"
gem 'slim-rails'
gem 'kaminari'
gem 'pg', '~> 1.1'
gem 'puma', '~> 5.0'
gem 'rails', '~> 7.0.8', '>= 7.0.8.1'
gem 'redcarpet'
gem 'slim-rails'
gem 'sprockets-rails'
gem 'redis'
gem 'elasticsearch-model'
gem 'model-msearch'
gem 'fancy_searchable', github: 'Twibooru/fancy_searchable', ref: '40687c9'
gem 'model-msearch'
gem 'sidekiq'
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
gem 'tzinfo-data', platforms: %i[ mingw mswin x64_mingw jruby ]
# Use Sass to process CSS
# gem "sassc-rails"
group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri mingw x64_mingw ]
gem 'debug', platforms: %i[ mri mingw x64_mingw ]
end
group :development do
gem "web-console"
gem 'annotate'
gem 'bullet'
gem 'rubocop', require: false
gem 'web-console'
end
group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara"
gem "selenium-webdriver"
gem 'capybara'
gem 'selenium-webdriver'
end

View file

@ -80,6 +80,7 @@ GEM
annotate (3.2.0)
activerecord (>= 3.2, < 8.0)
rake (>= 10.4, < 14.0)
ast (2.4.2)
base64 (0.2.0)
bindex (0.8.1)
builder (3.2.4)
@ -128,6 +129,7 @@ GEM
irb (1.12.0)
rdoc
reline (>= 0.4.2)
json (2.7.2)
kaminari (1.2.2)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.2)
@ -140,6 +142,7 @@ GEM
activerecord
kaminari-core (= 1.2.2)
kaminari-core (1.2.2)
language_server-protocol (3.17.0.3)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
@ -170,6 +173,10 @@ GEM
nio4r (2.7.1)
nokogiri (1.16.3-x86_64-linux)
racc (~> 1.4)
parallel (1.24.0)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
pg (1.5.6)
psych (5.1.2)
stringio
@ -208,6 +215,7 @@ GEM
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.1.0)
rdoc (6.6.3.1)
psych (>= 4.0.0)
@ -220,6 +228,20 @@ GEM
reline (0.5.0)
io-console (~> 0.5)
rexml (3.2.6)
rubocop (1.62.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.2)
parser (>= 3.3.0.4)
ruby-progressbar (1.13.0)
rubyzip (2.3.2)
selenium-webdriver (4.19.0)
base64 (~> 0.2)
@ -252,6 +274,7 @@ GEM
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
uniform_notifier (1.16.0)
uri (0.13.0)
web-console (4.2.1)
@ -284,6 +307,7 @@ DEPENDENCIES
rails (~> 7.0.8, >= 7.0.8.1)
redcarpet
redis
rubocop
selenium-webdriver
sidekiq
slim-rails

View file

@ -1,6 +1,7 @@
# frozen_string_literal: true
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require_relative "config/application"
require_relative 'config/application'
Rails.application.load_tasks

View file

@ -1,4 +1,3 @@
module ApplicationCable
class Channel < ActionCable::Channel::Base
end
# frozen_string_literal: true
class ApplicationCable::Channel < ActionCable::Channel::Base
end

View file

@ -1,4 +1,3 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
end
# frozen_string_literal: true
class ApplicationCable::Connection < ActionCable::Connection::Base
end

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class ApplicationController < ActionController::Base
before_action :start_timer
before_action :setup_pagination_and_tags

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class AuthorsController < ApplicationController
def show
@author = Author.find(params[:id])

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'redcarpet'
class ChaptersController < ApplicationController
@ -17,7 +18,7 @@ class ChaptersController < ApplicationController
# This is fucking bad, this gets rid of the redundant title - this should be fixed upstairs,
# in the actual generation of the Markdown.
if body.length >= 2 && body[0] == @chapter.title && body[1].length > 0 && body[1][0] == '='
if body.length >= 2 && body[0] == @chapter.title && !body[1].empty? && body[1][0] == '='
body = body[2..]
end

View file

@ -1,8 +1,9 @@
# frozen_string_literal: true
require 'open-uri'
# Handles proxying images from the FiMFiction CDN and caching them locally, in case they disappear.
class ImagesController < ApplicationController
#noinspection RubyMismatchedArgumentType
# noinspection RubyMismatchedArgumentType
def show
url = params[:url]
parsed = URI.parse(url)
@ -15,16 +16,17 @@ class ImagesController < ApplicationController
ext = File.extname(url)
hash = Digest::SHA256.hexdigest(url)
path = Rails.root.join('public', 'cached-images', hash + ext)
our_url = '/cached-images/' + hash + ext
our_url = "/cached-images/#{hash}#{ext}"
if File.exist? path
redirect_to our_url
return
end
File.open(path, 'wb') do |fp|
fp.write(Net::HTTP.get(parsed))
end
File.binwrite(
path,
Net::HTTP.get(parsed)
)
redirect_to our_url
end

View file

@ -1,7 +1,8 @@
# frozen_string_literal: true
# This whole class is a giant mess but I coded it fast so give me a break.
class SearchController < ApplicationController
ALLOWED_SORT_DIRS = [:asc, :desc]
ALLOWED_SORT_FIELDS = [:title, :author, :date_published, :date_updated, :num_words, :rel]
ALLOWED_SORT_DIRS = %i[asc desc]
ALLOWED_SORT_FIELDS = %i[title author date_published date_updated num_words rel]
before_action :load_tags
@ -74,10 +75,10 @@ class SearchController < ApplicationController
# returns: [included tags, excluded tags]
def parse_tag_queries
tag_searches = (@search_params['tags'] + ',' + @search_params['characters']).split(',').reject &:blank?
tag_searches = "#{@search_params['tags']},#{@search_params['characters']}".split(',').reject(&:blank?)
[
tag_searches.select { |t| t[0] != '-' },
tag_searches.reject { |t| t[0] == '-' },
tag_searches.select { |t| t[0] == '-' }
.map { |t| t[1..] }
]
@ -89,14 +90,14 @@ class SearchController < ApplicationController
# we need to sort on the keyword versions of text fields, to avoid using fielddata.
sf = case sf
when :rel then
:_score
when :title then
:title_keyword
when :author then
:author_keyword
else
sf
when :rel
:_score
when :title
:title_keyword
when :author
:author_keyword
else
sf
end
{sf => sd}
@ -111,7 +112,7 @@ class SearchController < ApplicationController
if params[:scope].present?
result = $redis.get("search_scope/#{params[:scope]}")
if result.present?
@search_params = JSON.load(result)
@search_params = JSON.parse(result)
@scope_key = params[:scope]
scope_valid = true
else

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class StaticPagesController < ApplicationController
def about
end

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class StoriesController < ApplicationController
def index
end

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module ApplicationHelper
# https://infusion.media/content-marketing/how-to-calculate-reading-time/
def reading_time(words)

View file

@ -1,2 +1,3 @@
# frozen_string_literal: true
module AuthorsHelper
end

View file

@ -1,2 +1,3 @@
# frozen_string_literal: true
module ChaptersHelper
end

View file

@ -1,2 +1,3 @@
# frozen_string_literal: true
module ImagesHelper
end

View file

@ -1,36 +1,37 @@
# frozen_string_literal: true
module SearchHelper
def rating_display(rating)
case rating
when 'everyone' then
when 'everyone'
tag.div class: 'frating ev', title: 'Rated Everyone' do
'Everyone'
end
when 'teen' then
tag.div class: 'frating', title: 'Rated Teen' do
'Teen'
end
when 'explicit' then
tag.div class: 'frating', title: 'Rated Explicit' do
'Explicit'
end
when 'teen'
tag.div class: 'frating', title: 'Rated Teen' do
'Teen'
end
when 'explicit'
tag.div class: 'frating', title: 'Rated Explicit' do
'Explicit'
end
end
end
def status_display(status)
case status
when 'complete' then
when 'complete'
tag.div class: 'fstatus sc', title: 'Complete' do
'Complete'
end
when 'incomplete' then
when 'incomplete'
tag.div class: 'fstatus si', title: 'Incomplete' do
'Incomplete'
end
when 'hiatus' then
when 'hiatus'
tag.div class: 'fstatus sh', title: 'On Hiatus' do
'On Hiatus'
end
when 'cancelled' then
when 'cancelled'
tag.div class: 'fstatus sn', title: 'Cancelled' do
'Cancelled'
end

View file

@ -1,2 +1,3 @@
# frozen_string_literal: true
module StaticPagesHelper
end

View file

@ -1,2 +1,3 @@
# frozen_string_literal: true
module StoriesHelper
end

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
module StoryIndex
def self.included(base)
base.settings index: { number_of_shards: 5, max_result_window: 10_000_000 } do
@ -31,10 +32,10 @@ module StoryIndex
[date_published: :desc]
end
def allowed_search_fields(access_options = {})
[:title, :completion_status, :content_rating, :date_published, :date_updated, :date_modified,
:num_comments, :num_views, :num_words, :rating, :short_description, :description_html,
:title, :title_keyword, :tags, :author, :author_keyword]
def allowed_search_fields(_access_options = {})
%i[title completion_status content_rating date_published date_updated date_modified
num_comments num_views num_words rating short_description description_html
title title_keyword tags author author_keyword]
end
end
@ -64,4 +65,4 @@ module StoryIndex
def as_indexed_json(*)
as_json
end
end
end

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked

View file

@ -4,8 +4,8 @@ class IndexUpdateJob < ApplicationJob
queue_as :high
def perform(cls, id)
obj = cls.constantize.find(id)
obj.update_index(defer: false) if obj
rescue StandardError => ex
Rails.logger.error ex.message
obj&.update_index(defer: false)
rescue StandardError => e
Rails.logger.error e.message
end
end

View file

@ -1,10 +1,12 @@
# frozen_string_literal: true
class RecountWordsJob < ApplicationJob
def perform(*)
Story.find_each do |story|
word_count = 0
story.chapters.each do |chapter|
next unless chapter.body
count = chapter.body.split(' ').size
count = chapter.body.split.size
chapter.update_columns(
num_words: count
)
@ -16,4 +18,4 @@ class RecountWordsJob < ApplicationJob
)
end
end
end
end

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: authors

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: chapters

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: stories

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: story_taggings

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: tags

View file

@ -8,7 +8,7 @@
# this file is here to facilitate running it.
#
require "rubygems"
require 'rubygems'
m = Module.new do
module_function
@ -18,12 +18,13 @@ m = Module.new do
end
def env_var_version
ENV["BUNDLER_VERSION"]
ENV['BUNDLER_VERSION']
end
def cli_arg_version
return unless invoked_as_script? # don't want to hijack other binstubs
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
return unless 'update'.start_with?(ARGV.first || ' ') # must be running `bundle update`
bundler_version = nil
update_index = nil
ARGV.each_with_index do |a, i|
@ -31,6 +32,7 @@ m = Module.new do
bundler_version = a
end
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
bundler_version = $1
update_index = i
end
@ -38,25 +40,27 @@ m = Module.new do
end
def gemfile
gemfile = ENV["BUNDLE_GEMFILE"]
gemfile = ENV['BUNDLE_GEMFILE']
return gemfile if gemfile && !gemfile.empty?
File.expand_path("../Gemfile", __dir__)
File.expand_path('../Gemfile', __dir__)
end
def lockfile
lockfile =
case File.basename(gemfile)
when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
else "#{gemfile}.lock"
when 'gems.rb' then gemfile.sub(/\.rb$/, '.locked')
else "#{gemfile}.lock"
end
File.expand_path(lockfile)
end
def lockfile_version
return unless File.file?(lockfile)
lockfile_contents = File.read(lockfile)
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
Regexp.last_match(1)
end
@ -76,20 +80,22 @@ m = Module.new do
end
def load_bundler!
ENV["BUNDLE_GEMFILE"] ||= gemfile
ENV['BUNDLE_GEMFILE'] ||= gemfile
activate_bundler
end
def activate_bundler
gem_error = activation_error_handling do
gem "bundler", bundler_requirement
gem 'bundler', bundler_requirement
end
return if gem_error.nil?
require_error = activation_error_handling do
require "bundler/version"
require 'bundler/version'
end
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
exit 42
end
@ -105,5 +111,5 @@ end
m.load_bundler!
if m.invoked_as_script?
load Gem.bin_path("bundler", "bundle")
load Gem.bin_path('bundler', 'bundle')
end

View file

@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require_relative "../config/application"
require "importmap/commands"
require_relative '../config/application'
require 'importmap/commands'

View file

@ -1,4 +1,5 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"
# frozen_string_literal: true
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'

View file

@ -1,4 +1,5 @@
#!/usr/bin/env ruby
require_relative "../config/boot"
require "rake"
# frozen_string_literal: true
require_relative '../config/boot'
require 'rake'
Rake.application.run

View file

@ -1,8 +1,9 @@
#!/usr/bin/env ruby
require "fileutils"
# frozen_string_literal: true
require 'fileutils'
# path to your application root.
APP_ROOT = File.expand_path("..", __dir__)
APP_ROOT = File.expand_path('..', __dir__)
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
@ -13,9 +14,9 @@ FileUtils.chdir APP_ROOT do
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
# Add necessary setup steps to this file.
puts "== Installing dependencies =="
system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
@ -23,11 +24,11 @@ FileUtils.chdir APP_ROOT do
# end
puts "\n== Preparing database =="
system! "bin/rails db:prepare"
system! 'bin/rails db:prepare'
puts "\n== Removing old logs and tempfiles =="
system! "bin/rails log:clear tmp:clear"
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
system! "bin/rails restart"
system! 'bin/rails restart'
end

View file

@ -1,6 +1,7 @@
# frozen_string_literal: true
# This file is used by Rack-based servers to start the application.
require_relative "config/environment"
require_relative 'config/environment'
run Rails.application
Rails.application.load_server

View file

@ -1,34 +1,40 @@
require_relative "boot"
# frozen_string_literal: true
require_relative 'boot'
require "rails"
require 'rails'
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require 'active_model/railtie'
require 'active_job/railtie'
require 'active_record/railtie'
# require "active_storage/engine"
require "action_controller/railtie"
require 'action_controller/railtie'
# require "action_mailer/railtie"
# require "action_mailbox/engine"
# require "action_text/engine"
require "action_view/railtie"
require "action_cable/engine"
require "rails/test_unit/railtie"
require 'action_view/railtie'
require 'action_cable/engine'
require 'rails/test_unit/railtie'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Foalfetch
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
class Foalfetch::Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
end
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
end

View file

@ -1,3 +1,4 @@
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
# frozen_string_literal: true
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require "bundler/setup" # Set up gems listed in the Gemfile.
require 'bundler/setup' # Set up gems listed in the Gemfile.

View file

@ -1,5 +1,6 @@
# frozen_string_literal: true
# Load the Rails application.
require_relative "application"
require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!

View file

@ -1,4 +1,5 @@
require "active_support/core_ext/integer/time"
# frozen_string_literal: true
require 'active_support/core_ext/integer/time'
Rails.application.configure do
config.after_initialize do
@ -28,13 +29,13 @@ Rails.application.configure do
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join("tmp/caching-dev.txt").exist?
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true
config.cache_store = :memory_store
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{2.days.to_i}"
'Cache-Control' => "public, max-age=#{2.days.to_i}"
}
else
config.action_controller.perform_caching = false

View file

@ -1,4 +1,5 @@
require "active_support/core_ext/integer/time"
# frozen_string_literal: true
require 'active_support/core_ext/integer/time'
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
@ -22,7 +23,7 @@ Rails.application.configure do
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass
@ -50,7 +51,7 @@ Rails.application.configure do
config.log_level = :info
# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
config.log_tags = [:request_id]
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
@ -67,13 +68,13 @@ Rails.application.configure do
config.active_support.report_deprecations = false
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
config.log_formatter = Logger::Formatter.new
# Use a different logger for distributed setups.
# require "syslog/logger"
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
if ENV["RAILS_LOG_TO_STDOUT"].present?
if ENV['RAILS_LOG_TO_STDOUT'].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)

View file

@ -1,4 +1,5 @@
require "active_support/core_ext/integer/time"
# frozen_string_literal: true
require 'active_support/core_ext/integer/time'
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
@ -14,12 +15,12 @@ Rails.application.configure do
# Eager loading loads your whole application. When running a single test locally,
# this probably isn't necessary. It's a good idea to do in a continuous integration
# system, or in some way before deploying your code.
config.eager_load = ENV["CI"].present?
config.eager_load = ENV['CI'].present?
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
}
# Show full error reports and disable caching.

View file

@ -1,7 +1,8 @@
# frozen_string_literal: true
# Pin npm packages by running ./bin/importmap
pin "application"
pin "@hotwired/turbo-rails", to: "turbo.min.js"
pin "@hotwired/stimulus", to: "stimulus.min.js"
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js"
pin_all_from "app/javascript/controllers", under: "controllers"
pin 'application'
pin '@hotwired/turbo-rails', to: 'turbo.min.js'
pin '@hotwired/stimulus', to: 'stimulus.min.js'
pin '@hotwired/stimulus-loading', to: 'stimulus-loading.js'
pin_all_from 'app/javascript/controllers', under: 'controllers'

View file

@ -1,7 +1,8 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = "1.0"
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy.

View file

@ -1,8 +1,9 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Configure parameters to be filtered from the log file. Use this to limit dissemination of
# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
# notations and behaviors.
Rails.application.config.filter_parameters += [
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
Rails.application.config.filter_parameters += %i[
passw secret token _key crypt salt certificate otp ssn
]

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Define an application-wide HTTP permissions policy. For further
# information see https://developers.google.com/web/updates/2018/06/feature-policy
#

View file

@ -2,7 +2,7 @@
ENV['REDIS_HOST'] ||= 'localhost'
#require 'hiredis'
# require 'hiredis'
require 'redis'
$redis = Redis.new(host: ENV['REDIS_HOST'])

View file

@ -1,28 +1,29 @@
# frozen_string_literal: true
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
max_threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }
min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
threads min_threads_count, max_threads_count
# Specifies the `worker_timeout` threshold that Puma will use to wait before
# terminating a worker in development environments.
#
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development'
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }
port ENV.fetch('PORT') { 3000 }
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }
environment ENV.fetch('RAILS_ENV') { 'development' }
# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
pidfile ENV.fetch('PIDFILE') { 'tmp/pids/server.pid' }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
Rails.application.routes.draw do
root 'search#index'
post '/search' => 'search#search'

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#

View file

@ -1,4 +1,5 @@
require "test_helper"
# frozen_string_literal: true
require 'test_helper'
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :selenium, using: :chrome, screen_size: [1400, 1400]

View file

@ -1,4 +1,5 @@
require "test_helper"
# frozen_string_literal: true
require 'test_helper'
class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase
# test "connects with cookies" do

View file

@ -1,4 +1,5 @@
require "test_helper"
# frozen_string_literal: true
require 'test_helper'
class AuthorsControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do

View file

@ -1,4 +1,5 @@
require "test_helper"
# frozen_string_literal: true
require 'test_helper'
class ChaptersControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do

View file

@ -1,4 +1,5 @@
require "test_helper"
# frozen_string_literal: true
require 'test_helper'
class ImagesControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do

View file

@ -1,4 +1,5 @@
require "test_helper"
# frozen_string_literal: true
require 'test_helper'
class SearchControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do

View file

@ -1,4 +1,5 @@
require "test_helper"
# frozen_string_literal: true
require 'test_helper'
class StaticPagesControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do

View file

@ -1,4 +1,5 @@
require "test_helper"
# frozen_string_literal: true
require 'test_helper'
class StoriesControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: authors
@ -10,7 +11,7 @@
# num_blog_posts :integer default(0), not null
# num_followers :integer default(0), not null
#
require "test_helper"
require 'test_helper'
class AuthorTest < ActiveSupport::TestCase
# test "the truth" do

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: chapters
@ -16,7 +17,7 @@
#
# index_chapters_on_story_id (story_id)
#
require "test_helper"
require 'test_helper'
class ChapterTest < ActiveSupport::TestCase
# test "the truth" do

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: stories
@ -25,7 +26,7 @@
#
# index_stories_on_author_id (author_id)
#
require "test_helper"
require 'test_helper'
class StoryTest < ActiveSupport::TestCase
# test "the truth" do

View file

@ -1,3 +1,4 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: tags
@ -7,7 +8,7 @@
# type :text not null
# old_id :text
#
require "test_helper"
require 'test_helper'
class TagTest < ActiveSupport::TestCase
# test "the truth" do

View file

@ -1,6 +1,7 @@
ENV["RAILS_ENV"] ||= "test"
require_relative "../config/environment"
require "rails/test_help"
# frozen_string_literal: true
ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
require 'rails/test_help'
class ActiveSupport::TestCase
# Run tests in parallel with specified workers