<commit_before><?php

/*
 * HiDev - integrate your development
 *
 * @link      https://hidev.me/
 * @package   hidev
 * @license   BSD-3-Clause
 * @copyright Copyright (c) 2014-2015, HiQDev (https://hiqdev.com/)
 */

namespace hidev\goals;

use hidev\helpers\Helper;
use Yii;

/**
 * Default Goal.
 */
class DefaultGoal extends BaseGoal
{
    public $goalName;

    public $done = false;

    protected $_fileType = null;

    public $vcsignore;

    public function init()
    {
        if ($this->vcsignore) {
            $this->vcs->setIgnore($this->vcsignore, 'first');
        }
    }

    public function getFileType()
    {
        return $this->_fileType;
    }

    public function setFileType($type)
    {
        $this->_fileType = $type;
    }

    public function setDeps($deps)
    {
        $res = $this->getDeps();
        foreach (Helper::ksplit($deps) as $d => $e) {
            $res[is_int($d) ? $e : $d] = $e;
        }
        $this->setItem('deps', $res);
    }

    public function getDeps()
    {
        return Helper::ksplit($this->rawItem('deps'));
    }

    public function actionDeps()
    {
        foreach ($this->getDeps() as $name => $enabled) {
            if ($enabled) {
                $this->module->runRequest($name);
            }
        }
    }

    public function actionPerform()
    {
        if ($this->done) {
            Yii::trace("Already done: $this->goalName");

            return;
        }
        Yii::trace("Started: $this->goalName");
        $this->actionDeps();
        $this->actionMake();
        $this->done = true;
    }

    public function actionLoad()
    {
        Yii::trace("Loading nothing for '$this->goalName'");
    }

    public function actionSave()
    {
        Yii::trace("Saving nothing for '$this->goalName'");
    }

    public function actionMake()
    {
        $this->actionLoad();
        $this->actionSave();
    }

    public function getRobo()
    {
        return Yii::$app->get('robo');
    }

    public function getConfig()
    {
        return Yii::$app->get('config');
    }

    public function getPackage()
    {
        return $this->getConfig()->getItem('package');
    }

    public function getVendor()
    {
        return $this->getConfig()->getItem('vendor');
    }

    public function getVcs()
    {
        return $this->getConfig()->getItem('git');
    }
}<commit_msg>* determining done: + is/markDone<commit_after><?php

/*
 * HiDev - integrate your development
 *
 * @link      https://hidev.me/
 * @package   hidev
 * @license   BSD-3-Clause
 * @copyright Copyright (c) 2014-2015, HiQDev (https://hiqdev.com/)
 */

namespace hidev\goals;

use hidev\helpers\Helper;
use Yii;

/**
 * Default Goal.
 */
class DefaultGoal extends BaseGoal
{
    public $goalName;

    public $done = [];

    protected $_fileType = null;

    public $vcsignore;

    public function init()
    {
        if ($this->vcsignore) {
            $this->vcs->setIgnore($this->vcsignore, 'first');
        }
    }

    public function getFileType()
    {
        return $this->_fileType;
    }

    public function setFileType($type)
    {
        $this->_fileType = $type;
    }

    public function setDeps($deps)
    {
        $res = $this->getDeps();
        foreach (Helper::ksplit($deps) as $d => $e) {
            $res[is_int($d) ? $e : $d] = $e;
        }
        $this->setItem('deps', $res);
    }

    public function getDeps()
    {
        return Helper::ksplit($this->rawItem('deps'));
    }

    public function actionDeps()
    {
        foreach ($this->getDeps() as $name => $enabled) {
            if ($enabled) {
                $this->module->runRequest($name);
            }
        }
    }

    public function isDone($action, $timestamp = null)
    {
        if ($this->done[$action]) {
            Yii::trace("Already done: $this->goalName/$action");
            return true;
        }
        return false;
    }

    public function markDone($action)
    {
        $this->done[$action] = microtime(1);
    }

    public function actionPerform()
    {
        if ($this->isDone('perform')) {
            return;
        }
        Yii::trace("Started: $this->goalName");
        $this->actionDeps();
        $this->actionMake();
        $this->markDone('perform');
    }

    public function actionLoad()
    {
        Yii::trace("Loading nothing for '$this->goalName'");
    }

    public function actionSave()
    {
        Yii::trace("Saving nothing for '$this->goalName'");
    }

    public function actionMake()
    {
        $this->actionLoad();
        $this->actionSave();
    }

    public function getRobo()
    {
        return Yii::$app->get('robo');
    }

    public function getConfig()
    {
        return Yii::$app->get('config');
    }

    public function getPackage()
    {
        return $this->getConfig()->getItem('package');
    }

    public function getVendor()
    {
        return $this->getConfig()->getItem('vendor');
    }

    public function getVcs()
    {
        /// TODO determine VCS
        return $this->getConfig()->getItem('git');
    }
}
{'fraction_non_alphanumeric': 0.15897032815877382, 'fraction_numerical': 0.003733542935743761, 'mean_word_length': 1.9923574368018813, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 69, 'https://': 4, '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': '5417360', 'n_tokens_mistral': 1640, 'n_tokens_neox': 1583, 'n_words': 314}