Permalink
Browse files

re-indented code

  • Loading branch information...
Grigore147 committed Sep 6, 2012
1 parent 829bb71 commit e3e0c774a05b267b854dfa314dd9c70a588fa869
View
@@ -18,45 +18,45 @@ App.version('0.1.0');
var create = App.command('create [path]')
.description('Create default application structure and base configuration')
.action(function(path) {
- path = path ? Path.resolve(root, path) + '/' : root;
-
- App.confirm('Create application at: '+ path +' ? [Yes|No]: ', function(ok) {
- if (ok) {
- if (!Fs.existsSync(path)) {
- mkdir.sync(path, 0755);
- }
+ path = path ? Path.resolve(root, path) + '/' : root;
- copy(mod_root + 'template', path, function(error) {
- console.log(error ? error : 'Done!');
-
- var empty_paths = [path + 'application/config/production', path + 'application/models',
- path + 'public/images', path + 'public/scripts', path + 'public/styles',
- path + 'modules', path + 'temp'];
-
- empty_paths.forEach(function(p) {
- if (!Fs.existsSync(p)) {
- mkdir.sync(p, 0777);
- }
- });
-
- var pack = {
- name: 'application-name',
- version: '0.0.1',
- private: true,
- dependencies: {
- katana: version,
- joose: '*'
- }
- };
+ App.confirm('Create application at: '+ path +' ? [Yes|No]: ', function(ok) {
+ if (ok) {
+ if (!Fs.existsSync(path)) {
+ mkdir.sync(path, 0755);
+ }
+
+ copy(mod_root + 'template', path, function(error) {
+ console.log(error ? error : 'Done!');
- Fs.writeFileSync(path + 'package.json', JSON.stringify(pack));
+ var empty_paths = [path + 'application/config/production', path + 'application/models',
+ path + 'public/images', path + 'public/scripts', path + 'public/styles',
+ path + 'modules', path + 'temp'];
+
+ empty_paths.forEach(function(p) {
+ if (!Fs.existsSync(p)) {
+ mkdir.sync(p, 0777);
+ }
+ });
+
+ var pack = {
+ name: 'application-name',
+ version: '0.0.1',
+ private: true,
+ dependencies: {
+ katana: version,
+ joose: '*'
+ }
+ };
+
+ Fs.writeFileSync(path + 'package.json', JSON.stringify(pack));
- process.stdin.destroy();
- });
- } else {
- process.stdin.destroy();
- }
- });
+ process.stdin.destroy();
+ });
+ } else {
+ process.stdin.destroy();
+ }
+ });
});
App.command('install <module>')
@@ -75,34 +75,3 @@ App.command('install <module>')
});
App.parse(process.argv);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
View
@@ -6,49 +6,49 @@ var Async = require('async');
// Call all EventListener's in parallel and callback on all done
EventEmitter.prototype.parallel = function(event, callback) {
- emit.call(this, event, callback, Array.prototype.slice.call(arguments, 2), 'parallel');
+ emit.call(this, event, callback, Array.prototype.slice.call(arguments, 2), 'parallel');
}
// Call all EventListener's in order they are added and callback on last done
EventEmitter.prototype.series = function(event, callback) {
- emit.call(this, event, callback, Array.prototype.slice.call(arguments, 2), 'series');
+ emit.call(this, event, callback, Array.prototype.slice.call(arguments, 2), 'series');
}
// Listener wrapper
var fn = function(listener, args) {
- return function(callback) {
- args = args.concat(callback);
+ return function(callback) {
+ args = args.concat(callback);
- listener.apply(listener, args);
- }
+ listener.apply(listener, args);
+ }
}
// Custom Event emit which allow to run event listeners in parallel or series
// also we could listen all event listeners complete with callback
function emit(event, callback, args, type) {
- // Get all listeners for this event added with standart addListener or on methods
- var listeners = this.listeners(event);
+ // Get all listeners for this event added with standart addListener or on methods
+ var listeners = this.listeners(event);
- // Prepared list of listeners
- var list = [];
+ // Prepared list of listeners
+ var list = [];
- if (args.length) {
- for (var i=0; i<listeners.length; i++) {
- // Wrap listener
- var f = fn(listeners[i], args);
+ if (args.length) {
+ for (var i=0; i<listeners.length; i++) {
+ // Wrap listener
+ var f = fn(listeners[i], args);
- list.push(f);
- }
- } else {
- list = listeners;
+ list.push(f);
}
+ } else {
+ list = listeners;
+ }
- // Parallel or Series
- var method = type === 'parallel' ? Async.parallel : Async.series;
+ // Parallel or Series
+ var method = type === 'parallel' ? Async.parallel : Async.series;
- method(list, callback || function(error, results) {
- if (error) { throw error; }
- });
+ method(list, callback || function(error, results) {
+ if (error) { throw error; }
+ });
}
// Methods call wrapper, around builder with regexp selector
@@ -58,35 +58,17 @@ Joose.Managed.Builder.meta.addMethod('call', function(targetMeta, info) {
var around = {};
this.meta.getMethods().eachOwn(function(fn, name) {
- methods[name] = fn;
+ methods[name] = fn;
});
Joose.O.each(info, function (value, name) {
for (method in methods) {
- if (new RegExp(name).test(method)) {
- around[method] = value;
- }
+ if (new RegExp(name).test(method)) {
+ around[method] = value;
+ }
}
});
this.meta.extend({ around: around });
}, Joose.Managed.Property.MethodModifier.Before);
});
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
View
@@ -6,71 +6,56 @@ var merge = require('./utils').merge;
var Config = {};
module.exports = function(config) {
- if (!config) { return Config.application.application; }
+ if (!config) { return Config.application.application; }
- var module = 'application';
+ var module = 'application';
- if (m = config.match(/(.*)(\:|\.)(.*)/i)) {
- module = m[1];
- config = m[3]!=='' ? m[3] : module;
- }
+ if (m = config.match(/(.*)(\:|\.)(.*)/i)) {
+ module = m[1];
+ config = m[3]!=='' ? m[3] : module;
+ }
- if (!Config[module]) { Config[module] = {}; }
+ if (!Config[module]) { Config[module] = {}; }
- if (config === '*') {
- return Config[module];
- }
+ if (config === '*') {
+ return Config[module];
+ }
- if (Config[module][config] === undefined) { Config[module][config] = {}; }
+ if (Config[module][config] === undefined) { Config[module][config] = {}; }
- return Config[module][config];
+ return Config[module][config];
}
module.exports.load = function(module) {
- module = module || 'application';
+ module = module || 'application';
- var path = module=='application' ? root+'application/config/' : root+'modules/'+module+'/config/';
+ var path = module=='application' ? root+'application/config/' : root+'modules/'+module+'/config/';
- if (!Config[module]) { Config[module] = {}; }
+ if (!Config[module]) { Config[module] = {}; }
- if (Fs.existsSync(path + 'development') && Fs.statSync(path + 'development').isDirectory()) {
- Fs.readdirSync(path + 'development').forEach(function(file) {
- var name = Path.basename(file, Path.extname(file));
+ if (Fs.existsSync(path + 'development') && Fs.statSync(path + 'development').isDirectory()) {
+ Fs.readdirSync(path + 'development').forEach(function(file) {
+ var name = Path.basename(file, Path.extname(file));
- Config[module][name] = require(path +'development/'+ name);
- });
- }
+ Config[module][name] = require(path +'development/'+ name);
+ });
+ }
- if (env !== 'development') {
- if (Fs.existsSync(path + env) && Fs.statSync(path + env).isDirectory()) {
- Fs.readdirSync(path + env).forEach(function(file) {
- var name = Path.basename(file, Path.extname(file));
+ if (env !== 'development') {
+ if (Fs.existsSync(path + env) && Fs.statSync(path + env).isDirectory()) {
+ Fs.readdirSync(path + env).forEach(function(file) {
+ var name = Path.basename(file, Path.extname(file));
- var config = require(path + env +'/'+ name);
+ var config = require(path + env +'/'+ name);
- merge(Config[module][name], Config[module][name], config);
- });
- }
+ merge(Config[module][name], Config[module][name], config);
+ });
}
+ }
- return Config[module];
+ return Config[module];
}
module.exports.Config = Config;
module.exports.load();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
View
@@ -3,27 +3,27 @@ var View = App.View;
var extend = App.Utils.extend;
Class('Katana.Core.Controller', {
- have: {
- data: []
- },
+ have: {
+ data: []
+ },
- methods: {
- initialize: function() {
+ methods: {
+ initialize: function() {
- },
+ },
- set: function(name, value) {
- if (typeof(name) === 'object') {
- this.data = extend(this.data, name);
- } else {
- this.data[name] = value;
- }
- },
+ set: function(name, value) {
+ if (typeof(name) === 'object') {
+ this.data = extend(this.data, name);
+ } else {
+ this.data[name] = value;
+ }
+ },
- render: function(template, data) {
- return View.render(template, extend(this.data, data));
- }
+ render: function(template, data) {
+ return View.render(template, extend(this.data, data));
}
+ }
});
module.exports = Katana.Core.Controller;
Oops, something went wrong.

0 comments on commit e3e0c77

Please sign in to comment.