Sha256: e1e9e413ece25fc358171700ecce8f788f5739ead41fbfb4a05297df787e1dd0
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true namespace :load do task :defaults do set :redirect_OK, false set :HTACCESS, <<~HTACCESS <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_URI} !/current/ RewriteRule ^(.*)$ current/$1 [L] </IfModule> HTACCESS end end namespace :deploy do namespace :simple_htaccess do task :create_htaccess do on roles :web do unless fetch(:redirect_OK) upload! StringIO.new(fetch(:HTACCESS)), "#{deploy_to}/.htaccess" end end end task :ensure_htaccess do on roles :web do path = "#{deploy_to}/.htaccess" if test("[ -f #{path} ]") existing_text = capture :cat, path set :redirect_OK, (existing_text.strip == fetch(:HTACCESS).strip) else execute :touch, path end end end desc 'Ensures basic .htaccess redirects are properly setup for Capistrano deployment' task ensure: %i[ensure_htaccess create_htaccess] end end after 'deploy:updated', 'deploy:simple_htaccess:ensure'
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
capistrano-simple-htaccess-0.1.1 | lib/capistrano/tasks/simple_htaccess.rake |