Skip to content
This repository
Browse code

Merge branch 'master' into experimental

  • Loading branch information...
commit 806c07420be3387a922669b59d495c3cd5befd3e 2 parents 6b10c84 + 51b4490
Kris Kowal authored February 28, 2010
171  catalog-2.json
@@ -87,19 +87,26 @@
87 87
             "lib": [
88 88
                 "lib"
89 89
             ],
90  
-            "lean": [
91  
-                "lib",
92  
-                "engines"
93  
-            ],
94  
-            "descriptorUrl": "http://github.com/tlrobinson/narwhal/raw/master/package.json",
95  
-            "packageUrl": "http://github.com/tlrobinson/narwhal/zipball/master",
  90
+            "lean": {
  91
+                "include": [
  92
+                    "engines/default/**/*",
  93
+                    "engines/rhino/bootstrap.js",
  94
+                    "engines/rhino/lib/**/*",
  95
+                    "engines/rhino/package.json",
  96
+                    "lib/**/*",
  97
+                    "narwhal.js",
  98
+                    "package.json"
  99
+                ]
  100
+            },
  101
+            "descriptorUrl": "http://github.com/280north/narwhal/raw/master/package.json",
  102
+            "packageUrl": "http://github.com/280north/narwhal/zipball/master",
96 103
             "packageArchive": "zip",
97 104
             "source": {
98 105
                 "type": "github",
99  
-                "user": "tlrobinson",
  106
+                "user": "280north",
100 107
                 "packageName": "narwhal",
101  
-                "descriptorUrl": "http://github.com/tlrobinson/narwhal/raw/master/package.json",
102  
-                "url": "http://github.com/tlrobinson/narwhal/zipball/master",
  108
+                "descriptorUrl": "http://github.com/280north/narwhal/raw/master/package.json",
  109
+                "url": "http://github.com/280north/narwhal/zipball/master",
103 110
                 "archive": "zip"
104 111
             },
105 112
             "dependencies": []
@@ -127,15 +134,15 @@
127 134
                 "1",
128 135
                 "1"
129 136
             ],
130  
-            "descriptorUrl": "http://github.com/tlrobinson/narwhal-jsc/raw/master/package.json",
131  
-            "packageUrl": "http://github.com/tlrobinson/narwhal-jsc/zipball/master",
  137
+            "descriptorUrl": "http://github.com/280north/narwhal-jsc/raw/master/package.json",
  138
+            "packageUrl": "http://github.com/280north/narwhal-jsc/zipball/master",
132 139
             "packageArchive": "zip",
133 140
             "source": {
134 141
                 "type": "github",
135  
-                "user": "tlrobinson",
  142
+                "user": "280north",
136 143
                 "packageName": "narwhal-jsc",
137  
-                "descriptorUrl": "http://github.com/tlrobinson/narwhal-jsc/raw/master/package.json",
138  
-                "url": "http://github.com/tlrobinson/narwhal-jsc/zipball/master",
  144
+                "descriptorUrl": "http://github.com/280north/narwhal-jsc/raw/master/package.json",
  145
+                "url": "http://github.com/280north/narwhal-jsc/zipball/master",
139 146
                 "archive": "zip"
140 147
             },
141 148
             "contributors": [
@@ -266,6 +273,12 @@
266 273
                     "type": "MPL"
267 274
                 },
268 275
                 {
  276
+                    "type": "GPL 2.0"
  277
+                },
  278
+                {
  279
+                    "type": "LGPL 2.1"
  280
+                },
  281
+                {
269 282
                     "type": "MIT"
270 283
                 }
271 284
             ],
@@ -426,15 +439,15 @@
426 439
                 "1",
427 440
                 "2"
428 441
             ],
429  
-            "descriptorUrl": "http://github.com/tlrobinson/jack/raw/master/package.json",
430  
-            "packageUrl": "http://github.com/tlrobinson/jack/zipball/master",
  442
+            "descriptorUrl": "http://github.com/280north/jack/raw/master/package.json",
  443
+            "packageUrl": "http://github.com/280north/jack/zipball/master",
431 444
             "packageArchive": "zip",
432 445
             "source": {
433 446
                 "type": "github",
434  
-                "user": "tlrobinson",
  447
+                "user": "280north",
435 448
                 "packageName": "jack",
436  
-                "descriptorUrl": "http://github.com/tlrobinson/jack/raw/master/package.json",
437  
-                "url": "http://github.com/tlrobinson/jack/zipball/master",
  449
+                "descriptorUrl": "http://github.com/280north/jack/raw/master/package.json",
  450
+                "url": "http://github.com/280north/jack/zipball/master",
438 451
                 "archive": "zip"
439 452
             }
440 453
         },
@@ -451,8 +464,7 @@
451 464
             },
452 465
             "email": "george.moschovitis@gmail.com",
453 466
             "dependencies": [
454  
-                "jack",
455  
-                "template"
  467
+                "jack"
456 468
             ],
