mobile_template 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +22 -0
  4. data/README.md +28 -0
  5. data/Rakefile +3 -0
  6. data/bin/mobile_template +71 -0
  7. data/lib/mobile_template/version.rb +4 -0
  8. data/lib/mobile_template.rb +5 -0
  9. data/mobile_template.gemspec +21 -0
  10. data/templates/assets/Gemfile +4 -0
  11. data/templates/assets/config.rb +96 -0
  12. data/templates/assets/config.ru +4 -0
  13. data/templates/assets/source/images/vendor/ajax-loader.gif +0 -0
  14. data/templates/assets/source/images/vendor/ajax-loader.png +0 -0
  15. data/templates/assets/source/images/vendor/icons-18-black.png +0 -0
  16. data/templates/assets/source/images/vendor/icons-18-white.png +0 -0
  17. data/templates/assets/source/images/vendor/icons-36-black.png +0 -0
  18. data/templates/assets/source/images/vendor/icons-36-white.png +0 -0
  19. data/templates/assets/source/index.html.erb +2 -0
  20. data/templates/assets/source/javascripts/app/index.js.coffee +2 -0
  21. data/templates/assets/source/javascripts/application.js.coffee +5 -0
  22. data/templates/assets/source/javascripts/vendor/cordova.js +4841 -0
  23. data/templates/assets/source/javascripts/vendor/jquery.js +9267 -0
  24. data/templates/assets/source/javascripts/vendor/jquery.mobile.js +7410 -0
  25. data/templates/assets/source/layout.erb +24 -0
  26. data/templates/assets/source/stylesheets/application.css.scss +2 -0
  27. data/templates/assets/source/stylesheets/vendor/jquery.mobile.css.scss +1872 -0
  28. data/templates/cordova_android/.gitignore +18 -0
  29. data/templates/cordova_android/LICENSE +202 -0
  30. data/templates/cordova_android/NOTICE +5 -0
  31. data/templates/cordova_android/README.md +95 -0
  32. data/templates/cordova_android/VERSION +1 -0
  33. data/templates/cordova_android/bin/BOOM +4 -0
  34. data/templates/cordova_android/bin/autotest +2 -0
  35. data/templates/cordova_android/bin/bench +29 -0
  36. data/templates/cordova_android/bin/create +46 -0
  37. data/templates/cordova_android/bin/create.bat +1 -0
  38. data/templates/cordova_android/bin/create.js +88 -0
  39. data/templates/cordova_android/bin/create.xml +79 -0
  40. data/templates/cordova_android/bin/node_modules/.bin/cake +7 -0
  41. data/templates/cordova_android/bin/node_modules/.bin/coffee +7 -0
  42. data/templates/cordova_android/bin/node_modules/.bin/nodeunit +120 -0
  43. data/templates/cordova_android/bin/node_modules/coffee-script/.npmignore +11 -0
  44. data/templates/cordova_android/bin/node_modules/coffee-script/LICENSE +22 -0
  45. data/templates/cordova_android/bin/node_modules/coffee-script/README +48 -0
  46. data/templates/cordova_android/bin/node_modules/coffee-script/Rakefile +78 -0
  47. data/templates/cordova_android/bin/node_modules/coffee-script/bin/cake +7 -0
  48. data/templates/cordova_android/bin/node_modules/coffee-script/bin/coffee +7 -0
  49. data/templates/cordova_android/bin/node_modules/coffee-script/extras/jsl.conf +44 -0
  50. data/templates/cordova_android/bin/node_modules/coffee-script/lib/browser.js +75 -0
  51. data/templates/cordova_android/bin/node_modules/coffee-script/lib/cake.js +76 -0
  52. data/templates/cordova_android/bin/node_modules/coffee-script/lib/coffee-script.js +135 -0
  53. data/templates/cordova_android/bin/node_modules/coffee-script/lib/command.js +301 -0
  54. data/templates/cordova_android/bin/node_modules/coffee-script/lib/grammar.js +591 -0
  55. data/templates/cordova_android/bin/node_modules/coffee-script/lib/helpers.js +66 -0
  56. data/templates/cordova_android/bin/node_modules/coffee-script/lib/index.js +8 -0
  57. data/templates/cordova_android/bin/node_modules/coffee-script/lib/lexer.js +656 -0
  58. data/templates/cordova_android/bin/node_modules/coffee-script/lib/nodes.js +2289 -0
  59. data/templates/cordova_android/bin/node_modules/coffee-script/lib/optparse.js +111 -0
  60. data/templates/cordova_android/bin/node_modules/coffee-script/lib/parser.js +676 -0
  61. data/templates/cordova_android/bin/node_modules/coffee-script/lib/repl.js +123 -0
  62. data/templates/cordova_android/bin/node_modules/coffee-script/lib/rewriter.js +363 -0
  63. data/templates/cordova_android/bin/node_modules/coffee-script/lib/scope.js +120 -0
  64. data/templates/cordova_android/bin/node_modules/coffee-script/package.json +27 -0
  65. data/templates/cordova_android/bin/node_modules/nodeunit/.gitignore +5 -0
  66. data/templates/cordova_android/bin/node_modules/nodeunit/.npmignore +3 -0
  67. data/templates/cordova_android/bin/node_modules/nodeunit/CONTRIBUTORS.md +60 -0
  68. data/templates/cordova_android/bin/node_modules/nodeunit/LICENSE +19 -0
  69. data/templates/cordova_android/bin/node_modules/nodeunit/Makefile +126 -0
  70. data/templates/cordova_android/bin/node_modules/nodeunit/README.md +432 -0
  71. data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit +120 -0
  72. data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit.json +10 -0
  73. data/templates/cordova_android/bin/node_modules/nodeunit/deps/async.js +623 -0
  74. data/templates/cordova_android/bin/node_modules/nodeunit/deps/console.log.js +55 -0
  75. data/templates/cordova_android/bin/node_modules/nodeunit/deps/ejs.js +125 -0
  76. data/templates/cordova_android/bin/node_modules/nodeunit/deps/json2.js +483 -0
  77. data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/nodeunit.js +1757 -0
  78. data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite1.js +12 -0
  79. data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite2.js +13 -0
  80. data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/test.html +16 -0
  81. data/templates/cordova_android/bin/node_modules/nodeunit/img/example_fail.png +0 -0
  82. data/templates/cordova_android/bin/node_modules/nodeunit/img/example_pass.png +0 -0
  83. data/templates/cordova_android/bin/node_modules/nodeunit/index.js +3 -0
  84. data/templates/cordova_android/bin/node_modules/nodeunit/lib/assert.js +316 -0
  85. data/templates/cordova_android/bin/node_modules/nodeunit/lib/core.js +260 -0
  86. data/templates/cordova_android/bin/node_modules/nodeunit/lib/nodeunit.js +82 -0
  87. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/browser.js +119 -0
  88. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/default.js +123 -0
  89. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/html.js +107 -0
  90. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/index.js +9 -0
  91. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/junit.js +183 -0
  92. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/minimal.js +112 -0
  93. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/skip_passed.js +105 -0
  94. data/templates/cordova_android/bin/node_modules/nodeunit/lib/track.js +48 -0
  95. data/templates/cordova_android/bin/node_modules/nodeunit/lib/types.js +187 -0
  96. data/templates/cordova_android/bin/node_modules/nodeunit/lib/utils.js +209 -0
  97. data/templates/cordova_android/bin/node_modules/nodeunit/man1/nodeunit.1 +95 -0
  98. data/templates/cordova_android/bin/node_modules/nodeunit/nodelint.cfg +4 -0
  99. data/templates/cordova_android/bin/node_modules/nodeunit/package.json +56 -0
  100. data/templates/cordova_android/bin/node_modules/nodeunit/share/junit.xml.ejs +19 -0
  101. data/templates/cordova_android/bin/node_modules/nodeunit/share/license.js +11 -0
  102. data/templates/cordova_android/bin/node_modules/nodeunit/share/nodeunit.css +70 -0
  103. data/templates/cordova_android/bin/templates/project/.cordova/android/readme.md +1 -0
  104. data/templates/cordova_android/bin/templates/project/.cordova/readme.md +3 -0
  105. data/templates/cordova_android/bin/templates/project/cordova/create +36 -0
  106. data/templates/cordova_android/bin/templates/project/cordova/debug +9 -0
  107. data/templates/cordova_android/bin/templates/project/cordova/emulate +12 -0
  108. data/templates/cordova_android/bin/templates/project/cordova/log +3 -0
  109. data/templates/cordova_android/bin/templates/project/cordova/templates/Activity.java +16 -0
  110. data/templates/cordova_android/bin/templates/project/cordova/templates/project/AndroidManifest.xml +50 -0
  111. data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/index.html +42 -0
  112. data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/main.js +146 -0
  113. data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/master.css +96 -0
  114. data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/drawable/icon.png +0 -0
  115. data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/cordova.xml +5 -0
  116. data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/plugins.xml +19 -0
  117. data/templates/cordova_android/bin/test +26 -0
  118. data/templates/cordova_android/bin/tests/autotest.coffee +4 -0
  119. data/templates/cordova_android/bin/tests/create.coffee +21 -0
  120. data/templates/cordova_android/bin/tests/debug.coffee +0 -0
  121. data/templates/cordova_android/bin/tests/test.coffee +0 -0
  122. data/templates/cordova_android/framework/.classpath +8 -0
  123. data/templates/cordova_android/framework/.project +33 -0
  124. data/templates/cordova_android/framework/AndroidManifest.xml +68 -0
  125. data/templates/cordova_android/framework/ant.properties +34 -0
  126. data/templates/cordova_android/framework/assets/js/accelerometer.js +137 -0
  127. data/templates/cordova_android/framework/assets/js/app.js +89 -0
  128. data/templates/cordova_android/framework/assets/js/battery.js +134 -0
  129. data/templates/cordova_android/framework/assets/js/camera.js +168 -0
  130. data/templates/cordova_android/framework/assets/js/capture.js +203 -0
  131. data/templates/cordova_android/framework/assets/js/compass.js +168 -0
  132. data/templates/cordova_android/framework/assets/js/contact.js +310 -0
  133. data/templates/cordova_android/framework/assets/js/cordova.android.js +4841 -0
  134. data/templates/cordova_android/framework/assets/js/cordova.js.base +924 -0
  135. data/templates/cordova_android/framework/assets/js/crypto.js +54 -0
  136. data/templates/cordova_android/framework/assets/js/device.js +83 -0
  137. data/templates/cordova_android/framework/assets/js/file.js +1082 -0
  138. data/templates/cordova_android/framework/assets/js/filetransfer.js +125 -0
  139. data/templates/cordova_android/framework/assets/js/geolocation.js +209 -0
  140. data/templates/cordova_android/framework/assets/js/header.txt +19 -0
  141. data/templates/cordova_android/framework/assets/js/media.js +233 -0
  142. data/templates/cordova_android/framework/assets/js/network.js +100 -0
  143. data/templates/cordova_android/framework/assets/js/notification.js +133 -0
  144. data/templates/cordova_android/framework/assets/js/position.js +100 -0
  145. data/templates/cordova_android/framework/assets/js/storage.js +439 -0
  146. data/templates/cordova_android/framework/assets/www/index.html +27 -0
  147. data/templates/cordova_android/framework/build.xml +216 -0
  148. data/templates/cordova_android/framework/libs/commons-codec-1.3.jar +0 -0
  149. data/templates/cordova_android/framework/proguard-project.txt +20 -0
  150. data/templates/cordova_android/framework/project.properties +14 -0
  151. data/templates/cordova_android/framework/res/drawable/icon.png +0 -0
  152. data/templates/cordova_android/framework/res/drawable/splash.png +0 -0
  153. data/templates/cordova_android/framework/res/layout/main.xml +29 -0
  154. data/templates/cordova_android/framework/res/values/strings.xml +23 -0
  155. data/templates/cordova_android/framework/res/xml/cordova.xml +37 -0
  156. data/templates/cordova_android/framework/res/xml/plugins.xml +37 -0
  157. data/templates/cordova_android/framework/src/com/phonegap/api/IPlugin.java +27 -0
  158. data/templates/cordova_android/framework/src/com/phonegap/api/LOG.java +28 -0
  159. data/templates/cordova_android/framework/src/com/phonegap/api/PhonegapActivity.java +28 -0
  160. data/templates/cordova_android/framework/src/com/phonegap/api/Plugin.java +27 -0
  161. data/templates/cordova_android/framework/src/com/phonegap/api/PluginManager.java +35 -0
  162. data/templates/cordova_android/framework/src/com/phonegap/api/PluginResult.java +53 -0
  163. data/templates/cordova_android/framework/src/org/apache/cordova/AccelListener.java +311 -0
  164. data/templates/cordova_android/framework/src/org/apache/cordova/App.java +198 -0
  165. data/templates/cordova_android/framework/src/org/apache/cordova/AudioHandler.java +364 -0
  166. data/templates/cordova_android/framework/src/org/apache/cordova/AudioPlayer.java +450 -0
  167. data/templates/cordova_android/framework/src/org/apache/cordova/AuthenticationToken.java +69 -0
  168. data/templates/cordova_android/framework/src/org/apache/cordova/BatteryListener.java +156 -0
  169. data/templates/cordova_android/framework/src/org/apache/cordova/CallbackServer.java +431 -0
  170. data/templates/cordova_android/framework/src/org/apache/cordova/CameraLauncher.java +500 -0
  171. data/templates/cordova_android/framework/src/org/apache/cordova/Capture.java +400 -0
  172. data/templates/cordova_android/framework/src/org/apache/cordova/CompassListener.java +308 -0
  173. data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessor.java +198 -0
  174. data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessorSdk5.java +1934 -0
  175. data/templates/cordova_android/framework/src/org/apache/cordova/ContactManager.java +113 -0
  176. data/templates/cordova_android/framework/src/org/apache/cordova/CordovaChromeClient.java +314 -0
  177. data/templates/cordova_android/framework/src/org/apache/cordova/CordovaWebViewClient.java +306 -0
  178. data/templates/cordova_android/framework/src/org/apache/cordova/Device.java +219 -0
  179. data/templates/cordova_android/framework/src/org/apache/cordova/DirectoryManager.java +161 -0
  180. data/templates/cordova_android/framework/src/org/apache/cordova/DroidGap.java +1417 -0
  181. data/templates/cordova_android/framework/src/org/apache/cordova/ExifHelper.java +165 -0
  182. data/templates/cordova_android/framework/src/org/apache/cordova/FileTransfer.java +458 -0
  183. data/templates/cordova_android/framework/src/org/apache/cordova/FileUploadResult.java +63 -0
  184. data/templates/cordova_android/framework/src/org/apache/cordova/FileUtils.java +1048 -0
  185. data/templates/cordova_android/framework/src/org/apache/cordova/GeoBroker.java +165 -0
  186. data/templates/cordova_android/framework/src/org/apache/cordova/GeoListener.java +133 -0
  187. data/templates/cordova_android/framework/src/org/apache/cordova/GpsListener.java +163 -0
  188. data/templates/cordova_android/framework/src/org/apache/cordova/HttpHandler.java +80 -0
  189. data/templates/cordova_android/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java +104 -0
  190. data/templates/cordova_android/framework/src/org/apache/cordova/NetworkListener.java +153 -0
  191. data/templates/cordova_android/framework/src/org/apache/cordova/NetworkManager.java +248 -0
  192. data/templates/cordova_android/framework/src/org/apache/cordova/Notification.java +366 -0
  193. data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceNode.java +34 -0
  194. data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceSet.java +62 -0
  195. data/templates/cordova_android/framework/src/org/apache/cordova/StandAlone.java +35 -0
  196. data/templates/cordova_android/framework/src/org/apache/cordova/Storage.java +239 -0
  197. data/templates/cordova_android/framework/src/org/apache/cordova/TempListener.java +112 -0
  198. data/templates/cordova_android/framework/src/org/apache/cordova/api/CordovaInterface.java +145 -0
  199. data/templates/cordova_android/framework/src/org/apache/cordova/api/IPlugin.java +116 -0
  200. data/templates/cordova_android/framework/src/org/apache/cordova/api/LOG.java +234 -0
  201. data/templates/cordova_android/framework/src/org/apache/cordova/api/Plugin.java +210 -0
  202. data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginManager.java +359 -0
  203. data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginResult.java +119 -0
  204. data/templates/cordova_android/framework/src/org/apache/cordova/file/EncodingException.java +28 -0
  205. data/templates/cordova_android/framework/src/org/apache/cordova/file/FileExistsException.java +28 -0
  206. data/templates/cordova_android/framework/src/org/apache/cordova/file/InvalidModificationException.java +29 -0
  207. data/templates/cordova_android/framework/src/org/apache/cordova/file/NoModificationAllowedException.java +28 -0
  208. data/templates/cordova_android/framework/src/org/apache/cordova/file/TypeMismatchException.java +29 -0
  209. data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceNodeTest.java +53 -0
  210. data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceSetTest.java +73 -0
  211. metadata +279 -0
