2019-10-01 19:41:33 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Vincula la versión del sitio con www a la versión sin
|
|
|
|
class DeployWww < Deploy
|
2021-08-02 00:53:00 +00:00
|
|
|
# La forma de hacer este deploy es generar un link simbólico entre el
|
|
|
|
# directorio canónico y el actual.
|
|
|
|
#
|
|
|
|
# XXX: Asume que el origen y el destino se encuentran en el mismo
|
|
|
|
# directorio (¿por qué no estarían?)
|
|
|
|
#
|
|
|
|
# @return [Boolean]
|
2019-10-01 19:41:33 +00:00
|
|
|
def deploy
|
2021-08-02 00:53:00 +00:00
|
|
|
return true if File.symlink? destination
|
2019-10-01 19:41:33 +00:00
|
|
|
|
2021-08-02 00:53:00 +00:00
|
|
|
File.symlink(site.deploy_local.hostname, destination).zero?
|
2019-10-01 19:41:33 +00:00
|
|
|
end
|
|
|
|
|
2021-08-02 00:53:00 +00:00
|
|
|
# @return [Integer]
|
2019-10-01 19:41:33 +00:00
|
|
|
def size
|
|
|
|
File.size destination
|
|
|
|
end
|
|
|
|
|
2021-08-02 00:53:00 +00:00
|
|
|
# El hostname por defecto incluye WWW
|
|
|
|
#
|
|
|
|
# @return [String]
|
|
|
|
def default_hostname
|
|
|
|
"www.#{site.deploy_local.hostname}"
|
2019-10-01 19:41:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2021-08-02 00:53:00 +00:00
|
|
|
# Elimina el link simbólico si se elimina este deploy.
|
2019-10-01 19:41:33 +00:00
|
|
|
def remove_destination!
|
2020-06-19 18:42:24 +00:00
|
|
|
FileUtils.rm_f destination
|
2019-10-01 19:41:33 +00:00
|
|
|
end
|
|
|
|
end
|