stringjs-rails 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE.txt +22 -0
- data/README.md +42 -0
- data/lib/stringjs-rails.rb +6 -0
- data/vendor/assets/javascripts/string.js +911 -0
- data/vendor/assets/javascripts/string.min.js +3 -0
- metadata +105 -0
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Jesper Josefsson
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Stringjs::Rails
|
2
|
+
|
3
|
+
This is a no-frills asset pipeline wrapper for the [String.js Javascript library][1].
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'stringjs-rails'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install stringjs-rails
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Add this line to your manifest:
|
22
|
+
|
23
|
+
//= require 'string'
|
24
|
+
|
25
|
+
Or use the minified version:
|
26
|
+
|
27
|
+
//= require 'string.min'
|
28
|
+
|
29
|
+
For usage of the library see the [String.js homepage][1].
|
30
|
+
|
31
|
+
## Versioning
|
32
|
+
Major, minor and patch numbers will match those of String.js. Should bugs be fixed in the gem itself, a fourth version number will be added.
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
1. Fork it
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
5. Create new Pull Request
|
41
|
+
|
42
|
+
[1]: http://stringjs.com
|
@@ -0,0 +1,911 @@
|
|
1
|
+
/*
|
2
|
+
string.js - Copyright (C) 2012-2013, JP Richardson <jprichardson@gmail.com>
|
3
|
+
*/
|
4
|
+
|
5
|
+
!(function() {
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
var VERSION = '1.3.0';
|
9
|
+
|
10
|
+
var ENTITIES = {};
|
11
|
+
|
12
|
+
function S(s) {
|
13
|
+
if (s !== null && s !== undefined) {
|
14
|
+
if (typeof s === 'string')
|
15
|
+
this.s = s;
|
16
|
+
else
|
17
|
+
this.s = s.toString();
|
18
|
+
} else {
|
19
|
+
this.s = s; //null or undefined
|
20
|
+
}
|
21
|
+
|
22
|
+
this.orig = s; //original object, currently only used by toCSV() and toBoolean()
|
23
|
+
|
24
|
+
if (s !== null && s !== undefined) {
|
25
|
+
if (this.__defineGetter__) {
|
26
|
+
this.__defineGetter__('length', function() {
|
27
|
+
return this.s.length;
|
28
|
+
})
|
29
|
+
} else {
|
30
|
+
this.length = s.length;
|
31
|
+
}
|
32
|
+
} else {
|
33
|
+
this.length = -1;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
var __nsp = String.prototype;
|
38
|
+
var __sp = S.prototype = {
|
39
|
+
|
40
|
+
between: function(left, right) {
|
41
|
+
var s = this.s;
|
42
|
+
var startPos = s.indexOf(left);
|
43
|
+
var endPos = s.indexOf(right);
|
44
|
+
var start = startPos + left.length;
|
45
|
+
return new S(endPos > startPos ? s.slice(start, endPos) : "");
|
46
|
+
},
|
47
|
+
|
48
|
+
//# modified slightly from https://github.com/epeli/underscore.string
|
49
|
+
camelize: function() {
|
50
|
+
var s = this.trim().s.replace(/(\-|_|\s)+(.)?/g, function(mathc, sep, c) {
|
51
|
+
return (c ? c.toUpperCase() : '');
|
52
|
+
});
|
53
|
+
return new S(s);
|
54
|
+
},
|
55
|
+
|
56
|
+
capitalize: function() {
|
57
|
+
return new S(this.s.substr(0, 1).toUpperCase() + this.s.substring(1).toLowerCase());
|
58
|
+
},
|
59
|
+
|
60
|
+
charAt: function(index) {
|
61
|
+
return this.s.charAt(index);
|
62
|
+
},
|
63
|
+
|
64
|
+
chompLeft: function(prefix) {
|
65
|
+
var s = this.s;
|
66
|
+
if (s.indexOf(prefix) === 0) {
|
67
|
+
s = s.slice(prefix.length);
|
68
|
+
return new S(s);
|
69
|
+
} else {
|
70
|
+
return this;
|
71
|
+
}
|
72
|
+
},
|
73
|
+
|
74
|
+
chompRight: function(suffix) {
|
75
|
+
if (this.endsWith(suffix)) {
|
76
|
+
var s = this.s;
|
77
|
+
s = s.slice(0, s.length - suffix.length);
|
78
|
+
return new S(s);
|
79
|
+
} else {
|
80
|
+
return this;
|
81
|
+
}
|
82
|
+
},
|
83
|
+
|
84
|
+
//#thanks Google
|
85
|
+
collapseWhitespace: function() {
|
86
|
+
var s = this.s.replace(/[\s\xa0]+/g, ' ').replace(/^\s+|\s+$/g, '');
|
87
|
+
return new S(s);
|
88
|
+
},
|
89
|
+
|
90
|
+
contains: function(ss) {
|
91
|
+
return this.s.indexOf(ss) >= 0;
|
92
|
+
},
|
93
|
+
|
94
|
+
//#modified from https://github.com/epeli/underscore.string
|
95
|
+
dasherize: function() {
|
96
|
+
var s = this.trim().s.replace(/[_\s]+/g, '-').replace(/([A-Z])/g, '-$1').replace(/-+/g, '-').toLowerCase();
|
97
|
+
return new S(s);
|
98
|
+
},
|
99
|
+
|
100
|
+
decodeHtmlEntities: function() { //https://github.com/substack/node-ent/blob/master/index.js
|
101
|
+
var s = this.s;
|
102
|
+
s = s.replace(/&#(\d+);?/g, function (_, code) {
|
103
|
+
return String.fromCharCode(code);
|
104
|
+
})
|
105
|
+
.replace(/&#[xX]([A-Fa-f0-9]+);?/g, function (_, hex) {
|
106
|
+
return String.fromCharCode(parseInt(hex, 16));
|
107
|
+
})
|
108
|
+
.replace(/&([^;\W]+;?)/g, function (m, e) {
|
109
|
+
var ee = e.replace(/;$/, '');
|
110
|
+
var target = ENTITIES[e] || (e.match(/;$/) && ENTITIES[ee]);
|
111
|
+
|
112
|
+
if (typeof target === 'number') {
|
113
|
+
return String.fromCharCode(target);
|
114
|
+
}
|
115
|
+
else if (typeof target === 'string') {
|
116
|
+
return target;
|
117
|
+
}
|
118
|
+
else {
|
119
|
+
return m;
|
120
|
+
}
|
121
|
+
})
|
122
|
+
|
123
|
+
return new S(s);
|
124
|
+
},
|
125
|
+
|
126
|
+
endsWith: function(suffix) {
|
127
|
+
var l = this.s.length - suffix.length;
|
128
|
+
return l >= 0 && this.s.indexOf(suffix, l) === l;
|
129
|
+
},
|
130
|
+
|
131
|
+
escapeHTML: function() { //from underscore.string
|
132
|
+
return new S(this.s.replace(/[&<>"']/g, function(m){ return '&' + reversedEscapeChars[m] + ';'; }));
|
133
|
+
},
|
134
|
+
|
135
|
+
ensureLeft: function(prefix) {
|
136
|
+
var s = this.s;
|
137
|
+
if (s.indexOf(prefix) === 0) {
|
138
|
+
return this;
|
139
|
+
} else {
|
140
|
+
return new S(prefix + s);
|
141
|
+
}
|
142
|
+
},
|
143
|
+
|
144
|
+
ensureRight: function(suffix) {
|
145
|
+
var s = this.s;
|
146
|
+
if (this.endsWith(suffix)) {
|
147
|
+
return this;
|
148
|
+
} else {
|
149
|
+
return new S(s + suffix);
|
150
|
+
}
|
151
|
+
},
|
152
|
+
|
153
|
+
isAlpha: function() {
|
154
|
+
return !/[^a-z\xC0-\xFF]/.test(this.s.toLowerCase());
|
155
|
+
},
|
156
|
+
|
157
|
+
isAlphaNumeric: function() {
|
158
|
+
return !/[^0-9a-z\xC0-\xFF]/.test(this.s.toLowerCase());
|
159
|
+
},
|
160
|
+
|
161
|
+
isEmpty: function() {
|
162
|
+
return this.s === null || this.s === undefined ? true : /^[\s\xa0]*$/.test(this.s);
|
163
|
+
},
|
164
|
+
|
165
|
+
isLower: function() {
|
166
|
+
return this.isAlpha() && this.s.toLowerCase() === this.s;
|
167
|
+
},
|
168
|
+
|
169
|
+
isNumeric: function() {
|
170
|
+
return !/[^0-9]/.test(this.s);
|
171
|
+
},
|
172
|
+
|
173
|
+
isUpper: function() {
|
174
|
+
return this.isAlpha() && this.s.toUpperCase() === this.s;
|
175
|
+
},
|
176
|
+
|
177
|
+
left: function(N) {
|
178
|
+
if (N >= 0) {
|
179
|
+
var s = this.s.substr(0, N);
|
180
|
+
return new S(s);
|
181
|
+
} else {
|
182
|
+
return this.right(-N);
|
183
|
+
}
|
184
|
+
},
|
185
|
+
|
186
|
+
lines: function() {
|
187
|
+
var lines = this.s.split('\n')
|
188
|
+
for (var i = 0; i < lines.length; ++i) {
|
189
|
+
lines[i] = lines[i].replace(/(^\s*|\s*$)/g, '');
|
190
|
+
}
|
191
|
+
return lines;
|
192
|
+
},
|
193
|
+
|
194
|
+
pad: function(len, ch) { //https://github.com/component/pad
|
195
|
+
ch = ch || ' ';
|
196
|
+
if (this.s.length >= len) return new S(this.s);
|
197
|
+
len = len - this.s.length;
|
198
|
+
var left = Array(Math.ceil(len / 2) + 1).join(ch);
|
199
|
+
var right = Array(Math.floor(len / 2) + 1).join(ch);
|
200
|
+
return new S(left + this.s + right);
|
201
|
+
},
|
202
|
+
|
203
|
+
padLeft: function(len, ch) { //https://github.com/component/pad
|
204
|
+
ch = ch || ' ';
|
205
|
+
if (this.s.length >= len) return new S(this.s);
|
206
|
+
return new S(Array(len - this.s.length + 1).join(ch) + this.s);
|
207
|
+
},
|
208
|
+
|
209
|
+
padRight: function(len, ch) { //https://github.com/component/pad
|
210
|
+
ch = ch || ' ';
|
211
|
+
if (this.s.length >= len) return new S(this.s);
|
212
|
+
return new S(this.s + Array(len - this.s.length + 1).join(ch));
|
213
|
+
},
|
214
|
+
|
215
|
+
parseCSV: function(delimiter, qualifier, escape) { //try to parse no matter what
|
216
|
+
delimiter = delimiter || ',';
|
217
|
+
escape = escape || '\\'
|
218
|
+
if (typeof qualifier == 'undefined')
|
219
|
+
qualifier = '"';
|
220
|
+
|
221
|
+
var i = 0, fieldBuffer = [], fields = [], len = this.s.length, inField = false, self = this;
|
222
|
+
var ca = function(i){return self.s.charAt(i)};
|
223
|
+
|
224
|
+
if (!qualifier)
|
225
|
+
inField = true;
|
226
|
+
|
227
|
+
while (i < len) {
|
228
|
+
var current = ca(i);
|
229
|
+
switch (current) {
|
230
|
+
case qualifier:
|
231
|
+
if (!inField) {
|
232
|
+
inField = true;
|
233
|
+
} else {
|
234
|
+
if (ca(i-1) === escape)
|
235
|
+
fieldBuffer.push(current);
|
236
|
+
else
|
237
|
+
inField = false;
|
238
|
+
}
|
239
|
+
break;
|
240
|
+
case delimiter:
|
241
|
+
if (inField && qualifier)
|
242
|
+
fieldBuffer.push(current);
|
243
|
+
else {
|
244
|
+
fields.push(fieldBuffer.join(''))
|
245
|
+
fieldBuffer.length = 0;
|
246
|
+
}
|
247
|
+
break;
|
248
|
+
case escape:
|
249
|
+
if (qualifier)
|
250
|
+
if (ca(i+1) !== qualifier)
|
251
|
+
fieldBuffer.push(current);
|
252
|
+
break;
|
253
|
+
default:
|
254
|
+
if (inField)
|
255
|
+
fieldBuffer.push(current);
|
256
|
+
break;
|
257
|
+
}
|
258
|
+
i += 1;
|
259
|
+
}
|
260
|
+
|
261
|
+
fields.push(fieldBuffer.join(''))
|
262
|
+
return fields;
|
263
|
+
},
|
264
|
+
|
265
|
+
replaceAll: function(ss, r) {
|
266
|
+
//var s = this.s.replace(new RegExp(ss, 'g'), r);
|
267
|
+
var s = this.s.split(ss).join(r)
|
268
|
+
return new S(s);
|
269
|
+
},
|
270
|
+
|
271
|
+
right: function(N) {
|
272
|
+
if (N >= 0) {
|
273
|
+
var s = this.s.substr(this.s.length - N, N);
|
274
|
+
return new S(s);
|
275
|
+
} else {
|
276
|
+
return this.left(-N);
|
277
|
+
}
|
278
|
+
},
|
279
|
+
|
280
|
+
slugify: function() {
|
281
|
+
var sl = (new S(this.s.replace(/[^\w\s-]/g, '').toLowerCase())).dasherize().s;
|
282
|
+
if (sl.charAt(0) === '-')
|
283
|
+
sl = sl.substr(1);
|
284
|
+
return new S(sl);
|
285
|
+
},
|
286
|
+
|
287
|
+
startsWith: function(prefix) {
|
288
|
+
return this.s.lastIndexOf(prefix, 0) === 0;
|
289
|
+
},
|
290
|
+
|
291
|
+
stripPunctuation: function() {
|
292
|
+
//return new S(this.s.replace(/[\.,-\/#!$%\^&\*;:{}=\-_`~()]/g,""));
|
293
|
+
return new S(this.s.replace(/[^\w\s]|_/g, "").replace(/\s+/g, " "));
|
294
|
+
},
|
295
|
+
|
296
|
+
stripTags: function() { //from sugar.js
|
297
|
+
var s = this.s, args = arguments.length > 0 ? arguments : [''];
|
298
|
+
multiArgs(args, function(tag) {
|
299
|
+
s = s.replace(RegExp('<\/?' + tag + '[^<>]*>', 'gi'), '');
|
300
|
+
});
|
301
|
+
return new S(s);
|
302
|
+
},
|
303
|
+
|
304
|
+
template: function(values, opening, closing) {
|
305
|
+
var s = this.s
|
306
|
+
var opening = opening || Export.TMPL_OPEN
|
307
|
+
var closing = closing || Export.TMPL_CLOSE
|
308
|
+
var r = new RegExp(opening + '(.+?)' + closing, 'g')
|
309
|
+
//, r = /\{\{(.+?)\}\}/g
|
310
|
+
var matches = s.match(r) || [];
|
311
|
+
|
312
|
+
matches.forEach(function(match) {
|
313
|
+
var key = match.substring(opening.length, match.length - closing.length);//chop {{ and }}
|
314
|
+
if (values[key])
|
315
|
+
s = s.replace(match, values[key]);
|
316
|
+
});
|
317
|
+
return new S(s);
|
318
|
+
},
|
319
|
+
|
320
|
+
times: function(n) {
|
321
|
+
return new S(new Array(n + 1).join(this.s));
|
322
|
+
},
|
323
|
+
|
324
|
+
toBoolean: function() {
|
325
|
+
if (typeof this.orig === 'string') {
|
326
|
+
var s = this.s.toLowerCase();
|
327
|
+
return s === 'true' || s === 'yes' || s === 'on';
|
328
|
+
} else
|
329
|
+
return this.orig === true || this.orig === 1;
|
330
|
+
},
|
331
|
+
|
332
|
+
toFloat: function(precision) {
|
333
|
+
var num = parseFloat(this.s, 10);
|
334
|
+
if (precision)
|
335
|
+
return parseFloat(num.toFixed(precision));
|
336
|
+
else
|
337
|
+
return num;
|
338
|
+
},
|
339
|
+
|
340
|
+
toInt: function() { //thanks Google
|
341
|
+
// If the string starts with '0x' or '-0x', parse as hex.
|
342
|
+
return /^\s*-?0x/i.test(this.s) ? parseInt(this.s, 16) : parseInt(this.s, 10);
|
343
|
+
},
|
344
|
+
|
345
|
+
trim: function() {
|
346
|
+
var s;
|
347
|
+
if (typeof String.prototype.trim === 'undefined') {
|
348
|
+
s = this.s.replace(/(^\s*|\s*$)/g, '');
|
349
|
+
} else {
|
350
|
+
s = this.s.trim();
|
351
|
+
}
|
352
|
+
return new S(s);
|
353
|
+
},
|
354
|
+
|
355
|
+
trimLeft: function() {
|
356
|
+
var s;
|
357
|
+
if (__nsp.trimLeft)
|
358
|
+
s = this.s.trimLeft();
|
359
|
+
else
|
360
|
+
s = this.s.replace(/(^\s*)/g, '');
|
361
|
+
return new S(s);
|
362
|
+
},
|
363
|
+
|
364
|
+
trimRight: function() {
|
365
|
+
var s;
|
366
|
+
if (__nsp.trimRight)
|
367
|
+
s = this.s.trimRight();
|
368
|
+
else
|
369
|
+
s = this.s.replace(/\s+$/, '');
|
370
|
+
return new S(s);
|
371
|
+
},
|
372
|
+
|
373
|
+
truncate: function(length, pruneStr) { //from underscore.string, author: github.com/rwz
|
374
|
+
var str = this.s;
|
375
|
+
|
376
|
+
length = ~~length;
|
377
|
+
pruneStr = pruneStr || '...';
|
378
|
+
|
379
|
+
if (str.length <= length) return new S(str);
|
380
|
+
|
381
|
+
var tmpl = function(c){ return c.toUpperCase() !== c.toLowerCase() ? 'A' : ' '; },
|
382
|
+
template = str.slice(0, length+1).replace(/.(?=\W*\w*$)/g, tmpl); // 'Hello, world' -> 'HellAA AAAAA'
|
383
|
+
|
384
|
+
if (template.slice(template.length-2).match(/\w\w/))
|
385
|
+
template = template.replace(/\s*\S+$/, '');
|
386
|
+
else
|
387
|
+
template = new S(template.slice(0, template.length-1)).trimRight().s;
|
388
|
+
|
389
|
+
return (template+pruneStr).length > str.length ? new S(str) : new S(str.slice(0, template.length)+pruneStr);
|
390
|
+
},
|
391
|
+
|
392
|
+
toCSV: function() {
|
393
|
+
var delim = ',', qualifier = '"', escapeChar = '\\', encloseNumbers = true, keys = false;
|
394
|
+
var dataArray = [];
|
395
|
+
|
396
|
+
function hasVal(it) {
|
397
|
+
return it !== null && it !== '';
|
398
|
+
}
|
399
|
+
|
400
|
+
if (typeof arguments[0] === 'object') {
|
401
|
+
delim = arguments[0].delimiter || delim;
|
402
|
+
delim = arguments[0].separator || delim;
|
403
|
+
qualifier = arguments[0].qualifier || qualifier;
|
404
|
+
encloseNumbers = !!arguments[0].encloseNumbers;
|
405
|
+
escapeChar = arguments[0].escapeChar || escapeChar;
|
406
|
+
keys = !!arguments[0].keys;
|
407
|
+
} else if (typeof arguments[0] === 'string') {
|
408
|
+
delim = arguments[0];
|
409
|
+
}
|
410
|
+
|
411
|
+
if (typeof arguments[1] === 'string')
|
412
|
+
qualifier = arguments[1];
|
413
|
+
|
414
|
+
if (arguments[1] === null)
|
415
|
+
qualifier = null;
|
416
|
+
|
417
|
+
if (this.orig instanceof Array)
|
418
|
+
dataArray = this.orig;
|
419
|
+
else { //object
|
420
|
+
for (var key in this.orig)
|
421
|
+
if (this.orig.hasOwnProperty(key))
|
422
|
+
if (keys)
|
423
|
+
dataArray.push(key);
|
424
|
+
else
|
425
|
+
dataArray.push(this.orig[key]);
|
426
|
+
}
|
427
|
+
|
428
|
+
var rep = escapeChar + qualifier;
|
429
|
+
var buildString = [];
|
430
|
+
for (var i = 0; i < dataArray.length; ++i) {
|
431
|
+
var shouldQualify = hasVal(qualifier)
|
432
|
+
if (typeof dataArray[i] == 'number')
|
433
|
+
shouldQualify &= encloseNumbers;
|
434
|
+
|
435
|
+
if (shouldQualify)
|
436
|
+
buildString.push(qualifier);
|
437
|
+
|
438
|
+
if (dataArray[i] !== null) {
|
439
|
+
var d = new S(dataArray[i]).replaceAll(qualifier, rep).s;
|
440
|
+
buildString.push(d);
|
441
|
+
} else
|
442
|
+
buildString.push('')
|
443
|
+
|
444
|
+
if (shouldQualify)
|
445
|
+
buildString.push(qualifier);
|
446
|
+
|
447
|
+
if (delim)
|
448
|
+
buildString.push(delim);
|
449
|
+
}
|
450
|
+
|
451
|
+
//chop last delim
|
452
|
+
//console.log(buildString.length)
|
453
|
+
buildString.length = buildString.length - 1;
|
454
|
+
return new S(buildString.join(''));
|
455
|
+
},
|
456
|
+
|
457
|
+
toString: function() {
|
458
|
+
return this.s;
|
459
|
+
},
|
460
|
+
|
461
|
+
//#modified from https://github.com/epeli/underscore.string
|
462
|
+
underscore: function() {
|
463
|
+
var s = this.trim().s.replace(/([a-z\d])([A-Z]+)/g, '$1_$2').replace(/[-\s]+/g, '_').toLowerCase();
|
464
|
+
if ((new S(this.s.charAt(0))).isUpper()) {
|
465
|
+
s = '_' + s;
|
466
|
+
}
|
467
|
+
return new S(s);
|
468
|
+
},
|
469
|
+
|
470
|
+
unescapeHTML: function() { //from underscore.string
|
471
|
+
return new S(this.s.replace(/\&([^;]+);/g, function(entity, entityCode){
|
472
|
+
var match;
|
473
|
+
|
474
|
+
if (entityCode in escapeChars) {
|
475
|
+
return escapeChars[entityCode];
|
476
|
+
} else if (match = entityCode.match(/^#x([\da-fA-F]+)$/)) {
|
477
|
+
return String.fromCharCode(parseInt(match[1], 16));
|
478
|
+
} else if (match = entityCode.match(/^#(\d+)$/)) {
|
479
|
+
return String.fromCharCode(~~match[1]);
|
480
|
+
} else {
|
481
|
+
return entity;
|
482
|
+
}
|
483
|
+
}));
|
484
|
+
},
|
485
|
+
|
486
|
+
valueOf: function() {
|
487
|
+
return this.s.valueOf();
|
488
|
+
}
|
489
|
+
|
490
|
+
}
|
491
|
+
|
492
|
+
var methodsAdded = [];
|
493
|
+
function extendPrototype() {
|
494
|
+
for (var name in __sp) {
|
495
|
+
(function(name){
|
496
|
+
var func = __sp[name];
|
497
|
+
if (!__nsp.hasOwnProperty(name)) {
|
498
|
+
methodsAdded.push(name);
|
499
|
+
__nsp[name] = function() {
|
500
|
+
String.prototype.s = this;
|
501
|
+
return func.apply(this, arguments);
|
502
|
+
}
|
503
|
+
}
|
504
|
+
})(name);
|
505
|
+
}
|
506
|
+
}
|
507
|
+
|
508
|
+
function restorePrototype() {
|
509
|
+
for (var i = 0; i < methodsAdded.length; ++i)
|
510
|
+
delete String.prototype[methodsAdded[i]];
|
511
|
+
methodsAdded.length = 0;
|
512
|
+
}
|
513
|
+
|
514
|
+
|
515
|
+
/*************************************
|
516
|
+
/* Attach Native JavaScript String Properties
|
517
|
+
/*************************************/
|
518
|
+
|
519
|
+
var nativeProperties = getNativeStringProperties();
|
520
|
+
for (var name in nativeProperties) {
|
521
|
+
(function(name) {
|
522
|
+
var stringProp = __nsp[name];
|
523
|
+
if (typeof stringProp == 'function') {
|
524
|
+
//console.log(stringProp)
|
525
|
+
if (!__sp[name]) {
|
526
|
+
if (nativeProperties[name] === 'string') {
|
527
|
+
__sp[name] = function() {
|
528
|
+
//console.log(name)
|
529
|
+
return new S(stringProp.apply(this, arguments));
|
530
|
+
}
|
531
|
+
} else {
|
532
|
+
__sp[name] = stringProp;
|
533
|
+
}
|
534
|
+
}
|
535
|
+
}
|
536
|
+
})(name);
|
537
|
+
}
|
538
|
+
|
539
|
+
|
540
|
+
/*************************************
|
541
|
+
/* Function Aliases
|
542
|
+
/*************************************/
|
543
|
+
|
544
|
+
__sp.repeat = __sp.times;
|
545
|
+
__sp.include = __sp.contains;
|
546
|
+
__sp.toInteger = __sp.toInt;
|
547
|
+
__sp.toBool = __sp.toBoolean;
|
548
|
+
__sp.decodeHTMLEntities = __sp.decodeHtmlEntities //ensure consistent casing scheme of 'HTML'
|
549
|
+
|
550
|
+
|
551
|
+
/*************************************
|
552
|
+
/* Private Functions
|
553
|
+
/*************************************/
|
554
|
+
|
555
|
+
function getNativeStringProperties() {
|
556
|
+
var names = getNativeStringPropertyNames();
|
557
|
+
var retObj = {};
|
558
|
+
|
559
|
+
for (var i = 0; i < names.length; ++i) {
|
560
|
+
var name = names[i];
|
561
|
+
var func = __nsp[name];
|
562
|
+
try {
|
563
|
+
var type = typeof func.apply('teststring', []);
|
564
|
+
retObj[name] = type;
|
565
|
+
} catch (e) {}
|
566
|
+
}
|
567
|
+
return retObj;
|
568
|
+
}
|
569
|
+
|
570
|
+
function getNativeStringPropertyNames() {
|
571
|
+
var results = [];
|
572
|
+
if (Object.getOwnPropertyNames) {
|
573
|
+
results = Object.getOwnPropertyNames(__nsp);
|
574
|
+
results.splice(results.indexOf('valueOf'), 1);
|
575
|
+
results.splice(results.indexOf('toString'), 1);
|
576
|
+
return results;
|
577
|
+
} else { //meant for legacy cruft, this could probably be made more efficient
|
578
|
+
var stringNames = {};
|
579
|
+
var objectNames = [];
|
580
|
+
for (var name in String.prototype)
|
581
|
+
stringNames[name] = name;
|
582
|
+
|
583
|
+
for (var name in Object.prototype)
|
584
|
+
delete stringNames[name];
|
585
|
+
|
586
|
+
//stringNames['toString'] = 'toString'; //this was deleted with the rest of the object names
|
587
|
+
for (var name in stringNames) {
|
588
|
+
results.push(name);
|
589
|
+
}
|
590
|
+
return results;
|
591
|
+
}
|
592
|
+
}
|
593
|
+
|
594
|
+
function Export(str) {
|
595
|
+
return new S(str);
|
596
|
+
};
|
597
|
+
|
598
|
+
//attach exports to StringJSWrapper
|
599
|
+
Export.extendPrototype = extendPrototype;
|
600
|
+
Export.restorePrototype = restorePrototype;
|
601
|
+
Export.VERSION = VERSION;
|
602
|
+
Export.TMPL_OPEN = '{{';
|
603
|
+
Export.TMPL_CLOSE = '}}';
|
604
|
+
Export.ENTITIES = ENTITIES;
|
605
|
+
|
606
|
+
|
607
|
+
|
608
|
+
/*************************************
|
609
|
+
/* Exports
|
610
|
+
/*************************************/
|
611
|
+
|
612
|
+
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
|
613
|
+
module.exports = Export;
|
614
|
+
|
615
|
+
} else {
|
616
|
+
|
617
|
+
if(typeof define === "function" && define.amd) {
|
618
|
+
define([], function() {
|
619
|
+
return Export;
|
620
|
+
});
|
621
|
+
} else {
|
622
|
+
window.S = Export;
|
623
|
+
}
|
624
|
+
}
|
625
|
+
|
626
|
+
|
627
|
+
/*************************************
|
628
|
+
/* 3rd Party Private Functions
|
629
|
+
/*************************************/
|
630
|
+
|
631
|
+
//from sugar.js
|
632
|
+
function multiArgs(args, fn) {
|
633
|
+
var result = [], i;
|
634
|
+
for(i = 0; i < args.length; i++) {
|
635
|
+
result.push(args[i]);
|
636
|
+
if(fn) fn.call(args, args[i], i);
|
637
|
+
}
|
638
|
+
return result;
|
639
|
+
}
|
640
|
+
|
641
|
+
//from underscore.string
|
642
|
+
var escapeChars = {
|
643
|
+
lt: '<',
|
644
|
+
gt: '>',
|
645
|
+
quot: '"',
|
646
|
+
apos: "'",
|
647
|
+
amp: '&'
|
648
|
+
};
|
649
|
+
|
650
|
+
//from underscore.string
|
651
|
+
var reversedEscapeChars = {};
|
652
|
+
for(var key in escapeChars){ reversedEscapeChars[escapeChars[key]] = key; }
|
653
|
+
|
654
|
+
ENTITIES = {
|
655
|
+
"amp" : "&",
|
656
|
+
"gt" : ">",
|
657
|
+
"lt" : "<",
|
658
|
+
"quot" : "\"",
|
659
|
+
"apos" : "'",
|
660
|
+
"AElig" : 198,
|
661
|
+
"Aacute" : 193,
|
662
|
+
"Acirc" : 194,
|
663
|
+
"Agrave" : 192,
|
664
|
+
"Aring" : 197,
|
665
|
+
"Atilde" : 195,
|
666
|
+
"Auml" : 196,
|
667
|
+
"Ccedil" : 199,
|
668
|
+
"ETH" : 208,
|
669
|
+
"Eacute" : 201,
|
670
|
+
"Ecirc" : 202,
|
671
|
+
"Egrave" : 200,
|
672
|
+
"Euml" : 203,
|
673
|
+
"Iacute" : 205,
|
674
|
+
"Icirc" : 206,
|
675
|
+
"Igrave" : 204,
|
676
|
+
"Iuml" : 207,
|
677
|
+
"Ntilde" : 209,
|
678
|
+
"Oacute" : 211,
|
679
|
+
"Ocirc" : 212,
|
680
|
+
"Ograve" : 210,
|
681
|
+
"Oslash" : 216,
|
682
|
+
"Otilde" : 213,
|
683
|
+
"Ouml" : 214,
|
684
|
+
"THORN" : 222,
|
685
|
+
"Uacute" : 218,
|
686
|
+
"Ucirc" : 219,
|
687
|
+
"Ugrave" : 217,
|
688
|
+
"Uuml" : 220,
|
689
|
+
"Yacute" : 221,
|
690
|
+
"aacute" : 225,
|
691
|
+
"acirc" : 226,
|
692
|
+
"aelig" : 230,
|
693
|
+
"agrave" : 224,
|
694
|
+
"aring" : 229,
|
695
|
+
"atilde" : 227,
|
696
|
+
"auml" : 228,
|
697
|
+
"ccedil" : 231,
|
698
|
+
"eacute" : 233,
|
699
|
+
"ecirc" : 234,
|
700
|
+
"egrave" : 232,
|
701
|
+
"eth" : 240,
|
702
|
+
"euml" : 235,
|
703
|
+
"iacute" : 237,
|
704
|
+
"icirc" : 238,
|
705
|
+
"igrave" : 236,
|
706
|
+
"iuml" : 239,
|
707
|
+
"ntilde" : 241,
|
708
|
+
"oacute" : 243,
|
709
|
+
"ocirc" : 244,
|
710
|
+
"ograve" : 242,
|
711
|
+
"oslash" : 248,
|
712
|
+
"otilde" : 245,
|
713
|
+
"ouml" : 246,
|
714
|
+
"szlig" : 223,
|
715
|
+
"thorn" : 254,
|
716
|
+
"uacute" : 250,
|
717
|
+
"ucirc" : 251,
|
718
|
+
"ugrave" : 249,
|
719
|
+
"uuml" : 252,
|
720
|
+
"yacute" : 253,
|
721
|
+
"yuml" : 255,
|
722
|
+
"copy" : 169,
|
723
|
+
"reg" : 174,
|
724
|
+
"nbsp" : 160,
|
725
|
+
"iexcl" : 161,
|
726
|
+
"cent" : 162,
|
727
|
+
"pound" : 163,
|
728
|
+
"curren" : 164,
|
729
|
+
"yen" : 165,
|
730
|
+
"brvbar" : 166,
|
731
|
+
"sect" : 167,
|
732
|
+
"uml" : 168,
|
733
|
+
"ordf" : 170,
|
734
|
+
"laquo" : 171,
|
735
|
+
"not" : 172,
|
736
|
+
"shy" : 173,
|
737
|
+
"macr" : 175,
|
738
|
+
"deg" : 176,
|
739
|
+
"plusmn" : 177,
|
740
|
+
"sup1" : 185,
|
741
|
+
"sup2" : 178,
|
742
|
+
"sup3" : 179,
|
743
|
+
"acute" : 180,
|
744
|
+
"micro" : 181,
|
745
|
+
"para" : 182,
|
746
|
+
"middot" : 183,
|
747
|
+
"cedil" : 184,
|
748
|
+
"ordm" : 186,
|
749
|
+
"raquo" : 187,
|
750
|
+
"frac14" : 188,
|
751
|
+
"frac12" : 189,
|
752
|
+
"frac34" : 190,
|
753
|
+
"iquest" : 191,
|
754
|
+
"times" : 215,
|
755
|
+
"divide" : 247,
|
756
|
+
"OElig;" : 338,
|
757
|
+
"oelig;" : 339,
|
758
|
+
"Scaron;" : 352,
|
759
|
+
"scaron;" : 353,
|
760
|
+
"Yuml;" : 376,
|
761
|
+
"fnof;" : 402,
|
762
|
+
"circ;" : 710,
|
763
|
+
"tilde;" : 732,
|
764
|
+
"Alpha;" : 913,
|
765
|
+
"Beta;" : 914,
|
766
|
+
"Gamma;" : 915,
|
767
|
+
"Delta;" : 916,
|
768
|
+
"Epsilon;" : 917,
|
769
|
+
"Zeta;" : 918,
|
770
|
+
"Eta;" : 919,
|
771
|
+
"Theta;" : 920,
|
772
|
+
"Iota;" : 921,
|
773
|
+
"Kappa;" : 922,
|
774
|
+
"Lambda;" : 923,
|
775
|
+
"Mu;" : 924,
|
776
|
+
"Nu;" : 925,
|
777
|
+
"Xi;" : 926,
|
778
|
+
"Omicron;" : 927,
|
779
|
+
"Pi;" : 928,
|
780
|
+
"Rho;" : 929,
|
781
|
+
"Sigma;" : 931,
|
782
|
+
"Tau;" : 932,
|
783
|
+
"Upsilon;" : 933,
|
784
|
+
"Phi;" : 934,
|
785
|
+
"Chi;" : 935,
|
786
|
+
"Psi;" : 936,
|
787
|
+
"Omega;" : 937,
|
788
|
+
"alpha;" : 945,
|
789
|
+
"beta;" : 946,
|
790
|
+
"gamma;" : 947,
|
791
|
+
"delta;" : 948,
|
792
|
+
"epsilon;" : 949,
|
793
|
+
"zeta;" : 950,
|
794
|
+
"eta;" : 951,
|
795
|
+
"theta;" : 952,
|
796
|
+
"iota;" : 953,
|
797
|
+
"kappa;" : 954,
|
798
|
+
"lambda;" : 955,
|
799
|
+
"mu;" : 956,
|
800
|
+
"nu;" : 957,
|
801
|
+
"xi;" : 958,
|
802
|
+
"omicron;" : 959,
|
803
|
+
"pi;" : 960,
|
804
|
+
"rho;" : 961,
|
805
|
+
"sigmaf;" : 962,
|
806
|
+
"sigma;" : 963,
|
807
|
+
"tau;" : 964,
|
808
|
+
"upsilon;" : 965,
|
809
|
+
"phi;" : 966,
|
810
|
+
"chi;" : 967,
|
811
|
+
"psi;" : 968,
|
812
|
+
"omega;" : 969,
|
813
|
+
"thetasym;" : 977,
|
814
|
+
"upsih;" : 978,
|
815
|
+
"piv;" : 982,
|
816
|
+
"ensp;" : 8194,
|
817
|
+
"emsp;" : 8195,
|
818
|
+
"thinsp;" : 8201,
|
819
|
+
"zwnj;" : 8204,
|
820
|
+
"zwj;" : 8205,
|
821
|
+
"lrm;" : 8206,
|
822
|
+
"rlm;" : 8207,
|
823
|
+
"ndash;" : 8211,
|
824
|
+
"mdash;" : 8212,
|
825
|
+
"lsquo;" : 8216,
|
826
|
+
"rsquo;" : 8217,
|
827
|
+
"sbquo;" : 8218,
|
828
|
+
"ldquo;" : 8220,
|
829
|
+
"rdquo;" : 8221,
|
830
|
+
"bdquo;" : 8222,
|
831
|
+
"dagger;" : 8224,
|
832
|
+
"Dagger;" : 8225,
|
833
|
+
"bull;" : 8226,
|
834
|
+
"hellip;" : 8230,
|
835
|
+
"permil;" : 8240,
|
836
|
+
"prime;" : 8242,
|
837
|
+
"Prime;" : 8243,
|
838
|
+
"lsaquo;" : 8249,
|
839
|
+
"rsaquo;" : 8250,
|
840
|
+
"oline;" : 8254,
|
841
|
+
"frasl;" : 8260,
|
842
|
+
"euro;" : 8364,
|
843
|
+
"image;" : 8465,
|
844
|
+
"weierp;" : 8472,
|
845
|
+
"real;" : 8476,
|
846
|
+
"trade;" : 8482,
|
847
|
+
"alefsym;" : 8501,
|
848
|
+
"larr;" : 8592,
|
849
|
+
"uarr;" : 8593,
|
850
|
+
"rarr;" : 8594,
|
851
|
+
"darr;" : 8595,
|
852
|
+
"harr;" : 8596,
|
853
|
+
"crarr;" : 8629,
|
854
|
+
"lArr;" : 8656,
|
855
|
+
"uArr;" : 8657,
|
856
|
+
"rArr;" : 8658,
|
857
|
+
"dArr;" : 8659,
|
858
|
+
"hArr;" : 8660,
|
859
|
+
"forall;" : 8704,
|
860
|
+
"part;" : 8706,
|
861
|
+
"exist;" : 8707,
|
862
|
+
"empty;" : 8709,
|
863
|
+
"nabla;" : 8711,
|
864
|
+
"isin;" : 8712,
|
865
|
+
"notin;" : 8713,
|
866
|
+
"ni;" : 8715,
|
867
|
+
"prod;" : 8719,
|
868
|
+
"sum;" : 8721,
|
869
|
+
"minus;" : 8722,
|
870
|
+
"lowast;" : 8727,
|
871
|
+
"radic;" : 8730,
|
872
|
+
"prop;" : 8733,
|
873
|
+
"infin;" : 8734,
|
874
|
+
"ang;" : 8736,
|
875
|
+
"and;" : 8743,
|
876
|
+
"or;" : 8744,
|
877
|
+
"cap;" : 8745,
|
878
|
+
"cup;" : 8746,
|
879
|
+
"int;" : 8747,
|
880
|
+
"there4;" : 8756,
|
881
|
+
"sim;" : 8764,
|
882
|
+
"cong;" : 8773,
|
883
|
+
"asymp;" : 8776,
|
884
|
+
"ne;" : 8800,
|
885
|
+
"equiv;" : 8801,
|
886
|
+
"le;" : 8804,
|
887
|
+
"ge;" : 8805,
|
888
|
+
"sub;" : 8834,
|
889
|
+
"sup;" : 8835,
|
890
|
+
"nsub;" : 8836,
|
891
|
+
"sube;" : 8838,
|
892
|
+
"supe;" : 8839,
|
893
|
+
"oplus;" : 8853,
|
894
|
+
"otimes;" : 8855,
|
895
|
+
"perp;" : 8869,
|
896
|
+
"sdot;" : 8901,
|
897
|
+
"lceil;" : 8968,
|
898
|
+
"rceil;" : 8969,
|
899
|
+
"lfloor;" : 8970,
|
900
|
+
"rfloor;" : 8971,
|
901
|
+
"lang;" : 9001,
|
902
|
+
"rang;" : 9002,
|
903
|
+
"loz;" : 9674,
|
904
|
+
"spades;" : 9824,
|
905
|
+
"clubs;" : 9827,
|
906
|
+
"hearts;" : 9829,
|
907
|
+
"diams;" : 9830
|
908
|
+
}
|
909
|
+
|
910
|
+
|
911
|
+
}).call(this);
|
@@ -0,0 +1,3 @@
|
|
1
|
+
/*
|
2
|
+
string.js - Copyright (C) 2012-2013, JP Richardson <jprichardson@gmail.com>
|
3
|
+
*/!function(){"use strict";function n(e){e!==null&&e!==undefined?typeof e=="string"?this.s=e:this.s=e.toString():this.s=e,this.orig=e,e!==null&&e!==undefined?this.__defineGetter__?this.__defineGetter__("length",function(){return this.s.length}):this.length=e.length:this.length=-1}function o(){for(var e in i)(function(e){var t=i[e];r.hasOwnProperty(e)||(s.push(e),r[e]=function(){return String.prototype.s=this,t.apply(this,arguments)})})(e)}function u(){for(var e=0;e<s.length;++e)delete String.prototype[s[e]];s.length=0}function l(){var e=c(),t={};for(var n=0;n<e.length;++n){var i=e[n],s=r[i];try{var o=typeof s.apply("teststring",[]);t[i]=o}catch(u){}}return t}function c(){var e=[];if(Object.getOwnPropertyNames)return e=Object.getOwnPropertyNames(r),e.splice(e.indexOf("valueOf"),1),e.splice(e.indexOf("toString"),1),e;var t={},n=[];for(var i in String.prototype)t[i]=i;for(var i in Object.prototype)delete t[i];for(var i in t)e.push(i);return e}function h(e){return new n(e)}function p(e,t){var n=[],r;for(r=0;r<e.length;r++)n.push(e[r]),t&&t.call(e,e[r],r);return n}var e="1.3.0",t={},r=String.prototype,i=n.prototype={between:function(e,t){var r=this.s,i=r.indexOf(e),s=r.indexOf(t),o=i+e.length;return new n(s>i?r.slice(o,s):"")},camelize:function(){var e=this.trim().s.replace(/(\-|_|\s)+(.)?/g,function(e,t,n){return n?n.toUpperCase():""});return new n(e)},capitalize:function(){return new n(this.s.substr(0,1).toUpperCase()+this.s.substring(1).toLowerCase())},charAt:function(e){return this.s.charAt(e)},chompLeft:function(e){var t=this.s;return t.indexOf(e)===0?(t=t.slice(e.length),new n(t)):this},chompRight:function(e){if(this.endsWith(e)){var t=this.s;return t=t.slice(0,t.length-e.length),new n(t)}return this},collapseWhitespace:function(){var e=this.s.replace(/[\s\xa0]+/g," ").replace(/^\s+|\s+$/g,"");return new n(e)},contains:function(e){return this.s.indexOf(e)>=0},dasherize:function(){var e=this.trim().s.replace(/[_\s]+/g,"-").replace(/([A-Z])/g,"-$1").replace(/-+/g,"-").toLowerCase();return new n(e)},decodeHtmlEntities:function(){var e=this.s;return e=e.replace(/&#(\d+);?/g,function(e,t){return String.fromCharCode(t)}).replace(/&#[xX]([A-Fa-f0-9]+);?/g,function(e,t){return String.fromCharCode(parseInt(t,16))}).replace(/&([^;\W]+;?)/g,function(e,n){var r=n.replace(/;$/,""),i=t[n]||n.match(/;$/)&&t[r];return typeof i=="number"?String.fromCharCode(i):typeof i=="string"?i:e}),new n(e)},endsWith:function(e){var t=this.s.length-e.length;return t>=0&&this.s.indexOf(e,t)===t},escapeHTML:function(){return new n(this.s.replace(/[&<>"']/g,function(e){return"&"+v[e]+";"}))},ensureLeft:function(e){var t=this.s;return t.indexOf(e)===0?this:new n(e+t)},ensureRight:function(e){var t=this.s;return this.endsWith(e)?this:new n(t+e)},isAlpha:function(){return!/[^a-z\xC0-\xFF]/.test(this.s.toLowerCase())},isAlphaNumeric:function(){return!/[^0-9a-z\xC0-\xFF]/.test(this.s.toLowerCase())},isEmpty:function(){return this.s===null||this.s===undefined?!0:/^[\s\xa0]*$/.test(this.s)},isLower:function(){return this.isAlpha()&&this.s.toLowerCase()===this.s},isNumeric:function(){return!/[^0-9]/.test(this.s)},isUpper:function(){return this.isAlpha()&&this.s.toUpperCase()===this.s},left:function(e){if(e>=0){var t=this.s.substr(0,e);return new n(t)}return this.right(-e)},lines:function(){var e=this.s.split("\n");for(var t=0;t<e.length;++t)e[t]=e[t].replace(/(^\s*|\s*$)/g,"");return e},pad:function(e,t){t=t||" ";if(this.s.length>=e)return new n(this.s);e-=this.s.length;var r=Array(Math.ceil(e/2)+1).join(t),i=Array(Math.floor(e/2)+1).join(t);return new n(r+this.s+i)},padLeft:function(e,t){return t=t||" ",this.s.length>=e?new n(this.s):new n(Array(e-this.s.length+1).join(t)+this.s)},padRight:function(e,t){return t=t||" ",this.s.length>=e?new n(this.s):new n(this.s+Array(e-this.s.length+1).join(t))},parseCSV:function(e,t,n){e=e||",",n=n||"\\",typeof t=="undefined"&&(t='"');var r=0,i=[],s=[],o=this.s.length,u=!1,a=this,f=function(e){return a.s.charAt(e)};t||(u=!0);while(r<o){var l=f(r);switch(l){case t:u?f(r-1)===n?i.push(l):u=!1:u=!0;break;case e:u&&t?i.push(l):(s.push(i.join("")),i.length=0);break;case n:t&&f(r+1)!==t&&i.push(l);break;default:u&&i.push(l)}r+=1}return s.push(i.join("")),s},replaceAll:function(e,t){var r=this.s.split(e).join(t);return new n(r)},right:function(e){if(e>=0){var t=this.s.substr(this.s.length-e,e);return new n(t)}return this.left(-e)},slugify:function(){var e=(new n(this.s.replace(/[^\w\s-]/g,"").toLowerCase())).dasherize().s;return e.charAt(0)==="-"&&(e=e.substr(1)),new n(e)},startsWith:function(e){return this.s.lastIndexOf(e,0)===0},stripPunctuation:function(){return new n(this.s.replace(/[^\w\s]|_/g,"").replace(/\s+/g," "))},stripTags:function(){var e=this.s,t=arguments.length>0?arguments:[""];return p(t,function(t){e=e.replace(RegExp("</?"+t+"[^<>]*>","gi"),"")}),new n(e)},template:function(e,t,r){var i=this.s,t=t||h.TMPL_OPEN,r=r||h.TMPL_CLOSE,s=new RegExp(t+"(.+?)"+r,"g"),o=i.match(s)||[];return o.forEach(function(n){var s=n.substring(t.length,n.length-r.length);e[s]&&(i=i.replace(n,e[s]))}),new n(i)},times:function(e){return new n((new Array(e+1)).join(this.s))},toBoolean:function(){if(typeof this.orig=="string"){var e=this.s.toLowerCase();return e==="true"||e==="yes"||e==="on"}return this.orig===!0||this.orig===1},toFloat:function(e){var t=parseFloat(this.s,10);return e?parseFloat(t.toFixed(e)):t},toInt:function(){return/^\s*-?0x/i.test(this.s)?parseInt(this.s,16):parseInt(this.s,10)},trim:function(){var e;return typeof String.prototype.trim=="undefined"?e=this.s.replace(/(^\s*|\s*$)/g,""):e=this.s.trim(),new n(e)},trimLeft:function(){var e;return r.trimLeft?e=this.s.trimLeft():e=this.s.replace(/(^\s*)/g,""),new n(e)},trimRight:function(){var e;return r.trimRight?e=this.s.trimRight():e=this.s.replace(/\s+$/,""),new n(e)},truncate:function(e,t){var r=this.s;e=~~e,t=t||"...";if(r.length<=e)return new n(r);var i=function(e){return e.toUpperCase()!==e.toLowerCase()?"A":" "},s=r.slice(0,e+1).replace(/.(?=\W*\w*$)/g,i);return s.slice(s.length-2).match(/\w\w/)?s=s.replace(/\s*\S+$/,""):s=(new n(s.slice(0,s.length-1))).trimRight().s,(s+t).length>r.length?new n(r):new n(r.slice(0,s.length)+t)},toCSV:function(){function u(e){return e!==null&&e!==""}var e=",",t='"',r="\\",i=!0,s=!1,o=[];typeof arguments[0]=="object"?(e=arguments[0].delimiter||e,e=arguments[0].separator||e,t=arguments[0].qualifier||t,i=!!arguments[0].encloseNumbers,r=arguments[0].escapeChar||r,s=!!arguments[0].keys):typeof arguments[0]=="string"&&(e=arguments[0]),typeof arguments[1]=="string"&&(t=arguments[1]),arguments[1]===null&&(t=null);if(this.orig instanceof Array)o=this.orig;else for(var a in this.orig)this.orig.hasOwnProperty(a)&&(s?o.push(a):o.push(this.orig[a]));var f=r+t,l=[];for(var c=0;c<o.length;++c){var h=u(t);typeof o[c]=="number"&&(h&=i),h&&l.push(t);if(o[c]!==null){var p=(new n(o[c])).replaceAll(t,f).s;l.push(p)}else l.push("");h&&l.push(t),e&&l.push(e)}return l.length=l.length-1,new n(l.join(""))},toString:function(){return this.s},underscore:function(){var e=this.trim().s.replace(/([a-z\d])([A-Z]+)/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase();return(new n(this.s.charAt(0))).isUpper()&&(e="_"+e),new n(e)},unescapeHTML:function(){return new n(this.s.replace(/\&([^;]+);/g,function(e,t){var n;return t in d?d[t]:(n=t.match(/^#x([\da-fA-F]+)$/))?String.fromCharCode(parseInt(n[1],16)):(n=t.match(/^#(\d+)$/))?String.fromCharCode(~~n[1]):e}))},valueOf:function(){return this.s.valueOf()}},s=[],a=l();for(var f in a)(function(e){var t=r[e];typeof t=="function"&&(i[e]||(a[e]==="string"?i[e]=function(){return new n(t.apply(this,arguments))}:i[e]=t))})(f);i.repeat=i.times,i.include=i.contains,i.toInteger=i.toInt,i.toBool=i.toBoolean,i.decodeHTMLEntities=i.decodeHtmlEntities,h.extendPrototype=o,h.restorePrototype=u,h.VERSION=e,h.TMPL_OPEN="{{",h.TMPL_CLOSE="}}",h.ENTITIES=t,typeof module!="undefined"&&typeof module.exports!="undefined"?module.exports=h:typeof define=="function"&&define.amd?define([],function(){return h}):window.S=h;var d={lt:"<",gt:">",quot:'"',apos:"'",amp:"&"},v={};for(var m in d)v[d[m]]=m;t={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,"OElig;":338,"oelig;":339,"Scaron;":352,"scaron;":353,"Yuml;":376,"fnof;":402,"circ;":710,"tilde;":732,"Alpha;":913,"Beta;":914,"Gamma;":915,"Delta;":916,"Epsilon;":917,"Zeta;":918,"Eta;":919,"Theta;":920,"Iota;":921,"Kappa;":922,"Lambda;":923,"Mu;":924,"Nu;":925,"Xi;":926,"Omicron;":927,"Pi;":928,"Rho;":929,"Sigma;":931,"Tau;":932,"Upsilon;":933,"Phi;":934,"Chi;":935,"Psi;":936,"Omega;":937,"alpha;":945,"beta;":946,"gamma;":947,"delta;":948,"epsilon;":949,"zeta;":950,"eta;":951,"theta;":952,"iota;":953,"kappa;":954,"lambda;":955,"mu;":956,"nu;":957,"xi;":958,"omicron;":959,"pi;":960,"rho;":961,"sigmaf;":962,"sigma;":963,"tau;":964,"upsilon;":965,"phi;":966,"chi;":967,"psi;":968,"omega;":969,"thetasym;":977,"upsih;":978,"piv;":982,"ensp;":8194,"emsp;":8195,"thinsp;":8201,"zwnj;":8204,"zwj;":8205,"lrm;":8206,"rlm;":8207,"ndash;":8211,"mdash;":8212,"lsquo;":8216,"rsquo;":8217,"sbquo;":8218,"ldquo;":8220,"rdquo;":8221,"bdquo;":8222,"dagger;":8224,"Dagger;":8225,"bull;":8226,"hellip;":8230,"permil;":8240,"prime;":8242,"Prime;":8243,"lsaquo;":8249,"rsaquo;":8250,"oline;":8254,"frasl;":8260,"euro;":8364,"image;":8465,"weierp;":8472,"real;":8476,"trade;":8482,"alefsym;":8501,"larr;":8592,"uarr;":8593,"rarr;":8594,"darr;":8595,"harr;":8596,"crarr;":8629,"lArr;":8656,"uArr;":8657,"rArr;":8658,"dArr;":8659,"hArr;":8660,"forall;":8704,"part;":8706,"exist;":8707,"empty;":8709,"nabla;":8711,"isin;":8712,"notin;":8713,"ni;":8715,"prod;":8719,"sum;":8721,"minus;":8722,"lowast;":8727,"radic;":8730,"prop;":8733,"infin;":8734,"ang;":8736,"and;":8743,"or;":8744,"cap;":8745,"cup;":8746,"int;":8747,"there4;":8756,"sim;":8764,"cong;":8773,"asymp;":8776,"ne;":8800,"equiv;":8801,"le;":8804,"ge;":8805,"sub;":8834,"sup;":8835,"nsub;":8836,"sube;":8838,"supe;":8839,"oplus;":8853,"otimes;":8855,"perp;":8869,"sdot;":8901,"lceil;":8968,"rceil;":8969,"lfloor;":8970,"rfloor;":8971,"lang;":9001,"rang;":9002,"loz;":9674,"spades;":9824,"clubs;":9827,"hearts;":9829,"diams;":9830}}.call(this);
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stringjs-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jesper Josefsson
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: railties
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.1'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.1'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.3'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.3'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: Wraps String.js and makes it available using the Rails asset pipeline
|
63
|
+
email:
|
64
|
+
- jesper.josefsson@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- lib/stringjs-rails.rb
|
70
|
+
- vendor/assets/javascripts/string.js
|
71
|
+
- vendor/assets/javascripts/string.min.js
|
72
|
+
- LICENSE.txt
|
73
|
+
- README.md
|
74
|
+
homepage: https://github.com/jesjos/stringjs-rails
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
hash: -1532851845134161308
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
segments:
|
97
|
+
- 0
|
98
|
+
hash: -1532851845134161308
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 1.8.25
|
102
|
+
signing_key:
|
103
|
+
specification_version: 3
|
104
|
+
summary: The String.js Javascript library ready for the Rails asset pipeline
|
105
|
+
test_files: []
|