sc-docs 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. data/.gitignore +4 -0
  2. data/.gitmodules +3 -0
  3. data/Gemfile +5 -0
  4. data/Gemfile.lock +48 -0
  5. data/LICENSE +21 -0
  6. data/README.md +59 -0
  7. data/bin/sc-docs +5 -0
  8. data/lib/sc_docs.rb +3 -0
  9. data/lib/sc_docs/cli.rb +54 -0
  10. data/lib/sc_docs/docs/Buildfile +8 -0
  11. data/lib/sc_docs/docs/README +8 -0
  12. data/lib/sc_docs/docs/apps/docs/Buildfile +15 -0
  13. data/lib/sc_docs/docs/apps/docs/controllers/classes.js +27 -0
  14. data/lib/sc_docs/docs/apps/docs/controllers/search_controller.js +62 -0
  15. data/lib/sc_docs/docs/apps/docs/controllers/selected_class.js +143 -0
  16. data/lib/sc_docs/docs/apps/docs/core.js +148 -0
  17. data/lib/sc_docs/docs/apps/docs/main.js +41 -0
  18. data/lib/sc_docs/docs/apps/docs/models/class.js +63 -0
  19. data/lib/sc_docs/docs/apps/docs/models/entity.js +29 -0
  20. data/lib/sc_docs/docs/apps/docs/models/method.js +79 -0
  21. data/lib/sc_docs/docs/apps/docs/models/property.js +48 -0
  22. data/lib/sc_docs/docs/apps/docs/resources/images/method_icon.png +0 -0
  23. data/lib/sc_docs/docs/apps/docs/resources/images/property_icon.png +0 -0
  24. data/lib/sc_docs/docs/apps/docs/resources/loading.rhtml +9 -0
  25. data/lib/sc_docs/docs/apps/docs/resources/main_page.css +156 -0
  26. data/lib/sc_docs/docs/apps/docs/resources/main_page.js +91 -0
  27. data/lib/sc_docs/docs/apps/docs/resources/templates/details.handlebars +81 -0
  28. data/lib/sc_docs/docs/apps/docs/resources/templates/extensions/signature.js +0 -0
  29. data/lib/sc_docs/docs/apps/docs/system/jquery_ui.js +62 -0
  30. data/lib/sc_docs/docs/apps/docs/system/showdown.js +1297 -0
  31. data/lib/sc_docs/docs/apps/docs/theme.js +29 -0
  32. data/lib/sc_docs/docs/apps/docs/views/detail_list.js +24 -0
  33. data/lib/sc_docs/docs/apps/docs/views/master_list.js +35 -0
  34. data/lib/sc_docs/docs/apps/docs/views/methods_collection.js +80 -0
  35. data/lib/sc_docs/docs/apps/docs/views/properties_collection.js +9 -0
  36. data/lib/sc_docs/generator.rb +145 -0
  37. data/lib/sc_docs/server.rb +21 -0
  38. data/lib/sc_docs/templates/docs.sproutcore.com/allclasses.tmpl +31 -0
  39. data/lib/sc_docs/templates/docs.sproutcore.com/allfiles.tmpl +66 -0
  40. data/lib/sc_docs/templates/docs.sproutcore.com/class.tmpl +437 -0
  41. data/lib/sc_docs/templates/docs.sproutcore.com/index.tmpl +52 -0
  42. data/lib/sc_docs/templates/docs.sproutcore.com/output/css/api.css +619 -0
  43. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/apidocs.jpg +0 -0
  44. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/apidocs.png +0 -0
  45. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/clearinput.png +0 -0
  46. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/cross.png +0 -0
  47. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/ddiagonal.png +0 -0
  48. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/diagonal.png +0 -0
  49. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/docbullet.jpg +0 -0
  50. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/docbullet.png +0 -0
  51. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/glow.png +0 -0
  52. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/logo.png +0 -0
  53. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/pixels.png +0 -0
  54. data/lib/sc_docs/templates/docs.sproutcore.com/output/img/search.png +0 -0
  55. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/api.js +134 -0
  56. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/jquery-bbq.js +18 -0
  57. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/lib/jquery-1.5.1.min.js +16 -0
  58. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/lib/modernizr-1.7.min.js +2 -0
  59. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/plugin.js +1 -0
  60. data/lib/sc_docs/templates/docs.sproutcore.com/output/js/script.js +5 -0
  61. data/lib/sc_docs/templates/docs.sproutcore.com/publish.js +200 -0
  62. data/lib/sc_docs/templates/docs.sproutcore.com/static/default.css +300 -0
  63. data/lib/sc_docs/templates/docs.sproutcore.com/static/header.html +19 -0
  64. data/lib/sc_docs/templates/docs.sproutcore.com/static/index.html +19 -0
  65. data/lib/sc_docs/templates/docs.sproutcore.com/symbol.tmpl +35 -0
  66. data/lib/sc_docs/templates/sc_fixture/publish.js +632 -0
  67. data/lib/sc_docs/version.rb +4 -0
  68. data/sc_docs.gemspec +27 -0
  69. data/vendor/jsdoc/README.txt +109 -0
  70. data/vendor/jsdoc/app/frame.js +33 -0
  71. data/vendor/jsdoc/app/frame/Chain.js +102 -0
  72. data/vendor/jsdoc/app/frame/Dumper.js +144 -0
  73. data/vendor/jsdoc/app/frame/Hash.js +84 -0
  74. data/vendor/jsdoc/app/frame/Link.js +173 -0
  75. data/vendor/jsdoc/app/frame/Namespace.js +10 -0
  76. data/vendor/jsdoc/app/frame/Opt.js +134 -0
  77. data/vendor/jsdoc/app/frame/Reflection.js +26 -0
  78. data/vendor/jsdoc/app/frame/String.js +93 -0
  79. data/vendor/jsdoc/app/frame/Testrun.js +129 -0
  80. data/vendor/jsdoc/app/handlers/FOODOC.js +26 -0
  81. data/vendor/jsdoc/app/handlers/XMLDOC.js +26 -0
  82. data/vendor/jsdoc/app/handlers/XMLDOC/DomReader.js +159 -0
  83. data/vendor/jsdoc/app/handlers/XMLDOC/XMLDoc.js +16 -0
  84. data/vendor/jsdoc/app/handlers/XMLDOC/XMLParse.js +292 -0
  85. data/vendor/jsdoc/app/lib/JSDOC.js +106 -0
  86. data/vendor/jsdoc/app/lib/JSDOC/DocComment.js +204 -0
  87. data/vendor/jsdoc/app/lib/JSDOC/DocTag.js +294 -0
  88. data/vendor/jsdoc/app/lib/JSDOC/JsDoc.js +140 -0
  89. data/vendor/jsdoc/app/lib/JSDOC/JsPlate.js +109 -0
  90. data/vendor/jsdoc/app/lib/JSDOC/Lang.js +144 -0
  91. data/vendor/jsdoc/app/lib/JSDOC/Parser.js +146 -0
  92. data/vendor/jsdoc/app/lib/JSDOC/PluginManager.js +33 -0
  93. data/vendor/jsdoc/app/lib/JSDOC/Symbol.js +644 -0
  94. data/vendor/jsdoc/app/lib/JSDOC/SymbolSet.js +243 -0
  95. data/vendor/jsdoc/app/lib/JSDOC/TextStream.js +41 -0
  96. data/vendor/jsdoc/app/lib/JSDOC/Token.js +18 -0
  97. data/vendor/jsdoc/app/lib/JSDOC/TokenReader.js +332 -0
  98. data/vendor/jsdoc/app/lib/JSDOC/TokenStream.js +133 -0
  99. data/vendor/jsdoc/app/lib/JSDOC/Util.js +32 -0
  100. data/vendor/jsdoc/app/lib/JSDOC/Walker.js +507 -0
  101. data/vendor/jsdoc/app/main.js +111 -0
  102. data/vendor/jsdoc/app/plugins/commentSrcJson.js +20 -0
  103. data/vendor/jsdoc/app/plugins/frameworkPrototype.js +16 -0
  104. data/vendor/jsdoc/app/plugins/functionCall.js +10 -0
  105. data/vendor/jsdoc/app/plugins/publishSrcHilite.js +62 -0
  106. data/vendor/jsdoc/app/plugins/symbolLink.js +10 -0
  107. data/vendor/jsdoc/app/plugins/tagParamConfig.js +31 -0
  108. data/vendor/jsdoc/app/plugins/tagSynonyms.js +43 -0
  109. data/vendor/jsdoc/app/run.js +297 -0
  110. data/vendor/jsdoc/app/t/TestDoc.js +144 -0
  111. data/vendor/jsdoc/app/t/runner.js +13 -0
  112. data/vendor/jsdoc/app/test.js +342 -0
  113. data/vendor/jsdoc/app/test/addon.js +24 -0
  114. data/vendor/jsdoc/app/test/anon_inner.js +14 -0
  115. data/vendor/jsdoc/app/test/augments.js +31 -0
  116. data/vendor/jsdoc/app/test/augments2.js +26 -0
  117. data/vendor/jsdoc/app/test/borrows.js +46 -0
  118. data/vendor/jsdoc/app/test/borrows2.js +23 -0
  119. data/vendor/jsdoc/app/test/config.js +22 -0
  120. data/vendor/jsdoc/app/test/constructs.js +18 -0
  121. data/vendor/jsdoc/app/test/encoding.js +10 -0
  122. data/vendor/jsdoc/app/test/encoding_other.js +12 -0
  123. data/vendor/jsdoc/app/test/event.js +54 -0
  124. data/vendor/jsdoc/app/test/exports.js +14 -0
  125. data/vendor/jsdoc/app/test/functions_anon.js +39 -0
  126. data/vendor/jsdoc/app/test/functions_nested.js +33 -0
  127. data/vendor/jsdoc/app/test/global.js +13 -0
  128. data/vendor/jsdoc/app/test/globals.js +25 -0
  129. data/vendor/jsdoc/app/test/ignore.js +10 -0
  130. data/vendor/jsdoc/app/test/inner.js +16 -0
  131. data/vendor/jsdoc/app/test/jsdoc_test.js +477 -0
  132. data/vendor/jsdoc/app/test/lend.js +33 -0
  133. data/vendor/jsdoc/app/test/memberof.js +19 -0
  134. data/vendor/jsdoc/app/test/memberof2.js +38 -0
  135. data/vendor/jsdoc/app/test/memberof3.js +33 -0
  136. data/vendor/jsdoc/app/test/memberof_constructor.js +17 -0
  137. data/vendor/jsdoc/app/test/module.js +17 -0
  138. data/vendor/jsdoc/app/test/multi_methods.js +25 -0
  139. data/vendor/jsdoc/app/test/name.js +19 -0
  140. data/vendor/jsdoc/app/test/namespace_nested.js +23 -0
  141. data/vendor/jsdoc/app/test/nocode.js +13 -0
  142. data/vendor/jsdoc/app/test/oblit_anon.js +20 -0
  143. data/vendor/jsdoc/app/test/overview.js +20 -0
  144. data/vendor/jsdoc/app/test/param_inline.js +37 -0
  145. data/vendor/jsdoc/app/test/params_optional.js +8 -0
  146. data/vendor/jsdoc/app/test/prototype.js +17 -0
  147. data/vendor/jsdoc/app/test/prototype_nested.js +9 -0
  148. data/vendor/jsdoc/app/test/prototype_oblit.js +13 -0
  149. data/vendor/jsdoc/app/test/prototype_oblit_constructor.js +24 -0
  150. data/vendor/jsdoc/app/test/public.js +10 -0
  151. data/vendor/jsdoc/app/test/scripts/code.js +5 -0
  152. data/vendor/jsdoc/app/test/scripts/notcode.txt +5 -0
  153. data/vendor/jsdoc/app/test/shared.js +42 -0
  154. data/vendor/jsdoc/app/test/shared2.js +2 -0
  155. data/vendor/jsdoc/app/test/shortcuts.js +22 -0
  156. data/vendor/jsdoc/app/test/static_this.js +13 -0
  157. data/vendor/jsdoc/app/test/synonyms.js +31 -0
  158. data/vendor/jsdoc/app/test/tosource.js +23 -0
  159. data/vendor/jsdoc/app/test/variable_redefine.js +14 -0
  160. data/vendor/jsdoc/changes.txt +127 -0
  161. data/vendor/jsdoc/conf/sample.conf +31 -0
  162. metadata +240 -0
