Sha256: 0f1ae603fc0aa5a32707ef892d9f8353102cf5ccc110dd3d87c1d43dd2d43c79

Contents?: true

Size: 1004 Bytes

Versions: 1

Compression:

Stored size: 1004 Bytes

Contents

require 'erb'

module Capistrano
  module DelayedJob
    module Helpers

      def bundle_delayed_job(*args)
        SSHKit::Command.new(:bundle, :exec, "script/delayed_job", args).to_command
      end

      def dj_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/delayed_job/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

1 entries across 1 versions & 1 rubygems

Version Path
capistrano-delayed-job-1.0.0 lib/capistrano/delayed_job/helpers.rb