<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;

/**
 * Migrate task
 *
 * Use this command line task to deploy and rollback changes.
 *
 * @package		Fuel
 * @version		1.0
 * @author		<NAME>
 * @link		http://fuelphp.com/docs/general/migrations.html
 */

class Migrate {

	public static function run()
	{
		// -v or --version
		$version = \Cli::option('v', \Cli::option('version'));

		$run = false;

		// Spoecific version
		if ($version > 0)
		{
			if (\Migrate::version($version) === false)
			{
				throw new \Oil\Exception('Already on migration: ' . $version .'.');
			}

			else
			{
				static::_update_version($version);
				\Cli::write('Migrated to version: ' . $version .'.', 'green');
			}
		}

		// Just go to the latest
		else
		{
			if (($result = \Migrate::latest()) === false)
			{
				throw new \Oil\Exception('Already on latest migration.');
			}

			else
			{
				static::_update_version($result);
				\Cli::write('Migrated to latest version: ' . $result .'.', 'green');
			}
		}
		
	}

	public static function up()
	{
		\Config::load('migrate', true);
		$version = \Config::get('migrate.version') + 1;

		if (\Migrate::version($version))
		{
			static::_update_version($version);
			\Cli::write('Migrated to version: ' . $version .'.', 'green');
		}
	}

	public static function down()
	{
		\Config::load('migrate', true);
		$version = \Config::get('migrate.version') - 1;

		if (\Migrate::version($version))
		{
			static::_update_version($version);
			\Cli::write('Migrated to version: ' . $version .'.', 'green');
		}
	}

	private static function _update_version($version)
	{
		$contents = '';
		$path = '';
		if (file_exists($path = APPPATH.'config'.DS.'migrate.php'))
		{
			$contents = file_get_contents($path);
		}
		elseif (file_exists($core_path = COREPATH.'config'.DS.'migrate.php'))
		{
			$contents = file_get_contents($core_path);
		}

		$contents = preg_replace("#('version'[ \t]+=>)[ \t]+([0-9]+),#i", "$1 $version,", $contents);

		file_put_contents($path, $contents);
	}

	public static function current()
	{
		\Migrate::current();
	}
<commit_msg>Fixed migrate task after renaming migrations config file.<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;

/**
 * Migrate task
 *
 * Use this command line task to deploy and rollback changes.
 *
 * @package		Fuel
 * @version		1.0
 * @author		<NAME>
 * @link		http://fuelphp.com/docs/general/migrations.html
 */

class Migrate {

	public static function run()
	{
		// -v or --version
		$version = \Cli::option('v', \Cli::option('version'));

		$run = false;

		// Spoecific version
		if ($version > 0)
		{
			if (\Migrate::version($version) === false)
			{
				throw new \Oil\Exception('Already on migration: ' . $version .'.');
			}

			else
			{
				static::_update_version($version);
				\Cli::write('Migrated to version: ' . $version .'.', 'green');
			}
		}

		// Just go to the latest
		else
		{
			if (($result = \Migrate::latest()) === false)
			{
				throw new \Oil\Exception('Already on latest migration.');
			}

			else
			{
				static::_update_version($result);
				\Cli::write('Migrated to latest version: ' . $result .'.', 'green');
			}
		}
		
	}

	public static function up()
	{
		\Config::load('migrations', true);
		$version = \Config::get('migrations.version') + 1;

		if (\Migrate::version($version))
		{
			static::_update_version($version);
			\Cli::write('Migrated to version: ' . $version .'.', 'green');
		}
	}

	public static function down()
	{
		\Config::load('migrations', true);
		$version = \Config::get('migrations.version') - 1;

		if (\Migrate::version($version))
		{
			static::_update_version($version);
			\Cli::write('Migrated to version: ' . $version .'.', 'green');
		}
	}

	private static function _update_version($version)
	{
		$contents = '';
		$path = '';
		if (file_exists($path = APPPATH.'config'.DS.'migrate.php'))
		{
			$contents = file_get_contents($path);
		}
		elseif (file_exists($core_path = COREPATH.'config'.DS.'migrate.php'))
		{
			$contents = file_get_contents($core_path);
		}

		$contents = preg_replace("#('version'[ \t]+=>)[ \t]+([0-9]+),#i", "$1 $version,", $contents);

		file_put_contents($path, $contents);
	}

	public static function current()
	{
		\Migrate::current();
	}

{'fraction_non_alphanumeric': 0.1864228667507356, 'fraction_numerical': 0.007986548970155528, 'mean_word_length': 3.1782265144863917, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2822350', 'n_tokens_mistral': 1886, 'n_tokens_neox': 1657, 'n_words': 357}