<commit_before><?php
namespace Kunstmaan\Skylab\Skeleton;

/**
 * ApacheSkeleton
 */
class AnacronSkeleton extends AbstractSkeleton
{

    const NAME = "anacron";

    /**
     * @return string
     */
    public function getName()
    {
        return self::NAME;
    }

    /**
     * @param \ArrayObject $project
     *
     * @return mixed
     */
    public function create(\ArrayObject $project)
    {
        $this->processProvider->executeSudoCommand("mkdir -p " . $this->fileSystemProvider->getProjectConfigDirectory($project["name"]) . "/fcron.d/");
        $this->processProvider->executeSudoCommand("touch " . $this->fileSystemProvider->getProjectConfigDirectory($project["name"]) . "/anacrontab");
    }

    /**
     * @return mixed
     */
    public function preMaintenance()
    {
    }

    /**
     * @return mixed
     */
    public function postMaintenance()
    {
    }

    /**
     * @param  \ArrayObject $project
     * @return mixed
     */
    public function maintenance(\ArrayObject $project)
    {
        $this->permissionsProvider->createGroupIfNeeded($project["name"]);
        $this->permissionsProvider->createUserIfNeeded($project["name"], $project["name"]);

        $cronjobscript = $this->fileSystemProvider->getProjectConfigDirectory($project["name"]) . "/anacronjobs";
        $crontab = $this->fileSystemProvider->getProjectConfigDirectory($project["name"]) . "/anacrontab";
        // cleanup
        $this->processProvider->executeSudoCommand("rm -f " . $cronjobscript);
        $this->processProvider->executeSudoCommand("rm -f " . $crontab);

        $this->processProvider->executeSudoCommand("crontab -r -u " . $project["name"], true);
        // generate anacronjobs file
        if (!$this->app["config"]["develmode"]) {
            $cronjobs = $this->fileSystemProvider->getDotDFiles($this->fileSystemProvider->getProjectConfigDirectory($project["name"]) . "/fcron.d/");
            foreach ($cronjobs as $cronjob) {
                $this->processProvider->executeSudoCommand("cat " . $cronjob->getRealPath() . " >> " . $cronjobscript);
                $this->processProvider->executeSudoCommand("echo -n '\n' >> " . $cronjobscript);
            }
            $projectAnacrontab = $this->fileSystemProvider->getProjectDirectory($project["name"]) . "/data/current/app/config/anacrontab";
            $this->processProvider->executeSudoCommand('echo "MAILTO=<EMAIL>" >> ' . $crontab);
            if (file_exists($projectAnacrontab)) {
                $this->processProvider->executeSudoCommand("cat " . $projectAnacrontab . " | sed -r 's/\/<path to>/".str_replace('/', '\/',$this->fileSystemProvider->getProjectDirectory($project["name"])) ."\/data\/current/g' >> " . $crontab);
                $this->processProvider->executeSudoCommand('echo >> ' . $crontab);
            }
            if (sizeof($cronjobs) > 0){
                $this->processProvider->executeSudoCommand("set -f;echo '0 3 * * * " . $cronjobscript . "' >> " . $crontab . ';set -f');
            }
            $this->processProvider->executeSudoCommand('echo >> ' . $crontab);
            // load the anacrontab file
            $this->processProvider->executeSudoCommand("crontab -u " . $project["name"] . " " . $crontab);
        }
    }

    /**
     * @param  \ArrayObject $project
     * @return mixed
     */
    public function preBackup(\ArrayObject $project)
    {
    }

    /**
     * @param  \ArrayObject $project
     * @return mixed
     */
    public function postBackup(\ArrayObject $project)<commit_msg>Fixed OS X sed option<commit_after><?php
namespace Kunstmaan\Skylab\Skeleton;

/**
 * ApacheSkeleton
 */
class AnacronSkeleton extends AbstractSkeleton
{

    const NAME = "anacron";

    /**
     * @return string
     */
    public function getName()
    {
        return self::NAME;
    }

