Coder Social home page Coder Social logo

jaime's Introduction

Jaime

Jaime is just a handy PHP5.3 utility class to automate repetitive tasks from the command line.

The way it works is simple. You instantiate the Jaime class. You pass a list of tasks (closures) inside an array with the please() method. Then yo ask Jaime to work().

For example, this is a simplified version of a Jaime Script that I use to deploy a WordPress plugin:

Example

<?php

	$jaime = require('jaime.php');

	$jaime->please(array(
	
		// it's nicer when you name your tasks descriptively
		'duplicate the theme directory'=>function($jaime){

			$folder = dirname(dirname(__FILE__));			
			$destination = dirname($folder).DIRECTORY_SEPARATOR."export";

			if (!is_dir($destination)) {
				mkdir($destination,0777,true);
			}
		
			// this is a shell command
			exec("cp -R -f $folder $destination");

			// remember is a handy function to pass variables between 
			// tasks without resorting to the globl scope
			$jaime->remember('build',$destination);			
		},
	
		'remove development stuff'=>function($jaime){
		
			// we retrieve values from Jaime's memory.
			$buildDir = $jaime->remember('build');
			chdir($buildDir);
			exec('rm -rf .git*');
			exec('rm -rf .sass-cache');		
		
		}, 
	
		'minify javascript'=>function($jaime){
		
			$buildDir = $jaime->remember('build');
			$appJs = $buildDir.'/themes/today/assets/js/app.js';
			$miniAppJs = $buildDir.'/themes/today/assets/js/app.min.js';

			// obviously you need to download YUICompressor first,
			$compressor  = dirname(__FILE__)."/yui/yuicompressor-2.4.2.jar";

			echo exec("java -jar $compressor -o $miniAppJs $appJs");

		},		
	
	));

	$jaime->work();

?>

I'll be adding more documentation and examples later.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.