<commit_before><?php

/*
 * This file is part of the Plum package.
 *
 * (c) 2010-2011 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Plum\Deployer;

use Plum\Server\ServerInterface;

class RsyncDeployer implements DeployerInterface
{
    /**
     * {@inheritDoc}
     */
    public function deploy(ServerInterface $server, array $options = array())
    {
        $dryRun = isset($options['dry_run']) ? '--dry-run' : '';

        // Exclude file
        $excludeFile = null;
        if (isset($options['rsync_exclude'])) {
            $excludeFile = realpath($options['rsync_exclude']);
            if (false === file_exists($excludeFile)) {
                throw new \InvalidArgumentException('The exclude file does not exist.');
            }
        }

        if (null !== $excludeFile) {
            $exclude = sprintf('--exclude-from \'%s\'', $excludeFile);
        } else {
            $exclude = '';
        }

        $ssh = '';
        if (22 !== $server->getPort()) {
            $ssh = sprintf('-e "ssh -p%d"', $server->getPort());
        }

        $login = sprintf('%s@%s:%s', $server->getUser(), $server->getHost(), $server->getDir());

        $command = sprintf('rsync %s %s %s ./ %s  %s',
                $dryRun,
                isset($options['options']) ? $options['options'] : '',
                $ssh,
                $login,
                $exclude
        );

        exec($command);
    }

    /**
     * {@inheritDoc}
     */
    public function getName()
    {
        return 'rsync';
    }
}<commit_msg>improved exception message<commit_after><?php

/*
 * This file is part of the Plum package.
 *
 * (c) 2010-2011 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Plum\Deployer;

use Plum\Server\ServerInterface;

class RsyncDeployer implements DeployerInterface
{
    /**
     * {@inheritDoc}
     */
    public function deploy(ServerInterface $server, array $options = array())
    {
        $dryRun = isset($options['dry_run']) ? '--dry-run' : '';

        // Exclude file
        $excludeFile = null;
        if (isset($options['rsync_exclude'])) {
            $excludeFile = $options['rsync_exclude'];
            if (false === file_exists($excludeFile)) {
                throw new \InvalidArgumentException(sprintf('The exclude file "%s" does not exist.', $excludeFile));
            }

            $excludeFile = realpath($excludeFile);
        }

        if (null !== $excludeFile) {
            $exclude = sprintf('--exclude-from \'%s\'', $excludeFile);
        } else {
            $exclude = '';
        }

        $ssh = '';
        if (22 !== $server->getPort()) {
            $ssh = sprintf('-e "ssh -p%d"', $server->getPort());
        }

        $login = sprintf('%s@%s:%s', $server->getUser(), $server->getHost(), $server->getDir());

        $command = sprintf('rsync %s %s %s ./ %s  %s',
                $dryRun,
                isset($options['options']) ? $options['options'] : '',
                $ssh,
                $login,
                $exclude
        );

        exec($command);
    }

    /**
     * {@inheritDoc}
     */
    public function getName()
    {
        return 'rsync';
    }
}
{'fraction_non_alphanumeric': 0.16356107660455488, 'fraction_numerical': 0.005915409642117717, 'mean_word_length': 1.9332176929748481, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4920669', 'n_tokens_mistral': 1050, 'n_tokens_neox': 973, 'n_words': 232}