hquery-patient-api 0.3.0

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 (145) hide show
  1. data/.gitignore +6 -0
  2. data/.travis.yml +17 -0
  3. data/Gemfile +14 -0
  4. data/LICENSE +57 -0
  5. data/README.md +34 -0
  6. data/Rakefile +41 -0
  7. data/VERSION +1 -0
  8. data/app/assets/javascripts/allergy.js.coffee +79 -0
  9. data/app/assets/javascripts/caregoal.js.coffee +18 -0
  10. data/app/assets/javascripts/condition.js.coffee +88 -0
  11. data/app/assets/javascripts/core.js.coffee +556 -0
  12. data/app/assets/javascripts/encounter.js.coffee +56 -0
  13. data/app/assets/javascripts/functionalstatus.js.coffee +48 -0
  14. data/app/assets/javascripts/immunization.js.coffee +115 -0
  15. data/app/assets/javascripts/languages.js.coffee +29 -0
  16. data/app/assets/javascripts/medicalequipment.js.coffee +28 -0
  17. data/app/assets/javascripts/medication.js.coffee +280 -0
  18. data/app/assets/javascripts/patient.js.coffee +302 -0
  19. data/app/assets/javascripts/pregnancy.js.coffee +24 -0
  20. data/app/assets/javascripts/procedure.js.coffee +28 -0
  21. data/app/assets/javascripts/provider.js.coffee +55 -0
  22. data/app/assets/javascripts/result.js.coffee +43 -0
  23. data/app/assets/javascripts/socialhistory.js.coffee +40 -0
  24. data/doc/jsdoc-toolkit/README.txt +183 -0
  25. data/doc/jsdoc-toolkit/app/frame.js +33 -0
  26. data/doc/jsdoc-toolkit/app/frame/Chain.js +102 -0
  27. data/doc/jsdoc-toolkit/app/frame/Dumper.js +144 -0
  28. data/doc/jsdoc-toolkit/app/frame/Hash.js +84 -0
  29. data/doc/jsdoc-toolkit/app/frame/Link.js +173 -0
  30. data/doc/jsdoc-toolkit/app/frame/Namespace.js +10 -0
  31. data/doc/jsdoc-toolkit/app/frame/Opt.js +134 -0
  32. data/doc/jsdoc-toolkit/app/frame/Reflection.js +26 -0
  33. data/doc/jsdoc-toolkit/app/frame/String.js +93 -0
  34. data/doc/jsdoc-toolkit/app/frame/Testrun.js +129 -0
  35. data/doc/jsdoc-toolkit/app/handlers/FOODOC.js +26 -0
  36. data/doc/jsdoc-toolkit/app/handlers/XMLDOC.js +26 -0
  37. data/doc/jsdoc-toolkit/app/handlers/XMLDOC/DomReader.js +159 -0
  38. data/doc/jsdoc-toolkit/app/handlers/XMLDOC/XMLDoc.js +16 -0
  39. data/doc/jsdoc-toolkit/app/handlers/XMLDOC/XMLParse.js +292 -0
  40. data/doc/jsdoc-toolkit/app/lib/JSDOC.js +106 -0
  41. data/doc/jsdoc-toolkit/app/lib/JSDOC/DocComment.js +204 -0
  42. data/doc/jsdoc-toolkit/app/lib/JSDOC/DocTag.js +294 -0
  43. data/doc/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js +140 -0
  44. data/doc/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js +109 -0
  45. data/doc/jsdoc-toolkit/app/lib/JSDOC/Lang.js +144 -0
  46. data/doc/jsdoc-toolkit/app/lib/JSDOC/Parser.js +146 -0
  47. data/doc/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js +33 -0
  48. data/doc/jsdoc-toolkit/app/lib/JSDOC/Symbol.js +644 -0
  49. data/doc/jsdoc-toolkit/app/lib/JSDOC/SymbolSet.js +243 -0
  50. data/doc/jsdoc-toolkit/app/lib/JSDOC/TextStream.js +41 -0
  51. data/doc/jsdoc-toolkit/app/lib/JSDOC/Token.js +18 -0
  52. data/doc/jsdoc-toolkit/app/lib/JSDOC/TokenReader.js +332 -0
  53. data/doc/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js +133 -0
  54. data/doc/jsdoc-toolkit/app/lib/JSDOC/Util.js +32 -0
  55. data/doc/jsdoc-toolkit/app/lib/JSDOC/Walker.js +507 -0
  56. data/doc/jsdoc-toolkit/app/main.js +111 -0
  57. data/doc/jsdoc-toolkit/app/plugins/commentSrcJson.js +20 -0
  58. data/doc/jsdoc-toolkit/app/plugins/frameworkPrototype.js +16 -0
  59. data/doc/jsdoc-toolkit/app/plugins/functionCall.js +10 -0
  60. data/doc/jsdoc-toolkit/app/plugins/publishSrcHilite.js +62 -0
  61. data/doc/jsdoc-toolkit/app/plugins/symbolLink.js +10 -0
  62. data/doc/jsdoc-toolkit/app/plugins/tagParamConfig.js +31 -0
  63. data/doc/jsdoc-toolkit/app/plugins/tagSynonyms.js +43 -0
  64. data/doc/jsdoc-toolkit/app/run.js +348 -0
  65. data/doc/jsdoc-toolkit/app/t/TestDoc.js +144 -0
  66. data/doc/jsdoc-toolkit/app/t/runner.js +13 -0
  67. data/doc/jsdoc-toolkit/app/test.js +342 -0
  68. data/doc/jsdoc-toolkit/app/test/addon.js +24 -0
  69. data/doc/jsdoc-toolkit/app/test/anon_inner.js +14 -0
  70. data/doc/jsdoc-toolkit/app/test/augments.js +31 -0
  71. data/doc/jsdoc-toolkit/app/test/augments2.js +26 -0
  72. data/doc/jsdoc-toolkit/app/test/borrows.js +46 -0
  73. data/doc/jsdoc-toolkit/app/test/borrows2.js +23 -0
  74. data/doc/jsdoc-toolkit/app/test/config.js +22 -0
  75. data/doc/jsdoc-toolkit/app/test/constructs.js +18 -0
  76. data/doc/jsdoc-toolkit/app/test/encoding.js +10 -0
  77. data/doc/jsdoc-toolkit/app/test/encoding_other.js +12 -0
  78. data/doc/jsdoc-toolkit/app/test/event.js +54 -0
  79. data/doc/jsdoc-toolkit/app/test/exports.js +14 -0
  80. data/doc/jsdoc-toolkit/app/test/functions_anon.js +39 -0
  81. data/doc/jsdoc-toolkit/app/test/functions_nested.js +33 -0
  82. data/doc/jsdoc-toolkit/app/test/global.js +13 -0
  83. data/doc/jsdoc-toolkit/app/test/globals.js +25 -0
  84. data/doc/jsdoc-toolkit/app/test/ignore.js +10 -0
  85. data/doc/jsdoc-toolkit/app/test/inner.js +16 -0
  86. data/doc/jsdoc-toolkit/app/test/jsdoc_test.js +477 -0
  87. data/doc/jsdoc-toolkit/app/test/lend.js +33 -0
  88. data/doc/jsdoc-toolkit/app/test/memberof.js +19 -0
  89. data/doc/jsdoc-toolkit/app/test/memberof2.js +38 -0
  90. data/doc/jsdoc-toolkit/app/test/memberof3.js +33 -0
  91. data/doc/jsdoc-toolkit/app/test/memberof_constructor.js +17 -0
  92. data/doc/jsdoc-toolkit/app/test/module.js +17 -0
  93. data/doc/jsdoc-toolkit/app/test/multi_methods.js +25 -0
  94. data/doc/jsdoc-toolkit/app/test/name.js +19 -0
  95. data/doc/jsdoc-toolkit/app/test/namespace_nested.js +23 -0
  96. data/doc/jsdoc-toolkit/app/test/nocode.js +13 -0
  97. data/doc/jsdoc-toolkit/app/test/oblit_anon.js +20 -0
  98. data/doc/jsdoc-toolkit/app/test/overview.js +20 -0
  99. data/doc/jsdoc-toolkit/app/test/param_inline.js +37 -0
  100. data/doc/jsdoc-toolkit/app/test/params_optional.js +8 -0
  101. data/doc/jsdoc-toolkit/app/test/prototype.js +17 -0
  102. data/doc/jsdoc-toolkit/app/test/prototype_nested.js +9 -0
  103. data/doc/jsdoc-toolkit/app/test/prototype_oblit.js +13 -0
  104. data/doc/jsdoc-toolkit/app/test/prototype_oblit_constructor.js +24 -0
  105. data/doc/jsdoc-toolkit/app/test/public.js +10 -0
  106. data/doc/jsdoc-toolkit/app/test/scripts/code.js +5 -0
  107. data/doc/jsdoc-toolkit/app/test/scripts/notcode.txt +5 -0
  108. data/doc/jsdoc-toolkit/app/test/shared.js +42 -0
  109. data/doc/jsdoc-toolkit/app/test/shared2.js +2 -0
  110. data/doc/jsdoc-toolkit/app/test/shortcuts.js +22 -0
  111. data/doc/jsdoc-toolkit/app/test/static_this.js +13 -0
  112. data/doc/jsdoc-toolkit/app/test/synonyms.js +31 -0
  113. data/doc/jsdoc-toolkit/app/test/tosource.js +23 -0
  114. data/doc/jsdoc-toolkit/app/test/variable_redefine.js +14 -0
  115. data/doc/jsdoc-toolkit/conf/sample.conf +31 -0
  116. data/doc/jsdoc-toolkit/java/build.xml +36 -0
  117. data/doc/jsdoc-toolkit/java/build_1.4.xml +36 -0
  118. data/doc/jsdoc-toolkit/java/classes/js.jar +0 -0
  119. data/doc/jsdoc-toolkit/java/src/JsDebugRun.java +21 -0
  120. data/doc/jsdoc-toolkit/java/src/JsRun.java +21 -0
  121. data/doc/jsdoc-toolkit/jsdebug.jar +0 -0
  122. data/doc/jsdoc-toolkit/jsrun.jar +0 -0
  123. data/doc/jsdoc-toolkit/jsrun.sh +52 -0
  124. data/doc/jsdoc-toolkit/out/jsdoc/files.html +218 -0
  125. data/doc/jsdoc-toolkit/out/jsdoc/index.html +218 -0
  126. data/doc/jsdoc-toolkit/out/jsdoc/symbols/Patient.html +546 -0
  127. data/doc/jsdoc-toolkit/out/jsdoc/symbols/_global_.html +463 -0
  128. data/doc/jsdoc-toolkit/out/jsdoc/symbols/src/tmp_patient.js.html +89 -0
  129. data/doc/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl +17 -0
  130. data/doc/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl +56 -0
  131. data/doc/jsdoc-toolkit/templates/jsdoc/class.tmpl +649 -0
  132. data/doc/jsdoc-toolkit/templates/jsdoc/index.tmpl +39 -0
  133. data/doc/jsdoc-toolkit/templates/jsdoc/publish.js +201 -0
  134. data/doc/jsdoc-toolkit/templates/jsdoc/static/default.css +162 -0
  135. data/doc/jsdoc-toolkit/templates/jsdoc/static/header.html +2 -0
  136. data/doc/jsdoc-toolkit/templates/jsdoc/static/index.html +19 -0
  137. data/doc/jsdoc-toolkit/templates/jsdoc/symbol.tmpl +35 -0
  138. data/hquery_patientapi.gemspec +14 -0
  139. data/lib/hquery-patient-api.rb +4 -0
  140. data/lib/hquery/engine.rb +4 -0
  141. data/lib/hquery/generator.rb +18 -0
  142. data/test/fixtures/patient/barry_berry.json +466 -0
  143. data/test/test_helper.rb +25 -0
  144. data/test/unit/patient_api_test.rb +178 -0
  145. metadata +193 -0
