Skip to content
Browse files

More buildprocess changes

  • Loading branch information...
1 parent c9a5331 commit bb03aaced77ad7daf9729671affc77fe7755cb3f @CRogers committed Apr 2, 2012
Showing with 47 additions and 20 deletions.
  1. +1 −1 Makefile
  2. +1 −0 lib/end.js
  3. +5 −6 lib/pattern.js
  4. +18 −6 lib/pun.js
  5. +12 −0 lib/start.js
  6. +4 −7 src/pattern.coffee
  7. +6 −0 tests/load.html
View
2 Makefile
@@ -11,7 +11,7 @@ TESTSRC = $(wildcard src/tests/*.coffee)
TESTJS = $(subst src/,,$(TESTSRC:.coffee=.js))
all: $(JS)
- cat $(JS) >lib/pun.js
+ cat lib/start.js $(JS) lib/end.js >lib/pun.js
test: $(TESTJS)
#RES = cat $@ sed -n '/<</,/>>/p' | sed 's/^[ \t]*//'
View
1 lib/end.js
@@ -0,0 +1 @@
+}).call(this);
View
11 lib/pattern.js
@@ -1,5 +1,5 @@
(function() {
- var bindIdent, matchInnerPattern, matchPattern, out, rawBindIdent, seeIfBinding, subIdent;
+ var bindIdent, matchInnerPattern, matchPattern, rawBindIdent, seeIfBinding, subIdent;
bindIdent = {};
rawBindIdent = {};
subIdent = {};
@@ -19,7 +19,7 @@
};
matchPattern = function(bindings, args, value, pattern) {
var i, key, valuePattern, vtype, _ref;
- if (pattern === out.pun._) {
+ if (pattern === pun._) {
return true;
}
if (pattern.__rawBindIdent === rawBindIdent) {
@@ -70,8 +70,7 @@
}
return true;
};
- out = this.windows || exports;
- out.pun = {
+ addExports({
_: {},
$: function(binding, innerPattern) {
return {
@@ -102,6 +101,6 @@
}
};
}
- };
- out.pun.$.__rawBindIdent = rawBindIdent;
+ });
+ pun.$.__rawBindIdent = rawBindIdent;
}).call(this);
View
24 lib/pun.js
@@ -1,8 +1,20 @@
+(function(){
+ var out = (typeof process === 'undefined' || !process.versions)
+ ? this.window || {}
+ : exports;
+
+ var pun = out.pun = {};
+
+ var addExports = function(es) {
+ for(var e in es)
+ pun[e] = es[e];
+ };
+
(function() {
}).call(this);
(function() {
- var bindIdent, matchInnerPattern, matchPattern, out, rawBindIdent, seeIfBinding, subIdent;
+ var bindIdent, matchInnerPattern, matchPattern, rawBindIdent, seeIfBinding, subIdent;
bindIdent = {};
rawBindIdent = {};
subIdent = {};
@@ -22,7 +34,7 @@
};
matchPattern = function(bindings, args, value, pattern) {
var i, key, valuePattern, vtype, _ref;
- if (pattern === out.pun._) {
+ if (pattern === pun._) {
return true;
}
if (pattern.__rawBindIdent === rawBindIdent) {
@@ -73,8 +85,7 @@
}
return true;
};
- out = this.windows || exports;
- out.pun = {
+ addExports({
_: {},
$: function(binding, innerPattern) {
return {
@@ -105,6 +116,7 @@
}
};
}
- };
- out.pun.$.__rawBindIdent = rawBindIdent;
+ });
+ pun.$.__rawBindIdent = rawBindIdent;
+}).call(this);
}).call(this);
View
12 lib/start.js
@@ -0,0 +1,12 @@
+(function(){
+ var out = (typeof process === 'undefined' || !process.versions)
+ ? this.window || {}
+ : exports;
+
+ var pun = out.pun = {};
+
+ var addExports = function(es) {
+ for(var e in es)
+ pun[e] = es[e];
+ };
+
View
11 src/pattern.coffee
@@ -20,7 +20,7 @@ matchInnerPattern = (bindings, args, value, pattern) ->
matchPattern = (bindings, args, value, pattern) ->
# wildcard operator means we accept all
- if pattern == out.pun._
+ if pattern == pun._
return true
# see if it's a "raw param"
@@ -76,11 +76,7 @@ matchPattern = (bindings, args, value, pattern) ->
return true
-# export to window if browser or exports if node
-out = (this.windows || exports)
-
-out.pun =
-
+addExports(
# wildcard operator
_: {}
@@ -102,7 +98,8 @@ out.pun =
if matchPattern bindings, matchArgs, value, pattern
return matchFunc.apply bindings, matchArgs
+)
# add an ident to the raw $ so we can use it as a param
-out.pun.$.__rawBindIdent = rawBindIdent
+pun.$.__rawBindIdent = rawBindIdent
View
6 tests/load.html
@@ -1,5 +1,11 @@
<html>
<head>
<script src="../lib/pun.js" /></script>
+ <script>
+
+ var $ = pun.$;
+ var _ = pun._;
+
+ </script>
</head>
</html>

0 comments on commit bb03aac

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