5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-06-02 13:14:18 +00:00

chore: rubocop

This commit is contained in:
f 2024-05-02 15:57:49 -03:00
parent 7a03269aa3
commit 8fba98f9fd
No known key found for this signature in database
5 changed files with 23 additions and 30 deletions

View file

@ -55,9 +55,7 @@ class BacktraceJob < ApplicationJob
x['backtrace'] x['backtrace']
end.flatten.map do |x| end.flatten.map do |x|
x['file'].split('@').last x['file'].split('@').last
end.uniq.select do |x| end.uniq.grep(%r{\Ahttps://})
%r{\Ahttps://} =~ x
end
end end
# Descarga y devuelve los datos de un archivo # Descarga y devuelve los datos de un archivo

View file

@ -27,12 +27,11 @@ class DeployJob < ApplicationJob
if site.building? if site.building?
notify = false notify = false
if 10.minutes.ago >= time raise DeployAlreadyRunningException unless 10.minutes.ago >= time
raise DeployTimedOutException,
"#{site.name} la tarea estuvo más de 10 minutos esperando, volviendo al estado original" raise DeployTimedOutException,
else "#{site.name} la tarea estuvo más de 10 minutos esperando, volviendo al estado original"
raise DeployAlreadyRunningException
end
end end
@deployed = {} @deployed = {}
@ -50,9 +49,7 @@ class DeployJob < ApplicationJob
nil nil
end.compact end.compact
if d == site.deployment_list.last && !status raise DeployException, 'Falló la compilación' if d == site.deployment_list.last && !status
raise DeployException, 'Falló la compilación'
end
rescue StandardError => e rescue StandardError => e
status = false status = false
seconds ||= 0 seconds ||= 0
@ -73,7 +70,7 @@ class DeployJob < ApplicationJob
return unless output return unless output
puts (Terminal::Table.new do |t| puts(Terminal::Table.new do |t|
t << (%w[type] + @deployed.values.first.keys) t << (%w[type] + @deployed.values.first.keys)
t.add_separator t.add_separator
@deployed.each do |type, row| @deployed.each do |type, row|

View file

@ -292,11 +292,11 @@ class Site < ApplicationRecord
# layouts. Si pasamos un layout que no existe, obtenemos un # layouts. Si pasamos un layout que no existe, obtenemos un
# NoMethodError # NoMethodError
@layouts_struct ||= Struct.new(*layout_keys, keyword_init: true) @layouts_struct ||= Struct.new(*layout_keys, keyword_init: true)
@layouts ||= @layouts_struct.new(**data['layouts'].map do |name, metadata| @layouts ||= @layouts_struct.new(**data['layouts'].to_h do |name, metadata|
[name.to_sym, [name.to_sym,
Layout.new(site: self, name: name.to_sym, meta: metadata.delete('meta')&.with_indifferent_access, Layout.new(site: self, name: name.to_sym, meta: metadata.delete('meta')&.with_indifferent_access,
metadata: metadata.with_indifferent_access)] metadata: metadata.with_indifferent_access)]
end.to_h) end)
end end
# TODO: Si la estructura de datos no existe, vamos a producir una # TODO: Si la estructura de datos no existe, vamos a producir una
@ -389,7 +389,7 @@ class Site < ApplicationRecord
end end
def reload def reload
super.tap do |s| super.tap do |_s|
reload_jekyll! reload_jekyll!
end end
self self
@ -479,7 +479,7 @@ class Site < ApplicationRecord
def clone_skel! def clone_skel!
return if jekyll? return if jekyll?
Rugged::Repository.clone_at(ENV['SKEL_SUTTY'], path, checkout_branch: design.gem) Rugged::Repository.clone_at(ENV.fetch('SKEL_SUTTY', nil), path, checkout_branch: design.gem)
# Necesita un bloque # Necesita un bloque
repository.rugged.remotes.rename('origin', 'upstream') {} repository.rugged.remotes.rename('origin', 'upstream') {}
@ -579,11 +579,11 @@ class Site < ApplicationRecord
deploy_local = deploys.find_by_type('DeployLocal') deploy_local = deploys.find_by_type('DeployLocal')
deploy_local.git_lfs deploy_local.git_lfs
if !gems_installed? || gemfile_updated? || gemfile_lock_updated? return unless !gems_installed? || gemfile_updated? || gemfile_lock_updated?
deploy_local.bundle
touch deploy_local.bundle
FileUtils.touch(gemfile_path) touch
end FileUtils.touch(gemfile_path)
end end
def gem_path def gem_path

View file

@ -76,10 +76,10 @@ class Usuarie < ApplicationRecord
# Si le usuarie (re)confirma su cuenta con una invitación pendiente, # Si le usuarie (re)confirma su cuenta con una invitación pendiente,
# considerarla aceptada también. # considerarla aceptada también.
def accept_invitation_after_confirmation! def accept_invitation_after_confirmation!
if confirmed? return unless confirmed?
self.invitation_token = nil
self.invitation_accepted_at ||= Time.now.utc self.invitation_token = nil
end self.invitation_accepted_at ||= Time.now.utc
end end
# Muestra un error si el idioma no está disponible al cambiar el # Muestra un error si el idioma no está disponible al cambiar el
@ -87,7 +87,7 @@ class Usuarie < ApplicationRecord
# #
# @return [nil] # @return [nil]
def locale_available! def locale_available!
return if I18n.locale_available? self.lang return if I18n.locale_available? lang
errors.add(:lang, I18n.t('activerecord.errors.models.usuarie.attributes.lang.not_available')) errors.add(:lang, I18n.t('activerecord.errors.models.usuarie.attributes.lang.not_available'))
nil nil

View file

@ -222,9 +222,7 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
end end
end end
private def with_all_locales
def with_all_locales(&block)
site.locales.map do |locale| site.locales.map do |locale|
next unless I18n.available_locales.include? locale next unless I18n.available_locales.include? locale