o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1337093726.068783: @value"%{I" class:EFI"ProcessedAsset;FI"logical_path;F"*ems/lib/batman/lib/tools/generator.jsI" pathname;F"v/private/var/www/html/development/projects/rails/ems/app/assets/javascripts/ems/lib/batman/lib/tools/generator.jsI"content_type;FI"application/javascript;FI" mtime;FI"2012-05-14T17:32:22+01:00;FI" length;Fi¨I" digest;F"%5db13d90723b28bec7d4216dc3d386feI" source;FI"¨(function() { var Batman, cli, exec, fs, path, spawn, util, utils, _ref; var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; fs = require('fs'); path = require('path'); util = require('util'); cli = require('./cli'); utils = require('./utils'); _ref = require('child_process'), spawn = _ref.spawn, exec = _ref.exec; Batman = require('../lib/batman.js'); cli.setUsage('batman [OPTIONS] generate app|model|controller|view \n batman [OPTIONS] new '); cli.parse({ app: ['-n', "The name of your Batman application (if generating an application component). This can also be stored in a .batman file in the project root.", "string"] }); cli.main(function(args, options) { var TemplateVars, command, count, destinationPath, replaceVars, source, transforms, walk; options.appName = options.app; command = args.shift(); if (command === 'new') { options.template = 'app'; if (args[0] == null) { this.error("Please provide a name for the application."); cli.getUsage(); } options.name = args[0]; } else if (args.length === 2) { options.template = args[0]; options.name = args[1]; } else { this.error("Please specify a template and a name for batman generate."); cli.getUsage(); } source = path.join(__dirname, 'templates', options.template); if (!path.existsSync(source)) { this.fatal("template " + options.template + " not found"); } TemplateVars = {}; if (options.template === 'app') { if (options.appName != null) { options.name = options.appName; } else { options.appName = options.name; } destinationPath = path.join(process.cwd(), options.appName); if (path.existsSync(destinationPath)) { this.fatal('Destination already exists!'); } else { fs.mkdirSync(destinationPath, 0755); } } else { destinationPath = process.cwd(); Batman.mixin(options, utils.getConfig()); } options.appName = Batman.helpers.camelize(options.appName); Batman.mixin(TemplateVars, { app: options.appName, name: options.name }); transforms = [ (function(x) { return x.toUpperCase(); }), (function(x) { return Batman.helpers.camelize(x); }), (function(x) { return Batman.helpers.underscore(x).toLowerCase(); }) ]; replaceVars = function(string) { var f, templateKey, value, _i, _len; for (templateKey in TemplateVars) { value = TemplateVars[templateKey]; if (value == null) { console.error("template key " + templateKey + " not defined!"); } string = string.replace(new RegExp("\\$_" + templateKey + "\\$", 'g'), value); for (_i = 0, _len = transforms.length; _i < _len; _i++) { f = transforms[_i]; string = string.replace(new RegExp("\\$" + (f(templateKey)) + "\\$", 'g'), f(value)); } } return string; }; count = 0; walk = __bind(function(aPath) { var sourcePath; if (aPath == null) { aPath = "/"; } sourcePath = path.join(source, aPath); return fs.readdirSync(sourcePath).forEach(__bind(function(file) { var destFile, dir, ext, newFile, oldFile, resultName, sourceFile, stat; if (file === '.gitignore') { return; } resultName = replaceVars(file); sourceFile = path.join(sourcePath, file); destFile = path.join(destinationPath, aPath, resultName); ext = path.extname(file).toLowerCase().slice(1); stat = fs.statSync(sourceFile); if (stat.isDirectory()) { dir = path.join(destinationPath, aPath, resultName); if (!path.existsSync(dir)) { fs.mkdirSync(dir, 0755); } return walk(path.join(aPath, file)); } else if (ext === 'png' || ext === 'jpg' || ext === 'gif') { newFile = fs.createWriteStream(destFile); oldFile = fs.createReadStream(sourceFile); this.info("creating " + destFile); return util.pump(oldFile, newFile, function(err) { if (err != null) { throw err; } }); } else { if (file.charAt(0) === '.') { return; } count++; return fs.readFile(sourceFile, 'utf8', __bind(function(err, fileContents) { if (err != null) { throw err; } this.info("creating " + destFile); return fs.writeFile(destFile, replaceVars(fileContents), __bind(function(err) { if (err != null) { throw err; } if (--count === 0) { return this.ok("" + options.name + " generated successfully."); } }, this)); }, this)); } }, this)); }, this); return walk(); }); }).call(this); ;FI"dependency_digest;F"%8c375a9e50734ea7cfd3943d81f67b63I"required_paths;F["v/private/var/www/html/development/projects/rails/ems/app/assets/javascripts/ems/lib/batman/lib/tools/generator.jsI"dependency_paths;F[{I" path;F"v/private/var/www/html/development/projects/rails/ems/app/assets/javascripts/ems/lib/batman/lib/tools/generator.jsI" mtime;FI"2012-05-14T17:32:22+01:00;FI" digest;F"%5db13d90723b28bec7d4216dc3d386feI" _version;F"%9f3b95dd7ea3030dc35985c0a8020862