Skip to content
Browse files

documentation tweaks

  • Loading branch information...
1 parent 00ff190 commit cc3abd1de406f6ea6587ebe6d130ef47a675eccd @raganwald committed
Showing with 87 additions and 45 deletions.
  1. +9 −1 README.md
  2. +18 −2 docs/quick.md
  3. +59 −41 lib/YouAreDaChef.js
  4. +1 −1 license.txt → license.md
View
10 README.md
@@ -88,9 +88,17 @@ You can also try making a [cryptic][cry] reference to a [computed][comp], non-lo
Where can I read more?
---
+[Quick Start Guide][qsg]
[Separating Concerns in Coffeescript using Aspect-Oriented Programming][blog]
[Implementing Garbage Collection in CS/JS with Aspect-Oriented Programming][gc]
[js]: https://github.com/raganwald/YouAreDaChef/blob/master/lib/YouAreDaChef.js
[gc]: https://github.com/raganwald/homoiconic/blob/master/2012/03/garbage_collection_in_coffeescript.md#readme
-[blog]: https://github.com/raganwald/homoiconic/blob/master/2011/11/YouAreDaChef.md#readme
+[blog]: https://github.com/raganwald/homoiconic/blob/master/2011/11/YouAreDaChef.md#readme
+
+### Et cetera
+
+YouAreDaChef was created by [Reg "raganwald" Braithwaite][raganwald]. It is available under the terms of the [MIT License][lic].
+
+[raganwald]: http://braythwayt.com
+[lic]: https://github.com/raganwald/YouAreDaChef/blob/master/license.md
View
20 docs/quick.md
@@ -130,7 +130,7 @@ And when you want to hand out a lot of the same kind of advice, pass in a hash o
.clazz(Square)
.before
- set_memo:(index) ->
+ set_memo: (index) ->
if (existing = @get_memo(index))
existing.decrementReference()
@@ -248,4 +248,20 @@ Or:
Or:
curl -o YouAreDaChef.zip https://nodeload.github.com/raganwald/YouAreDaChef/zipball/master
-
+
+### Where can I read more?
+
+[YouAreDaChef REAADME][yadc]
+[Separating Concerns in Coffeescript using Aspect-Oriented Programming][blog]
+[Implementing Garbage Collection in CS/JS with Aspect-Oriented Programming][gc]
+
+[js]: https://github.com/raganwald/YouAreDaChef/blob/master/lib/YouAreDaChef.js
+[gc]: https://github.com/raganwald/homoiconic/blob/master/2012/03/garbage_collection_in_coffeescript.md#readme
+[blog]: https://github.com/raganwald/homoiconic/blob/master/2011/11/YouAreDaChef.md#readme
+
+### Et cetera
+
+[YouAreDaChef][yadc] was created by [Reg "raganwald" Braithwaite][raganwald]. It is available under the terms of the [MIT License][lic].
+
+[raganwald]: http://braythwayt.com
+[lic]: https://github.com/raganwald/YouAreDaChef/blob/master/license.md
View
100 lib/YouAreDaChef.js
@@ -1,11 +1,15 @@
+// Generated by CoffeeScript 1.3.1
(function() {
- var Combinator, YouAreDaChef, _;
- var __slice = Array.prototype.slice, __hasProp = Object.prototype.hasOwnProperty;
+ var Combinator, YouAreDaChef, _,
+ __slice = [].slice,
+ __hasProp = {}.hasOwnProperty;
_ = require('underscore');
Combinator = (function() {
+ Combinator.name = 'Combinator';
+
function Combinator() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
@@ -13,10 +17,13 @@
this.methods([]);
this["for"].apply(this, args);
this;
+
}
Combinator.prototype.namespace = function(name) {
- if (name == null) name = null;
+ if (name == null) {
+ name = null;
+ }
if (name != null) {
this._namespace = name;
return this;
@@ -81,13 +88,17 @@
return !_advice.apply(this, args);
};
}
- if (!clazzes.length) throw "Need to define one or more classes";
+ if (!clazzes.length) {
+ throw "Need to define one or more classes";
+ }
return _.each(clazzes, function(clazz) {
var daemonize, expr;
daemonize = function(name, inject) {
- var daemonology, key, _base, _ref, _ref2;
- if (inject == null) inject = [];
- daemonology = (_ref = (_base = ((_ref2 = clazz.__YouAreDaChef) != null ? _ref2 : clazz.__YouAreDaChef = {}))[name]) != null ? _ref : _base[name] = {};
+ var daemonology, key, _base, _ref, _ref1;
+ if (inject == null) {
+ inject = [];
+ }
+ daemonology = (_ref = (_base = ((_ref1 = clazz.__YouAreDaChef) != null ? _ref1 : clazz.__YouAreDaChef = {}))[name]) != null ? _ref : _base[name] = {};
_.defaults(daemonology, {
before: [],
after: [],
@@ -97,45 +108,45 @@
});
if (!clazz.prototype.hasOwnProperty("before_" + name + "_daemon")) {
clazz.prototype["before_" + name + "_daemon"] = function() {
- var args, daemon, daemon_args, _i, _len, _ref3, _ref4, _ref5;
+ var args, daemon, daemon_args, _i, _len, _ref2, _ref3, _ref4;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
daemon_args = inject.concat(args);
- _ref3 = daemonology.before.reverse();
- for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
- daemon = _ref3[_i];
+ _ref2 = daemonology.before.reverse();
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
+ daemon = _ref2[_i];
daemon[1].apply(this, daemon_args);
}
- return (_ref4 = clazz.__super__) != null ? (_ref5 = _ref4["before_" + name + "_daemon"]) != null ? _ref5.apply(this, args) : void 0 : void 0;
+ return (_ref3 = clazz.__super__) != null ? (_ref4 = _ref3["before_" + name + "_daemon"]) != null ? _ref4.apply(this, args) : void 0 : void 0;
};
clazz.prototype["after_" + name + "_daemon"] = function() {
- var args, daemon, daemon_args, _i, _len, _ref3, _ref4, _ref5, _results;
+ var args, daemon, daemon_args, _i, _len, _ref2, _ref3, _ref4, _results;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
daemon_args = inject.concat(args);
- if ((_ref3 = clazz.__super__) != null) {
- if ((_ref4 = _ref3["after_" + name + "_daemon"]) != null) {
- _ref4.apply(this, args);
+ if ((_ref2 = clazz.__super__) != null) {
+ if ((_ref3 = _ref2["after_" + name + "_daemon"]) != null) {
+ _ref3.apply(this, args);
}
}
- _ref5 = daemonology.after;
+ _ref4 = daemonology.after;
_results = [];
- for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
- daemon = _ref5[_i];
+ for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
+ daemon = _ref4[_i];
_results.push(daemon[1].apply(this, daemon_args));
}
return _results;
};
clazz.prototype["around_" + name + "_daemon"] = function() {
- var args, daemon, daemon_args, default_fn, fn, fn_list, _i, _len, _ref3, _ref4, _ref5;
- var _this = this;
+ var args, daemon, daemon_args, default_fn, fn, fn_list, _i, _len, _ref2, _ref3, _ref4,
+ _this = this;
default_fn = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
daemon_args = inject.concat(args);
fn_list = [];
- if (((_ref3 = clazz.__super__) != null ? _ref3["around_" + name + "_daemon"] : void 0) != null) {
- fn_list.unshift((_ref4 = clazz.__super__) != null ? _ref4["around_" + name + "_daemon"] : void 0);
+ if (((_ref2 = clazz.__super__) != null ? _ref2["around_" + name + "_daemon"] : void 0) != null) {
+ fn_list.unshift((_ref3 = clazz.__super__) != null ? _ref3["around_" + name + "_daemon"] : void 0);
}
- _ref5 = daemonology.around;
- for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
- daemon = _ref5[_i];
+ _ref4 = daemonology.around;
+ for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
+ daemon = _ref4[_i];
fn_list.unshift(daemon[1]);
}
fn = _.reduce(fn_list, function(acc, advice) {
@@ -152,18 +163,20 @@
return fn.apply(this, args);
};
clazz.prototype["guard_" + name + "_daemon"] = function() {
- var args, daemon, daemon_args, _i, _len, _ref3, _ref4, _ref5;
+ var args, daemon, daemon_args, _i, _len, _ref2, _ref3, _ref4;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
daemon_args = inject.concat(args);
- if (((_ref3 = clazz.__super__) != null ? _ref3["guard_" + name + "_daemon"] : void 0) != null) {
- if (!((_ref4 = clazz.__super__) != null ? _ref4["guard_" + name + "_daemon"].apply(this, args) : void 0)) {
+ if (((_ref2 = clazz.__super__) != null ? _ref2["guard_" + name + "_daemon"] : void 0) != null) {
+ if (!((_ref3 = clazz.__super__) != null ? _ref3["guard_" + name + "_daemon"].apply(this, args) : void 0)) {
return false;
}
}
- _ref5 = daemonology.guard;
- for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
- daemon = _ref5[_i];
- if (!daemon[1].apply(this, daemon_args)) return false;
+ _ref4 = daemonology.guard;
+ for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
+ daemon = _ref4[_i];
+ if (!daemon[1].apply(this, daemon_args)) {
+ return false;
+ }
}
return true;
};
@@ -197,12 +210,12 @@
]);
}
clazz.prototype[name] = function() {
- var args, _ref3;
- var _this = this;
+ var args, _ref2,
+ _this = this;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (clazz.prototype["guard_" + name + "_daemon"].apply(this, args)) {
clazz.prototype["before_" + name + "_daemon"].apply(this, args);
- return _.tap((_ref3 = clazz.prototype["around_" + name + "_daemon"]).call.apply(_ref3, [this, _.last(daemonology["default"])[1]].concat(__slice.call(args))), function(retv) {
+ return _.tap((_ref2 = clazz.prototype["around_" + name + "_daemon"]).call.apply(_ref2, [this, _.last(daemonology["default"])[1]].concat(__slice.call(args))), function(retv) {
return clazz.prototype["after_" + name + "_daemon"].apply(_this, args);
});
}
@@ -220,7 +233,9 @@
} else {
if (_.isFunction(advice)) {
advice = ["" + (daemonology[verb].length + 1), advice];
- } else if (_.isArray(advice)) {} else {
+ } else if (_.isArray(advice)) {
+
+ } else {
key = _.keys(advice)[0];
advice = [key, advice[key]];
}
@@ -230,7 +245,9 @@
if (pointcut_exprs.length === 1 && (expr = pointcut_exprs[0]) instanceof RegExp) {
_.each(_.functions(clazz.prototype), function(name) {
var match_data;
- if (match_data = name.match(expr)) return daemonize(name, match_data);
+ if (match_data = name.match(expr)) {
+ return daemonize(name, match_data);
+ }
});
} else {
_.each(pointcut_exprs, function(name) {
@@ -295,9 +312,9 @@
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return (function(func, args, ctor) {
ctor.prototype = func.prototype;
- var child = new ctor, result = func.apply(child, args);
- return typeof result === "object" ? result : child;
- })(Combinator, args, function() {});
+ var child = new ctor, result = func.apply(child, args), t = typeof result;
+ return t == "object" || t == "function" ? result || child : child;
+ })(Combinator, args, function(){});
};
_.each(['for', 'namespace', 'clazz', 'method', 'clazzes', 'methods', 'tag'], function(definition_method_name) {
@@ -322,4 +339,5 @@
this;
+
}).call(this);
View
2 license.txt → license.md
@@ -1,4 +1,4 @@
-Copyright (c) 2011 Reginald Braithwaite
+Copyright (c) 2011-2012 Reginald Braithwaite
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

0 comments on commit cc3abd1

Please sign in to comment.
Something went wrong with that request. Please try again.