<commit_before><?php

/*
 * Travis plugin for HiDev
 *
 * @link      https://github.com/hiqdev/hidev-travis
 * @package   hidev-travis
 * @license   BSD-3-Clause
 * @copyright Copyright (c) 2015, HiQDev (https://hiqdev.com/)
 */

namespace hidev\travisci\goals;

/**
 * Goal for .travis.yml config file.
 */
class TravisYmlGoal extends \hidev\goals\TemplateGoal
{
    protected $_file = '.travis.yml';

    protected $_items = [
        'sudo'    => false,
        'install' => ['hidev travis/install'],
        'script'  => ['hidev travis/script'],
    ];

    /**
     * Reorders config elements
     */
    public function actionSave()
    {
        $items = $this->_items;
        $lang = $items['language'];
        $lops = $items[$lang];
        unset($items['language'], $items[$lang]);
        $this->_items = [
            'language' => $lang,
            $lang      => $lops,
        ] + $items;
        parent::actionSave();
    }

}<commit_msg>+ actual .travis.yml generation<commit_after><?php

/*
 * Travis plugin for HiDev
 *
 * @link      https://github.com/hiqdev/hidev-travis
 * @package   hidev-travis
 * @license   BSD-3-Clause
 * @copyright Copyright (c) 2015, HiQDev (https://hiqdev.com/)
 */

namespace hidev\travisci\goals;

/**
 * Goal for .travis.yml config file.
 * For the moment PHP projects only.
 */
class TravisYmlGoal extends \hidev\goals\TemplateGoal
{
    protected $_file = '.travis.yml';

    protected $_bin;

    public function getBin()
    {
        if ($this->_bin === null) {
            $this->_bin = $this->detectBin();
        }
        return $this->_bin;
    }

    public function detectBin()
    {
        if ($this->package->fullName == 'hiqdev/hidev') {
            return './bin';
        }
        if ($this->config->get('composer.json')->hasRequireAny('hiqdev/hidev')) {
            return './vendor/bin';
        }

        return '$HOME/.composer/vendor/bin';
    }

    public $globalRequires = ['fxp/composer-asset-plugin:~1.1' => 1];

    public function getGlobalRequiresString()
    {
        return '"' . implode('" "', array_keys($this->globalRequires)) . '"';
    }

    /**
     * Reorders config elements
     */
    public function actionSave()
    {
        $this->setItems([
            'sudo'    => false,
            'install' => [
                'travis_retry composer self-update',
                'travis_retry composer global require ' . $this->getGlobalRequiresString(),
                'travis_retry composer install --no-interaction',
                $this->getBin() . '/hidev travis/install',
            ],
            'script'  => [$this->getBin() . '/hidev travis/script'],
        ]);
        $items = $this->_items;
        $lang = $items['language'];
        $lops = $items[$lang];
        unset($items['language'], $items[$lang]);
        $this->_items = [
            'language' => $lang,
            $lang      => $lops,
        ] + $items;
        parent::actionSave();
    }

}
{'fraction_non_alphanumeric': 0.16638598854833278, 'fraction_numerical': 0.004378578646008757, 'mean_word_length': 2.0, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 32, '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': '5080753', 'n_tokens_mistral': 955, 'n_tokens_neox': 939, 'n_words': 182}