@@ -0,0 +1,40 @@
1
+ ###*
2
+ @namespace scoping into the hquery namespace
3
+ ###
4
+ this.hQuery ||= {}
5
+
6
+ # =require core.coffee
7
+
8
+ ###*
9
+
10
+ The Social History Observation is used to define the patient's occupational, personal (e.g. lifestyle),
11
+ social, and environmental history and health risk factors, as well as administrative data such as
12
+ marital status, race, ethnicity and religious affiliation. The types of conditions
13
+ described have been constrained to the SNOMED CT code system using constrained code set, 2.16.840.1.113883.3.88.12.80.60:
14
+ 229819007 Tobacco use and exposure
15
+ 256235009 Exercise
16
+ 160573003 Alcohol Intake
17
+ 364393001 Nutritional observable
18
+ 364703007 Employment detail
19
+ 425400000 Toxic exposure status
20
+ 363908000 Details of drug misuse behavior
21
+ 228272008 Health-related behavior
22
+ 105421008 Educational achievement
23
+
24
+ note: Social History is not part of the existing green c32.
25
+ @exports Socialhistory as hQuery.Socialhistory
26
+ @augments hQuery.CodedEntry
27
+ ###
28
+ class hQuery.Socialhistory extends hQuery.CodedEntry
29
+
30
+ constructor: (@json) ->
31
+ super(@json)
32
+
33
+
34
+ ###*
35
+ Value returns the value of the result. This will return an object. The properties of this
36
+ object are dependent on the type of result.
37
+ ###
38
+ value: -> @json['value']
39
+
40
+
@@ -0,0 +1,183 @@
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 Java and Mozilla's Rhino
8
+ JavaScript runtime 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
+ JsDoc Toolkit is known to work with:
26
+ java version "1.6.0_03"
27
+ Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
28
+ on Windows XP,
29
+ and java version "1.5.0_19"
30
+ Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_19-b02-304)
31
+ on Mac OS X 10.5.
32
+
33
+ Other versions of java may or may not work with JsDoc Toolkit.
34
+
35
+ ======================================================================
36
+
37
+ USAGE:
38
+
39
+ Running JsDoc Toolkit requires you to have Java installed on your
40
+ computer. For more information see http://www.java.com/getjava/
41
+
42
+ Before running the JsDoc Toolkit app you should change your current
43
+ working directory to the jsdoc-toolkit folder. Then follow the
44
+ examples below, or as shown on the project wiki.
45
+
46
+ On a computer running Windows a valid command line to run JsDoc
47
+ Toolkit might look like this:
48
+
49
+ > java -jar jsrun.jar app\run.js -a -t=templates\jsdoc mycode.js
50
+
51
+ On Mac OS X or Linux the same command would look like this:
52
+
53
+ $ java -jar jsrun.jar app/run.js -a -t=templates/jsdoc mycode.js
54
+
55
+ The above assumes your current working directory contains jsrun.jar,
56
+ the "app" and "templates" subdirectories from the standard JsDoc
57
+ Toolkit distribution and that the relative path to the code you wish
58
+ to document is "mycode.js".
59
+
60
+ The output documentation files will be saved to a new directory named
61
+ "out" (by default) in the current directory, or if you specify a
62
+ -d=somewhere_else option, to the somewhere_else directory.
63
+
64
+ For help (usage notes) enter this on the command line:
65
+
66
+ $ java -jar jsrun.jar app/run.js --help
67
+
68
+ More information about the various command line options used by JsDoc
69
+ Toolkit are available on the project wiki.
70
+
71
+ ======================================================================
72
+
73
+ RUNNING VIA SHELL SCRIPT
74
+
75
+ Avi Deitcher has contributed the file jsrun.sh with the following usage notes:
76
+
77
+ A script to simplify running jsdoc from the command-line, especially when
78
+ running from within a development or build environment such as ant.
79
+
80
+ Normally, to run jsdoc, you need a command-line as the following:
81
+ java -Djsdoc.dir=/some/long/dir/path/to/jsdoc -jar
82
+ /some/long/dir/path/to/jsdoc/jsrun.jar /some/long/dir/path/to/jsdoc/app/run.js
83
+ -t=template -r=4 /some/long/dir/path/to/my/src/code
84
+
85
+ This can get tedious to redo time and again, and difficult to use from within a build environment.
86
+
87
+ To simplify the process, jsrun.sh will automatically run this path, as well as passing through any arguments.
88
+
89
+ Usage: jsrun.sh <run.js arguments>
90
+
91
+ All <run.js arguments> will be passed through.
92
+ Additionally, jsrun.sh will take the following actions:
93
+ 1) If the environment variable JSDOCDIR is set, it will add
94
+ "-Djsdoc.dir=$JSDOCDIR" to the command-line
95
+ 2) If the environment variable JSDOCTEMPLATEDIR is set, it will add
96
+ "-Djsdoc.template.dir=$JSDOCTEMPLATEDIR" to the command-line
97
+ 3) java with the appropriate path to jsrun.jar and run.js will be instantiated
98
+
99
+ If not variables are set, it is assumed that the path to jsrun.jar and app/ is in the current working directory.
100
+
101
+ Example:
102
+ # jsrun.sh ./src/
103
+ Assuming JSDOCDIR=/some/path/to/my/jsdoc will cause the following command to
104
+ execute:
105
+ java -Djsdoc.dir=/some/path/to/my/jsdoc -jar /some/path/to/my/jsdoc/jsrun.jar
106
+ /some/path/to/my/jsdoc/app/run.js ./src/
107
+
108
+ ======================================================================
109
+
110
+ TESTING:
111
+
112
+ To run the suite of unit tests included with JsDoc Toolkit enter this
113
+ on the command line:
114
+
115
+ $ java -jar jsrun.jar app/run.js -T
116
+
117
+ To see a dump of the internal data structure that JsDoc Toolkit has
118
+ built from your source files use this command:
119
+
120
+ $ java -jar jsrun.jar app/run.js mycode.js -Z
121
+
122
+ ======================================================================
123
+
124
+ LICENSE:
125
+
126
+ JSDoc.pm
127
+
128
+ This project is based on the JSDoc.pm tool, created by Michael
129
+ Mathews and Gabriel Reid. More information on JsDoc.pm can
130
+ be found on the JSDoc.pm homepage: http://jsdoc.sourceforge.net/
131
+
132
+ Complete documentation on JsDoc Toolkit can be found on the project
133
+ wiki at http://code.google.com/p/jsdoc-toolkit/w/list
134
+
135
+ Rhino
136
+
137
+ Rhino (JavaScript in Java) is open source and licensed by Mozilla
138
+ under the MPL 1.1 or later/GPL 2.0 or later licenses, the text of
139
+ which is available at http://www.mozilla.org/MPL/
140
+
141
+ You can obtain the source code for Rhino from the Mozilla web site at
142
+ http://www.mozilla.org/rhino/download.html
143
+
144
+ JsDoc Toolkit is a larger work that uses the Rhino JavaScript engine
145
+ but is not derived from it in any way. The Rhino library is used
146
+ without modification and without any claims whatsoever.
147
+
148
+ The Rhino Debugger
149
+
150
+ You can obtain more information about the Rhino Debugger from the
151
+ Mozilla web site at http://www.mozilla.org/rhino/debugger.html
152
+
153
+ JsDoc Toolkit is a larger work that uses the Rhino Debugger but
154
+ is not derived from it in any way. The Rhino Debugger is used
155
+ without modification and without any claims whatsoever.
156
+
157
+ JsDoc Toolkit
158
+
159
+ All code specific to JsDoc Toolkit are free, open source and licensed
160
+ for use under the X11/MIT License.
161
+
162
+ JsDoc Toolkit is Copyright (c)2009 Michael Mathews <micmath@gmail.com>
163
+
164
+ This program is free software; you can redistribute it and/or
165
+ modify it under the terms below.
166
+
167
+ Permission is hereby granted, free of charge, to any person obtaining
168
+ a copy of this software and associated documentation files (the
169
+ "Software"), to deal in the Software without restriction, including
170
+ without limitation the rights to use, copy, modify, merge, publish,
171
+ distribute, sublicense, and/or sell copies of the Software, and to
172
+ permit persons to whom the Software is furnished to do so, subject to
173
+ the following conditions: The above copyright notice and this
174
+ permission notice must be included in all copies or substantial
175
+ portions of the Software.
176
+
177
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
178
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
179
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
180
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
181
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
182
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
183
+ 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
+ };