yellow-brick-road 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/README.rst +42 -20
  2. data/lib/generators/templates/yellow_brick_road.rb.erb +19 -0
  3. data/lib/generators/yellow_brick_road/install_generator.rb +14 -0
  4. data/lib/yellow-brick-road/config.rb +41 -8
  5. data/lib/yellow-brick-road/directive_processor.rb +6 -5
  6. data/lib/yellow-brick-road/engine.rb +2 -3
  7. data/lib/yellow-brick-road/soy_processor.rb +1 -1
  8. data/lib/yellow-brick-road/version.rb +1 -1
  9. data/test/dummy/app/assets/javascripts/closure-deps.js +1 -1
  10. data/test/dummy/config/initializers/yellow_brick_road.rb +18 -1
  11. data/test/dummy/log/development.log +2208 -0
  12. data/test/dummy/tmp/cache/assets/C33/E00/sprockets%2F50c54266987e056bca666f8951752841 +2556 -0
  13. data/test/dummy/tmp/cache/assets/C48/990/sprockets%2F182c7921a46c3b8603c7f5595a111407 +823 -0
  14. data/test/dummy/tmp/cache/assets/C53/B40/sprockets%2F48cf0c035092dc945559526a279061c6 +204 -0
  15. data/test/dummy/tmp/cache/assets/C60/DB0/sprockets%2F3f00684578f2a3246581db667309ed89 +187 -0
  16. data/test/dummy/tmp/cache/assets/C60/E40/sprockets%2F3c5422f721521f492a5f02ca00b70009 +457 -0
  17. data/test/dummy/tmp/cache/assets/C73/DE0/sprockets%2F21f1f4574326846114a3c106873cebc3 +0 -0
  18. data/test/dummy/tmp/cache/assets/C7E/9F0/sprockets%2F89862076204c62c4593ac20de32da909 +4 -4
  19. data/test/dummy/tmp/cache/assets/C80/6F0/sprockets%2F56459a0713f8610d7d261f8be93073a2 +115 -0
  20. data/test/dummy/tmp/cache/assets/C8D/E10/sprockets%2F34b84bc4732937f885707002eda3896e +511 -0
  21. data/test/dummy/tmp/cache/assets/C93/CB0/sprockets%2F539b403b24833ca478a6f5877f37687c +239 -0
  22. data/test/dummy/tmp/cache/assets/C9A/C70/sprockets%2F10933dc6d342f604514713510b9ef0ab +806 -0
  23. data/test/dummy/tmp/cache/assets/CA0/7C0/sprockets%2Ff591bc0af8f085501241305c04907d3e +590 -0
  24. data/test/dummy/tmp/cache/assets/CA1/4A0/sprockets%2F5a9ad311e7d225b530b597041714b1e9 +2539 -0
  25. data/test/dummy/tmp/cache/assets/CA7/310/sprockets%2F45664cf816315200b574e029fde6f10a +0 -0
  26. data/test/dummy/tmp/cache/assets/CA7/A80/sprockets%2F1f32590957635a5a4f35442bc22f4ca4 +0 -0
  27. data/test/dummy/tmp/cache/assets/CAE/1D0/sprockets%2F2e62c7733d38a817a1532a744c6287bd +72 -0
  28. data/test/dummy/tmp/cache/assets/CB2/3C0/sprockets%2F9c35c290501a896b82c31448a39f3d5d +142 -0
  29. data/test/dummy/tmp/cache/assets/CB3/F20/sprockets%2F558b00e493fb501f7d95761e7eb40273 +2539 -0
  30. data/test/dummy/tmp/cache/assets/CBE/550/sprockets%2Fd680cac830e0b3408ba910f0b0421147 +2 -2
  31. data/test/dummy/tmp/cache/assets/CCD/480/sprockets%2Ffe7e11511634a2d03e1a20980b4593cf +0 -0
  32. data/test/dummy/tmp/cache/assets/CD0/080/sprockets%2Ffd5cbb87741244521d013d11c55573fa +204 -0
  33. data/test/dummy/tmp/cache/assets/CD2/020/sprockets%2Ff97740ba22118a2c91e992aac041843b +811 -0
  34. data/test/dummy/tmp/cache/assets/CD8/D90/sprockets%2F55dd841661d646f0024261a08ecf8ec0 +823 -0
  35. data/test/dummy/tmp/cache/assets/CE3/0D0/sprockets%2F301f97a178fd839a81bd663a6e22b616 +811 -0
  36. data/test/dummy/tmp/cache/assets/CE4/330/sprockets%2Fbd23466639af99164ab8e1c93721f14b +127 -0
  37. data/test/dummy/tmp/cache/assets/CE6/8A0/sprockets%2F3c0e7c5fa31563c8e820d6771e09918d +103 -0
  38. data/test/dummy/tmp/cache/assets/CEB/120/sprockets%2F857a0dde6829f7a27b93a840e1c60469 +522 -0
  39. data/test/dummy/tmp/cache/assets/CEE/CF0/sprockets%2F376f94b987d8156056c4e1d38ec06bf0 +0 -0
  40. data/test/dummy/tmp/cache/assets/CF2/C10/sprockets%2Fc64ef8a9dd0a1c3101d662750105c11a +806 -0
  41. data/test/dummy/tmp/cache/assets/CF3/CD0/sprockets%2F4bb42a5a6b504190f10d20b1c5f93d54 +1529 -0
  42. data/test/dummy/tmp/cache/assets/CF6/890/sprockets%2F36007a87f140155b5a04f2ca6b262dcc +494 -0
  43. data/test/dummy/tmp/cache/assets/CF6/9D0/sprockets%2F34b7199e9d33994c8ec7a442d60ca985 +173 -0
  44. data/test/dummy/tmp/cache/assets/CFA/A90/sprockets%2F901ba405a6d6747f6412ed4d0e0ac620 +256 -0
  45. data/test/dummy/tmp/cache/assets/CFC/E70/sprockets%2F8ee639668b5f0e629fbe0d62d1394689 +173 -0
  46. data/test/dummy/tmp/cache/assets/D04/1B0/sprockets%2F418f2b3b6b08b320f6db268a0991c54c +0 -0
  47. data/test/dummy/tmp/cache/assets/D05/920/sprockets%2F909507434dcc270db4853e4c147f0aac +5 -4
  48. data/test/dummy/tmp/cache/assets/D07/DB0/sprockets%2F0c17d7dac64290e385c91eb6f1570b31 +511 -0
  49. data/test/dummy/tmp/cache/assets/D07/EE0/sprockets%2F4999982b09e0b786894fce44f5d783cc +1371 -0
  50. data/test/dummy/tmp/cache/assets/D09/380/sprockets%2F14383e18fa2faac6b561a29d8e132863 +0 -0
  51. data/test/dummy/tmp/cache/assets/D0D/200/sprockets%2F545a7e34cce1d4272d83d58fd4215d42 +1277 -0
  52. data/test/dummy/tmp/cache/assets/D0E/870/sprockets%2F84996444f4f1f3fdc0248131cfb1a3b6 +794 -0
  53. data/test/dummy/tmp/cache/assets/D15/F60/sprockets%2Fa28394e3f80365b5bc86794dd46daa22 +0 -0
  54. data/test/dummy/tmp/cache/assets/D18/950/sprockets%2Fcf650d67c5d431ffdb38552e562299b2 +474 -0
  55. data/test/dummy/tmp/cache/assets/D18/E10/sprockets%2Fec7c58f640556b401fcd66528352dc9d +474 -0
  56. data/test/dummy/tmp/cache/assets/D20/660/sprockets%2F0d2875475ced01df962f3d758cda7792 +103 -0
  57. data/test/dummy/tmp/cache/assets/D22/AB0/sprockets%2F0b08e7f81651aaf739a93d61ae99779c +283 -0
  58. data/test/dummy/tmp/cache/assets/D2E/B20/sprockets%2Feed5412a17a52b1a335925e2af1f75d3 +0 -0
  59. data/test/dummy/tmp/cache/assets/D36/700/sprockets%2Fd219bf9db2eacc105bb294755093a437 +505 -0
  60. data/test/dummy/tmp/cache/assets/D3B/A10/sprockets%2Fcf38b51682d84a04da7b8a7313de52c6 +207 -0
  61. data/test/dummy/tmp/cache/assets/D3C/0E0/sprockets%2Fe9d7aba138d602c4a6ac701bc9615977 +505 -0
  62. data/test/dummy/tmp/cache/assets/D3E/FF0/sprockets%2F6bd8ccd3e02f397c20f349d5c0960e51 +0 -0
  63. data/test/dummy/tmp/cache/assets/D41/B30/sprockets%2Fba1b93913dd01d83ac9a96df334456f8 +0 -0
  64. data/test/dummy/tmp/cache/assets/D41/DA0/sprockets%2Fe8d00810698a9fcee032022fefd084f7 +0 -0
  65. data/test/dummy/tmp/cache/assets/D44/CF0/sprockets%2Ffa31a45f04884493c909c5a67fcbdf23 +1371 -0
  66. data/test/dummy/tmp/cache/assets/D47/BE0/sprockets%2F0b5ebdf6dec160a264698e7f745061e8 +142 -0
  67. data/test/dummy/tmp/cache/assets/D4C/F30/sprockets%2Ff90155c10f59a3fe44959ac09bf817fe +2556 -0
  68. data/test/dummy/tmp/cache/assets/D4E/7C0/sprockets%2Ff01b58512d01eda23fd5cb23a2b28b60 +1529 -0
  69. data/test/dummy/tmp/cache/assets/D4E/860/sprockets%2F86eed0c77c47d0970345bbabb58d8939 +1277 -0
  70. data/test/dummy/tmp/cache/assets/D4E/C30/sprockets%2F52420c10c73ca310d026565eafdadb4e +1545 -0
  71. data/test/dummy/tmp/cache/assets/D4E/F60/sprockets%2F9893a3c5aeb1a9e77469f4751b4d3c3f +115 -0
  72. data/test/dummy/tmp/cache/assets/D4F/E60/sprockets%2F17ee65de1f78c3dd5c165a9867e810b6 +165 -0
  73. data/test/dummy/tmp/cache/assets/D57/0D0/sprockets%2Fa29e6e8106d9d5ed1e2889126cfbf877 +300 -0
  74. data/test/dummy/tmp/cache/assets/D5C/650/sprockets%2Fe1c381da3cc213a639e956ae3315a2bd +607 -0
  75. data/test/dummy/tmp/cache/assets/D61/860/sprockets%2Fbf032a3b4aad2c2e25704e65c966cf45 +794 -0
  76. data/test/dummy/tmp/cache/assets/D63/B20/sprockets%2F31fc70ce66bb80fb9421be34eb3b0287 +0 -0
  77. data/test/dummy/tmp/cache/assets/D64/D60/sprockets%2Fa544ea03bf0a45948a053ba76ec2a79f +239 -0
  78. data/test/dummy/tmp/cache/assets/D6B/F90/sprockets%2F66636712ecb1fcc777dccf7643a0e1b1 +127 -0
  79. data/test/dummy/tmp/cache/assets/D6E/AD0/sprockets%2Fc91cdc6a72c729d7a64119198b3d2eab +0 -0
  80. data/test/dummy/tmp/cache/assets/D6F/140/sprockets%2F9ddc51f4388dd5243a28dba1ce47572b +53 -0
  81. data/test/dummy/tmp/cache/assets/D72/800/sprockets%2F92baa375d54e16fe0a5c7f079a1ce992 +165 -0
  82. data/test/dummy/tmp/cache/assets/D74/220/sprockets%2F3f888bda53179cb945eab35fbd31a708 +53 -0
  83. data/test/dummy/tmp/cache/assets/D78/5F0/sprockets%2F638ed6af667d4fc5147f72ff34aa2d33 +0 -0
  84. data/test/dummy/tmp/cache/assets/D7D/640/sprockets%2F95a7c5580f957c31e1ab9d0773ed5fde +607 -0
  85. data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +6 -5
  86. data/test/dummy/tmp/cache/assets/D89/020/sprockets%2Fa06df6166e70324e712e54b1cafca0ae +187 -0
  87. data/test/dummy/tmp/cache/assets/D8A/9F0/sprockets%2Fc06547ca33ee3d03be14ce045ae1c9e2 +207 -0
  88. data/test/dummy/tmp/cache/assets/D9E/B80/sprockets%2F9561df1d45c7ff4aa8ac3e2df0c99121 +0 -0
  89. data/test/dummy/tmp/cache/assets/DA3/F30/sprockets%2Fe015d6ccdfcf022e47c83d7906f728ae +457 -0
  90. data/test/dummy/tmp/cache/assets/DAE/190/sprockets%2F433c7b21968be8d1f9bfdbdf7a637c57 +0 -0
  91. data/test/dummy/tmp/cache/assets/DB3/600/sprockets%2F9b70ae73f15ba693886eeef4eb5d6c75 +0 -0
  92. data/test/dummy/tmp/cache/assets/DB4/510/sprockets%2F29cdae8e29c88fd9ddbd4831419560fe +1260 -0
  93. data/test/dummy/tmp/cache/assets/DC1/4A0/sprockets%2F0b63dfcf163f2faeb612724eb4545bcc +1354 -0
  94. data/test/dummy/tmp/cache/assets/DC4/C10/sprockets%2Fcf48f4cbad3db33146eab4c577c1d209 +300 -0
  95. data/test/dummy/tmp/cache/assets/DC4/CA0/sprockets%2Fd0da8a60ea4dc16b9fd3e2a50d88633c +0 -0
  96. data/test/dummy/tmp/cache/assets/DC7/8C0/sprockets%2F1ad68dcc9ef598d3811ba2ac5c0ea182 +1354 -0
  97. data/test/dummy/tmp/cache/assets/DC7/C00/sprockets%2Fba755ff3a81c3192f0e45a4f7c0c7dcb +0 -0
  98. data/test/dummy/tmp/cache/assets/DCA/760/sprockets%2F717c4cea10bf601090ffdfe4e668e4cb +283 -0
  99. data/test/dummy/tmp/cache/assets/DCA/DE0/sprockets%2F51dcced9ec2b3cd4b1cc2949f860c361 +590 -0
  100. data/test/dummy/tmp/cache/assets/DD7/E70/sprockets%2F2595d8c8d1d5f4deb096247fb3bfc7ab +256 -0
  101. data/test/dummy/tmp/cache/assets/DE1/9D0/sprockets%2F8befd77af580ee16ec42ec95b1766ff3 +1545 -0
  102. data/test/dummy/tmp/cache/assets/E00/D80/sprockets%2F9debc27161f7bccf2d84a36b8c36c4bf +522 -0
  103. data/test/dummy/tmp/cache/assets/E00/E60/sprockets%2Fac159b94b0a6d621e4f6cde9b4de87bb +0 -0
  104. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  105. data/test/dummy/tmp/cache/assets/E1B/D00/sprockets%2F886dff4afe55f9d3f8abe434f2689add +72 -0
  106. data/test/dummy/tmp/cache/assets/E1B/F20/sprockets%2Fa4bbc04eb83ebf94fd8134c3abd220dd +494 -0
  107. data/test/dummy/tmp/cache/assets/E71/0C0/sprockets%2F5ffdc0daa0a1f9638c787897ceefcdee +1260 -0
  108. metadata +186 -10
  109. data/test/dummy/tmp/pids/server.pid +0 -1