    /**
     * @param \ArrayObject $project
     *
     * @return mixed
     */
    public function create(\ArrayObject $project)
    {
        $this->processProvider->executeSudoCommand("mkdir -p " . $this->fileSystemProvider->getProjectConfigDirectory($project["name"]) . "/fcron.d/");
        $this->processProvider->executeSudoCommand("touch " . $this->fileSystemProvider->getProjectConfigDirectory($project["name"]) . "/anacrontab");
    }

    /**
     * @return mixed
     */
    public function preMaintenance()
    {
    }

    /**
     * @return mixed
     */
    public function postMaintenance()
    {
    }

    /**
     * @param  \ArrayObject $project
     * @return mixed
     */
    public function maintenance(\ArrayObject $project)
    {
        $this->permissionsProvider->createGroupIfNeeded($project["name"]);
        $this->permissionsProvider->createUserIfNeeded($project["name"], $project["name"]);

        $cronjobscript = $this->fileSystemProvider->getProjectConfigDirectory($project["name"]) . "/anacronjobs";
        $crontab = $this->fileSystemProvider->getProjectConfigDirectory($project["name"]) . "/anacrontab";
        // cleanup
        $this->processProvider->executeSudoCommand("rm -f " . $cronjobscript);
        $this->processProvider->executeSudoCommand("rm -f " . $crontab);

        $this->processProvider->executeSudoCommand("crontab -r -u " . $project["name"], true);
        // generate anacronjobs file
        if (!$this->app["config"]["develmode"]) {
            $cronjobs = $this->fileSystemProvider->getDotDFiles($this->fileSystemProvider->getProjectConfigDirectory($project["name"]) . "/fcron.d/");
            foreach ($cronjobs as $cronjob) {
                $this->processProvider->executeSudoCommand("cat " . $cronjob->getRealPath() . " >> " . $cronjobscript);
                $this->processProvider->executeSudoCommand("echo -n '\n' >> " . $cronjobscript);
            }
            $projectAnacrontab = $this->fileSystemProvider->getProjectDirectory($project["name"]) . "/data/current/app/config/anacrontab";
            $this->processProvider->executeSudoCommand('echo "MAILTO=<EMAIL>" >> ' . $crontab);
            if (file_exists($projectAnacrontab)) {
                $os = strtolower(PHP_OS);
                switch ($os) {
                    case 'linux': //Linux
                        $sed = 'sed -r';
                        break;
                    case 'darwin': //OSX
                        $sed = 'sed -E';
                        break;
                    default:
                        throw new \Exception("Unsupported OS: " . $os);
                        break;
                }

                $this->processProvider->executeSudoCommand("cat " . $projectAnacrontab . " | " . $sed . " 's/\/<path to>/".str_replace('/', '\/',$this->fileSystemProvider->getProjectDirectory($project["name"])) ."\/data\/current/g' >> " . $crontab);
                $this->processProvider->executeSudoCommand('echo >> ' . $crontab);
            }
            if (sizeof($cronjobs) > 0){
                $this->processProvider->executeSudoCommand("set -f;echo '0 3 * * * " . $cronjobscript . "' >> " . $crontab . ';set -f');
            }
            $this->processProvider->executeSudoCommand('echo >> ' . $crontab);
            // load the anacrontab file
            $this->processProvider->executeSudoCommand("crontab -u " . $project["name"] . " " . $crontab);
        }
    }

    /**
     * @param  \ArrayObject $project
     * @return mixed
     */
    public function preBackup(\ArrayObject $project)
    {
    }

    /**
     * @param  \ArrayObject $project
     * @return mixed
     */
    public function postBackup(\ArrayObject $project)
{'fraction_non_alphanumeric': 0.16293252021742013, 'fraction_numerical': 0.0007954394803128729, 'mean_word_length': 2.3648528099910795, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 133, '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': '365270', 'n_tokens_mistral': 2243, 'n_tokens_neox': 2172, 'n_words': 329}