Sha256: 3dad83cda7ffe4247d439e0a212f763ff4ffccecac60eafaa46782d86515a3ec

Contents?: true

Size: 989 Bytes

Versions: 8

Compression:

Stored size: 989 Bytes

Contents

require 'erb'

module Capistrano
  module UnicornNginx
    module Helpers

      def bundle_unicorn(*args)
        SSHKit::Command.new(:bundle, :exec, :unicorn, args).to_command
      end

      def template(template_name)
        config_file = "#{fetch(:templates_path)}/#{template_name}"
        # if no customized file, proceed with default
        unless File.exists?(config_file)
          config_file = File.join(File.dirname(__FILE__), "../../generators/capistrano/unicorn_nginx/templates/#{template_name}")
        end
        StringIO.new(ERB.new(File.read(config_file)).result(binding))
      end

      def file_exists?(path)
        test "[ -e #{path} ]"
      end

      def deploy_user
        capture :id, '-un'
      end

      def sudo_upload!(from, to)
        filename = File.basename(to)
        to_dir = File.dirname(to)
        tmp_file = "#{fetch(:tmp_dir)}/#{filename}"
        upload! from, tmp_file
        sudo :mv, tmp_file, to_dir
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
capistrano-unicorn-nginx-3.2.0 lib/capistrano/unicorn_nginx/helpers.rb
capistrano-unicorn-nginx-3.1.2 lib/capistrano/unicorn_nginx/helpers.rb
capistrano-unicorn-nginx-3.1.1 lib/capistrano/unicorn_nginx/helpers.rb
capistrano-unicorn-nginx-3.1.0 lib/capistrano/unicorn_nginx/helpers.rb
capistrano-unicorn-nginx-3.0.0 lib/capistrano/unicorn_nginx/helpers.rb
capistrano-unicorn-nginx-2.1.0 lib/capistrano/unicorn_nginx/helpers.rb
capistrano-unicorn-nginx-2.0.0 lib/capistrano/unicorn_nginx/helpers.rb
capistrano-unicorn-nginx-1.0.2 lib/capistrano/unicorn_nginx/helpers.rb