@@ -0,0 +1,1277 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1325538161.859575: @value{I"
2
+ class:EFI"BundledAsset;
3
+ FI"id;
4
+ F"%f2f72cca20744496f7a310f92f345c0cI"logical_path;
5
+ FI""closure/goog/string/string.js;
6
+ TI"
7
+ F"n/Volumes/Development/dev-web/closure-library-wrapper/vendor/closure-library/closure/goog/string/string.jsI"content_type;
8
+ FI"application/javascript;
9
+ FI"
10
+ mtime;
11
+ FI"2012-01-02T16:18:52+00:00;
12
+ FI" body;
13
+ FI"o�// Copyright 2006 The Closure Library Authors. All Rights Reserved.
14
+ //
15
+ // Licensed under the Apache License, Version 2.0 (the "License");
16
+ // you may not use this file except in compliance with the License.
17
+ // You may obtain a copy of the License at
18
+ //
19
+ // http://www.apache.org/licenses/LICENSE-2.0
20
+ //
21
+ // Unless required by applicable law or agreed to in writing, software
22
+ // distributed under the License is distributed on an "AS-IS" BASIS,
23
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
+ // See the License for the specific language governing permissions and
25
+ // limitations under the License.
26
+
27
+ /**
28
+ * @fileoverview Utilities for string manipulation.
29
+ */
30
+
31
+
32
+ /**
33
+ * Namespace for string utilities
34
+ */
35
+
36
+ goog.provide('goog.string');
37
+ goog.provide('goog.string.Unicode');
38
+
39
+
40
+ /**
41
+ * Common Unicode string characters.
42
+ * @enum {string}
43
+ */
44
+ goog.string.Unicode = {
45
+ NBSP: '\xa0'
46
+ };
47
+
48
+
49
+ /**
50
+ * Fast prefix-checker.
51
+ * @param {string} str The string to check.
52
+ * @param {string} prefix A string to look for at the start of {@code str}.
53
+ * @return {boolean} True if {@code str} begins with {@code prefix}.
54
+ */
55
+ goog.string.startsWith = function(str, prefix) {
56
+ return str.lastIndexOf(prefix, 0) == 0;
57
+ };
58
+
59
+
60
+ /**
61
+ * Fast suffix-checker.
62
+ * @param {string} str The string to check.
63
+ * @param {string} suffix A string to look for at the end of {@code str}.
64
+ * @return {boolean} True if {@code str} ends with {@code suffix}.
65
+ */
66
+ goog.string.endsWith = function(str, suffix) {
67
+ var l = str.length - suffix.length;
68
+ return l >= 0 && str.indexOf(suffix, l) == l;
69
+ };
70
+
71
+
72
+ /**
73
+ * Case-insensitive prefix-checker.
74
+ * @param {string} str The string to check.
75
+ * @param {string} prefix A string to look for at the end of {@code str}.
76
+ * @return {boolean} True if {@code str} begins with {@code prefix} (ignoring
77
+ * case).
78
+ */
79
+ goog.string.caseInsensitiveStartsWith = function(str, prefix) {
80
+ return goog.string.caseInsensitiveCompare(
81
+ prefix, str.substr(0, prefix.length)) == 0;
82
+ };
83
+
84
+
85
+ /**
86
+ * Case-insensitive suffix-checker.
87
+ * @param {string} str The string to check.
88
+ * @param {string} suffix A string to look for at the end of {@code str}.
89
+ * @return {boolean} True if {@code str} ends with {@code suffix} (ignoring
90
+ * case).
91
+ */
92
+ goog.string.caseInsensitiveEndsWith = function(str, suffix) {
93
+ return goog.string.caseInsensitiveCompare(
94
+ suffix, str.substr(str.length - suffix.length, suffix.length)) == 0;
95
+ };
96
+
97
+
98
+ /**
99
+ * Does simple python-style string substitution.
100
+ * subs("foo%s hot%s", "bar", "dog") becomes "foobar hotdog".
101
+ * @param {string} str The string containing the pattern.
102
+ * @param {...*} var_args The items to substitute into the pattern.
103
+ * @return {string} A copy of {@code str} in which each occurrence of
104
+ * {@code %s} has been replaced an argument from {@code var_args}.
105
+ */
106
+ goog.string.subs = function(str, var_args) {
107
+ // This appears to be slow, but testing shows it compares more or less
108
+ // equivalent to the regex.exec method.
109
+ for (var i = 1; i < arguments.length; i++) {
110
+ // We cast to String in case an argument is a Function. Replacing $&, for
111
+ // example, with $$$& stops the replace from subsituting the whole match
112
+ // into the resultant string. $$$& in the first replace becomes $$& in the
113
+ // second, which leaves $& in the resultant string. Also:
114
+ // $$, $`, $', $n $nn
115
+ var replacement = String(arguments[i]).replace(/\$/g, '$$$$');
116
+ str = str.replace(/\%s/, replacement);
117
+ }
118
+ return str;
119
+ };
120
+
121
+
122
+ /**
123
+ * Converts multiple whitespace chars (spaces, non-breaking-spaces, new lines
124
+ * and tabs) to a single space, and strips leading and trailing whitespace.
125
+ * @param {string} str Input string.
126
+ * @return {string} A copy of {@code str} with collapsed whitespace.
127
+ */
128
+ goog.string.collapseWhitespace = function(str) {
129
+ // Since IE doesn't include non-breaking-space (0xa0) in their \s character
130
+ // class (as required by section 7.2 of the ECMAScript spec), we explicitly
131
+ // include it in the regexp to enforce consistent cross-browser behavior.
132
+ return str.replace(/[\s\xa0]+/g, ' ').replace(/^\s+|\s+$/g, '');
133
+ };
134
+
135
+
136
+ /**
137
+ * Checks if a string is empty or contains only whitespaces.
138
+ * @param {string} str The string to check.
139
+ * @return {boolean} True if {@code str} is empty or whitespace only.
140
+ */
141
+ goog.string.isEmpty = function(str) {
142
+ // testing length == 0 first is actually slower in all browsers (about the
143
+ // same in Opera).
144
+ // Since IE doesn't include non-breaking-space (0xa0) in their \s character
145
+ // class (as required by section 7.2 of the ECMAScript spec), we explicitly
146
+ // include it in the regexp to enforce consistent cross-browser behavior.
147
+ return /^[\s\xa0]*$/.test(str);
148
+ };
149
+
150
+
151
+ /**
152
+ * Checks if a string is null, empty or contains only whitespaces.
153
+ * @param {*} str The string to check.
154
+ * @return {boolean} True if{@code str} is null, empty, or whitespace only.
155
+ */
156
+ goog.string.isEmptySafe = function(str) {
157
+ return goog.string.isEmpty(goog.string.makeSafe(str));
158
+ };
159
+
160
+
161
+ /**
162
+ * Checks if a string is all breaking whitespace.
163
+ * @param {string} str The string to check.
164
+ * @return {boolean} Whether the string is all breaking whitespace.
165
+ */
166
+ goog.string.isBreakingWhitespace = function(str) {
167
+ return !/[^\t\n\r ]/.test(str);
168
+ };
169
+
170
+
171
+ /**
172
+ * Checks if a string contains all letters.
173
+ * @param {string} str string to check.
174
+ * @return {boolean} True if {@code str} consists entirely of letters.
175
+ */
176
+ goog.string.isAlpha = function(str) {
177
+ return !/[^a-zA-Z]/.test(str);
178
+ };
179
+
180
+
181
+ /**
182
+ * Checks if a string contains only numbers.
183
+ * @param {*} str string to check. If not a string, it will be
184
+ * casted to one.
185
+ * @return {boolean} True if {@code str} is numeric.
186
+ */
187
+ goog.string.isNumeric = function(str) {
188
+ return !/[^0-9]/.test(str);
189
+ };
190
+
191
+
192
+ /**
193
+ * Checks if a string contains only numbers or letters.
194
+ * @param {string} str string to check.
195
+ * @return {boolean} True if {@code str} is alphanumeric.
196
+ */
197
+ goog.string.isAlphaNumeric = function(str) {
198
+ return !/[^a-zA-Z0-9]/.test(str);
199
+ };
200
+
201
+
202
+ /**
203
+ * Checks if a character is a space character.
204
+ * @param {string} ch Character to check.
205
+ * @return {boolean} True if {code ch} is a space.
206
+ */
207
+ goog.string.isSpace = function(ch) {
208
+ return ch == ' ';
209
+ };
210
+
211
+
212
+ /**
213
+ * Checks if a character is a valid unicode character.
214
+ * @param {string} ch Character to check.
215
+ * @return {boolean} True if {code ch} is a valid unicode character.
216
+ */
217
+ goog.string.isUnicodeChar = function(ch) {
218
+ return ch.length == 1 && ch >= ' ' && ch <= '~' ||
219
+ ch >= '\u0080' && ch <= '\uFFFD';
220
+ };
221
+
222
+
223
+ /**
224
+ * Takes a string and replaces newlines with a space. Multiple lines are
225
+ * replaced with a single space.
226
+ * @param {string} str The string from which to strip newlines.
227
+ * @return {string} A copy of {@code str} stripped of newlines.
228
+ */
229
+ goog.string.stripNewlines = function(str) {
230
+ return str.replace(/(\r\n|\r|\n)+/g, ' ');
231
+ };
232
+
233
+
234
+ /**
235
+ * Replaces Windows and Mac new lines with unix style: \r or \r\n with \n.
236
+ * @param {string} str The string to in which to canonicalize newlines.
237
+ * @return {string} {@code str} A copy of {@code} with canonicalized newlines.
238
+ */
239
+ goog.string.canonicalizeNewlines = function(str) {
240
+ return str.replace(/(\r\n|\r|\n)/g, '\n');
241
+ };
242
+
243
+
244
+ /**
245
+ * Normalizes whitespace in a string, replacing all whitespace chars with
246
+ * a space.
247
+ * @param {string} str The string in which to normalize whitespace.
248
+ * @return {string} A copy of {@code str} with all whitespace normalized.
249
+ */
250
+ goog.string.normalizeWhitespace = function(str) {
251
+ return str.replace(/\xa0|\s/g, ' ');
252
+ };
253
+
254
+
255
+ /**
256
+ * Normalizes spaces in a string, replacing all consecutive spaces and tabs
257
+ * with a single space. Replaces non-breaking space with a space.
258
+ * @param {string} str The string in which to normalize spaces.
259
+ * @return {string} A copy of {@code str} with all consecutive spaces and tabs
260
+ * replaced with a single space.
261
+ */
262
+ goog.string.normalizeSpaces = function(str) {
263
+ return str.replace(/\xa0|[ \t]+/g, ' ');
264
+ };
265
+
266
+
267
+ /**
268
+ * Removes the breaking spaces from the left and right of the string and
269
+ * collapses the sequences of breaking spaces in the middle into single spaces.
270
+ * The original and the result strings render the same way in HTML.
271
+ * @param {string} str A string in which to collapse spaces.
272
+ * @return {string} Copy of the string with normalized breaking spaces.
273
+ */
274
+ goog.string.collapseBreakingSpaces = function(str) {
275
+ return str.replace(/[\t\r\n ]+/g, ' ').replace(
276
+ /^[\t\r\n ]+|[\t\r\n ]+$/g, '');
277
+ };
278
+
279
+
280
+ /**
281
+ * Trims white spaces to the left and right of a string.
282
+ * @param {string} str The string to trim.
283
+ * @return {string} A trimmed copy of {@code str}.
284
+ */
285
+ goog.string.trim = function(str) {
286
+ // Since IE doesn't include non-breaking-space (0xa0) in their \s character
287
+ // class (as required by section 7.2 of the ECMAScript spec), we explicitly
288
+ // include it in the regexp to enforce consistent cross-browser behavior.
289
+ return str.replace(/^[\s\xa0]+|[\s\xa0]+$/g, '');
290
+ };
291
+
292
+
293
+ /**
294
+ * Trims whitespaces at the left end of a string.
295
+ * @param {string} str The string to left trim.
296
+ * @return {string} A trimmed copy of {@code str}.
297
+ */
298
+ goog.string.trimLeft = function(str) {
299
+ // Since IE doesn't include non-breaking-space (0xa0) in their \s character
300
+ // class (as required by section 7.2 of the ECMAScript spec), we explicitly
301
+ // include it in the regexp to enforce consistent cross-browser behavior.
302
+ return str.replace(/^[\s\xa0]+/, '');
303
+ };
304
+
305
+
306
+ /**
307
+ * Trims whitespaces at the right end of a string.
308
+ * @param {string} str The string to right trim.
309
+ * @return {string} A trimmed copy of {@code str}.
310
+ */
311
+ goog.string.trimRight = function(str) {
312
+ // Since IE doesn't include non-breaking-space (0xa0) in their \s character
313
+ // class (as required by section 7.2 of the ECMAScript spec), we explicitly
314
+ // include it in the regexp to enforce consistent cross-browser behavior.
315
+ return str.replace(/[\s\xa0]+$/, '');
316
+ };
317
+
318
+
319
+ /**
320
+ * A string comparator that ignores case.
321
+ * -1 = str1 less than str2
322
+ * 0 = str1 equals str2
323
+ * 1 = str1 greater than str2
324
+ *
325
+ * @param {string} str1 The string to compare.
326
+ * @param {string} str2 The string to compare {@code str1} to.
327
+ * @return {number} The comparator result, as described above.
328
+ */
329
+ goog.string.caseInsensitiveCompare = function(str1, str2) {
330
+ var test1 = String(str1).toLowerCase();
331
+ var test2 = String(str2).toLowerCase();
332
+
333
+ if (test1 < test2) {
334
+ return -1;
335
+ } else if (test1 == test2) {
336
+ return 0;
337
+ } else {
338
+ return 1;
339
+ }
340
+ };
341
+
342
+
343
+ /**
344
+ * Regular expression used for splitting a string into substrings of fractional
345
+ * numbers, integers, and non-numeric characters.
346
+ * @type {RegExp}
347
+ * @private
348
+ */
349
+ goog.string.numerateCompareRegExp_ = /(\.\d+)|(\d+)|(\D+)/g;
350
+
351
+
352
+ /**
353
+ * String comparison function that handles numbers in a way humans might expect.
354
+ * Using this function, the string "File 2.jpg" sorts before "File 10.jpg". The
355
+ * comparison is mostly case-insensitive, though strings that are identical
356
+ * except for case are sorted with the upper-case strings before lower-case.
357
+ *
358
+ * This comparison function is significantly slower (about 500x) than either
359
+ * the default or the case-insensitive compare. It should not be used in
360
+ * time-critical code, but should be fast enough to sort several hundred short
361
+ * strings (like filenames) with a reasonable delay.
362
+ *
363
+ * @param {string} str1 The string to compare in a numerically sensitive way.
364
+ * @param {string} str2 The string to compare {@code str1} to.
365
+ * @return {number} less than 0 if str1 < str2, 0 if str1 == str2, greater than
366
+ * 0 if str1 > str2.
367
+ */
368
+ goog.string.numerateCompare = function(str1, str2) {
369
+ if (str1 == str2) {
370
+ return 0;
371
+ }
372
+ if (!str1) {
373
+ return -1;
374
+ }
375
+ if (!str2) {
376
+ return 1;
377
+ }
378
+
379
+ // Using match to split the entire string ahead of time turns out to be faster
380
+ // for most inputs than using RegExp.exec or iterating over each character.
381
+ var tokens1 = str1.toLowerCase().match(goog.string.numerateCompareRegExp_);
382
+ var tokens2 = str2.toLowerCase().match(goog.string.numerateCompareRegExp_);
383
+
384
+ var count = Math.min(tokens1.length, tokens2.length);
385
+
386
+ for (var i = 0; i < count; i++) {
387
+ var a = tokens1[i];
388
+ var b = tokens2[i];
389
+
390
+ // Compare pairs of tokens, returning if one token sorts before the other.
391
+ if (a != b) {
392
+
393
+ // Only if both tokens are integers is a special comparison required.
394
+ // Decimal numbers are sorted as strings (e.g., '.09' < '.1').
395
+ var num1 = parseInt(a, 10);
396
+ if (!isNaN(num1)) {
397
+ var num2 = parseInt(b, 10);
398
+ if (!isNaN(num2) && num1 - num2) {
399
+ return num1 - num2;
400
+ }
401
+ }
402
+ return a < b ? -1 : 1;
403
+ }
404
+ }
405
+
406
+ // If one string is a substring of the other, the shorter string sorts first.
407
+ if (tokens1.length != tokens2.length) {
408
+ return tokens1.length - tokens2.length;
409
+ }
410
+
411
+ // The two strings must be equivalent except for case (perfect equality is
412
+ // tested at the head of the function.) Revert to default ASCII-betical string
413
+ // comparison to stablize the sort.
414
+ return str1 < str2 ? -1 : 1;
415
+ };
416
+
417
+
418
+ /**
419
+ * Regular expression used for determining if a string needs to be encoded.
420
+ * @type {RegExp}
421
+ * @private
422
+ */
423
+ goog.string.encodeUriRegExp_ = /^[a-zA-Z0-9\-_.!~*'()]*$/;
424
+
425
+
426
+ /**
427
+ * URL-encodes a string
428
+ * @param {*} str The string to url-encode.
429
+ * @return {string} An encoded copy of {@code str} that is safe for urls.
430
+ * Note that '#', ':', and other characters used to delimit portions
431
+ * of URLs *will* be encoded.
432
+ */
433
+ goog.string.urlEncode = function(str) {
434
+ str = String(str);
435
+ // Checking if the search matches before calling encodeURIComponent avoids an
436
+ // extra allocation in IE6. This adds about 10us time in FF and a similiar
437
+ // over head in IE6 for lower working set apps, but for large working set
438
+ // apps like Gmail, it saves about 70us per call.
439
+ if (!goog.string.encodeUriRegExp_.test(str)) {
440
+ return encodeURIComponent(str);
441
+ }
442
+ return str;
443
+ };
444
+
445
+
446
+ /**
447
+ * URL-decodes the string. We need to specially handle '+'s because
448
+ * the javascript library doesn't convert them to spaces.
449
+ * @param {string} str The string to url decode.
450
+ * @return {string} The decoded {@code str}.
451
+ */
452
+ goog.string.urlDecode = function(str) {
453
+ return decodeURIComponent(str.replace(/\+/g, ' '));
454
+ };
455
+
456
+
457
+ /**
458
+ * Converts \n to <br>s or <br />s.
459
+ * @param {string} str The string in which to convert newlines.
460
+ * @param {boolean=} opt_xml Whether to use XML compatible tags.
461
+ * @return {string} A copy of {@code str} with converted newlines.
462
+ */
463
+ goog.string.newLineToBr = function(str, opt_xml) {
464
+ return str.replace(/(\r\n|\r|\n)/g, opt_xml ? '<br />' : '<br>');
465
+ };
466
+
467
+
468
+ /**
469
+ * Escape double quote '"' characters in addition to '&', '<', and '>' so that a
470
+ * string can be included in an HTML tag attribute value within double quotes.
471
+ *
472
+ * It should be noted that > doesn't need to be escaped for the HTML or XML to
473
+ * be valid, but it has been decided to escape it for consistency with other
474
+ * implementations.
475
+ *
476
+ * NOTE(user):
477
+ * HtmlEscape is often called during the generation of large blocks of HTML.
478
+ * Using statics for the regular expressions and strings is an optimization
479
+ * that can more than half the amount of time IE spends in this function for
480
+ * large apps, since strings and regexes both contribute to GC allocations.
481
+ *
482
+ * Testing for the presence of a character before escaping increases the number
483
+ * of function calls, but actually provides a speed increase for the average
484
+ * case -- since the average case often doesn't require the escaping of all 4
485
+ * characters and indexOf() is much cheaper than replace().
486
+ * The worst case does suffer slightly from the additional calls, therefore the
487
+ * opt_isLikelyToContainHtmlChars option has been included for situations
488
+ * where all 4 HTML entities are very likely to be present and need escaping.
489
+ *
490
+ * Some benchmarks (times tended to fluctuate +-0.05ms):
491
+ * FireFox IE6
492
+ * (no chars / average (mix of cases) / all 4 chars)
493
+ * no checks 0.13 / 0.22 / 0.22 0.23 / 0.53 / 0.80
494
+ * indexOf 0.08 / 0.17 / 0.26 0.22 / 0.54 / 0.84
495
+ * indexOf + re test 0.07 / 0.17 / 0.28 0.19 / 0.50 / 0.85
496
+ *
497
+ * An additional advantage of checking if replace actually needs to be called
498
+ * is a reduction in the number of object allocations, so as the size of the
499
+ * application grows the difference between the various methods would increase.
500
+ *
501
+ * @param {string} str string to be escaped.
502
+ * @param {boolean=} opt_isLikelyToContainHtmlChars Don't perform a check to see
503
+ * if the character needs replacing - use this option if you expect each of
504
+ * the characters to appear often. Leave false if you expect few html
505
+ * characters to occur in your strings, such as if you are escaping HTML.
506
+ * @return {string} An escaped copy of {@code str}.
507
+ */
508
+ goog.string.htmlEscape = function(str, opt_isLikelyToContainHtmlChars) {
509
+
510
+ if (opt_isLikelyToContainHtmlChars) {
511
+ return str.replace(goog.string.amperRe_, '&amp;')
512
+ .replace(goog.string.ltRe_, '&lt;')
513
+ .replace(goog.string.gtRe_, '&gt;')
514
+ .replace(goog.string.quotRe_, '&quot;');
515
+
516
+ } else {
517
+ // quick test helps in the case when there are no chars to replace, in
518
+ // worst case this makes barely a difference to the time taken
519
+ if (!goog.string.allRe_.test(str)) return str;
520
+
521
+ // str.indexOf is faster than regex.test in this case
522
+ if (str.indexOf('&') != -1) {
523
+ str = str.replace(goog.string.amperRe_, '&amp;');
524
+ }
525
+ if (str.indexOf('<') != -1) {
526
+ str = str.replace(goog.string.ltRe_, '&lt;');
527
+ }
528
+ if (str.indexOf('>') != -1) {
529
+ str = str.replace(goog.string.gtRe_, '&gt;');
530
+ }
531
+ if (str.indexOf('"') != -1) {
532
+ str = str.replace(goog.string.quotRe_, '&quot;');
533
+ }
534
+ return str;
535
+ }
536
+ };
537
+
538
+
539
+ /**
540
+ * Regular expression that matches an ampersand, for use in escaping.
541
+ * @type {RegExp}
542
+ * @private
543
+ */
544
+ goog.string.amperRe_ = /&/g;
545
+
546
+
547
+ /**
548
+ * Regular expression that matches a less than sign, for use in escaping.
549
+ * @type {RegExp}
550
+ * @private
551
+ */
552
+ goog.string.ltRe_ = /</g;
553
+
554
+
555
+ /**
556
+ * Regular expression that matches a greater than sign, for use in escaping.
557
+ * @type {RegExp}
558
+ * @private
559
+ */
560
+ goog.string.gtRe_ = />/g;
561
+
562
+
563
+ /**
564
+ * Regular expression that matches a double quote, for use in escaping.
565
+ * @type {RegExp}
566
+ * @private
567
+ */
568
+ goog.string.quotRe_ = /\"/g;
569
+
570
+
571
+ /**
572
+ * Regular expression that matches any character that needs to be escaped.
573
+ * @type {RegExp}
574
+ * @private
575
+ */
576
+ goog.string.allRe_ = /[&<>\"]/;
577
+
578
+
579
+ /**
580
+ * Unescapes an HTML string.
581
+ *
582
+ * @param {string} str The string to unescape.
583
+ * @return {string} An unescaped copy of {@code str}.
584
+ */
585
+ goog.string.unescapeEntities = function(str) {
586
+ if (goog.string.contains(str, '&')) {
587
+ // We are careful not to use a DOM if we do not have one. We use the []
588
+ // notation so that the JSCompiler will not complain about these objects and
589
+ // fields in the case where we have no DOM.
590
+ if ('document' in goog.global) {
591
+ return goog.string.unescapeEntitiesUsingDom_(str);
592
+ } else {
593
+ // Fall back on pure XML entities
594
+ return goog.string.unescapePureXmlEntities_(str);
595
+ }
596
+ }
597
+ return str;
598
+ };
599
+
600
+
601
+ /**
602
+ * Unescapes an HTML string using a DOM to resolve non-XML, non-numeric
603
+ * entities. This function is XSS-safe and whitespace-preserving.
604
+ * @private
605
+ * @param {string} str The string to unescape.
606
+ * @return {string} The unescaped {@code str} string.
607
+ */
608
+ goog.string.unescapeEntitiesUsingDom_ = function(str) {
609
+ var seen = {'&amp;': '&', '&lt;': '<', '&gt;': '>', '&quot;': '"'};
610
+ var div = document.createElement('div');
611
+ // Match as many valid entity characters as possible. If the actual entity
612
+ // happens to be shorter, it will still work as innerHTML will return the
613
+ // trailing characters unchanged. Since the entity characters do not include
614
+ // open angle bracket, there is no chance of XSS from the innerHTML use.
615
+ // Since no whitespace is passed to innerHTML, whitespace is preserved.
616
+ return str.replace(goog.string.HTML_ENTITY_PATTERN_, function(s, entity) {
617
+ // Check for cached entity.
618
+ var value = seen[s];
619
+ if (value) {
620
+ return value;
621
+ }
622
+ // Check for numeric entity.
623
+ if (entity.charAt(0) == '#') {
624
+ // Prefix with 0 so that hex entities (e.g. &#x10) parse as hex numbers.
625
+ var n = Number('0' + entity.substr(1));
626
+ if (!isNaN(n)) {
627
+ value = String.fromCharCode(n);
628
+ }
629
+ }
630
+ // Fall back to innerHTML otherwise.
631
+ if (!value) {
632
+ // Append a non-entity character to avoid a bug in Webkit that parses
633
+ // an invalid entity at the end of innerHTML text as the empty string.
634
+ div.innerHTML = s + ' ';
635
+ // Then remove the trailing character from the result.
636
+ value = div.firstChild.nodeValue.slice(0, -1);
637
+ }
638
+ // Cache and return.
639
+ return seen[s] = value;
640
+ });
641
+ };
642
+
643
+
644
+ /**
645
+ * Unescapes XML entities.
646
+ * @private
647
+ * @param {string} str The string to unescape.
648
+ * @return {string} An unescaped copy of {@code str}.
649
+ */
650
+ goog.string.unescapePureXmlEntities_ = function(str) {
651
+ return str.replace(/&([^;]+);/g, function(s, entity) {
652
+ switch (entity) {
653
+ case 'amp':
654
+ return '&';
655
+ case 'lt':
656
+ return '<';
657
+ case 'gt':
658
+ return '>';
659
+ case 'quot':
660
+ return '"';
661
+ default:
662
+ if (entity.charAt(0) == '#') {
663
+ // Prefix with 0 so that hex entities (e.g. &#x10) parse as hex.
664
+ var n = Number('0' + entity.substr(1));
665
+ if (!isNaN(n)) {
666
+ return String.fromCharCode(n);
667
+ }
668
+ }
669
+ // For invalid entities we just return the entity
670
+ return s;
671
+ }
672
+ });
673
+ };
674
+
675
+
676
+ /**
677
+ * Regular expression that matches an HTML entity.
678
+ * See also HTML5: Tokenization / Tokenizing character references.
679
+ * @private
680
+ * @type {!RegExp}
681
+ */
682
+ goog.string.HTML_ENTITY_PATTERN_ = /&([^;\s<&]+);?/g;
683
+
684
+
685
+ /**
686
+ * Do escaping of whitespace to preserve spatial formatting. We use character
687
+ * entity #160 to make it safer for xml.
688
+ * @param {string} str The string in which to escape whitespace.
689
+ * @param {boolean=} opt_xml Whether to use XML compatible tags.
690
+ * @return {string} An escaped copy of {@code str}.
691
+ */
692
+ goog.string.whitespaceEscape = function(str, opt_xml) {
693
+ return goog.string.newLineToBr(str.replace(/ /g, ' &#160;'), opt_xml);
694
+ };
695
+
696
+
697
+ /**
698
+ * Strip quote characters around a string. The second argument is a string of
699
+ * characters to treat as quotes. This can be a single character or a string of
700
+ * multiple character and in that case each of those are treated as possible
701
+ * quote characters. For example:
702
+ *
703
+ * <pre>
704
+ * goog.string.stripQuotes('"abc"', '"`') --> 'abc'
705
+ * goog.string.stripQuotes('`abc`', '"`') --> 'abc'
706
+ * </pre>
707
+ *
708
+ * @param {string} str The string to strip.
709
+ * @param {string} quoteChars The quote characters to strip.
710
+ * @return {string} A copy of {@code str} without the quotes.
711
+ */
712
+ goog.string.stripQuotes = function(str, quoteChars) {
713
+ var length = quoteChars.length;
714
+ for (var i = 0; i < length; i++) {
715
+ var quoteChar = length == 1 ? quoteChars : quoteChars.charAt(i);
716
+ if (str.charAt(0) == quoteChar && str.charAt(str.length - 1) == quoteChar) {
717
+ return str.substring(1, str.length - 1);
718
+ }
719
+ }
720
+ return str;
721
+ };
722
+
723
+
724
+ /**
725
+ * Truncates a string to a certain length and adds '...' if necessary. The
726
+ * length also accounts for the ellipsis, so a maximum length of 10 and a string
727
+ * 'Hello World!' produces 'Hello W...'.
728
+ * @param {string} str The string to truncate.
729
+ * @param {number} chars Max number of characters.
730
+ * @param {boolean=} opt_protectEscapedCharacters Whether to protect escaped
731
+ * characters from being cut off in the middle.
732
+ * @return {string} The truncated {@code str} string.
733
+ */
734
+ goog.string.truncate = function(str, chars, opt_protectEscapedCharacters) {
735
+ if (opt_protectEscapedCharacters) {
736
+ str = goog.string.unescapeEntities(str);
737
+ }
738
+
739
+ if (str.length > chars) {
740
+ str = str.substring(0, chars - 3) + '...';
741
+ }
742
+
743
+ if (opt_protectEscapedCharacters) {
744
+ str = goog.string.htmlEscape(str);
745
+ }
746
+
747
+ return str;
748
+ };
749
+
750
+
751
+ /**
752
+ * Truncate a string in the middle, adding "..." if necessary,
753
+ * and favoring the beginning of the string.
754
+ * @param {string} str The string to truncate the middle of.
755
+ * @param {number} chars Max number of characters.
756
+ * @param {boolean=} opt_protectEscapedCharacters Whether to protect escaped
757
+ * characters from being cutoff in the middle.
758
+ * @param {number=} opt_trailingChars Optional number of trailing characters to
759
+ * leave at the end of the string, instead of truncating as close to the
760
+ * middle as possible.
761
+ * @return {string} A truncated copy of {@code str}.
762
+ */
763
+ goog.string.truncateMiddle = function(str, chars,
764
+ opt_protectEscapedCharacters, opt_trailingChars) {
765
+ if (opt_protectEscapedCharacters) {
766
+ str = goog.string.unescapeEntities(str);
767
+ }
768
+
769
+ if (opt_trailingChars && str.length > chars) {
770
+ if (opt_trailingChars > chars) {
771
+ opt_trailingChars = chars;
772
+ }
773
+ var endPoint = str.length - opt_trailingChars;
774
+ var startPoint = chars - opt_trailingChars;
775
+ str = str.substring(0, startPoint) + '...' + str.substring(endPoint);
776
+ } else if (str.length > chars) {
777
+ // Favor the beginning of the string:
778
+ var half = Math.floor(chars / 2);
779
+ var endPos = str.length - half;
780
+ half += chars % 2;
781
+ str = str.substring(0, half) + '...' + str.substring(endPos);
782
+ }
783
+
784
+ if (opt_protectEscapedCharacters) {
785
+ str = goog.string.htmlEscape(str);
786
+ }
787
+
788
+ return str;
789
+ };
790
+
791
+
792
+ /**
793
+ * Special chars that need to be escaped for goog.string.quote.
794
+ * @private
795
+ * @type {Object}
796
+ */
797
+ goog.string.specialEscapeChars_ = {
798
+ '\0': '\\0',
799
+ '\b': '\\b',
800
+ '\f': '\\f',
801
+ '\n': '\\n',
802
+ '\r': '\\r',
803
+ '\t': '\\t',
804
+ '\x0B': '\\x0B', // '\v' is not supported in JScript
805
+ '"': '\\"',
806
+ '\\': '\\\\'
807
+ };
808
+
809
+
810
+ /**
811
+ * Character mappings used internally for goog.string.escapeChar.
812
+ * @private
813
+ * @type {Object}
814
+ */
815
+ goog.string.jsEscapeCache_ = {
816
+ '\'': '\\\''
817
+ };
818
+
819
+
820
+ /**
821
+ * Encloses a string in double quotes and escapes characters so that the
822
+ * string is a valid JS string.
823
+ * @param {string} s The string to quote.
824
+ * @return {string} A copy of {@code s} surrounded by double quotes.
825
+ */
826
+ goog.string.quote = function(s) {
827
+ s = String(s);
828
+ if (s.quote) {
829
+ return s.quote();
830
+ } else {
831
+ var sb = ['"'];
832
+ for (var i = 0; i < s.length; i++) {
833
+ var ch = s.charAt(i);
834
+ var cc = ch.charCodeAt(0);
835
+ sb[i + 1] = goog.string.specialEscapeChars_[ch] ||
836
+ ((cc > 31 && cc < 127) ? ch : goog.string.escapeChar(ch));
837
+ }
838
+ sb.push('"');
839
+ return sb.join('');
840
+ }
841
+ };
842
+
843
+
844
+ /**
845
+ * Takes a string and returns the escaped string for that character.
846
+ * @param {string} str The string to escape.
847
+ * @return {string} An escaped string representing {@code str}.
848
+ */
849
+ goog.string.escapeString = function(str) {
850
+ var sb = [];
851
+ for (var i = 0; i < str.length; i++) {
852
+ sb[i] = goog.string.escapeChar(str.charAt(i));
853
+ }
854
+ return sb.join('');
855
+ };
856
+
857
+
858
+ /**
859
+ * Takes a character and returns the escaped string for that character. For
860
+ * example escapeChar(String.fromCharCode(15)) -> "\\x0E".
861
+ * @param {string} c The character to escape.
862
+ * @return {string} An escaped string representing {@code c}.
863
+ */
864
+ goog.string.escapeChar = function(c) {
865
+ if (c in goog.string.jsEscapeCache_) {
866
+ return goog.string.jsEscapeCache_[c];
867
+ }
868
+
869
+ if (c in goog.string.specialEscapeChars_) {
870
+ return goog.string.jsEscapeCache_[c] = goog.string.specialEscapeChars_[c];
871
+ }
872
+
873
+ var rv = c;
874
+ var cc = c.charCodeAt(0);
875
+ if (cc > 31 && cc < 127) {
876
+ rv = c;
877
+ } else {
878
+ // tab is 9 but handled above
879
+ if (cc < 256) {
880
+ rv = '\\x';
881
+ if (cc < 16 || cc > 256) {
882
+ rv += '0';
883
+ }
884
+ } else {
885
+ rv = '\\u';
886
+ if (cc < 4096) { // \u1000
887
+ rv += '0';
888
+ }
889
+ }
890
+ rv += cc.toString(16).toUpperCase();
891
+ }
892
+
893
+ return goog.string.jsEscapeCache_[c] = rv;
894
+ };
895
+
896
+
897
+ /**
898
+ * Takes a string and creates a map (Object) in which the keys are the
899
+ * characters in the string. The value for the key is set to true. You can
900
+ * then use goog.object.map or goog.array.map to change the values.
901
+ * @param {string} s The string to build the map from.
902
+ * @return {Object} The map of characters used.
903
+ */
904
+ // TODO(arv): It seems like we should have a generic goog.array.toMap. But do
905
+ // we want a dependency on goog.array in goog.string?
906
+ goog.string.toMap = function(s) {
907
+ var rv = {};
908
+ for (var i = 0; i < s.length; i++) {
909
+ rv[s.charAt(i)] = true;
910
+ }
911
+ return rv;
912
+ };
913
+
914
+
915
+ /**
916
+ * Checks whether a string contains a given character.
917
+ * @param {string} s The string to test.
918
+ * @param {string} ss The substring to test for.
919
+ * @return {boolean} True if {@code s} contains {@code ss}.
920
+ */
921
+ goog.string.contains = function(s, ss) {
922
+ return s.indexOf(ss) != -1;
923
+ };
924
+
925
+
926
+ /**
927
+ * Returns the non-overlapping occurrences of ss in s.
928
+ * If either s or ss evalutes to false, then returns zero.
929
+ * @param {string} s The string to look in.
930
+ * @param {string} ss The string to look for.
931
+ * @return {number} Number of occurrences of ss in s.
932
+ */
933
+ goog.string.countOf = function(s, ss) {
934
+ return s && ss ? s.split(ss).length - 1 : 0;
935
+ };
936
+
937
+
938
+ /**
939
+ * Removes a substring of a specified length at a specific
940
+ * index in a string.
941
+ * @param {string} s The base string from which to remove.
942
+ * @param {number} index The index at which to remove the substring.
943
+ * @param {number} stringLength The length of the substring to remove.
944
+ * @return {string} A copy of {@code s} with the substring removed or the full
945
+ * string if nothing is removed or the input is invalid.
946
+ */
947
+ goog.string.removeAt = function(s, index, stringLength) {
948
+ var resultStr = s;
949
+ // If the index is greater or equal to 0 then remove substring
950
+ if (index >= 0 && index < s.length && stringLength > 0) {
951
+ resultStr = s.substr(0, index) +
952
+ s.substr(index + stringLength, s.length - index - stringLength);
953
+ }
954
+ return resultStr;
955
+ };
956
+
957
+
958
+ /**
959
+ * Removes the first occurrence of a substring from a string.
960
+ * @param {string} s The base string from which to remove.
961
+ * @param {string} ss The string to remove.
962
+ * @return {string} A copy of {@code s} with {@code ss} removed or the full
963
+ * string if nothing is removed.
964
+ */
965
+ goog.string.remove = function(s, ss) {
966
+ var re = new RegExp(goog.string.regExpEscape(ss), '');
967
+ return s.replace(re, '');
968
+ };
969
+
970
+
971
+ /**
972
+ * Removes all occurrences of a substring from a string.
973
+ * @param {string} s The base string from which to remove.
974
+ * @param {string} ss The string to remove.
975
+ * @return {string} A copy of {@code s} with {@code ss} removed or the full
976
+ * string if nothing is removed.
977
+ */
978
+ goog.string.removeAll = function(s, ss) {
979
+ var re = new RegExp(goog.string.regExpEscape(ss), 'g');
980
+ return s.replace(re, '');
981
+ };
982
+
983
+
984
+ /**
985
+ * Escapes characters in the string that are not safe to use in a RegExp.
986
+ * @param {*} s The string to escape. If not a string, it will be casted
987
+ * to one.
988
+ * @return {string} A RegExp safe, escaped copy of {@code s}.
989
+ */
990
+ goog.string.regExpEscape = function(s) {
991
+ return String(s).replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g, '\\$1').
992
+ replace(/\x08/g, '\\x08');
993
+ };
994
+
995
+
996
+ /**
997
+ * Repeats a string n times.
998
+ * @param {string} string The string to repeat.
999
+ * @param {number} length The number of times to repeat.
1000
+ * @return {string} A string containing {@code length} repetitions of
1001
+ * {@code string}.
1002
+ */
1003
+ goog.string.repeat = function(string, length) {
1004
+ return new Array(length + 1).join(string);
1005
+ };
1006
+
1007
+
1008
+ /**
1009
+ * Pads number to given length and optionally rounds it to a given precision.
1010
+ * For example:
1011
+ * <pre>padNumber(1.25, 2, 3) -> '01.250'
1012
+ * padNumber(1.25, 2) -> '01.25'
1013
+ * padNumber(1.25, 2, 1) -> '01.3'
1014
+ * padNumber(1.25, 0) -> '1.25'</pre>
1015
+ *
1016
+ * @param {number} num The number to pad.
1017
+ * @param {number} length The desired length.
1018
+ * @param {number=} opt_precision The desired precision.
1019
+ * @return {string} {@code num} as a string with the given options.
1020
+ */
1021
+ goog.string.padNumber = function(num, length, opt_precision) {
1022
+ var s = goog.isDef(opt_precision) ? num.toFixed(opt_precision) : String(num);
1023
+ var index = s.indexOf('.');
1024
+ if (index == -1) {
1025
+ index = s.length;
1026
+ }
1027
+ return goog.string.repeat('0', Math.max(0, length - index)) + s;
1028
+ };
1029
+
1030
+
1031
+ /**
1032
+ * Returns a string representation of the given object, with
1033
+ * null and undefined being returned as the empty string.
1034
+ *
1035
+ * @param {*} obj The object to convert.
1036
+ * @return {string} A string representation of the {@code obj}.
1037
+ */
1038
+ goog.string.makeSafe = function(obj) {
1039
+ return obj == null ? '' : String(obj);
1040
+ };
1041
+
1042
+
1043
+ /**
1044
+ * Concatenates string expressions. This is useful
1045
+ * since some browsers are very inefficient when it comes to using plus to
1046
+ * concat strings. Be careful when using null and undefined here since
1047
+ * these will not be included in the result. If you need to represent these
1048
+ * be sure to cast the argument to a String first.
1049
+ * For example:
1050
+ * <pre>buildString('a', 'b', 'c', 'd') -> 'abcd'
1051
+ * buildString(null, undefined) -> ''
1052
+ * </pre>
1053
+ * @param {...*} var_args A list of strings to concatenate. If not a string,
1054
+ * it will be casted to one.
1055
+ * @return {string} The concatenation of {@code var_args}.
1056
+ */
1057
+ goog.string.buildString = function(var_args) {
1058
+ return Array.prototype.join.call(arguments, '');
1059
+ };
1060
+
1061
+
1062
+ /**
1063
+ * Returns a string with at least 64-bits of randomness.
1064
+ *
1065
+ * Doesn't trust Javascript's random function entirely. Uses a combination of
1066
+ * random and current timestamp, and then encodes the string in base-36 to
1067
+ * make it shorter.
1068
+ *
1069
+ * @return {string} A random string, e.g. sn1s7vb4gcic.
1070
+ */
1071
+ goog.string.getRandomString = function() {
1072
+ var x = 2147483648;
1073
+ return Math.floor(Math.random() * x).toString(36) +
1074
+ Math.abs(Math.floor(Math.random() * x) ^ goog.now()).toString(36);
1075
+ };
1076
+
1077
+
1078
+ /**
1079
+ * Compares two version numbers.
1080
+ *
1081
+ * @param {string|number} version1 Version of first item.
1082
+ * @param {string|number} version2 Version of second item.
1083
+ *
1084
+ * @return {number} 1 if {@code version1} is higher.
1085
+ * 0 if arguments are equal.
1086
+ * -1 if {@code version2} is higher.
1087
+ */
1088
+ goog.string.compareVersions = function(version1, version2) {
1089
+ var order = 0;
1090
+ // Trim leading and trailing whitespace and split the versions into
1091
+ // subversions.
1092
+ var v1Subs = goog.string.trim(String(version1)).split('.');
1093
+ var v2Subs = goog.string.trim(String(version2)).split('.');
1094
+ var subCount = Math.max(v1Subs.length, v2Subs.length);
1095
+
1096
+ // Iterate over the subversions, as long as they appear to be equivalent.
1097
+ for (var subIdx = 0; order == 0 && subIdx < subCount; subIdx++) {
1098
+ var v1Sub = v1Subs[subIdx] || '';
1099
+ var v2Sub = v2Subs[subIdx] || '';
1100
+
1101
+ // Split the subversions into pairs of numbers and qualifiers (like 'b').
1102
+ // Two different RegExp objects are needed because they are both using
1103
+ // the 'g' flag.
1104
+ var v1CompParser = new RegExp('(\\d*)(\\D*)', 'g');
1105
+ var v2CompParser = new RegExp('(\\d*)(\\D*)', 'g');
1106
+ do {
1107
+ var v1Comp = v1CompParser.exec(v1Sub) || ['', '', ''];
1108
+ var v2Comp = v2CompParser.exec(v2Sub) || ['', '', ''];
1109
+ // Break if there are no more matches.
1110
+ if (v1Comp[0].length == 0 && v2Comp[0].length == 0) {
1111
+ break;
1112
+ }
1113
+
1114
+ // Parse the numeric part of the subversion. A missing number is
1115
+ // equivalent to 0.
1116
+ var v1CompNum = v1Comp[1].length == 0 ? 0 : parseInt(v1Comp[1], 10);
1117
+ var v2CompNum = v2Comp[1].length == 0 ? 0 : parseInt(v2Comp[1], 10);
1118
+
1119
+ // Compare the subversion components. The number has the highest
1120
+ // precedence. Next, if the numbers are equal, a subversion without any
1121
+ // qualifier is always higher than a subversion with any qualifier. Next,
1122
+ // the qualifiers are compared as strings.
1123
+ order = goog.string.compareElements_(v1CompNum, v2CompNum) ||
1124
+ goog.string.compareElements_(v1Comp[2].length == 0,
1125
+ v2Comp[2].length == 0) ||
1126
+ goog.string.compareElements_(v1Comp[2], v2Comp[2]);
1127
+ // Stop as soon as an inequality is discovered.
1128
+ } while (order == 0);
1129
+ }
1130
+
1131
+ return order;
1132
+ };
1133
+
1134
+
1135
+ /**
1136
+ * Compares elements of a version number.
1137
+ *
1138
+ * @param {string|number|boolean} left An element from a version number.
1139
+ * @param {string|number|boolean} right An element from a version number.
1140
+ *
1141
+ * @return {number} 1 if {@code left} is higher.
1142
+ * 0 if arguments are equal.
1143
+ * -1 if {@code right} is higher.
1144
+ * @private
1145
+ */
1146
+ goog.string.compareElements_ = function(left, right) {
1147
+ if (left < right) {
1148
+ return -1;
1149
+ } else if (left > right) {
1150
+ return 1;
1151
+ }
1152
+ return 0;
1153
+ };
1154
+
1155
+
1156
+ /**
1157
+ * Maximum value of #goog.string.hashCode, exclusive. 2^32.
1158
+ * @type {number}
1159
+ * @private
1160
+ */
1161
+ goog.string.HASHCODE_MAX_ = 0x100000000;
1162
+
1163
+
1164
+ /**
1165
+ * String hash function similar to java.lang.String.hashCode().
1166
+ * The hash code for a string is computed as
1167
+ * s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
1168
+ * where s[i] is the ith character of the string and n is the length of
1169
+ * the string. We mod the result to make it between 0 (inclusive) and 2^32
1170
+ * (exclusive).
1171
+ * @param {string} str A string.
1172
+ * @return {number} Hash value for {@code str}, between 0 (inclusive) and 2^32
1173
+ * (exclusive). The empty string returns 0.
1174
+ */
1175
+ goog.string.hashCode = function(str) {
1176
+ var result = 0;
1177
+ for (var i = 0; i < str.length; ++i) {
1178
+ result = 31 * result + str.charCodeAt(i);
1179
+ // Normalize to 4 byte range, 0 ... 2^32.
1180
+ result %= goog.string.HASHCODE_MAX_;
1181
+ }
1182
+ return result;
1183
+ };
1184
+
1185
+
1186
+ /**
1187
+ * The most recent unique ID. |0 is equivalent to Math.floor in this case.
1188
+ * @type {number}
1189
+ * @private
1190
+ */
1191
+ goog.string.uniqueStringCounter_ = Math.random() * 0x80000000 | 0;
1192
+
1193
+
1194
+ /**
1195
+ * Generates and returns a string which is unique in the current document.
1196
+ * This is useful, for example, to create unique IDs for DOM elements.
1197
+ * @return {string} A unique id.
1198
+ */
1199
+ goog.string.createUniqueString = function() {
1200
+ return 'goog_' + goog.string.uniqueStringCounter_++;
1201
+ };
1202
+
1203
+
1204
+ /**
1205
+ * Converts the supplied string to a number, which may be Ininity or NaN.
1206
+ * This function strips whitespace: (toNumber(' 123') === 123)
1207
+ * This function accepts scientific notation: (toNumber('1e1') === 10)
1208
+ *
1209
+ * This is better than Javascript's built-in conversions because, sadly:
1210
+ * (Number(' ') === 0) and (parseFloat('123a') === 123)
1211
+ *
1212
+ * @param {string} str The string to convert.
1213
+ * @return {number} The number the supplied string represents, or NaN.
1214
+ */
1215
+ goog.string.toNumber = function(str) {
1216
+ var num = Number(str);
1217
+ if (num == 0 && goog.string.isEmpty(str)) {
1218
+ return NaN;
1219
+ }
1220
+ return num;
1221
+ };
1222
+
1223
+
1224
+ /**
1225
+ * A memoized cache for goog.string.toCamelCase.
1226
+ * @type {Object.<string>}
1227
+ * @private
1228
+ */
1229
+ goog.string.toCamelCaseCache_ = {};
1230
+
1231
+
1232
+ /**
1233
+ * Converts a string from selector-case to camelCase (e.g. from
1234
+ * "multi-part-string" to "multiPartString"), useful for converting
1235
+ * CSS selectors and HTML dataset keys to their equivalent JS properties.
1236
+ * @param {string} str The string in selector-case form.
1237
+ * @return {string} The string in camelCase form.
1238
+ */
1239
+ goog.string.toCamelCase = function(str) {
1240
+ return goog.string.toCamelCaseCache_[str] ||
1241
+ (goog.string.toCamelCaseCache_[str] =
1242
+ String(str).replace(/\-([a-z])/g, function(all, match) {
1243
+ return match.toUpperCase();
1244
+ }));
1245
+ };
1246
+
1247
+
1248
+ /**
1249
+ * A memoized cache for goog.string.toSelectorCase.
1250
+ * @type {Object.<string>}
1251
+ * @private
1252
+ */
1253
+ goog.string.toSelectorCaseCache_ = {};
1254
+
1255
+
1256
+ /**
1257
+ * Converts a string from camelCase to selector-case (e.g. from
1258
+ * "multiPartString" to "multi-part-string"), useful for converting JS
1259
+ * style and dataset properties to equivalent CSS selectors and HTML keys.
1260
+ * @param {string} str The string in camelCase form.
1261
+ * @return {string} The string in selector-case form.
1262
+ */
1263
+ goog.string.toSelectorCase = function(str) {
1264
+ return goog.string.toSelectorCaseCache_[str] ||
1265
+ (goog.string.toSelectorCaseCache_[str] =
1266
+ String(str).replace(/([A-Z])/g, '-$1').toLowerCase());
1267
+ };
1268
+ ;
1269
+ FI"asset_paths;
1270
+ F["n/Volumes/Development/dev-web/closure-library-wrapper/vendor/closure-library/closure/goog/string/string.jsI"dependency_paths;
1271
+ F[{I" path;
1272
+ F"n/Volumes/Development/dev-web/closure-library-wrapper/vendor/closure-library/closure/goog/string/string.jsI"
1273
+ mtime;
1274
+ FIu: Time
1275
+ T: offsetiI"hexdigest;
1276
+ F"%0ff21dc4a73f6afee61652a225b63dc9I"
1277
+ F"%46dde6621c301f4928e3b34efee9e3b5