<commit_before><?php

/**
 * Fuel
 *
 * Fuel is a fast, lightweight, community driven PHP5 framework.
 *
 * @package    Fuel
 * @version    1.0
 * @author     Fuel Development Team
 * @license    MIT License
 * @copyright  2010 - 2011 Fuel Development Team
 * @link       http://fuelphp.com
 */

namespace Fuel\Tasks;

/**
 * Setup commandline:
 *      php oil refine hybrid
 *
 * @package  hybrid
 */
class Hybrid {

    /**
     * Send command with runtime option:
     *      php oil refine hybrid --install
     *      php oil refine hybrid --help
     *      php oil refine hybrid --test
     *
     * @static
     * @access  public
     * @return  void
     */
    public static function run()
    {
        $install    = \Cli::option('i') or \Cli::option('install');
        $help       = \Cli::option('h') or \Cli::option('help');
        $test       = \Cli::option('t') or \Cli::option('test');

        switch (true)
        {
            case $install :
                static::install();
            break;

            case $help :
                static::help();
            break;

            case $test :
                static::test();
            break;
        }
    }

    /**
     * Test Hybrid package installation, make sure app/config/app.php is using the right configuration
     *
     * @static
     * @access  public
     * @return  void
     */
    public static function test()
    {
        \Config::load('app', 'app');
        
        $has_error = false;

        if (false === \Config::get('app.auth', false) or false === \Config::get('app._route_', false))
        {
            \Cli::write('Please update your APPPATH/config/app.php, you\'re running on an outdated configuration', 'red');
            $has_error = true;
        }

        if (true === \class_exists('\\Model_Users_Metum') and false === \Config::get('app.auth.use_meta', false))
        {
            \Cli::write('Please set app.auth.use_meta to TRUE in APPPATH/config/app.php', 'red');
            $has_error = true;
        }

        if (true === \class_exists('\\Model_Users_Auth') and false === \Config::get('app.auth.use_auth', false))
        {
            \Cli::write('Please set app.auth.use_auth to TRUE in APPPATH/config/app.php', 'red');
            $has_error = true;
        }

        if (true === \Config::get('app.auth.use_facebook', false))
        {
            if ('' === \Config::get('app.api.facebook.app_id', null))
            {
                \Cli::write('Please provide app.api.facebook.app_id in APPPATH/config/app.php', 'red');
                $has_error = true;
            }

            if ('' === \Config::get('app.api.facebook.secret', null))
            {
                \Cli::write('Please provide app.api.facebook.secret in APPPATH/config/app.php', 'red');
                $has_error = true;
            }
        }

        if (true === \Config::get('app.auth.use_twitter', false))
        {
            if ('' === \Config::get('app.api.twitter.consumer_key', ''))
            {
                \Cli::write('Please provide app.api.twitter.consumer_key in APPPATH/config/app.php', 'red');<commit_msg>Fixed #25: Check if Model_Twitter or Model_Facebook exist<commit_after><?php

/**
 * Fuel
 *
 * Fuel is a fast, lightweight, community driven PHP5 framework.
 *
 * @package    Fuel
 * @version    1.0
 * @author     Fuel Development Team
 * @license    MIT License
 * @copyright  2010 - 2011 Fuel Development Team
 * @link       http://fuelphp.com
 */

namespace Fuel\Tasks;

/**
 * Setup commandline:
 *      php oil refine hybrid
 *
 * @package  hybrid
 */
class Hybrid {

    /**
     * Send command with runtime option:
     *      php oil refine hybrid --install
     *      php oil refine hybrid --help
     *      php oil refine hybrid --test
     *
     * @static
     * @access  public
     * @return  void
     */
    public static function run()
    {
        $install    = \Cli::option('i') or \Cli::option('install');
        $help       = \Cli::option('h') or \Cli::option('help');
        $test       = \Cli::option('t') or \Cli::option('test');

        switch (true)
        {
            case $install :
                static::install();
            break;

            case $help :
                static::help();
            break;

            case $test :
                static::test();
            break;
        }
    }

    /**
     * Test Hybrid package installation, make sure app/config/app.php is using the right configuration
     *
     * @static
     * @access  public
     * @return  void
     */
    public static function test()
    {
        \Config::load('app', 'app');
        
        $has_error = false;

        if (false === \Config::get('app.auth', false) or false === \Config::get('app._route_', false))
        {
            \Cli::write('Please update your APPPATH/config/app.php, you\'re running on an outdated configuration', 'red');
            $has_error = true;
        }

        if (true === \class_exists('\\Model_Users_Metum') and false === \Config::get('app.auth.use_meta', false))
        {
            \Cli::write('Please set app.auth.use_meta to TRUE in APPPATH/config/app.php', 'red');
            $has_error = true;
        }

        if (true === \class_exists('\\Model_Users_Auth') and false === \Config::get('app.auth.use_auth', false))
        {
            \Cli::write('Please set app.auth.use_auth to TRUE in APPPATH/config/app.php', 'red');
            $has_error = true;
        }

        if (true === \Config::get('app.auth.use_facebook', false))
        {
            if (false === \class_exists('\\Model_Users_Facebook'))
            {
                \Cli::write('\\Model_Users_Facebook is not available', 'red');
                $Has_error = true;    
            }

            if (false === \class_exists('\\Model_Facebook'))
            {
                \Cli::write('\\Model_Facebook is not available', 'red');
                $Has_error = true;  
            }

            if ('' === \Config::get('app.api.facebook.app_id', null))
            {
                \Cli::write('Please provide app.api.facebook.app_id in APPPATH/config/app.php', 'red');
                $has_error = true;
            }

            if ('' === \Config::get('app.api.facebook.secret', null))
            {
                \Cli::write('Please provide app.api.facebook.secret in APPPATH/config/app.php', 'red');
                $has_error = true;
            }
        }

        if (true === \Config::get('app.auth.use_twitter', false))
        {
            if (false === \class_exists('\\Model_Users_Twitter'))
            {
                \Cli::write('\\Model_Users_Twitter is not available', 'red');
                $Has_error = true;    
            }

            if (false === \class_exists('\\Model_Twitter'))
            {
                \Cli::write('\\Model_Twitter is not available', 'red');
                $Has_error = true;  
            }

            if ('' === \Config::get('app.api.twitter.consumer_key', ''))
            {
                \Cli::write('Please provide app.api.twitter.consumer_key in APPPATH/config/app.php', 'red');
{'fraction_non_alphanumeric': 0.15132867132867134, 'fraction_numerical': 0.0033566433566433566, 'mean_word_length': 1.6802848575712144, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2832834', 'n_tokens_mistral': 2169, 'n_tokens_neox': 2029, 'n_words': 476}