457 469
             "contributors": [
458 470
                 {
@@ -619,15 +631,15 @@
619 631
                 "dom",
620 632
                 "xmlhttprequest"
621 633
             ],
622  
-            "descriptorUrl": "http://github.com/tlrobinson/browserjs/raw/master/package.json",
623  
-            "packageUrl": "http://github.com/tlrobinson/browserjs/zipball/master",
  634
+            "descriptorUrl": "http://github.com/280north/browserjs/raw/master/package.json",
  635
+            "packageUrl": "http://github.com/280north/browserjs/zipball/master",
624 636
             "packageArchive": "zip",
625 637
             "source": {
626 638
                 "type": "github",
627  
-                "user": "tlrobinson",
  639
+                "user": "280north",
628 640
                 "packageName": "browserjs",
629  
-                "descriptorUrl": "http://github.com/tlrobinson/browserjs/raw/master/package.json",
630  
-                "url": "http://github.com/tlrobinson/browserjs/zipball/master",
  641
+                "descriptorUrl": "http://github.com/280north/browserjs/raw/master/package.json",
  642
+                "url": "http://github.com/280north/browserjs/zipball/master",
631 643
                 "archive": "zip"
632 644
             },
633 645
             "contributors": [
@@ -995,40 +1007,57 @@
995 1007
         },
996 1008
         "jsdocs": {
997 1009
             "name": "jsdocs",
998  
-            "description": "Tool for generating template-formatted, multi-page HTML (or XML, JSON, or any other text-based) documentation from commented JavaScript source code.",
  1010
+            "description": "JavaScript documentation generator. Tool for generating template-formatted, multi-page HTML (or XML, JSON, or any other text-based) documentation from commented JavaScript source code.",
  1011
+            "version": [
  1012
+                "0",
  1013
+                "1",
  1014
+                "0"
  1015
+            ],
999 1016
             "keywords": [
1000 1017
                 "jsdoc",
1001 1018
                 "documentation"
1002 1019
             ],
1003  
-            "author": {
1004  
-                "name": "Irakli Gozalishvili",
1005  
-                "url": "http://rfobic.wordpress.com/"
1006  
-            },
1007  
-            "email": "rfobic@gmail.com",
1008  
-            "lib": [
1009  
-                "lib"
  1020
+            "maintainers": [
  1021
+                {
  1022
+                    "name": "Irakli Gozalishvili",
  1023
+                    "email": "rfobic@gmail.com",
  1024
+                    "web": "http://rfobic.wordpress.com/"
  1025
+                }
1010 1026
             ],
1011  
-            "lean": [
1012  
-                "lib",
1013  
-                "engines"
  1027
+            "contributors": [
  1028
+                {
  1029
+                    "name": "Irakli Gozalishvili",
  1030
+                    "email": "rfobic@gmail.com"
  1031
+                }
1014 1032
             ],
1015  
-            "version": {
1016  
-                "label": "0.1",
1017  
-                "numeric": [
1018  
-                    0,
1019  
-                    1
1020  
-                ],
1021  
-                "status": "development"
  1033
+            "bugs": {
  1034
+                "web": "http://github.com/Gozala/jsdocs/issues/"
1022 1035
             },
1023  
-            "license": [
1024  
-                "MPL 1.1",
1025  
-                "GPL 2.0",
1026  
-                "LGPL 2.1"
  1036
+            "licenses": [
  1037
+                {
  1038
+                    "type": "MIT"
  1039
+                }
1027 1040
             ],
1028  
-            "dependencies": [
1029  
-                "syntax-stroop",
1030  
-                "seethrough"
  1041
+            "repositories": [
  1042
+                {
  1043
+                    "type": "git",
  1044
+                    "url": "git://github.com/Gozala/jsdocs.git"
  1045
+                }
  1046
+            ],
  1047
+            "os": [
  1048
+                "linux",
  1049
+                "macos",
  1050
+                "win"
  1051
+            ],
  1052
+            "cpu": [
  1053
+                "x86",
  1054
+                "ppc",
  1055
+                "x86_64"
1031 1056
             ],
  1057
+            "directories": {
  1058
+                "lib": "lib",
  1059
+                "bin": "bin"
  1060
+            },
1032 1061
             "descriptorUrl": "http://github.com/Gozala/jsdocs/raw/master/package.json",
1033 1062
             "packageUrl": "http://github.com/Gozala/jsdocs/zipball/master",
1034 1063
             "packageArchive": "zip",
@@ -1040,12 +1069,7 @@
1040 1069
                 "url": "http://github.com/Gozala/jsdocs/zipball/master",
1041 1070
                 "archive": "zip"
1042 1071
             },
1043  
-            "contributors": [
1044  
-                {
1045  
-                    "name": "Irakli Gozalishvili",
1046  
-                    "url": "http://rfobic.wordpress.com/"
1047  
-                }
1048  
-            ]
  1072
+            "dependencies": []
1049 1073
         },
1050 1074
         "syntax-stroop": {
1051 1075
             "name": "syntax-stroop",
@@ -1610,7 +1634,7 @@
1610 1634
                 "email": "sergi.mansilla@gmail.com"
1611 1635
             },
1612 1636
             "jars": [
1613  
-                "jars/mongo-0.11.jar"
  1637
+                "mongo-1.2.jar"
1614 1638
             ],
1615 1639
             "email": "sergi.mansilla@gmail.com",
1616 1640
             "dependencies": [],
@@ -1845,9 +1869,7 @@
1845 1869
         "ojunit": {
1846 1870
             "name": "ojunit",
1847 1871
             "dependencies": [
1848  
-                "narwhal",
1849  
-                "objective-j",
1850  
-                "cappuccino"
  1872
+                "narwhal"
1851 1873
             ],
1852 1874
             "author": {
1853 1875
                 "name": "Tom Robinson",
@@ -1863,6 +1885,15 @@
1863 1885
                 },
1864 1886
                 {
1865 1887
                     "name": "Martin Hacker"
  1888
+                },
  1889
+                {
  1890
+                    "name": "Derek Hammer"
  1891
+                },
  1892
+                {
  1893
+                    "name": "Francisco Tolmasky"
  1894
+                },
  1895
+                {
  1896
+                    "name": "Andrew Burkhalter"
1866 1897
                 }
1867 1898
             ],
1868 1899
             "description": "A simple Objective-J unit test framework.",
@@ -1875,6 +1906,11 @@
1875 1906
             "objj-frameworks": [
1876 1907
                 "Framework"
1877 1908
             ],
  1909
+            "version": [
  1910
+                "0",
  1911
+                "1",
  1912
+                "0"
  1913
+            ],
1878 1914
             "descriptorUrl": "http://github.com/280north/ojunit/raw/master/package.json",
1879 1915
             "packageUrl": "http://github.com/280north/ojunit/zipball/master",
1880 1916
             "packageArchive": "zip",
@@ -1885,8 +1921,7 @@
1885 1921
                 "descriptorUrl": "http://github.com/280north/ojunit/raw/master/package.json",
1886 1922
                 "url": "http://github.com/280north/ojunit/zipball/master",
1887 1923
                 "archive": "zip"
1888  
-            },
1889  
-            "version": []
  1924
+            }
1890 1925
         },
1891 1926
         "qxoo": {
1892 1927
             "name": "qxoo",
@@ -2558,8 +2593,7 @@
2558 2593
             ],
2559 2594
             "version": [
2560 2595
                 "0",
2561  
-                "0",
2562  
-                "1"
  2596
+                "2"
2563 2597
             ],
2564 2598
             "descriptorUrl": "http://github.com/280north/commonjs-shrinksafe/raw/master/package.json",
2565 2599
             "packageUrl": "http://github.com/280north/commonjs-shrinksafe/zipball/master",
@@ -2581,15 +2615,16 @@
2581 2615
             "description": "Haml ported to server-side Javascript. This is a traditional server-side templating language.",
2582 2616
             "keywords": [
2583 2617
                 "haml",
2584  
-                "template"
  2618
+                "template",
  2619
+                "nodejs"
2585 2620
             ],
2586 2621
             "author": {
2587 2622
                 "name": "Tim Caswell"
2588 2623
             },
2589 2624
             "version": [
2590 2625
                 "0",
2591  
-                "0",
2592  
-                "1"
  2626
+                "1",
  2627
+                "2"
2593 2628
             ],
2594 2629
             "descriptorUrl": "http://github.com/creationix/haml-js/raw/master/package.json",
2595 2630
             "packageUrl": "http://github.com/creationix/haml-js/zipball/master",
32  docs/lib/system.md
Source Rendered
... ...
@@ -0,0 +1,32 @@
  1
+
  2
+CommonJS Standard:
  3
+
  4
+ * `args`
  5
+ * `env`
  6
+ * `stdin`
  7
+ * `stdout`
  8
+ * `stderr`
  9
+
  10
+Bootstrap protocol:
  11
+
  12
+ * `prefixes`
  13
+ * `prefix`
  14
+ * `enginePrefix`
  15
+ * `global`
  16
+ * `engine`
  17
+ * `engines`
  18
+ * `os` =~ /\bwin(dows|nt)\b/i
  19
+ * `print`
  20
+ * `evaluate`
  21
+ * `debug`
  22
+ * `verbose`
  23
+ * `evalGlobal`
  24
+
  25
+Rhino:
  26
+
  27
+ * `originalArgs`
  28
+ * `appEngine`
  29
+ * `appEngineHosting`
  30
+ * `log` Deprecated?
  31
+ * `fs` Deprecated?
  32
+
4  docs/quick-start.md
Source Rendered
@@ -4,8 +4,8 @@ Narwhal Quick Start
4 4
 
5 5
 Download Narwhal.
6 6
 
7  
-* download and extract the [zip](http://github.com/tlrobinson/narwhal/zipball/master) or [tar](http://github.com/tlrobinson/narwhal/tarball/master) archive, or
8  
-* `git clone git://github.com/tlrobinson/narwhal.git`
  7
+* download and extract the [zip](http://github.com/280north/narwhal/zipball/master) or [tar](http://github.com/280north/narwhal/tarball/master) archive, or
  8
+* `git clone git://github.com/280north/narwhal.git`
9 9
 
10 10
 Put Narwhal on your PATH environment variable.
11 11
 
125  engines/default/lib/file-engine.js
... ...
@@ -1,122 +1,3 @@
1  
-
2  
-// -- tlrobinson Tom Robinson
3  
-// -- kriskowal Kris Kowal Copyright (C) 2009-2010 MIT License
4  
-
5  
-// HACK: use "fs.read" and "fs.isFile" until properly implemented.
6  
-// save "fs" here since it will be replaced in "system" later.
7  
-var fs = system.fs;
8  
-
9  
-var exports = require('./file');
10  
-
11  
-exports.SEPARATOR = '/';
12  
-exports.ALT_SEPARATOR = undefined;
13  
-exports.ROOT = '/';
14  
-
15  
-exports.cwd = function () {
16  
-    return system.env['PWD'] || '.';
17  
-};
18  
-
19  
-// TODO necessary for package loading
20  
-exports.list = function (path) {
21  
-    throw Error("list not yet implemented.");
22  
-};
23  
-
24  
-// TODO necessary for package loading
25  
-exports.canonical = function (path) {
26  
-    // does not resolve symlinks
27  
-    return exports.absolute(path);
28  
-};
29  
-
30  
-exports.exists = function (path) {
31  
-    throw Error("exists not yet implemented.");
32  
-};
33  
-
34  
-// TODO necessary for lazy module reloading in sandboxes
35  
-exports.mtime = function (path) {
36  
-    return Date();
37  
-};
38  
-
39  
-exports.size = function (path) {
40  
-    throw Error("size not yet implemented.");
41  
-};
42  
-
43  
-exports.stat = function (path) {
44  
-    return {
45  
-        mtime: exports.mtime(path),
46  
-        size: exports.size(path)
47  
-    }
48  
-};
49  
-
50  
-// TODO necessary for package loading
51  
-exports.isDirectory = function (path) {
52  
-    //throw Error("isDirectory not yet implemented.");
53  
-    system.log.warn("isDirectory not yet implemented. ("+path+")");
54  
-    return false;
55  
-};
56  
-
57  
-// TODO necessary for module loading
58  
-exports.isFile = function (path) {
59  
-    return fs.isFile(path);
60  
-};
61  
-
62  
-exports.isLink = function (path) {
63  
-    throw Error("isLink not yet implemented.");
64  
-};
65  
-
66  
-exports.isReadable = function (path) {
67  
-    throw Error("isReadable not yet implemented.");
68  
-};
69  
-
70  
-exports.isWritable = function (path) {
71  
-    throw Error("isWritable not yet implemented.");
72  
-};
73  
-
74  
-exports.rename = function (source, target) {
75  
-    throw Error("rename not yet implemented.");
76  
-};
77  
-
78  
-exports.move = function (source, target) {
79  
-    throw Error("move not yet implemented.");
80  
-};
81  
-
82  
-exports.remove = function (path) {
83  
-    throw Error("remove not yet implemented.");
84  
-};
85  
-
86  
-exports.mkdir = function (path) {
87  
-    throw Error("mkdir not yet implemented.");
88  
-};
89  
-
90  
-exports.rmdir = function(path) {
91  
-    throw Error("rmdir not yet implemented.");
92  
-};
93  
-
94  
-exports.touch = function (path, mtime) {
95  
-    throw Error("touch not yet implemented.");
96  
-};
97  
-
98  
-exports.FileIO = function (path, mode, permissions) {
99  
-    mode = exports.mode(mode);
100  
-    var read = mode.read,
101  
-        write = mode.write,
102  
-        append = mode.append,
103  
-        update = mode.update;
104  
-
105  
-    if (update) {
106  
-        throw new Error("Updating IO not yet implemented.");
107  
-    } else if (write || append) {
108  
-        throw new Error("Writing IO not yet implemented.");
109  
-    } else if (read) {
110  
-        // FIXME temporary hack
111  
-        return {
112  
-            'read': function () {
113  
-                return fs.read(path);
114  
-            },
115  
-            'close': function () {
116  
-            }
117  
-        };
118  
-    } else {
119  
-        throw new Error("Files must be opened either for read, write, or update mode.");
120  
-    }
121  
-};
122  
-
  1
+throw new Error(
  2
+"This module is no longer supported.  Please contact the\n" + 
  3
+"Narwhal developer team if you see this exception.");
11  engines/default/lib/system.js
@@ -8,9 +8,13 @@ exports.print = function () {
8 8
     exports.stdout.write(Array.prototype.join.call(arguments, ' ') + "\n").flush();
9 9
 };
10 10
 
11  
-exports.stdin  = new IO(function(){}, null);
12  
-exports.stdout = new IO(null, function(string) { exports.print(String(string).replace(/\n$/,"")); });
13  
-exports.stderr = new IO(null, function(string) { exports.print(String(string).replace(/\n$/,"")); });
  11
+exports.stdin  = new IO(function () {}, null);
  12
+exports.stdout = new IO(null, function(string) {
  13
+    exports.print(String(string).replace(/\n$/,""));
  14
+});
  15
+exports.stderr = new IO(null, function(string) {
  16
+    exports.print(String(string).replace(/\n$/,""));
  17
+});
14 18
 
15 19
 exports.args = global.arguments || [];
16 20
 
@@ -21,3 +25,4 @@ exports.fs = require('./file');
21 25
 // default logger
22 26
 var Logger = require("logger").Logger;
23 27
 exports.log = new Logger(exports.stderr);
  28
+
9  engines/rhino/lib/uuid.js
... ...
@@ -1,7 +1,14 @@
1 1
 
2 2
 // -- kriszyp Kris Zyp
  3
+// -- tlrobinson Tom Robinson
3 4
 
4 5
 exports.randomUUID = function(){
5  
-    return String(java.util.UUID.randomUUID())
  6
+    require("narwhal").deprecated("randomUUID is deprecated in favor of uuid");
  7
+    return String(java.util.UUID.randomUUID());
  8
+};
  9
+
  10
+// compatible with Narwhal's main UUID module
  11
+exports.uuid = function(){
  12
+    return String(java.util.UUID.randomUUID()).toUpperCase();
6 13
 };
7 14
 
66  engines/template/lib/file-engine.js
@@ -8,6 +8,9 @@ exports.SEPARATOR = '/';
8 8
 
9 9
 exports.cwd = function () {
10 10
     throw Error("cwd not yet implemented.");
  11
+    // might work if you don't implement canonical
  12
+    // in terms of cwd:
  13
+    return exports.canonical('.');
11 14
 };
12 15
 
13 16
 // TODO necessary for package loading
@@ -18,6 +21,47 @@ exports.list = function (path) {
18 21
 // TODO necessary for package loading
19 22
 exports.canonical = function (path) {
20 23
     throw Error("canonical not yet implemented.");
  24
+    // an implementation in terms of readlink, cwd, and the pure-js
  25
+    // methods provided by Narwhal's file-bootstrap, join, split,
  26
+    // and isDrive, which depends on system.os to distinguish
  27
+    // windows and unix drives
  28
+    var paths = [exports.cwd(), path];
  29
+    var outs = [];
  30
+    var prev;
  31
+    for (var i = 0, ii = paths.length; i < ii; i++) {
  32
+        var path = paths[i];
  33
+        var ins = exports.split(path);
  34
+        if (exports.isDrive(ins[0]))
  35
+            outs = [ins.shift()];
  36
+        while (ins.length) {
  37
+            var leaf = ins.shift();
  38
+            var consider = exports.join.apply(
  39
+                undefined,
  40
+                outs.concat([leaf])
  41
+            );
  42
+
  43
+            // cycle breaker; does not throw an error since every
  44
+            // invalid path must also have an intrinsic canonical
  45
+            // name.
  46
+            if (consider == prev) {
  47
+                ins.unshift.apply(ins, exports.split(link));
  48
+                break;
  49
+            }
  50
+            prev = consider;
  51
+
  52
+            try {
  53
+                var link = exports.readlink(consider);
  54
+            } catch (exception) {
  55
+                link = undefined;
  56
+            }
  57
+            if (link !== undefined) {
  58
+                ins.unshift.apply(ins, exports.split(link));
  59
+            } else {
  60
+                outs.push(leaf)
  61
+            }
  62
+        }
  63
+    }
  64
+    return exports.join.apply(undefined, outs);
21 65
 };
22 66
 
23 67
 exports.exists = function (path) {
@@ -34,6 +78,9 @@ exports.size = function (path) {
34 78
 };
35 79
 
36 80
 exports.stat = function (path) {
  81
+    throw Error("stat not yet implemented.");
  82
+    // this might work if you've got mtime and size implemented
  83
+    // separately.  this isn't a complete stat implementation.
37 84
     return {
38 85
         mtime: exports.mtime(path),
39 86
         size: exports.size(path)
@@ -48,12 +95,11 @@ exports.isDirectory = function (path) {
48 95
 // TODO necessary for module loading
49 96
 exports.isFile = function (path) {
50 97
     throw Error("isFile not yet implemented.");
  98
+    // XXX note that isFile is one of the routines
  99
+    // probably at least partially implemented by
  100
+    // the partial "file" module injected by the
  101
+    // engine bootstrap.js.
51 102
 };
52  
-// XXX remove this if you implement isFile here
53  
-// from bootstrap system object:
54  
-exports.isFile = system.fs.isFile;
55  
-
56  
-exports.isFile = system.fs.isFile; // TEMPORARY HACK
57 103
 
58 104
 exports.isLink = function (path) {
59 105
     throw Error("isLink not yet implemented.");
@@ -91,8 +137,14 @@ exports.touch = function (path, mtime) {
91 137
     throw Error("touch not yet implemented.");
92 138
 };
93 139
 
94  
-// FIXME temporary hack
95  
-var read = system.fs.read; // from bootstrap system object
  140
+exports.read = function (path) {
  141
+    throw Error("read not yet implemented.");
  142
+    // XXX Note: read is one of the methods that was
  143
+    // at least partially implemented in the engine's
  144
+    // bootstrap.js.  you might take advanage of that
  145
+    // at least temporarily; until you can implement
  146
+    // read in terms of open(path).read()
  147
+};
96 148
 
97 149
 exports.FileIO = function (path, mode, permissions) {
98 150
     mode = exports.mode(mode);
15  lib/args.js
@@ -326,7 +326,7 @@ exports.Parser.prototype.check = function () {
326 326
 
327 327
 // TODO break this into sub-functions
328 328
 // TODO wrap with a try catch and print the progress through the arguments
329  
-exports.Parser.prototype.parse = function (args, options, noCommand) {
  329
+exports.Parser.prototype.parse = function (args, options, noCommand, allowInterleaved) {
330 330
     var self = this;
331 331
 
332 332
     this.check();
@@ -377,6 +377,8 @@ exports.Parser.prototype.parse = function (args, options, noCommand) {
377 377
             options[option.getName()] = option._def;
378 378
     });
379 379
 
  380
+    var interleavedArgs = [];
  381
+
380 382
     // walk args
381 383
     ARGS: while (args.length) {
382 384
         var arg = args.shift();
@@ -466,15 +468,16 @@ exports.Parser.prototype.parse = function (args, options, noCommand) {
466 468
             }
467 469
 
468 470
         } else {
469  
-            // TODO permit options interleaved with arguments,
470  
-            //  with associated actions, for any of positional
471  
-            //  args, variadic args, and accumulated args
472  
-            args.unshift(arg);
473  
-            break;
  471
+            interleavedArgs.push(arg);
  472
+            if (!allowInterleaved)
  473
+                break;
474 474
         }
475 475
 
476 476
     }
477 477
 
  478
+    // add the interleaved arguments back in
  479
+    args.unshift.apply(args, interleavedArgs)
  480
+
478 481
     if (util.len(this._commands)) {
479 482
         if (args.length) {
480 483
             if (util.has(this._commands, args[0])) {
2  lib/base16.js
@@ -9,7 +9,7 @@ var struct = require('struct');
9 9
 exports.encode = function (n) {
10 10
     var length = n.length;
11 11
     var result = [];
12  
-    var alphabet = struct.alphabet16Lower;
  12
+    var alphabet = struct.alphabet16Upper;
13 13
     for (var i = 0; i < length; i++) {
14 14
         n[i] = n[i] & 0xFF;
15 15
         result.push(alphabet[(n.charCodeAt(i) >>> 4) & 0xF], alphabet[n.charCodeAt(i) & 0xF]);
13  lib/http-client.js
@@ -14,6 +14,7 @@ var newTransactionId = (function () {
14 14
         return id ++;
15 15
     };
16 16
 })();
  17
+
17 18
 var transaction = (function () {
18 19
     var hidden = {};
19 20
     return function (id, del) {
@@ -26,7 +27,6 @@ var transaction = (function () {
26 27
     };
27 28
 })();
28 29
 
29  
-
30 30
 // {method, url, headers, body}
31 31
 // return value is {status:status, headers:{..}, body:[..]}
32 32
 function HttpClient (settings) {
@@ -36,6 +36,7 @@ function HttpClient (settings) {
36 36
 };
37 37
 
38 38
 HttpClient.prototype = {
  39
+
39 40
     create : function HttpClient_create () {
40 41
         // clean up, set up defaults.
41 42
         transaction(this.txId, true);
@@ -47,12 +48,14 @@ HttpClient.prototype = {
47 48
         });
48 49
         return this;
49 50
     },
  51
+
50 52
     setOptions : function HttpClient_setOption (settings) {
51 53
         for (var key in settings)  if (settings.hasOwnProperty(key)) {
52 54
             this.setOption(key, settings[key]);
53 55
         }
54 56
         return this;
55 57
     },
  58
+
56 59
     setOption : function HttpClient_setOption (key, val) {
57 60
         var guts = transaction(this.txId);
58 61
         switch (key) {
@@ -71,18 +74,21 @@ HttpClient.prototype = {
71 74
         }
72 75
         return this;
73 76
     },
  77
+
74 78
     setHeaders : function HttpClient_setHeaders (headers) {
75 79
         for (var h in headers) if (headers.hasOwnProperty(h)) {
76 80
             this.setHeader(h, headers[h]);
77 81
         }
78 82
         return this;
79 83
     },
  84
+
80 85
     setHeader : function HttpClient_setHeader (key, val) {
81 86
         var guts = transaction(this.txId);
82 87
         if (!guts.hasOwnProperty("headers")) guts.headers = {};
83 88
         HashP.set(guts.headers, key, val);
84 89
         return this;
85 90
     },
  91
+
86 92
     write : function HttpClient_write (data) {
87 93
         var guts = transaction(this.txId);
88 94
         var len = HashP.get(guts.headers, "Content-Length") || 0;
@@ -91,6 +97,7 @@ HttpClient.prototype = {
91 97
         guts.body.push(data);
92 98
         return this;
93 99
     },
  100
+
94 101
     connect : function HttpClient_connect (decode) {
95 102
         var guts = transaction(this.txId);
96 103
         var resp = engine.connect(guts);
@@ -98,7 +105,9 @@ HttpClient.prototype = {
98 105
         transaction(this.txId, true);
99 106
         return resp;
100 107
     }
  108
+
101 109
 };
  110
+
102 111
 HttpClient.decode = function HttpClient_decode (resp, encoding) {
103 112
     encoding = encoding || HashP.get(resp.headers, "Content-Encoding");
104 113
     if (!encoding) {
@@ -119,11 +128,13 @@ HttpClient.decode = function HttpClient_decode (resp, encoding) {
119 128
     }};
120 129
     return resp;
121 130
 };
  131
+
122 132
 HttpClient.undecode = function HttpClient_undecode (resp) {
123 133
     if ("_rawBody" in resp) resp.body = resp._rawBody;
124 134
     delete resp._rawBody;
125 135
     return resp;
126 136
 };
  137
+
127 138
 HttpClient.print = function HttpClient_print (resp) {
128 139
     var out = [];
129 140
     out.push(resp.statusText);
18  lib/loader.js
@@ -14,6 +14,7 @@ var file = require(/**/"file"/**/);
14 14
 // this gets swapped out with a full fledged-read before
15 15
 //  we're done using it
16 16
 var read = file.read;
  17
+var Module = system.Module || system.evaluate; // legacy
17 18
 
18 19
 exports.Loader = function (options) {
19 20
     var loader = {};
@@ -60,15 +61,24 @@ exports.Loader = function (options) {
60 61
         return text;
61 62
     };
62 63
 
63  
-    loader.evaluate = function (text, topId, path) {
  64
+    loader.Module = function (text, topId, path) {
64 65
         if (system.evaluate) {
65 66
             if (!path)
66 67
                 path = loader.find(topId);
67  
-            var factory = system.evaluate(text, path, 1);
  68
+            var factory = Module(text, path, 1);
68 69
             factory.path = path;
69 70
             return factory;
70 71
         } else {
71  
-            return new Function("with(arguments[0]){"+text+"\n//*/}");
  72
+            return function (inject) {
  73
+                var keys = [], values = [];
  74
+                for (var key in inject) {
  75
+                    if (Object.prototype.hasOwnProperty.call(inject, key)) {
  76
+                        keys.push(key);
  77
+                        values.push(inject[key]);
  78
+                    }
  79
+                }
  80
+                return Function.apply(null, keys).apply(this, values);
  81
+            };
72 82
         }
73 83
     };
74 84
 
@@ -84,7 +94,7 @@ exports.Loader = function (options) {
84 94
     };
85 95
 
86 96
     loader.reload = function (topId, path) {
87  
-        factories[topId] = loader.evaluate(loader.fetch(topId, path), topId, path);
  97
+        factories[topId] = loader.Module(loader.fetch(topId, path), topId, path);
88 98
     };
89 99
 
90 100
     loader.isLoaded = function (topId) {
12  lib/narwhal.js
@@ -61,7 +61,7 @@ parser.option('-d', '--debug', 'debug')
61 61
     .inc();
62 62
 
63 63
 parser.option('-v', '--verbose', 'verbose')
64  
-    .help("verbose mode: trace module loads. \0bold(\0green(-vv\0)\0) for all 'require' calls.")
  64
+    .help("verbose mode: trace module loads. \0bold(\0green(-vv\0)\0) for all 'require' calls")
65 65
     .def(0)
66 66
     .inc();
67 67
 
@@ -80,12 +80,18 @@ parser.option('-l', '--log', 'level')
80 80
     .choices({'critical': 0, 'error': 1, 'warn': 2, 'info': 3, 'debug': 4});
81 81
 
82 82
 parser.option('-V', '--version')
83  
-    .help("print Narwhal version number and exit.")
  83
+    .help("print Narwhal version number and exit")
84 84
     .action(function () {
85  
-        this.print("Narwhal Version 0.");
  85
+        this.print("Narwhal Version 0");
86 86
         this.exit();
87 87
     });
88 88
 
  89
+parser.option('--no-term')
  90
+    .help("disables terminal coloring (term module)")
  91
+    .action(function () {
  92
+        require("term").stream.disable();
  93
+    });
  94
+
89 95
 parser.option('-O', 'optimize').inc().hidden();
90 96
 
91 97
 parser.option('--narwhal')
73  lib/narwhal/tusk/commands/install.js
@@ -10,6 +10,8 @@ var json = require("json");
10 10
 var http = require("http");
11 11
 var zip = require("zip");
12 12
 var packages = require("packages");
  13
+var URI = require("uri");
  14
+var UUID = require("uuid");
13 15
 
14 16
 var parser = exports.parser = new args.Parser();
15 17
 
@@ -41,7 +43,7 @@ parser.action(function (options) {
41 43
 });
42 44
 
43 45
 exports.install = function (options, names) {
44  
-    
  46
+
45 47
     var localSourcePath = fs.cwdPath();
46 48
 
47 49
     if (!tusk.getCatalogPath().isFile()) {
@@ -63,25 +65,51 @@ exports.install = function (options, names) {
63 65
         return;
64 66
     }
65 67
 
  68
+    // download remote zips
  69
+    // TODO: detect tars?
  70
+    var names = names.map(function (name) {
  71
+        var uri = URI.parse(name);
  72
+        if (uri.scheme === "http" || uri.scheme === "https") {
  73
+            var zipFile = tusk.getZipsDirectory().join(UUID.uuid()+".zip");
  74
+            var zipData = http.read(name, 'b');
  75
+            zipFile.write(zipData, 'b');
  76
+            cleanupPaths.push(zipFile);
  77
+
  78
+            return zipFile.toString();
  79
+        }
  80
+        return name;
  81
+    });
  82
+
66 83
     // validate the requested names against those
67 84
     //  in the catalog of downloadable packages.
68 85
     var names = names.map(function (name) {
69 86
         var localPath = fs.path(fs.absolute(name).replace(/\/$/, "")); // FIXME: basename/dirname broken with trailing slash
70 87
         var localPackagePath = localPath.join("package.json");
71  
-        if (localPackagePath.isFile()) {
72  
-            var packageData = json.decode(localPackagePath.read({charset: 'utf-8'}));
  88
+        if (name.match(/\.zip$/) && localPath.isFile()) {
  89
+            var packageName = null;
  90
+            new zip.Unzip(localPath).forEach(function (entry) {
  91
+                if (!packageName && entry.getName().match(/^[^\/]+\/package.json/)) {
  92
+                    var packageData = json.decode(entry.read('b').decodeToString("UTF-8"));
  93
+                    packageName = packageData.name || String(localPath.basename());
  94
+
  95
+                    packageData.packageUrl = "file://" + localPath;
  96
+                    catalog.packages[packageName] = packageData;
  97
+                }
  98
+            });
  99
+            return packageName;
  100
+        }
  101
+        else if (localPackagePath.isFile()) {
  102
+            var packageData = json.decode(localPackagePath.read({charset: 'UTF-8'}));
73 103
             var packageName = packageData.name || String(localPath.basename());
74  
-            
  104
+
75 105
             packageData.packageUrl = "file://" + localPath;
76  
-            packageData.type = "directory";
77  
-            
78 106
             catalog.packages[packageName] = packageData;
79 107
             return packageName;
80 108
         } else if (util.has(catalog.packages, name)) {
81 109
             // nothing to do.
82 110
             return name;
83 111
         }
84  
-        
  112
+
85 113
         parser.print("ERROR: Package not found: " + util.enquote(name));
86 114
         return null;
87 115
     }).filter(function(name) { return !!name; });
@@ -118,7 +146,7 @@ exports.install = function (options, names) {
118 146
 
119 147
     // note missing packages
120 148
     var missing = exports.missing(packages.catalog, dependencies);
121  
-    
  149
+
122 150
     // add forced packages back in
123 151
     if (options.force) {
124 152
         names.forEach(function(name) {
@@ -126,18 +154,18 @@ exports.install = function (options, names) {
126 154
                 missing.push(name);
127 155
         });
128 156
     }
129  
-    
  157
+
130 158
     if (!missing.length) {
131 159
         print('No new packages to install.');
132 160
         this.exit();
133 161
     }
134  
-    print('The following packages will be downloaded and installed:');
  162
+    print('The following packages will be installed:');
135 163
     printUl(missing);
136 164
 
137 165
     // download missing packages
138 166
     var zipsDirectory = tusk.getZipsDirectory();
139 167
     zipsDirectory.mkdirs();
140  
-    
  168
+
141 169
     missing.forEach(function (name) {
142 170
         if (/^file:\/\//.test(catalog.packages[name].packageUrl)) {
143 171
             print('Local package: ' + name);
@@ -145,7 +173,7 @@ exports.install = function (options, names) {
145 173
         }
146 174
         var info = catalog.packages[name];
147 175
         print('Downloading: ' + info.packageUrl);
148  
-        if (options.simulate) 
  176
+        if (options.simulate)
149 177
             return;
150 178
         var zipFile = zipsDirectory.join(name + '.zip')
151 179
         if (options.resume && zipFile.isFile())
@@ -173,27 +201,30 @@ exports.install = function (options, names) {
173 201
                     return;
174 202
                 }
175 203
             }
176  
-            
  204
+
177 205
             var components = catalog.packages[name].packageUrl.match(/^file:\/\/(.*)$/);
178  
-            if (components) {
179  
-                var sourcePath = components[1];
  206
+            var sourcePath =  components ? components[1] : zipsDirectory.join(name + '.zip');
  207
+
  208
+            if (!sourcePath.match(/\.zip$/)) {
180 209
                 print('Copying: ' + sourcePath);
181 210
                 if (options.simulate)
182 211
                     return;
183 212
 
184 213
                 fs.copyTree(sourcePath, targetPath);
185 214
 
186  
-                var files = targetPath.listTree().filter(function(f) { return targetPath.join(f).isFile(); });
187  
-                print(" + " + files.join("\n + "));
188  
-                notes[name].files.push.apply(notes[name].files.push, files);
  215
+                targetPath.listTree().forEach(function(f) {
  216
+                    if (targetPath.join(f).isFile()) {
  217
+                        print(" + " + f);
  218
+                        notes[name].files.push(f);
  219
+                    }
  220
+                });
189 221
             } else {
190  
-                var zipFile = zipsDirectory.join(name + '.zip');
191  
-                print('Unzipping: ' + zipFile);
  222
+                print('Unzipping: ' + sourcePath);
192 223
                 if (options.simulate)
193 224
                     return;
194 225
 
195 226
                 // unzip
196  
-                new zip.Unzip(zipFile).forEach(function (entry) {
  227
+                new zip.Unzip(sourcePath).forEach(function (entry) {
197 228
                     if (entry.isDirectory())
198 229
                         return;
199 230
                     var parts = fs.split(entry.getName());
3  narwhal.js
@@ -58,7 +58,6 @@ var requireFake = function(id, path, force) {
58 58
     var exports = modules[id] = modules[id] || {};
59 59
     var module = {id: id, path: path};
60 60
 
61  
-
62 61
     var factory = system.evaluate(file.read(path), path, 1);
63 62
     factory({
64 63
         require: requireFake,
@@ -128,9 +127,9 @@ try {
128 127
 }
129 128
 
130 129
 // load the complete system module
131  
-require.force("system");
132 130
 require.force("file");
133 131
 require.force("file-engine");
  132
+require.force("system");
134 133
 
135 134
 // augment the path search array with those provided in
136 135
 //  environment variables
8  sources.json
@@ -3,11 +3,11 @@
3 3
     "sources": {
4 4
         "narwhal": {
5 5
             "type": "github",
6  
-            "user": "tlrobinson"
  6
+            "user": "280north"
7 7
         },
8 8
         "narwhal-jsc": {
9 9
             "type": "github",
10  
-            "user": "tlrobinson"
  10
+            "user": "280north"
11 11
         },
12 12
         "narwhal-v8": {
13 13
             "type": "github",
@@ -31,7 +31,7 @@
31 31
         },
32 32
         "jack": {
33 33
             "type": "github",
34  
-            "user": "tlrobinson"
  34
+            "user": "280north"
35 35
         },
36 36
         "nitro": {
37 37
             "type": "github",
@@ -51,7 +51,7 @@
51 51
         },
52 52
         "browserjs": {
53 53
             "type": "github",
54  
-            "user": "tlrobinson"
  54
+            "user": "280north"
55 55
         },
56 56
         "inspec": {
57 57
             "type": "github",
5  tests/commonjs/es5/date-regression.js
... ...
@@ -0,0 +1,5 @@
  1
+
  2
+exports.testDate = function (ASSERT) {
  3
+    ASSERT.equal(new Date(1970, 0, 1), "Thu Jan 01 1970 00:00:00 GMT-0800 (PST)");
  4
+};
  5
+

0 notes on commit 806c074

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