@@ -0,0 +1,656 @@
1
+ (function() {
2
+ var ASSIGNED, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NO_NEWLINE, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, key, last, starts, _ref;
3
+ var __indexOf = Array.prototype.indexOf || function(item) {
4
+ for (var i = 0, l = this.length; i < l; i++) {
5
+ if (this[i] === item) return i;
6
+ }
7
+ return -1;
8
+ };
9
+ Rewriter = require('./rewriter').Rewriter;
10
+ _ref = require('./helpers'), count = _ref.count, starts = _ref.starts, compact = _ref.compact, last = _ref.last;
11
+ exports.Lexer = Lexer = (function() {
12
+ function Lexer() {}
13
+ Lexer.prototype.tokenize = function(code, opts) {
14
+ var i;
15
+ if (opts == null) {
16
+ opts = {};
17
+ }
18
+ if (WHITESPACE.test(code)) {
19
+ code = "\n" + code;
20
+ }
21
+ code = code.replace(/\r/g, '').replace(TRAILING_SPACES, '');
22
+ this.code = code;
23
+ this.line = opts.line || 0;
24
+ this.indent = 0;
25
+ this.indebt = 0;
26
+ this.outdebt = 0;
27
+ this.indents = [];
28
+ this.tokens = [];
29
+ i = 0;
30
+ while (this.chunk = code.slice(i)) {
31
+ i += this.identifierToken() || this.commentToken() || this.whitespaceToken() || this.lineToken() || this.heredocToken() || this.stringToken() || this.numberToken() || this.regexToken() || this.jsToken() || this.literalToken();
32
+ }
33
+ this.closeIndentation();
34
+ if (opts.rewrite === false) {
35
+ return this.tokens;
36
+ }
37
+ return (new Rewriter).rewrite(this.tokens);
38
+ };
39
+ Lexer.prototype.identifierToken = function() {
40
+ var colon, forcedIdentifier, id, input, match, prev, tag, _ref2, _ref3;
41
+ if (!(match = IDENTIFIER.exec(this.chunk))) {
42
+ return 0;
43
+ }
44
+ input = match[0], id = match[1], colon = match[2];
45
+ if (id === 'own' && this.tag() === 'FOR') {
46
+ this.token('OWN', id);
47
+ return id.length;
48
+ }
49
+ forcedIdentifier = colon || (prev = last(this.tokens)) && (((_ref2 = prev[0]) === '.' || _ref2 === '?.' || _ref2 === '::') || !prev.spaced && prev[0] === '@');
50
+ tag = 'IDENTIFIER';
51
+ if (!forcedIdentifier && (__indexOf.call(JS_KEYWORDS, id) >= 0 || __indexOf.call(COFFEE_KEYWORDS, id) >= 0)) {
52
+ tag = id.toUpperCase();
53
+ if (tag === 'WHEN' && (_ref3 = this.tag(), __indexOf.call(LINE_BREAK, _ref3) >= 0)) {
54
+ tag = 'LEADING_WHEN';
55
+ } else if (tag === 'FOR') {
56
+ this.seenFor = true;
57
+ } else if (tag === 'UNLESS') {
58
+ tag = 'IF';
59
+ } else if (__indexOf.call(UNARY, tag) >= 0) {
60
+ tag = 'UNARY';
61
+ } else if (__indexOf.call(RELATION, tag) >= 0) {
62
+ if (tag !== 'INSTANCEOF' && this.seenFor) {
63
+ tag = 'FOR' + tag;
64
+ this.seenFor = false;
65
+ } else {
66
+ tag = 'RELATION';
67
+ if (this.value() === '!') {
68
+ this.tokens.pop();
69
+ id = '!' + id;
70
+ }
71
+ }
72
+ }
73
+ }
74
+ if (__indexOf.call(JS_FORBIDDEN, id) >= 0) {
75
+ if (forcedIdentifier) {
76
+ tag = 'IDENTIFIER';
77
+ id = new String(id);
78
+ id.reserved = true;
79
+ } else if (__indexOf.call(RESERVED, id) >= 0) {
80
+ this.identifierError(id);
81
+ }
82
+ }
83
+ if (!forcedIdentifier) {
84
+ if (__indexOf.call(COFFEE_ALIASES, id) >= 0) {
85
+ id = COFFEE_ALIAS_MAP[id];
86
+ }
87
+ tag = (function() {
88
+ switch (id) {
89
+ case '!':
90
+ return 'UNARY';
91
+ case '==':
92
+ case '!=':
93
+ return 'COMPARE';
94
+ case '&&':
95
+ case '||':
96
+ return 'LOGIC';
97
+ case 'true':
98
+ case 'false':
99
+ case 'null':
100
+ case 'undefined':
101
+ return 'BOOL';
102
+ case 'break':
103
+ case 'continue':
104
+ case 'debugger':
105
+ return 'STATEMENT';
106
+ default:
107
+ return tag;
108
+ }
109
+ })();
110
+ }
111
+ this.token(tag, id);
112
+ if (colon) {
113
+ this.token(':', ':');
114
+ }
115
+ return input.length;
116
+ };
117
+ Lexer.prototype.numberToken = function() {
118
+ var match, number;
119
+ if (!(match = NUMBER.exec(this.chunk))) {
120
+ return 0;
121
+ }
122
+ number = match[0];
123
+ this.token('NUMBER', number);
124
+ return number.length;
125
+ };
126
+ Lexer.prototype.stringToken = function() {
127
+ var match, string;
128
+ switch (this.chunk.charAt(0)) {
129
+ case "'":
130
+ if (!(match = SIMPLESTR.exec(this.chunk))) {
131
+ return 0;
132
+ }
133
+ this.token('STRING', (string = match[0]).replace(MULTILINER, '\\\n'));
134
+ break;
135
+ case '"':
136
+ if (!(string = this.balancedString(this.chunk, '"'))) {
137
+ return 0;
138
+ }
139
+ if (0 < string.indexOf('#{', 1)) {
140
+ this.interpolateString(string.slice(1, -1));
141
+ } else {
142
+ this.token('STRING', this.escapeLines(string));
143
+ }
144
+ break;
145
+ default:
146
+ return 0;
147
+ }
148
+ this.line += count(string, '\n');
149
+ return string.length;
150
+ };
151
+ Lexer.prototype.heredocToken = function() {
152
+ var doc, heredoc, match, quote;
153
+ if (!(match = HEREDOC.exec(this.chunk))) {
154
+ return 0;
155
+ }
156
+ heredoc = match[0];
157
+ quote = heredoc.charAt(0);
158
+ doc = this.sanitizeHeredoc(match[2], {
159
+ quote: quote,
160
+ indent: null
161
+ });
162
+ if (quote === '"' && 0 <= doc.indexOf('#{')) {
163
+ this.interpolateString(doc, {
164
+ heredoc: true
165
+ });
166
+ } else {
167
+ this.token('STRING', this.makeString(doc, quote, true));
168
+ }
169
+ this.line += count(heredoc, '\n');
170
+ return heredoc.length;
171
+ };
172
+ Lexer.prototype.commentToken = function() {
173
+ var comment, here, match;
174
+ if (!(match = this.chunk.match(COMMENT))) {
175
+ return 0;
176
+ }
177
+ comment = match[0], here = match[1];
178
+ if (here) {
179
+ this.token('HERECOMMENT', this.sanitizeHeredoc(here, {
180
+ herecomment: true,
181
+ indent: Array(this.indent + 1).join(' ')
182
+ }));
183
+ this.token('TERMINATOR', '\n');
184
+ }
185
+ this.line += count(comment, '\n');
186
+ return comment.length;
187
+ };
188
+ Lexer.prototype.jsToken = function() {
189
+ var match, script;
190
+ if (!(this.chunk.charAt(0) === '`' && (match = JSTOKEN.exec(this.chunk)))) {
191
+ return 0;
192
+ }
193
+ this.token('JS', (script = match[0]).slice(1, -1));
194
+ return script.length;
195
+ };
196
+ Lexer.prototype.regexToken = function() {
197
+ var length, match, prev, regex, _ref2;
198
+ if (this.chunk.charAt(0) !== '/') {
199
+ return 0;
200
+ }
201
+ if (match = HEREGEX.exec(this.chunk)) {
202
+ length = this.heregexToken(match);
203
+ this.line += count(match[0], '\n');
204
+ return length;
205
+ }
206
+ prev = last(this.tokens);
207
+ if (prev && (_ref2 = prev[0], __indexOf.call((prev.spaced ? NOT_REGEX : NOT_SPACED_REGEX), _ref2) >= 0)) {
208
+ return 0;
209
+ }
210
+ if (!(match = REGEX.exec(this.chunk))) {
211
+ return 0;
212
+ }
213
+ regex = match[0];
214
+ this.token('REGEX', regex === '//' ? '/(?:)/' : regex);
215
+ return regex.length;
216
+ };
217
+ Lexer.prototype.heregexToken = function(match) {
218
+ var body, flags, heregex, re, tag, tokens, value, _i, _len, _ref2, _ref3, _ref4, _ref5;
219
+ heregex = match[0], body = match[1], flags = match[2];
220
+ if (0 > body.indexOf('#{')) {
221
+ re = body.replace(HEREGEX_OMIT, '').replace(/\//g, '\\/');
222
+ this.token('REGEX', "/" + (re || '(?:)') + "/" + flags);
223
+ return heregex.length;
224
+ }
225
+ this.token('IDENTIFIER', 'RegExp');
226
+ this.tokens.push(['CALL_START', '(']);
227
+ tokens = [];
228
+ _ref2 = this.interpolateString(body, {
229
+ regex: true
230
+ });
231
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
232
+ _ref3 = _ref2[_i], tag = _ref3[0], value = _ref3[1];
233
+ if (tag === 'TOKENS') {
234
+ tokens.push.apply(tokens, value);
235
+ } else {
236
+ if (!(value = value.replace(HEREGEX_OMIT, ''))) {
237
+ continue;
238
+ }
239
+ value = value.replace(/\\/g, '\\\\');
240
+ tokens.push(['STRING', this.makeString(value, '"', true)]);
241
+ }
242
+ tokens.push(['+', '+']);
243
+ }
244
+ tokens.pop();
245
+ if (((_ref4 = tokens[0]) != null ? _ref4[0] : void 0) !== 'STRING') {
246
+ this.tokens.push(['STRING', '""'], ['+', '+']);
247
+ }
248
+ (_ref5 = this.tokens).push.apply(_ref5, tokens);
249
+ if (flags) {
250
+ this.tokens.push([',', ','], ['STRING', '"' + flags + '"']);
251
+ }
252
+ this.token(')', ')');
253
+ return heregex.length;
254
+ };
255
+ Lexer.prototype.lineToken = function() {
256
+ var diff, indent, match, noNewlines, prev, size;
257
+ if (!(match = MULTI_DENT.exec(this.chunk))) {
258
+ return 0;
259
+ }
260
+ indent = match[0];
261
+ this.line += count(indent, '\n');
262
+ prev = last(this.tokens, 1);
263
+ size = indent.length - 1 - indent.lastIndexOf('\n');
264
+ noNewlines = this.unfinished();
265
+ if (size - this.indebt === this.indent) {
266
+ if (noNewlines) {
267
+ this.suppressNewlines();
268
+ } else {
269
+ this.newlineToken();
270
+ }
271
+ return indent.length;
272
+ }
273
+ if (size > this.indent) {
274
+ if (noNewlines) {
275
+ this.indebt = size - this.indent;
276
+ this.suppressNewlines();
277
+ return indent.length;
278
+ }
279
+ diff = size - this.indent + this.outdebt;
280
+ this.token('INDENT', diff);
281
+ this.indents.push(diff);
282
+ this.outdebt = this.indebt = 0;
283
+ } else {
284
+ this.indebt = 0;
285
+ this.outdentToken(this.indent - size, noNewlines);
286
+ }
287
+ this.indent = size;
288
+ return indent.length;
289
+ };
290
+ Lexer.prototype.outdentToken = function(moveOut, noNewlines, close) {
291
+ var dent, len;
292
+ while (moveOut > 0) {
293
+ len = this.indents.length - 1;
294
+ if (this.indents[len] === void 0) {
295
+ moveOut = 0;
296
+ } else if (this.indents[len] === this.outdebt) {
297
+ moveOut -= this.outdebt;
298
+ this.outdebt = 0;
299
+ } else if (this.indents[len] < this.outdebt) {
300
+ this.outdebt -= this.indents[len];
301
+ moveOut -= this.indents[len];
302
+ } else {
303
+ dent = this.indents.pop() - this.outdebt;
304
+ moveOut -= dent;
305
+ this.outdebt = 0;
306
+ this.token('OUTDENT', dent);
307
+ }
308
+ }
309
+ if (dent) {
310
+ this.outdebt -= moveOut;
311
+ }
312
+ if (!(this.tag() === 'TERMINATOR' || noNewlines)) {
313
+ this.token('TERMINATOR', '\n');
314
+ }
315
+ return this;
316
+ };
317
+ Lexer.prototype.whitespaceToken = function() {
318
+ var match, nline, prev;
319
+ if (!((match = WHITESPACE.exec(this.chunk)) || (nline = this.chunk.charAt(0) === '\n'))) {
320
+ return 0;
321
+ }
322
+ prev = last(this.tokens);
323
+ if (prev) {
324
+ prev[match ? 'spaced' : 'newLine'] = true;
325
+ }
326
+ if (match) {
327
+ return match[0].length;
328
+ } else {
329
+ return 0;
330
+ }
331
+ };
332
+ Lexer.prototype.newlineToken = function() {
333
+ if (this.tag() !== 'TERMINATOR') {
334
+ this.token('TERMINATOR', '\n');
335
+ }
336
+ return this;
337
+ };
338
+ Lexer.prototype.suppressNewlines = function() {
339
+ if (this.value() === '\\') {
340
+ this.tokens.pop();
341
+ }
342
+ return this;
343
+ };
344
+ Lexer.prototype.literalToken = function() {
345
+ var match, prev, tag, value, _ref2, _ref3, _ref4, _ref5;
346
+ if (match = OPERATOR.exec(this.chunk)) {
347
+ value = match[0];
348
+ if (CODE.test(value)) {
349
+ this.tagParameters();
350
+ }
351
+ } else {
352
+ value = this.chunk.charAt(0);
353
+ }
354
+ tag = value;
355
+ prev = last(this.tokens);
356
+ if (value === '=' && prev) {
357
+ if (!prev[1].reserved && (_ref2 = prev[1], __indexOf.call(JS_FORBIDDEN, _ref2) >= 0)) {
358
+ this.assignmentError();
359
+ }
360
+ if ((_ref3 = prev[1]) === '||' || _ref3 === '&&') {
361
+ prev[0] = 'COMPOUND_ASSIGN';
362
+ prev[1] += '=';
363
+ return value.length;
364
+ }
365
+ }
366
+ if (value === ';') {
367
+ tag = 'TERMINATOR';
368
+ } else if (__indexOf.call(MATH, value) >= 0) {
369
+ tag = 'MATH';
370
+ } else if (__indexOf.call(COMPARE, value) >= 0) {
371
+ tag = 'COMPARE';
372
+ } else if (__indexOf.call(COMPOUND_ASSIGN, value) >= 0) {
373
+ tag = 'COMPOUND_ASSIGN';
374
+ } else if (__indexOf.call(UNARY, value) >= 0) {
375
+ tag = 'UNARY';
376
+ } else if (__indexOf.call(SHIFT, value) >= 0) {
377
+ tag = 'SHIFT';
378
+ } else if (__indexOf.call(LOGIC, value) >= 0 || value === '?' && (prev != null ? prev.spaced : void 0)) {
379
+ tag = 'LOGIC';
380
+ } else if (prev && !prev.spaced) {
381
+ if (value === '(' && (_ref4 = prev[0], __indexOf.call(CALLABLE, _ref4) >= 0)) {
382
+ if (prev[0] === '?') {
383
+ prev[0] = 'FUNC_EXIST';
384
+ }
385
+ tag = 'CALL_START';
386
+ } else if (value === '[' && (_ref5 = prev[0], __indexOf.call(INDEXABLE, _ref5) >= 0)) {
387
+ tag = 'INDEX_START';
388
+ switch (prev[0]) {
389
+ case '?':
390
+ prev[0] = 'INDEX_SOAK';
391
+ break;
392
+ case '::':
393
+ prev[0] = 'INDEX_PROTO';
394
+ }
395
+ }
396
+ }
397
+ this.token(tag, value);
398
+ return value.length;
399
+ };
400
+ Lexer.prototype.sanitizeHeredoc = function(doc, options) {
401
+ var attempt, herecomment, indent, match, _ref2;
402
+ indent = options.indent, herecomment = options.herecomment;
403
+ if (herecomment) {
404
+ if (HEREDOC_ILLEGAL.test(doc)) {
405
+ throw new Error("block comment cannot contain \"*/\", starting on line " + (this.line + 1));
406
+ }
407
+ if (doc.indexOf('\n') <= 0) {
408
+ return doc;
409
+ }
410
+ } else {
411
+ while (match = HEREDOC_INDENT.exec(doc)) {
412
+ attempt = match[1];
413
+ if (indent === null || (0 < (_ref2 = attempt.length) && _ref2 < indent.length)) {
414
+ indent = attempt;
415
+ }
416
+ }
417
+ }
418
+ if (indent) {
419
+ doc = doc.replace(RegExp("\\n" + indent, "g"), '\n');
420
+ }
421
+ if (!herecomment) {
422
+ doc = doc.replace(/^\n/, '');
423
+ }
424
+ return doc;
425
+ };
426
+ Lexer.prototype.tagParameters = function() {
427
+ var i, stack, tok, tokens;
428
+ if (this.tag() !== ')') {
429
+ return this;
430
+ }
431
+ stack = [];
432
+ tokens = this.tokens;
433
+ i = tokens.length;
434
+ tokens[--i][0] = 'PARAM_END';
435
+ while (tok = tokens[--i]) {
436
+ switch (tok[0]) {
437
+ case ')':
438
+ stack.push(tok);
439
+ break;
440
+ case '(':
441
+ case 'CALL_START':
442
+ if (stack.length) {
443
+ stack.pop();
444
+ } else if (tok[0] === '(') {
445
+ tok[0] = 'PARAM_START';
446
+ return this;
447
+ } else {
448
+ return this;
449
+ }
450
+ }
451
+ }
452
+ return this;
453
+ };
454
+ Lexer.prototype.closeIndentation = function() {
455
+ return this.outdentToken(this.indent);
456
+ };
457
+ Lexer.prototype.identifierError = function(word) {
458
+ throw SyntaxError("Reserved word \"" + word + "\" on line " + (this.line + 1));
459
+ };
460
+ Lexer.prototype.assignmentError = function() {
461
+ throw SyntaxError("Reserved word \"" + (this.value()) + "\" on line " + (this.line + 1) + " can't be assigned");
462
+ };
463
+ Lexer.prototype.balancedString = function(str, end) {
464
+ var i, letter, match, prev, stack, _ref2;
465
+ stack = [end];
466
+ for (i = 1, _ref2 = str.length; 1 <= _ref2 ? i < _ref2 : i > _ref2; 1 <= _ref2 ? i++ : i--) {
467
+ switch (letter = str.charAt(i)) {
468
+ case '\\':
469
+ i++;
470
+ continue;
471
+ case end:
472
+ stack.pop();
473
+ if (!stack.length) {
474
+ return str.slice(0, i + 1);
475
+ }
476
+ end = stack[stack.length - 1];
477
+ continue;
478
+ }
479
+ if (end === '}' && (letter === '"' || letter === "'")) {
480
+ stack.push(end = letter);
481
+ } else if (end === '}' && letter === '/' && (match = HEREGEX.exec(str.slice(i)) || REGEX.exec(str.slice(i)))) {
482
+ i += match[0].length - 1;
483
+ } else if (end === '}' && letter === '{') {
484
+ stack.push(end = '}');
485
+ } else if (end === '"' && prev === '#' && letter === '{') {
486
+ stack.push(end = '}');
487
+ }
488
+ prev = letter;
489
+ }
490
+ throw new Error("missing " + (stack.pop()) + ", starting on line " + (this.line + 1));
491
+ };
492
+ Lexer.prototype.interpolateString = function(str, options) {
493
+ var expr, heredoc, i, inner, interpolated, len, letter, nested, pi, regex, tag, tokens, value, _len, _ref2, _ref3, _ref4;
494
+ if (options == null) {
495
+ options = {};
496
+ }
497
+ heredoc = options.heredoc, regex = options.regex;
498
+ tokens = [];
499
+ pi = 0;
500
+ i = -1;
501
+ while (letter = str.charAt(i += 1)) {
502
+ if (letter === '\\') {
503
+ i += 1;
504
+ continue;
505
+ }
506
+ if (!(letter === '#' && str.charAt(i + 1) === '{' && (expr = this.balancedString(str.slice(i + 1), '}')))) {
507
+ continue;
508
+ }
509
+ if (pi < i) {
510
+ tokens.push(['NEOSTRING', str.slice(pi, i)]);
511
+ }
512
+ inner = expr.slice(1, -1);
513
+ if (inner.length) {
514
+ nested = new Lexer().tokenize(inner, {
515
+ line: this.line,
516
+ rewrite: false
517
+ });
518
+ nested.pop();
519
+ if (((_ref2 = nested[0]) != null ? _ref2[0] : void 0) === 'TERMINATOR') {
520
+ nested.shift();
521
+ }
522
+ if (len = nested.length) {
523
+ if (len > 1) {
524
+ nested.unshift(['(', '(']);
525
+ nested.push([')', ')']);
526
+ }
527
+ tokens.push(['TOKENS', nested]);
528
+ }
529
+ }
530
+ i += expr.length;
531
+ pi = i + 1;
532
+ }
533
+ if ((i > pi && pi < str.length)) {
534
+ tokens.push(['NEOSTRING', str.slice(pi)]);
535
+ }
536
+ if (regex) {
537
+ return tokens;
538
+ }
539
+ if (!tokens.length) {
540
+ return this.token('STRING', '""');
541
+ }
542
+ if (tokens[0][0] !== 'NEOSTRING') {
543
+ tokens.unshift(['', '']);
544
+ }
545
+ if (interpolated = tokens.length > 1) {
546
+ this.token('(', '(');
547
+ }
548
+ for (i = 0, _len = tokens.length; i < _len; i++) {
549
+ _ref3 = tokens[i], tag = _ref3[0], value = _ref3[1];
550
+ if (i) {
551
+ this.token('+', '+');
552
+ }
553
+ if (tag === 'TOKENS') {
554
+ (_ref4 = this.tokens).push.apply(_ref4, value);
555
+ } else {
556
+ this.token('STRING', this.makeString(value, '"', heredoc));
557
+ }
558
+ }
559
+ if (interpolated) {
560
+ this.token(')', ')');
561
+ }
562
+ return tokens;
563
+ };
564
+ Lexer.prototype.token = function(tag, value) {
565
+ return this.tokens.push([tag, value, this.line]);
566
+ };
567
+ Lexer.prototype.tag = function(index, tag) {
568
+ var tok;
569
+ return (tok = last(this.tokens, index)) && (tag ? tok[0] = tag : tok[0]);
570
+ };
571
+ Lexer.prototype.value = function(index, val) {
572
+ var tok;
573
+ return (tok = last(this.tokens, index)) && (val ? tok[1] = val : tok[1]);
574
+ };
575
+ Lexer.prototype.unfinished = function() {
576
+ var prev, value;
577
+ return LINE_CONTINUER.test(this.chunk) || (prev = last(this.tokens, 1)) && prev[0] !== '.' && (value = this.value()) && !value.reserved && NO_NEWLINE.test(value) && !CODE.test(value) && !ASSIGNED.test(this.chunk);
578
+ };
579
+ Lexer.prototype.escapeLines = function(str, heredoc) {
580
+ return str.replace(MULTILINER, heredoc ? '\\n' : '');
581
+ };
582
+ Lexer.prototype.makeString = function(body, quote, heredoc) {
583
+ if (!body) {
584
+ return quote + quote;
585
+ }
586
+ body = body.replace(/\\([\s\S])/g, function(match, contents) {
587
+ if (contents === '\n' || contents === quote) {
588
+ return contents;
589
+ } else {
590
+ return match;
591
+ }
592
+ });
593
+ body = body.replace(RegExp("" + quote, "g"), '\\$&');
594
+ return quote + this.escapeLines(body, heredoc) + quote;
595
+ };
596
+ return Lexer;
597
+ })();
598
+ JS_KEYWORDS = ['true', 'false', 'null', 'this', 'new', 'delete', 'typeof', 'in', 'instanceof', 'return', 'throw', 'break', 'continue', 'debugger', 'if', 'else', 'switch', 'for', 'while', 'do', 'try', 'catch', 'finally', 'class', 'extends', 'super'];
599
+ COFFEE_KEYWORDS = ['undefined', 'then', 'unless', 'until', 'loop', 'of', 'by', 'when'];
600
+ COFFEE_ALIAS_MAP = {
601
+ and: '&&',
602
+ or: '||',
603
+ is: '==',
604
+ isnt: '!=',
605
+ not: '!',
606
+ yes: 'true',
607
+ no: 'false',
608
+ on: 'true',
609
+ off: 'false'
610
+ };
611
+ COFFEE_ALIASES = (function() {
612
+ var _results;
613
+ _results = [];
614
+ for (key in COFFEE_ALIAS_MAP) {
615
+ _results.push(key);
616
+ }
617
+ return _results;
618
+ })();
619
+ COFFEE_KEYWORDS = COFFEE_KEYWORDS.concat(COFFEE_ALIASES);
620
+ RESERVED = ['case', 'default', 'function', 'var', 'void', 'with', 'const', 'let', 'enum', 'export', 'import', 'native', '__hasProp', '__extends', '__slice', '__bind', '__indexOf'];
621
+ JS_FORBIDDEN = JS_KEYWORDS.concat(RESERVED);
622
+ exports.RESERVED = RESERVED.concat(JS_KEYWORDS).concat(COFFEE_KEYWORDS);
623
+ IDENTIFIER = /^([$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)([^\n\S]*:(?!:))?/;
624
+ NUMBER = /^0x[\da-f]+|^\d*\.?\d+(?:e[+-]?\d+)?/i;
625
+ HEREDOC = /^("""|''')([\s\S]*?)(?:\n[^\n\S]*)?\1/;
626
+ OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?\.|\.{2,3})/;
627
+ WHITESPACE = /^[^\n\S]+/;
628
+ COMMENT = /^###([^#][\s\S]*?)(?:###[^\n\S]*|(?:###)?$)|^(?:\s*#(?!##[^#]).*)+/;
629
+ CODE = /^[-=]>/;
630
+ MULTI_DENT = /^(?:\n[^\n\S]*)+/;
631
+ SIMPLESTR = /^'[^\\']*(?:\\.[^\\']*)*'/;
632
+ JSTOKEN = /^`[^\\`]*(?:\\.[^\\`]*)*`/;
633
+ REGEX = /^\/(?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/[imgy]{0,4}(?!\w)/;
634
+ HEREGEX = /^\/{3}([\s\S]+?)\/{3}([imgy]{0,4})(?!\w)/;
635
+ HEREGEX_OMIT = /\s+(?:#.*)?/g;
636
+ MULTILINER = /\n/g;
637
+ HEREDOC_INDENT = /\n+([^\n\S]*)/g;
638
+ HEREDOC_ILLEGAL = /\*\//;
639
+ ASSIGNED = /^\s*@?([$A-Za-z_][$\w\x7f-\uffff]*|['"].*['"])[^\n\S]*?[:=][^:=>]/;
640
+ LINE_CONTINUER = /^\s*(?:,|\??\.(?![.\d])|::)/;
641
+ TRAILING_SPACES = /\s+$/;
642
+ NO_NEWLINE = /^(?:[-+*&|\/%=<>!.\\][<>=&|]*|and|or|is(?:nt)?|n(?:ot|ew)|delete|typeof|instanceof)$/;
643
+ COMPOUND_ASSIGN = ['-=', '+=', '/=', '*=', '%=', '||=', '&&=', '?=', '<<=', '>>=', '>>>=', '&=', '^=', '|='];
644
+ UNARY = ['!', '~', 'NEW', 'TYPEOF', 'DELETE', 'DO'];
645
+ LOGIC = ['&&', '||', '&', '|', '^'];
646
+ SHIFT = ['<<', '>>', '>>>'];
647
+ COMPARE = ['==', '!=', '<', '>', '<=', '>='];
648
+ MATH = ['*', '/', '%'];
649
+ RELATION = ['IN', 'OF', 'INSTANCEOF'];
650
+ BOOL = ['TRUE', 'FALSE', 'NULL', 'UNDEFINED'];
651
+ NOT_REGEX = ['NUMBER', 'REGEX', 'BOOL', '++', '--', ']'];
652
+ NOT_SPACED_REGEX = NOT_REGEX.concat(')', '}', 'THIS', 'IDENTIFIER', 'STRING');
653
+ CALLABLE = ['IDENTIFIER', 'STRING', 'REGEX', ')', ']', '}', '?', '::', '@', 'THIS', 'SUPER'];
654
+ INDEXABLE = CALLABLE.concat('NUMBER', 'BOOL');
655
+ LINE_BREAK = ['INDENT', 'OUTDENT', 'TERMINATOR'];
656
+ }).call(this);