@@ -0,0 +1,4 @@
1
+ module ScDocs
2
+ VERSION = "0.0.1"
3
+ end
4
+
@@ -0,0 +1,27 @@
1
+ lib = File.expand_path('../lib/', __FILE__)
2
+ $:.unshift lib unless $:.include?(lib)
3
+
4
+ require 'sc_docs/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "sc-docs"
8
+ s.version = ScDocs::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.authors = ["Majd Taby", "Peter Wagenet"]
11
+ s.email = ["majd@sproutcore.com", "peterw@sproutcore.com"]
12
+ s.homepage = "http://sproutcore.com"
13
+ s.summary = %q{Docs Generator for SproutCore}
14
+ s.description = %q{A tool to generate docs for SproutCore and SproutCore applications.}
15
+
16
+ s.required_rubygems_version = ">= 1.3.6"
17
+
18
+ s.add_dependency "thor"
19
+ s.add_dependency "rack"
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = %w(sc-docs)
24
+ s.require_paths = ["lib"]
25
+ end
26
+
27
+
@@ -0,0 +1,109 @@
1
+ ======================================================================
2
+
3
+ DESCRIPTION:
4
+
5
+ This is the source code for JsDoc Toolkit, an automatic documentation
6
+ generation tool for JavaScript. It is written in JavaScript and is run
7
+ from a command line (or terminal) using the Node.JS JavaScript runtime
8
+ engine.
9
+
10
+ Using this tool you can automatically turn JavaDoc-like comments in
11
+ your JavaScript source code into published output files, such as HTML
12
+ or XML.
13
+
14
+ For more information, to report a bug, or to browse the technical
15
+ documentation for this tool please visit the official JsDoc Toolkit
16
+ project homepage at http://code.google.com/p/jsdoc-toolkit/
17
+
18
+ For the most up-to-date documentation on JsDoc Toolkit see the
19
+ official wiki at http://code.google.com/p/jsdoc-toolkit/w/list
20
+
21
+ ======================================================================
22
+
23
+ REQUIREMENTS:
24
+
25
+ Node.JS interpreter http://nodejs.org
26
+
27
+ ======================================================================
28
+
29
+ USAGE:
30
+
31
+ Before running the JsDoc Toolkit app you should change your current
32
+ working directory to the jsdoc-toolkit folder. Then follow the
33
+ examples below, or as shown on the project wiki.
34
+
35
+ On Mac OS X or Linux the command would look like this:
36
+
37
+ $ app/run.js -a -t=templates/jsdoc mycode.js
38
+
39
+ The above assumes your current working directory contains the "app"
40
+ and "templates" subdirectories from the standard JsDoc Toolkit
41
+ distribution and that the relative path to the code you wish to
42
+ document is "mycode.js".
43
+
44
+ The output documentation files will be saved to a new directory named
45
+ "out" (by default) in the current directory, or if you specify a
46
+ -d=somewhere_else option, to the somewhere_else directory.
47
+
48
+ For help (usage notes) enter this on the command line:
49
+
50
+ $ app/run.js --help
51
+
52
+ More information about the various command line options used by JsDoc
53
+ Toolkit are available on the project wiki.
54
+
55
+ ======================================================================
56
+
57
+ TESTING:
58
+
59
+ To run the suite of unit tests included with JsDoc Toolkit enter this
60
+ on the command line:
61
+
62
+ $ app/run.js -T
63
+
64
+ To see a dump of the internal data structure that JsDoc Toolkit has
65
+ built from your source files use this command:
66
+
67
+ $ app/run.js mycode.js -Z
68
+
69
+ ======================================================================
70
+
71
+ LICENSE:
72
+
73
+ JSDoc.pm
74
+
75
+ This project is based on the JSDoc.pm tool, created by Michael
76
+ Mathews and Gabriel Reid. More information on JsDoc.pm can
77
+ be found on the JSDoc.pm homepage: http://jsdoc.sourceforge.net/
78
+
79
+ Complete documentation on JsDoc Toolkit can be found on the project
80
+ wiki at http://code.google.com/p/jsdoc-toolkit/w/list
81
+
82
+ JsDoc Toolkit
83
+
84
+ All code specific to JsDoc Toolkit are free, open source and licensed
85
+ for use under the X11/MIT License.
86
+
87
+ JsDoc Toolkit is Copyright (c)2009 Michael Mathews <micmath@gmail.com>
88
+ Additional portions are Copyright (c)2010 Aaron Wirtz <me@awirtz.com>
89
+
90
+ This program is free software; you can redistribute it and/or
91
+ modify it under the terms below.
92
+
93
+ Permission is hereby granted, free of charge, to any person obtaining
94
+ a copy of this software and associated documentation files (the
95
+ "Software"), to deal in the Software without restriction, including
96
+ without limitation the rights to use, copy, modify, merge, publish,
97
+ distribute, sublicense, and/or sell copies of the Software, and to
98
+ permit persons to whom the Software is furnished to do so, subject to
99
+ the following conditions: The above copyright notice and this
100
+ permission notice must be included in all copies or substantial
101
+ portions of the Software.
102
+
103
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
104
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
105
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
106
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
107
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
108
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
109
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,33 @@
1
+ IO.include("frame/Opt.js");
2
+ IO.include("frame/Chain.js");
3
+ IO.include("frame/Link.js");
4
+ IO.include("frame/String.js");
5
+ IO.include("frame/Hash.js");
6
+ IO.include("frame/Namespace.js");
7
+ //IO.include("frame/Reflection.js");
8
+
9
+ /** A few helper functions to make life a little easier. */
10
+
11
+ function defined(o) {
12
+ return (o !== undefined);
13
+ }
14
+
15
+ function copy(o) { // todo check for circular refs
16
+ if (o == null || typeof(o) != 'object') return o;
17
+ var c = new o.constructor();
18
+ for(var p in o) c[p] = copy(o[p]);
19
+ return c;
20
+ }
21
+
22
+ function isUnique(arr) {
23
+ var l = arr.length;
24
+ for(var i = 0; i < l; i++ ) {
25
+ if (arr.lastIndexOf(arr[i]) > i) return false;
26
+ }
27
+ return true;
28
+ }
29
+
30
+ /** Returns the given string with all regex meta characters backslashed. */
31
+ RegExp.escapeMeta = function(str) {
32
+ return str.replace(/([$^\\\/()|?+*\[\]{}.-])/g, "\\$1");
33
+ }
@@ -0,0 +1,102 @@
1
+ /**@constructor*/
2
+ function ChainNode(object, link) {
3
+ this.value = object;
4
+ this.link = link; // describes this node's relationship to the previous node
5
+ }
6
+
7
+ /**@constructor*/
8
+ function Chain(valueLinks) {
9
+ this.nodes = [];
10
+ this.cursor = -1;
11
+
12
+ if (valueLinks && valueLinks.length > 0) {
13
+ this.push(valueLinks[0], "//");
14
+ for (var i = 1, l = valueLinks.length; i < l; i+=2) {
15
+ this.push(valueLinks[i+1], valueLinks[i]);
16
+ }
17
+ }
18
+ }
19
+
20
+ Chain.prototype.push = function(o, link) {
21
+ if (this.nodes.length > 0 && link) this.nodes.push(new ChainNode(o, link));
22
+ else this.nodes.push(new ChainNode(o));
23
+ }
24
+
25
+ Chain.prototype.unshift = function(o, link) {
26
+ if (this.nodes.length > 0 && link) this.nodes[0].link = link;
27
+ this.nodes.unshift(new ChainNode(o));
28
+ this.cursor++;
29
+ }
30
+
31
+ Chain.prototype.get = function() {
32
+ if (this.cursor < 0 || this.cursor > this.nodes.length-1) return null;
33
+ return this.nodes[this.cursor];
34
+ }
35
+
36
+ Chain.prototype.first = function() {
37
+ this.cursor = 0;
38
+ return this.get();
39
+ }
40
+
41
+ Chain.prototype.last = function() {
42
+ this.cursor = this.nodes.length-1;
43
+ return this.get();
44
+ }
45
+
46
+ Chain.prototype.next = function() {
47
+ this.cursor++;
48
+ return this.get();
49
+ }
50
+
51
+ Chain.prototype.prev = function() {
52
+ this.cursor--;
53
+ return this.get();
54
+ }
55
+
56
+ Chain.prototype.toString = function() {
57
+ var string = "";
58
+ for (var i = 0, l = this.nodes.length; i < l; i++) {
59
+ if (this.nodes[i].link) string += " -("+this.nodes[i].link+")-> ";
60
+ string += this.nodes[i].value.toString();
61
+ }
62
+ return string;
63
+ }
64
+
65
+ Chain.prototype.joinLeft = function() {
66
+ var result = "";
67
+ for (var i = 0, l = this.cursor; i < l; i++) {
68
+ if (result && this.nodes[i].link) result += this.nodes[i].link;
69
+ result += this.nodes[i].value.toString();
70
+ }
71
+ return result;
72
+ }
73
+
74
+
75
+ /* USAGE:
76
+
77
+ var path = "one/two/three.four/five-six";
78
+ var pathChain = new Chain(path.split(/([\/.-])/));
79
+ print(pathChain);
80
+
81
+ var lineage = new Chain();
82
+ lineage.push("Port");
83
+ lineage.push("Les", "son");
84
+ lineage.push("Dawn", "daughter");
85
+ lineage.unshift("Purdie", "son");
86
+
87
+ print(lineage);
88
+
89
+ // walk left
90
+ for (var node = lineage.last(); node !== null; node = lineage.prev()) {
91
+ print("< "+node.value);
92
+ }
93
+
94
+ // walk right
95
+ var node = lineage.first()
96
+ while (node !== null) {
97
+ print(node.value);
98
+ node = lineage.next();
99
+ if (node && node.link) print("had a "+node.link+" named");
100
+ }
101
+
102
+ */
@@ -0,0 +1,144 @@
1
+ /**
2
+ * @class
3
+ <pre>
4
+ This is a lightly modified version of Kevin Jones' JavaScript
5
+ library Data.Dump. To download the original visit:
6
+ <a href="http://openjsan.org/doc/k/ke/kevinj/Data/Dump/">http://openjsan.org/doc/k/ke/kevinj/Data/Dump/</a>
7
+
8
+ AUTHORS
9
+
10
+ The Data.Dump JavaScript module is written by Kevin Jones
11
+ (kevinj@cpan.org), based on Data::Dump by Gisle Aas (gisle@aas.no),
12
+ based on Data::Dumper by Gurusamy Sarathy (gsar@umich.edu).
13
+
14
+ COPYRIGHT
15
+
16
+ Copyright 2007 Kevin Jones. Copyright 1998-2000,2003-2004 Gisle Aas.
17
+ Copyright 1996-1998 Gurusamy Sarathy.
18
+
19
+ This program is free software; you can redistribute it and/or modify
20
+ it under the terms of the Perl Artistic License
21
+
22
+ See http://www.perl.com/perl/misc/Artistic.html
23
+ </pre>
24
+ * @static
25
+ */
26
+ Dumper = {
27
+ /** @param [...] The objects to dump. */
28
+ dump: function () {
29
+ if (arguments.length > 1)
30
+ return this._dump(arguments);
31
+ else if (arguments.length == 1)
32
+ return this._dump(arguments[0]);
33
+ else
34
+ return "()";
35
+ },
36
+
37
+ _dump: function (obj) {
38
+ if (typeof obj == 'undefined') return 'undefined';
39
+ var out;
40
+ if (obj.serialize) { return obj.serialize(); }
41
+ var type = this._typeof(obj);
42
+ if (obj.circularReference) obj.circularReference++;
43
+ switch (type) {
44
+ case 'circular':
45
+ out = "{ //circularReference\n}";
46
+ break;
47
+ case 'object':
48
+ var pairs = new Array;
49
+
50
+ for (var prop in obj) {
51
+ if (prop != "circularReference" && obj.hasOwnProperty(prop)) { //hide inherited properties
52
+ pairs.push(prop + ': ' + this._dump(obj[prop]));
53
+ }
54
+ }
55
+
56
+ out = '{' + this._format_list(pairs) + '}';
57
+ break;
58
+
59
+ case 'string':
60
+ for (var prop in Dumper.ESC) {
61
+ if (Dumper.ESC.hasOwnProperty(prop)) {
62
+ obj = obj.replace(prop, Dumper.ESC[prop]);
63
+ }
64
+ }
65
+
66
+ // Escape UTF-8 Strings
67
+ if (obj.match(/^[\x00-\x7f]*$/)) {
68
+ out = '"' + obj.replace(/\"/g, "\\\"").replace(/([\n\r]+)/g, "\\$1") + '"';
69
+ }
70
+ else {
71
+ out = "unescape('"+escape(obj)+"')";
72
+ }
73
+ break;
74
+
75
+ case 'array':
76
+ var elems = new Array;
77
+
78
+ for (var i=0; i<obj.length; i++) {
79
+ elems.push( this._dump(obj[i]) );
80
+ }
81
+
82
+ out = '[' + this._format_list(elems) + ']';
83
+ break;
84
+
85
+ case 'date':
86
+ // firefox returns GMT strings from toUTCString()...
87
+ var utc_string = obj.toUTCString().replace(/GMT/,'UTC');
88
+ out = 'new Date("' + utc_string + '")';
89
+ break;
90
+
91
+ case 'element':
92
+ // DOM element
93
+ out = this._dump_dom(obj);
94
+ break;
95
+
96
+ default:
97
+ out = obj;
98
+ }
99
+
100
+ out = String(out).replace(/\n/g, '\n ');
101
+ out = out.replace(/\n (.*)$/,"\n$1");
102
+
103
+ return out;
104
+ },
105
+
106
+ _format_list: function (list) {
107
+ if (!list.length) return '';
108
+ var nl = list.toString().length > 60 ? '\n' : ' ';
109
+ return nl + list.join(',' + nl) + nl;
110
+ },
111
+
112
+ _typeof: function (obj) {
113
+ if (obj && obj.circularReference && obj.circularReference > 1) return 'circular';
114
+ if (Array.prototype.isPrototypeOf(obj)) return 'array';
115
+ if (Date.prototype.isPrototypeOf(obj)) return 'date';
116
+ if (typeof obj.nodeType != 'undefined') return 'element';
117
+ return typeof(obj);
118
+ },
119
+
120
+ _dump_dom: function (obj) {
121
+ return '"' + Dumper.nodeTypes[obj.nodeType] + '"';
122
+ }
123
+ };
124
+
125
+ Dumper.ESC = {
126
+ "\t": "\\t",
127
+ "\n": "\\n",
128
+ "\f": "\\f"
129
+ };
130
+
131
+ Dumper.nodeTypes = {
132
+ 1: "ELEMENT_NODE",
133
+ 2: "ATTRIBUTE_NODE",
134
+ 3: "TEXT_NODE",
135
+ 4: "CDATA_SECTION_NODE",
136
+ 5: "ENTITY_REFERENCE_NODE",
137
+ 6: "ENTITY_NODE",
138
+ 7: "PROCESSING_INSTRUCTION_NODE",
139
+ 8: "COMMENT_NODE",
140
+ 9: "DOCUMENT_NODE",
141
+ 10: "DOCUMENT_TYPE_NODE",
142
+ 11: "DOCUMENT_FRAGMENT_NODE",
143
+ 12: "NOTATION_NODE"
144
+ };
@@ -0,0 +1,84 @@
1
+ /**
2
+ @constructor
3
+ @example
4
+ var _index = new Hash();
5
+ _index.set("a", "apple");
6
+ _index.set("b", "blue");
7
+ _index.set("c", "coffee");
8
+
9
+ for (var p = _index.first(); p; p = _index.next()) {
10
+ print(p.key+" is for "+p.value);
11
+ }
12
+
13
+ */
14
+ var Hash = function() {
15
+ this._map = {};
16
+ this._keys = [];
17
+ this._vals = [];
18
+ this.reset();
19
+ }
20
+
21
+ Hash.prototype.set = function(k, v) {
22
+ if (k != "") {
23
+ this._keys.push(k);
24
+ this._map["="+k] = this._vals.length;
25
+ this._vals.push(v);
26
+ }
27
+ }
28
+
29
+ Hash.prototype.replace = function(k, k2, v) {
30
+ if (k == k2) return;
31
+
32
+ var offset = this._map["="+k];
33
+ this._keys[offset] = k2;
34
+ if (typeof v != "undefined") this._vals[offset] = v;
35
+ this._map["="+k2] = offset;
36
+ delete(this._map["="+k]);
37
+ }
38
+
39
+ Hash.prototype.drop = function(k) {
40
+ if (k != "") {
41
+ var offset = this._map["="+k];
42
+ this._keys.splice(offset, 1);
43
+ this._vals.splice(offset, 1);
44
+ delete(this._map["="+k]);
45
+ for (var p in this._map) {
46
+ if (this._map[p] >= offset) this._map[p]--;
47
+ }
48
+ if (this._cursor >= offset && this._cursor > 0) this._cursor--;
49
+ }
50
+ }
51
+
52
+ Hash.prototype.get = function(k) {
53
+ if (k != "") {
54
+ return this._vals[this._map["="+k]];
55
+ }
56
+ }
57
+
58
+ Hash.prototype.keys = function() {
59
+ return this._keys;
60
+ }
61
+
62
+ Hash.prototype.hasKey = function(k) {
63
+ if (k != "") {
64
+ return (typeof this._map["="+k] != "undefined");
65
+ }
66
+ }
67
+
68
+ Hash.prototype.values = function() {
69
+ return this._vals;
70
+ }
71
+
72
+ Hash.prototype.reset = function() {
73
+ this._cursor = 0;
74
+ }
75
+
76
+ Hash.prototype.first = function() {
77
+ this.reset();
78
+ return this.next();
79
+ }
80
+
81
+ Hash.prototype.next = function() {
82
+ if (this._cursor++ < this._keys.length)
83
+ return {key: this._keys[this._cursor-1], value: this._vals[this._cursor-1]};
84
+ }