Sha256: b091b88dda9a3cd9e0c9aa97e8e24495c5d5c69f247fa12e2ad37352e9ac5537

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

require 'active_support'

module PersistantDirectory
  # Create persistant directories in /deploy/to/shared
  #
  # Create /deploy/to/shared/public/assets
  #
  #   PersistantDirectory.create('public/assets')
  #
  # Create multiple directories at once
  #
  #   PersistantDirectory.create('public/icons', 'public/files')
  def create(*args)
    options = args.extract_options!
    args.each do |directory|
      try_sudo "mkdir -p -m 775 #{shared_path}/#{directory}"
      try_sudo "chown #{fetch(:runner, "app")}:wheel #{shared_path}/#{directory}"
    end
  end
  
  # Symlink shared persistant directories to the current deployment directory
  #
  # Symlink /deploy/to/shared/public/assets to /deploy/to/current/public/assets
  #
  #   PersistantDirectory.symlink('public/assets')
  #
  # Symlink multiple directories at once
  #
  #   PersistantDirectory.symlink('public/icons', 'public/files')
  def symlink(*args)
    options = args.extract_options!
    directory = args.first
    
    run "ln -s #{shared_path}/#{directory} #{current_path}/#{directory}"
  end
end

Capistrano.plugin :persistant_directory, PersistantDirectory

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fingercap-0.3.2 lib/fingercap/persistant_directory.rb
fingercap-0.3.1 lib/fingercap/persistant_directory.rb
fingercap-0.1 lib/fingercap/persistant_directory.rb
fingercap-0.2 lib/fingercap/persistant_directory.rb
fingercap-0.2.1 lib/fingercap/persistant_directory.rb