underscore_string_rails 3.0.2.0.2
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +38 -0
- data/Rakefile +22 -0
- data/config/routes.rb +2 -0
- data/lib/tasks/underscore_string_rails_tasks.rake +4 -0
- data/lib/underscore_string_rails/engine.rb +12 -0
- data/lib/underscore_string_rails/version.rb +3 -0
- data/lib/underscore_string_rails.rb +4 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +14 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config/application.rb +32 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +41 -0
- data/spec/dummy/config/environments/production.rb +79 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +56 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/log/test.log +4 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/59141bf990f2a8199dd782f46c4f811f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6fc24dfdcea0b54eefc76ba521f8f162 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/9d92747e8c48b01a6ad19676b52f755a +0 -0
- data/spec/integration/underscore_string_rails_spec.rb +11 -0
- data/spec/spec_helper.rb +18 -0
- data/vendor/assets/javascript/underscore.string.js +1013 -0
- metadata +173 -0
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Underscore.string Rails Assets" do
|
|
4
|
+
|
|
5
|
+
it 'provides underscore.string.js on the asset pipeline' do
|
|
6
|
+
visit '/assets/underscore.string.js'
|
|
7
|
+
expect(page).to have_content('Underscore.string')
|
|
8
|
+
expect(page).to have_content("Version '3.0.2'")
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
|
2
|
+
|
|
3
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
|
4
|
+
require 'rspec/rails'
|
|
5
|
+
require 'capybara/rspec'
|
|
6
|
+
|
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
|
8
|
+
|
|
9
|
+
# Load support files
|
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
|
11
|
+
|
|
12
|
+
RSpec.configure do |config|
|
|
13
|
+
config.include Capybara::DSL
|
|
14
|
+
config.mock_with :rspec
|
|
15
|
+
config.infer_base_class_for_anonymous_controllers = false
|
|
16
|
+
config.order = "random"
|
|
17
|
+
config.color = true
|
|
18
|
+
end
|
|
@@ -0,0 +1,1013 @@
|
|
|
1
|
+
!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.s=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
|
|
2
|
+
var trim = _dereq_('./trim');
|
|
3
|
+
var decap = _dereq_('./decapitalize');
|
|
4
|
+
|
|
5
|
+
module.exports = function camelize(str, decapitalize) {
|
|
6
|
+
str = trim(str).replace(/[-_\s]+(.)?/g, function(match, c) {
|
|
7
|
+
return c ? c.toUpperCase() : "";
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
if (decapitalize === true) {
|
|
11
|
+
return decap(str);
|
|
12
|
+
} else {
|
|
13
|
+
return str;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
},{"./decapitalize":9,"./trim":60}],2:[function(_dereq_,module,exports){
|
|
18
|
+
var makeString = _dereq_('./helper/makeString');
|
|
19
|
+
|
|
20
|
+
module.exports = function capitalize(str) {
|
|
21
|
+
str = makeString(str);
|
|
22
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
},{"./helper/makeString":19}],3:[function(_dereq_,module,exports){
|
|
26
|
+
var makeString = _dereq_('./helper/makeString');
|
|
27
|
+
|
|
28
|
+
module.exports = function chars(str) {
|
|
29
|
+
return makeString(str).split('');
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
},{"./helper/makeString":19}],4:[function(_dereq_,module,exports){
|
|
33
|
+
module.exports = function chop(str, step) {
|
|
34
|
+
if (str == null) return [];
|
|
35
|
+
str = String(str);
|
|
36
|
+
step = ~~step;
|
|
37
|
+
return step > 0 ? str.match(new RegExp('.{1,' + step + '}', 'g')) : [str];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
},{}],5:[function(_dereq_,module,exports){
|
|
41
|
+
var capitalize = _dereq_('./capitalize');
|
|
42
|
+
var camelize = _dereq_('./camelize');
|
|
43
|
+
var makeString = _dereq_('./helper/makeString');
|
|
44
|
+
|
|
45
|
+
module.exports = function classify(str) {
|
|
46
|
+
str = makeString(str);
|
|
47
|
+
return capitalize(camelize(str.replace(/[\W_]/g, ' ')).replace(/\s/g, ''));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
},{"./camelize":1,"./capitalize":2,"./helper/makeString":19}],6:[function(_dereq_,module,exports){
|
|
51
|
+
var trim = _dereq_('./trim');
|
|
52
|
+
|
|
53
|
+
module.exports = function clean(str) {
|
|
54
|
+
return trim(str).replace(/\s+/g, ' ');
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
},{"./trim":60}],7:[function(_dereq_,module,exports){
|
|
58
|
+
var makeString = _dereq_('./helper/makeString');
|
|
59
|
+
|
|
60
|
+
module.exports = function(str, substr) {
|
|
61
|
+
str = makeString(str);
|
|
62
|
+
substr = makeString(substr);
|
|
63
|
+
|
|
64
|
+
if (str.length === 0 || substr.length === 0) return 0;
|
|
65
|
+
|
|
66
|
+
var count = 0,
|
|
67
|
+
pos = 0,
|
|
68
|
+
length = substr.length;
|
|
69
|
+
|
|
70
|
+
while (true) {
|
|
71
|
+
pos = str.indexOf(substr, pos);
|
|
72
|
+
if (pos === -1) break;
|
|
73
|
+
count++;
|
|
74
|
+
pos += length;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return count;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
},{"./helper/makeString":19}],8:[function(_dereq_,module,exports){
|
|
81
|
+
var trim = _dereq_('./trim');
|
|
82
|
+
|
|
83
|
+
module.exports = function dasherize(str) {
|
|
84
|
+
return trim(str).replace(/([A-Z])/g, '-$1').replace(/[-_\s]+/g, '-').toLowerCase();
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
},{"./trim":60}],9:[function(_dereq_,module,exports){
|
|
88
|
+
var makeString = _dereq_('./helper/makeString');
|
|
89
|
+
|
|
90
|
+
module.exports = function decapitalize(str) {
|
|
91
|
+
str = makeString(str);
|
|
92
|
+
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
},{"./helper/makeString":19}],10:[function(_dereq_,module,exports){
|
|
96
|
+
var makeString = _dereq_('./helper/makeString');
|
|
97
|
+
|
|
98
|
+
function getIndent(str) {
|
|
99
|
+
var matches = str.match(/^[\s\\t]*/gm);
|
|
100
|
+
var indent = matches[0].length;
|
|
101
|
+
|
|
102
|
+
for (var i = 1; i < matches.length; i++) {
|
|
103
|
+
indent = Math.min(matches[i].length, indent);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return indent;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
module.exports = function dedent(str, pattern) {
|
|
110
|
+
str = makeString(str);
|
|
111
|
+
var indent = getIndent(str);
|
|
112
|
+
var reg;
|
|
113
|
+
|
|
114
|
+
if (indent === 0) return str;
|
|
115
|
+
|
|
116
|
+
if (typeof pattern === 'string') {
|
|
117
|
+
reg = new RegExp('^' + pattern, 'gm');
|
|
118
|
+
} else {
|
|
119
|
+
reg = new RegExp('^[ \\t]{' + indent + '}', 'gm');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return str.replace(reg, '');
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
},{"./helper/makeString":19}],11:[function(_dereq_,module,exports){
|
|
126
|
+
var makeString = _dereq_('./helper/makeString');
|
|
127
|
+
var toPositive = _dereq_('./helper/toPositive');
|
|
128
|
+
|
|
129
|
+
module.exports = function endsWith(str, ends, position) {
|
|
130
|
+
str = makeString(str);
|
|
131
|
+
ends = '' + ends;
|
|
132
|
+
if (typeof position == 'undefined') {
|
|
133
|
+
position = str.length - ends.length;
|
|
134
|
+
} else {
|
|
135
|
+
position = Math.min(toPositive(position), str.length) - ends.length;
|
|
136
|
+
}
|
|
137
|
+
return position >= 0 && str.indexOf(ends, position) === position;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
},{"./helper/makeString":19,"./helper/toPositive":21}],12:[function(_dereq_,module,exports){
|
|
141
|
+
var makeString = _dereq_('./helper/makeString');
|
|
142
|
+
var escapeChars = _dereq_('./helper/escapeChars');
|
|
143
|
+
var reversedEscapeChars = {};
|
|
144
|
+
|
|
145
|
+
for(var key in escapeChars) reversedEscapeChars[escapeChars[key]] = key;
|
|
146
|
+
reversedEscapeChars["'"] = '#39';
|
|
147
|
+
|
|
148
|
+
module.exports = function escapeHTML(str) {
|
|
149
|
+
return makeString(str).replace(/[&<>"']/g, function(m) {
|
|
150
|
+
return '&' + reversedEscapeChars[m] + ';';
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
},{"./helper/escapeChars":17,"./helper/makeString":19}],13:[function(_dereq_,module,exports){
|
|
155
|
+
module.exports = function() {
|
|
156
|
+
var result = {};
|
|
157
|
+
|
|
158
|
+
for (var prop in this) {
|
|
159
|
+
if (!this.hasOwnProperty(prop) || prop.match(/^(?:include|contains|reverse|join)$/)) continue;
|
|
160
|
+
result[prop] = this[prop];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return result;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
},{}],14:[function(_dereq_,module,exports){
|
|
167
|
+
// Underscore.string
|
|
168
|
+
// (c) 2010 Esa-Matti Suuronen <esa-matti aet suuronen dot org>
|
|
169
|
+
// Underscore.string is freely distributable under the terms of the MIT license.
|
|
170
|
+
// Documentation: https://github.com/epeli/underscore.string
|
|
171
|
+
// Some code is borrowed from MooTools and Alexandru Marasteanu.
|
|
172
|
+
// Version '3.0.2'
|
|
173
|
+
|
|
174
|
+
'use strict';
|
|
175
|
+
|
|
176
|
+
function s(value) {
|
|
177
|
+
/* jshint validthis: true */
|
|
178
|
+
if (!(this instanceof s)) return new s(value);
|
|
179
|
+
this._wrapped = value;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
s.VERSION = '3.0.2';
|
|
183
|
+
|
|
184
|
+
s.isBlank = _dereq_('./isBlank');
|
|
185
|
+
s.stripTags = _dereq_('./stripTags');
|
|
186
|
+
s.capitalize = _dereq_('./capitalize');
|
|
187
|
+
s.decapitalize = _dereq_('./decapitalize');
|
|
188
|
+
s.chop = _dereq_('./chop');
|
|
189
|
+
s.trim = _dereq_('./trim');
|
|
190
|
+
s.clean = _dereq_('./clean');
|
|
191
|
+
s.count = _dereq_('./count');
|
|
192
|
+
s.chars = _dereq_('./chars');
|
|
193
|
+
s.swapCase = _dereq_('./swapCase');
|
|
194
|
+
s.escapeHTML = _dereq_('./escapeHTML');
|
|
195
|
+
s.unescapeHTML = _dereq_('./unescapeHTML');
|
|
196
|
+
s.splice = _dereq_('./splice');
|
|
197
|
+
s.insert = _dereq_('./insert');
|
|
198
|
+
s.replaceAll = _dereq_('./replaceAll');
|
|
199
|
+
s.include = _dereq_('./include');
|
|
200
|
+
s.join = _dereq_('./join');
|
|
201
|
+
s.lines = _dereq_('./lines');
|
|
202
|
+
s.dedent = _dereq_('./dedent');
|
|
203
|
+
s.reverse = _dereq_('./reverse');
|
|
204
|
+
s.startsWith = _dereq_('./startsWith');
|
|
205
|
+
s.endsWith = _dereq_('./endsWith');
|
|
206
|
+
s.pred = _dereq_('./pred');
|
|
207
|
+
s.succ = _dereq_('./succ');
|
|
208
|
+
s.titleize = _dereq_('./titleize');
|
|
209
|
+
s.camelize = _dereq_('./camelize');
|
|
210
|
+
s.underscored = _dereq_('./underscored');
|
|
211
|
+
s.dasherize = _dereq_('./dasherize');
|
|
212
|
+
s.classify = _dereq_('./classify');
|
|
213
|
+
s.humanize = _dereq_('./humanize');
|
|
214
|
+
s.ltrim = _dereq_('./ltrim');
|
|
215
|
+
s.rtrim = _dereq_('./rtrim');
|
|
216
|
+
s.truncate = _dereq_('./truncate');
|
|
217
|
+
s.prune = _dereq_('./prune');
|
|
218
|
+
s.words = _dereq_('./words');
|
|
219
|
+
s.pad = _dereq_('./pad');
|
|
220
|
+
s.lpad = _dereq_('./lpad');
|
|
221
|
+
s.rpad = _dereq_('./rpad');
|
|
222
|
+
s.lrpad = _dereq_('./lrpad');
|
|
223
|
+
s.sprintf = _dereq_('./sprintf');
|
|
224
|
+
s.vsprintf = _dereq_('./vsprintf');
|
|
225
|
+
s.toNumber = _dereq_('./toNumber');
|
|
226
|
+
s.numberFormat = _dereq_('./numberFormat');
|
|
227
|
+
s.strRight = _dereq_('./strRight');
|
|
228
|
+
s.strRightBack = _dereq_('./strRightBack');
|
|
229
|
+
s.strLeft = _dereq_('./strLeft');
|
|
230
|
+
s.strLeftBack = _dereq_('./strLeftBack');
|
|
231
|
+
s.toSentence = _dereq_('./toSentence');
|
|
232
|
+
s.toSentenceSerial = _dereq_('./toSentenceSerial');
|
|
233
|
+
s.slugify = _dereq_('./slugify');
|
|
234
|
+
s.surround = _dereq_('./surround');
|
|
235
|
+
s.quote = _dereq_('./quote');
|
|
236
|
+
s.unquote = _dereq_('./unquote');
|
|
237
|
+
s.repeat = _dereq_('./repeat');
|
|
238
|
+
s.naturalCmp = _dereq_('./naturalCmp');
|
|
239
|
+
s.levenshtein = _dereq_('./levenshtein');
|
|
240
|
+
s.toBoolean = _dereq_('./toBoolean');
|
|
241
|
+
s.exports = _dereq_('./exports');
|
|
242
|
+
s.escapeRegExp = _dereq_('./helper/escapeRegExp');
|
|
243
|
+
|
|
244
|
+
// Aliases
|
|
245
|
+
s.strip = s.trim;
|
|
246
|
+
s.lstrip = s.ltrim;
|
|
247
|
+
s.rstrip = s.rtrim;
|
|
248
|
+
s.center = s.lrpad;
|
|
249
|
+
s.rjust = s.lpad;
|
|
250
|
+
s.ljust = s.rpad;
|
|
251
|
+
s.contains = s.include;
|
|
252
|
+
s.q = s.quote;
|
|
253
|
+
s.toBool = s.toBoolean;
|
|
254
|
+
s.camelcase = s.camelize;
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
// Implement chaining
|
|
258
|
+
s.prototype = {
|
|
259
|
+
value: function value() {
|
|
260
|
+
return this._wrapped;
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
function fn2method(key, fn) {
|
|
265
|
+
if (typeof fn !== "function") return;
|
|
266
|
+
s.prototype[key] = function() {
|
|
267
|
+
var args = [this._wrapped].concat(Array.prototype.slice.call(arguments));
|
|
268
|
+
var res = fn.apply(null, args);
|
|
269
|
+
// if the result is non-string stop the chain and return the value
|
|
270
|
+
return typeof res === 'string' ? new s(res) : res;
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Copy functions to instance methods for chaining
|
|
275
|
+
for (var key in s) fn2method(key, s[key]);
|
|
276
|
+
|
|
277
|
+
fn2method("tap", function tap(string, fn) {
|
|
278
|
+
return fn(string);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
function prototype2method(methodName) {
|
|
282
|
+
fn2method(methodName, function(context) {
|
|
283
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
|
284
|
+
return String.prototype[methodName].apply(context, args);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
var prototypeMethods = [
|
|
289
|
+
"toUpperCase",
|
|
290
|
+
"toLowerCase",
|
|
291
|
+
"split",
|
|
292
|
+
"replace",
|
|
293
|
+
"slice",
|
|
294
|
+
"substring",
|
|
295
|
+
"substr",
|
|
296
|
+
"concat"
|
|
297
|
+
];
|
|
298
|
+
|
|
299
|
+
for (var key in prototypeMethods) prototype2method(prototypeMethods[key]);
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
module.exports = s;
|
|
303
|
+
|
|
304
|
+
},{"./camelize":1,"./capitalize":2,"./chars":3,"./chop":4,"./classify":5,"./clean":6,"./count":7,"./dasherize":8,"./decapitalize":9,"./dedent":10,"./endsWith":11,"./escapeHTML":12,"./exports":13,"./helper/escapeRegExp":18,"./humanize":22,"./include":23,"./insert":24,"./isBlank":25,"./join":26,"./levenshtein":27,"./lines":28,"./lpad":29,"./lrpad":30,"./ltrim":31,"./naturalCmp":32,"./numberFormat":33,"./pad":34,"./pred":35,"./prune":36,"./quote":37,"./repeat":38,"./replaceAll":39,"./reverse":40,"./rpad":41,"./rtrim":42,"./slugify":43,"./splice":44,"./sprintf":45,"./startsWith":46,"./strLeft":47,"./strLeftBack":48,"./strRight":49,"./strRightBack":50,"./stripTags":51,"./succ":52,"./surround":53,"./swapCase":54,"./titleize":55,"./toBoolean":56,"./toNumber":57,"./toSentence":58,"./toSentenceSerial":59,"./trim":60,"./truncate":61,"./underscored":62,"./unescapeHTML":63,"./unquote":64,"./vsprintf":65,"./words":66}],15:[function(_dereq_,module,exports){
|
|
305
|
+
var makeString = _dereq_('./makeString');
|
|
306
|
+
|
|
307
|
+
module.exports = function adjacent(str, direction) {
|
|
308
|
+
str = makeString(str);
|
|
309
|
+
if (str.length === 0) {
|
|
310
|
+
return '';
|
|
311
|
+
}
|
|
312
|
+
return str.slice(0, -1) + String.fromCharCode(str.charCodeAt(str.length - 1) + direction);
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
},{"./makeString":19}],16:[function(_dereq_,module,exports){
|
|
316
|
+
var escapeRegExp = _dereq_('./escapeRegExp');
|
|
317
|
+
|
|
318
|
+
module.exports = function defaultToWhiteSpace(characters) {
|
|
319
|
+
if (characters == null)
|
|
320
|
+
return '\\s';
|
|
321
|
+
else if (characters.source)
|
|
322
|
+
return characters.source;
|
|
323
|
+
else
|
|
324
|
+
return '[' + escapeRegExp(characters) + ']';
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
},{"./escapeRegExp":18}],17:[function(_dereq_,module,exports){
|
|
328
|
+
var escapeChars = {
|
|
329
|
+
lt: '<',
|
|
330
|
+
gt: '>',
|
|
331
|
+
quot: '"',
|
|
332
|
+
amp: '&',
|
|
333
|
+
apos: "'"
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
module.exports = escapeChars;
|
|
337
|
+
|
|
338
|
+
},{}],18:[function(_dereq_,module,exports){
|
|
339
|
+
var makeString = _dereq_('./makeString');
|
|
340
|
+
|
|
341
|
+
module.exports = function escapeRegExp(str) {
|
|
342
|
+
return makeString(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
},{"./makeString":19}],19:[function(_dereq_,module,exports){
|
|
346
|
+
/**
|
|
347
|
+
* Ensure some object is a coerced to a string
|
|
348
|
+
**/
|
|
349
|
+
module.exports = function makeString(object) {
|
|
350
|
+
if (object == null) return '';
|
|
351
|
+
return '' + object;
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
},{}],20:[function(_dereq_,module,exports){
|
|
355
|
+
module.exports = function strRepeat(str, qty){
|
|
356
|
+
if (qty < 1) return '';
|
|
357
|
+
var result = '';
|
|
358
|
+
while (qty > 0) {
|
|
359
|
+
if (qty & 1) result += str;
|
|
360
|
+
qty >>= 1, str += str;
|
|
361
|
+
}
|
|
362
|
+
return result;
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
},{}],21:[function(_dereq_,module,exports){
|
|
366
|
+
module.exports = function toPositive(number) {
|
|
367
|
+
return number < 0 ? 0 : (+number || 0);
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
},{}],22:[function(_dereq_,module,exports){
|
|
371
|
+
var capitalize = _dereq_('./capitalize');
|
|
372
|
+
var underscored = _dereq_('./underscored');
|
|
373
|
+
var trim = _dereq_('./trim');
|
|
374
|
+
|
|
375
|
+
module.exports = function humanize(str) {
|
|
376
|
+
return capitalize(trim(underscored(str).replace(/_id$/, '').replace(/_/g, ' ')));
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
},{"./capitalize":2,"./trim":60,"./underscored":62}],23:[function(_dereq_,module,exports){
|
|
380
|
+
var makeString = _dereq_('./helper/makeString');
|
|
381
|
+
|
|
382
|
+
module.exports = function include(str, needle) {
|
|
383
|
+
if (needle === '') return true;
|
|
384
|
+
return makeString(str).indexOf(needle) !== -1;
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
},{"./helper/makeString":19}],24:[function(_dereq_,module,exports){
|
|
388
|
+
var splice = _dereq_('./splice');
|
|
389
|
+
|
|
390
|
+
module.exports = function insert(str, i, substr) {
|
|
391
|
+
return splice(str, i, 0, substr);
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
},{"./splice":44}],25:[function(_dereq_,module,exports){
|
|
395
|
+
var makeString = _dereq_('./helper/makeString');
|
|
396
|
+
|
|
397
|
+
module.exports = function isBlank(str) {
|
|
398
|
+
return (/^\s*$/).test(makeString(str));
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
},{"./helper/makeString":19}],26:[function(_dereq_,module,exports){
|
|
402
|
+
var makeString = _dereq_('./helper/makeString');
|
|
403
|
+
var slice = [].slice;
|
|
404
|
+
|
|
405
|
+
module.exports = function join() {
|
|
406
|
+
var args = slice.call(arguments),
|
|
407
|
+
separator = args.shift();
|
|
408
|
+
|
|
409
|
+
return args.join(makeString(separator));
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
},{"./helper/makeString":19}],27:[function(_dereq_,module,exports){
|
|
413
|
+
var makeString = _dereq_('./helper/makeString');
|
|
414
|
+
|
|
415
|
+
module.exports = function levenshtein(str1, str2) {
|
|
416
|
+
str1 = makeString(str1);
|
|
417
|
+
str2 = makeString(str2);
|
|
418
|
+
|
|
419
|
+
var current = [],
|
|
420
|
+
prev, value;
|
|
421
|
+
|
|
422
|
+
for (var i = 0; i <= str2.length; i++)
|
|
423
|
+
for (var j = 0; j <= str1.length; j++) {
|
|
424
|
+
if (i && j)
|
|
425
|
+
if (str1.charAt(j - 1) === str2.charAt(i - 1))
|
|
426
|
+
value = prev;
|
|
427
|
+
else
|
|
428
|
+
value = Math.min(current[j], current[j - 1], prev) + 1;
|
|
429
|
+
else
|
|
430
|
+
value = i + j;
|
|
431
|
+
|
|
432
|
+
prev = current[j];
|
|
433
|
+
current[j] = value;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
return current.pop();
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
},{"./helper/makeString":19}],28:[function(_dereq_,module,exports){
|
|
440
|
+
module.exports = function lines(str) {
|
|
441
|
+
if (str == null) return [];
|
|
442
|
+
return String(str).split(/\r?\n/);
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
},{}],29:[function(_dereq_,module,exports){
|
|
446
|
+
var pad = _dereq_('./pad');
|
|
447
|
+
|
|
448
|
+
module.exports = function lpad(str, length, padStr) {
|
|
449
|
+
return pad(str, length, padStr);
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
},{"./pad":34}],30:[function(_dereq_,module,exports){
|
|
453
|
+
var pad = _dereq_('./pad');
|
|
454
|
+
|
|
455
|
+
module.exports = function lrpad(str, length, padStr) {
|
|
456
|
+
return pad(str, length, padStr, 'both');
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
},{"./pad":34}],31:[function(_dereq_,module,exports){
|
|
460
|
+
var makeString = _dereq_('./helper/makeString');
|
|
461
|
+
var defaultToWhiteSpace = _dereq_('./helper/defaultToWhiteSpace');
|
|
462
|
+
var nativeTrimLeft = String.prototype.trimLeft;
|
|
463
|
+
|
|
464
|
+
module.exports = function ltrim(str, characters) {
|
|
465
|
+
str = makeString(str);
|
|
466
|
+
if (!characters && nativeTrimLeft) return nativeTrimLeft.call(str);
|
|
467
|
+
characters = defaultToWhiteSpace(characters);
|
|
468
|
+
return str.replace(new RegExp('^' + characters + '+'), '');
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
},{"./helper/defaultToWhiteSpace":16,"./helper/makeString":19}],32:[function(_dereq_,module,exports){
|
|
472
|
+
module.exports = function naturalCmp(str1, str2) {
|
|
473
|
+
if (str1 == str2) return 0;
|
|
474
|
+
if (!str1) return -1;
|
|
475
|
+
if (!str2) return 1;
|
|
476
|
+
|
|
477
|
+
var cmpRegex = /(\.\d+)|(\d+)|(\D+)/g,
|
|
478
|
+
tokens1 = String(str1).match(cmpRegex),
|
|
479
|
+
tokens2 = String(str2).match(cmpRegex),
|
|
480
|
+
count = Math.min(tokens1.length, tokens2.length);
|
|
481
|
+
|
|
482
|
+
for (var i = 0; i < count; i++) {
|
|
483
|
+
var a = tokens1[i],
|
|
484
|
+
b = tokens2[i];
|
|
485
|
+
|
|
486
|
+
if (a !== b) {
|
|
487
|
+
var num1 = +a;
|
|
488
|
+
var num2 = +b;
|
|
489
|
+
if (num1 === num1 && num2 === num2) {
|
|
490
|
+
return num1 > num2 ? 1 : -1;
|
|
491
|
+
}
|
|
492
|
+
return a < b ? -1 : 1;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
if (tokens1.length != tokens2.length)
|
|
497
|
+
return tokens1.length - tokens2.length;
|
|
498
|
+
|
|
499
|
+
return str1 < str2 ? -1 : 1;
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
},{}],33:[function(_dereq_,module,exports){
|
|
503
|
+
module.exports = function numberFormat(number, dec, dsep, tsep) {
|
|
504
|
+
if (isNaN(number) || number == null) return '';
|
|
505
|
+
|
|
506
|
+
number = number.toFixed(~~dec);
|
|
507
|
+
tsep = typeof tsep == 'string' ? tsep : ',';
|
|
508
|
+
|
|
509
|
+
var parts = number.split('.'),
|
|
510
|
+
fnums = parts[0],
|
|
511
|
+
decimals = parts[1] ? (dsep || '.') + parts[1] : '';
|
|
512
|
+
|
|
513
|
+
return fnums.replace(/(\d)(?=(?:\d{3})+$)/g, '$1' + tsep) + decimals;
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
},{}],34:[function(_dereq_,module,exports){
|
|
517
|
+
var makeString = _dereq_('./helper/makeString');
|
|
518
|
+
var strRepeat = _dereq_('./helper/strRepeat');
|
|
519
|
+
|
|
520
|
+
module.exports = function pad(str, length, padStr, type) {
|
|
521
|
+
str = makeString(str);
|
|
522
|
+
length = ~~length;
|
|
523
|
+
|
|
524
|
+
var padlen = 0;
|
|
525
|
+
|
|
526
|
+
if (!padStr)
|
|
527
|
+
padStr = ' ';
|
|
528
|
+
else if (padStr.length > 1)
|
|
529
|
+
padStr = padStr.charAt(0);
|
|
530
|
+
|
|
531
|
+
switch (type) {
|
|
532
|
+
case 'right':
|
|
533
|
+
padlen = length - str.length;
|
|
534
|
+
return str + strRepeat(padStr, padlen);
|
|
535
|
+
case 'both':
|
|
536
|
+
padlen = length - str.length;
|
|
537
|
+
return strRepeat(padStr, Math.ceil(padlen / 2)) + str + strRepeat(padStr, Math.floor(padlen / 2));
|
|
538
|
+
default: // 'left'
|
|
539
|
+
padlen = length - str.length;
|
|
540
|
+
return strRepeat(padStr, padlen) + str;
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
},{"./helper/makeString":19,"./helper/strRepeat":20}],35:[function(_dereq_,module,exports){
|
|
545
|
+
var adjacent = _dereq_('./helper/adjacent');
|
|
546
|
+
|
|
547
|
+
module.exports = function succ(str) {
|
|
548
|
+
return adjacent(str, -1);
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
},{"./helper/adjacent":15}],36:[function(_dereq_,module,exports){
|
|
552
|
+
/**
|
|
553
|
+
* _s.prune: a more elegant version of truncate
|
|
554
|
+
* prune extra chars, never leaving a half-chopped word.
|
|
555
|
+
* @author github.com/rwz
|
|
556
|
+
*/
|
|
557
|
+
var makeString = _dereq_('./helper/makeString');
|
|
558
|
+
var rtrim = _dereq_('./rtrim');
|
|
559
|
+
|
|
560
|
+
module.exports = function prune(str, length, pruneStr) {
|
|
561
|
+
str = makeString(str);
|
|
562
|
+
length = ~~length;
|
|
563
|
+
pruneStr = pruneStr != null ? String(pruneStr) : '...';
|
|
564
|
+
|
|
565
|
+
if (str.length <= length) return str;
|
|
566
|
+
|
|
567
|
+
var tmpl = function(c) {
|
|
568
|
+
return c.toUpperCase() !== c.toLowerCase() ? 'A' : ' ';
|
|
569
|
+
},
|
|
570
|
+
template = str.slice(0, length + 1).replace(/.(?=\W*\w*$)/g, tmpl); // 'Hello, world' -> 'HellAA AAAAA'
|
|
571
|
+
|
|
572
|
+
if (template.slice(template.length - 2).match(/\w\w/))
|
|
573
|
+
template = template.replace(/\s*\S+$/, '');
|
|
574
|
+
else
|
|
575
|
+
template = rtrim(template.slice(0, template.length - 1));
|
|
576
|
+
|
|
577
|
+
return (template + pruneStr).length > str.length ? str : str.slice(0, template.length) + pruneStr;
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
},{"./helper/makeString":19,"./rtrim":42}],37:[function(_dereq_,module,exports){
|
|
581
|
+
var surround = _dereq_('./surround');
|
|
582
|
+
|
|
583
|
+
module.exports = function quote(str, quoteChar) {
|
|
584
|
+
return surround(str, quoteChar || '"');
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
},{"./surround":53}],38:[function(_dereq_,module,exports){
|
|
588
|
+
var makeString = _dereq_('./helper/makeString');
|
|
589
|
+
var strRepeat = _dereq_('./helper/strRepeat');
|
|
590
|
+
|
|
591
|
+
module.exports = function repeat(str, qty, separator) {
|
|
592
|
+
str = makeString(str);
|
|
593
|
+
|
|
594
|
+
qty = ~~qty;
|
|
595
|
+
|
|
596
|
+
// using faster implementation if separator is not needed;
|
|
597
|
+
if (separator == null) return strRepeat(str, qty);
|
|
598
|
+
|
|
599
|
+
// this one is about 300x slower in Google Chrome
|
|
600
|
+
for (var repeat = []; qty > 0; repeat[--qty] = str) {}
|
|
601
|
+
return repeat.join(separator);
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
},{"./helper/makeString":19,"./helper/strRepeat":20}],39:[function(_dereq_,module,exports){
|
|
605
|
+
var makeString = _dereq_('./helper/makeString');
|
|
606
|
+
|
|
607
|
+
module.exports = function replaceAll(str, find, replace, ignorecase) {
|
|
608
|
+
var flags = (ignorecase === true)?'gi':'g';
|
|
609
|
+
var reg = new RegExp(find, flags);
|
|
610
|
+
|
|
611
|
+
return makeString(str).replace(reg, replace);
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
},{"./helper/makeString":19}],40:[function(_dereq_,module,exports){
|
|
615
|
+
var chars = _dereq_('./chars');
|
|
616
|
+
|
|
617
|
+
module.exports = function reverse(str) {
|
|
618
|
+
return chars(str).reverse().join('');
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
},{"./chars":3}],41:[function(_dereq_,module,exports){
|
|
622
|
+
var pad = _dereq_('./pad');
|
|
623
|
+
|
|
624
|
+
module.exports = function rpad(str, length, padStr) {
|
|
625
|
+
return pad(str, length, padStr, 'right');
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
},{"./pad":34}],42:[function(_dereq_,module,exports){
|
|
629
|
+
var makeString = _dereq_('./helper/makeString');
|
|
630
|
+
var defaultToWhiteSpace = _dereq_('./helper/defaultToWhiteSpace');
|
|
631
|
+
var nativeTrimRight = String.prototype.trimRight;
|
|
632
|
+
|
|
633
|
+
module.exports = function rtrim(str, characters) {
|
|
634
|
+
str = makeString(str);
|
|
635
|
+
if (!characters && nativeTrimRight) return nativeTrimRight.call(str);
|
|
636
|
+
characters = defaultToWhiteSpace(characters);
|
|
637
|
+
return str.replace(new RegExp(characters + '+$'), '');
|
|
638
|
+
};
|
|
639
|
+
|
|
640
|
+
},{"./helper/defaultToWhiteSpace":16,"./helper/makeString":19}],43:[function(_dereq_,module,exports){
|
|
641
|
+
var makeString = _dereq_('./helper/makeString');
|
|
642
|
+
var defaultToWhiteSpace = _dereq_('./helper/defaultToWhiteSpace');
|
|
643
|
+
var trim = _dereq_('./trim');
|
|
644
|
+
var dasherize = _dereq_('./dasherize');
|
|
645
|
+
|
|
646
|
+
module.exports = function slugify(str) {
|
|
647
|
+
var from = "ąàáäâãåæăćčĉęèéëêĝĥìíïîĵłľńňòóöőôõðøśșšŝťțŭùúüűûñÿýçżźž",
|
|
648
|
+
to = "aaaaaaaaaccceeeeeghiiiijllnnoooooooossssttuuuuuunyyczzz",
|
|
649
|
+
regex = new RegExp(defaultToWhiteSpace(from), 'g');
|
|
650
|
+
|
|
651
|
+
str = makeString(str).toLowerCase().replace(regex, function(c){
|
|
652
|
+
var index = from.indexOf(c);
|
|
653
|
+
return to.charAt(index) || '-';
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
return trim(dasherize(str.replace(/[^\w\s-]/g, '-')), '-');
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
},{"./dasherize":8,"./helper/defaultToWhiteSpace":16,"./helper/makeString":19,"./trim":60}],44:[function(_dereq_,module,exports){
|
|
660
|
+
var chars = _dereq_('./chars');
|
|
661
|
+
|
|
662
|
+
module.exports = function splice(str, i, howmany, substr) {
|
|
663
|
+
var arr = chars(str);
|
|
664
|
+
arr.splice(~~i, ~~howmany, substr);
|
|
665
|
+
return arr.join('');
|
|
666
|
+
};
|
|
667
|
+
|
|
668
|
+
},{"./chars":3}],45:[function(_dereq_,module,exports){
|
|
669
|
+
// sprintf() for JavaScript 0.7-beta1
|
|
670
|
+
// http://www.diveintojavascript.com/projects/javascript-sprintf
|
|
671
|
+
//
|
|
672
|
+
// Copyright (c) Alexandru Marasteanu <alexaholic [at) gmail (dot] com>
|
|
673
|
+
// All rights reserved.
|
|
674
|
+
var strRepeat = _dereq_('./helper/strRepeat');
|
|
675
|
+
var toString = Object.prototype.toString;
|
|
676
|
+
var sprintf = (function() {
|
|
677
|
+
function get_type(variable) {
|
|
678
|
+
return toString.call(variable).slice(8, -1).toLowerCase();
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
var str_repeat = strRepeat;
|
|
682
|
+
|
|
683
|
+
var str_format = function() {
|
|
684
|
+
if (!str_format.cache.hasOwnProperty(arguments[0])) {
|
|
685
|
+
str_format.cache[arguments[0]] = str_format.parse(arguments[0]);
|
|
686
|
+
}
|
|
687
|
+
return str_format.format.call(null, str_format.cache[arguments[0]], arguments);
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
str_format.format = function(parse_tree, argv) {
|
|
691
|
+
var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
|
|
692
|
+
for (i = 0; i < tree_length; i++) {
|
|
693
|
+
node_type = get_type(parse_tree[i]);
|
|
694
|
+
if (node_type === 'string') {
|
|
695
|
+
output.push(parse_tree[i]);
|
|
696
|
+
}
|
|
697
|
+
else if (node_type === 'array') {
|
|
698
|
+
match = parse_tree[i]; // convenience purposes only
|
|
699
|
+
if (match[2]) { // keyword argument
|
|
700
|
+
arg = argv[cursor];
|
|
701
|
+
for (k = 0; k < match[2].length; k++) {
|
|
702
|
+
if (!arg.hasOwnProperty(match[2][k])) {
|
|
703
|
+
throw new Error(sprintf('[_.sprintf] property "%s" does not exist', match[2][k]));
|
|
704
|
+
}
|
|
705
|
+
arg = arg[match[2][k]];
|
|
706
|
+
}
|
|
707
|
+
} else if (match[1]) { // positional argument (explicit)
|
|
708
|
+
arg = argv[match[1]];
|
|
709
|
+
}
|
|
710
|
+
else { // positional argument (implicit)
|
|
711
|
+
arg = argv[cursor++];
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) {
|
|
715
|
+
throw new Error(sprintf('[_.sprintf] expecting number but found %s', get_type(arg)));
|
|
716
|
+
}
|
|
717
|
+
switch (match[8]) {
|
|
718
|
+
case 'b': arg = arg.toString(2); break;
|
|
719
|
+
case 'c': arg = String.fromCharCode(arg); break;
|
|
720
|
+
case 'd': arg = parseInt(arg, 10); break;
|
|
721
|
+
case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break;
|
|
722
|
+
case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break;
|
|
723
|
+
case 'o': arg = arg.toString(8); break;
|
|
724
|
+
case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break;
|
|
725
|
+
case 'u': arg = Math.abs(arg); break;
|
|
726
|
+
case 'x': arg = arg.toString(16); break;
|
|
727
|
+
case 'X': arg = arg.toString(16).toUpperCase(); break;
|
|
728
|
+
}
|
|
729
|
+
arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg);
|
|
730
|
+
pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' ';
|
|
731
|
+
pad_length = match[6] - String(arg).length;
|
|
732
|
+
pad = match[6] ? str_repeat(pad_character, pad_length) : '';
|
|
733
|
+
output.push(match[5] ? arg + pad : pad + arg);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
return output.join('');
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
str_format.cache = {};
|
|
740
|
+
|
|
741
|
+
str_format.parse = function(fmt) {
|
|
742
|
+
var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
|
|
743
|
+
while (_fmt) {
|
|
744
|
+
if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
|
|
745
|
+
parse_tree.push(match[0]);
|
|
746
|
+
}
|
|
747
|
+
else if ((match = /^\x25{2}/.exec(_fmt)) !== null) {
|
|
748
|
+
parse_tree.push('%');
|
|
749
|
+
}
|
|
750
|
+
else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) {
|
|
751
|
+
if (match[2]) {
|
|
752
|
+
arg_names |= 1;
|
|
753
|
+
var field_list = [], replacement_field = match[2], field_match = [];
|
|
754
|
+
if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
|
|
755
|
+
field_list.push(field_match[1]);
|
|
756
|
+
while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
|
|
757
|
+
if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
|
|
758
|
+
field_list.push(field_match[1]);
|
|
759
|
+
}
|
|
760
|
+
else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
|
|
761
|
+
field_list.push(field_match[1]);
|
|
762
|
+
}
|
|
763
|
+
else {
|
|
764
|
+
throw new Error('[_.sprintf] huh?');
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
else {
|
|
769
|
+
throw new Error('[_.sprintf] huh?');
|
|
770
|
+
}
|
|
771
|
+
match[2] = field_list;
|
|
772
|
+
}
|
|
773
|
+
else {
|
|
774
|
+
arg_names |= 2;
|
|
775
|
+
}
|
|
776
|
+
if (arg_names === 3) {
|
|
777
|
+
throw new Error('[_.sprintf] mixing positional and named placeholders is not (yet) supported');
|
|
778
|
+
}
|
|
779
|
+
parse_tree.push(match);
|
|
780
|
+
}
|
|
781
|
+
else {
|
|
782
|
+
throw new Error('[_.sprintf] huh?');
|
|
783
|
+
}
|
|
784
|
+
_fmt = _fmt.substring(match[0].length);
|
|
785
|
+
}
|
|
786
|
+
return parse_tree;
|
|
787
|
+
};
|
|
788
|
+
|
|
789
|
+
return str_format;
|
|
790
|
+
})();
|
|
791
|
+
|
|
792
|
+
module.exports = sprintf;
|
|
793
|
+
|
|
794
|
+
},{"./helper/strRepeat":20}],46:[function(_dereq_,module,exports){
|
|
795
|
+
var makeString = _dereq_('./helper/makeString');
|
|
796
|
+
var toPositive = _dereq_('./helper/toPositive');
|
|
797
|
+
|
|
798
|
+
module.exports = function startsWith(str, starts, position) {
|
|
799
|
+
str = makeString(str);
|
|
800
|
+
starts = '' + starts;
|
|
801
|
+
position = position == null ? 0 : Math.min(toPositive(position), str.length);
|
|
802
|
+
return str.lastIndexOf(starts, position) === position;
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
},{"./helper/makeString":19,"./helper/toPositive":21}],47:[function(_dereq_,module,exports){
|
|
806
|
+
var makeString = _dereq_('./helper/makeString');
|
|
807
|
+
|
|
808
|
+
module.exports = function strLeft(str, sep) {
|
|
809
|
+
str = makeString(str);
|
|
810
|
+
sep = makeString(sep);
|
|
811
|
+
var pos = !sep ? -1 : str.indexOf(sep);
|
|
812
|
+
return~ pos ? str.slice(0, pos) : str;
|
|
813
|
+
};
|
|
814
|
+
|
|
815
|
+
},{"./helper/makeString":19}],48:[function(_dereq_,module,exports){
|
|
816
|
+
var makeString = _dereq_('./helper/makeString');
|
|
817
|
+
|
|
818
|
+
module.exports = function strLeftBack(str, sep) {
|
|
819
|
+
str = makeString(str);
|
|
820
|
+
sep = makeString(sep);
|
|
821
|
+
var pos = str.lastIndexOf(sep);
|
|
822
|
+
return~ pos ? str.slice(0, pos) : str;
|
|
823
|
+
};
|
|
824
|
+
|
|
825
|
+
},{"./helper/makeString":19}],49:[function(_dereq_,module,exports){
|
|
826
|
+
var makeString = _dereq_('./helper/makeString');
|
|
827
|
+
|
|
828
|
+
module.exports = function strRight(str, sep) {
|
|
829
|
+
str = makeString(str);
|
|
830
|
+
sep = makeString(sep);
|
|
831
|
+
var pos = !sep ? -1 : str.indexOf(sep);
|
|
832
|
+
return~ pos ? str.slice(pos + sep.length, str.length) : str;
|
|
833
|
+
};
|
|
834
|
+
|
|
835
|
+
},{"./helper/makeString":19}],50:[function(_dereq_,module,exports){
|
|
836
|
+
var makeString = _dereq_('./helper/makeString');
|
|
837
|
+
|
|
838
|
+
module.exports = function strRightBack(str, sep) {
|
|
839
|
+
str = makeString(str);
|
|
840
|
+
sep = makeString(sep);
|
|
841
|
+
var pos = !sep ? -1 : str.lastIndexOf(sep);
|
|
842
|
+
return~ pos ? str.slice(pos + sep.length, str.length) : str;
|
|
843
|
+
};
|
|
844
|
+
|
|
845
|
+
},{"./helper/makeString":19}],51:[function(_dereq_,module,exports){
|
|
846
|
+
var makeString = _dereq_('./helper/makeString');
|
|
847
|
+
|
|
848
|
+
module.exports = function stripTags(str) {
|
|
849
|
+
return makeString(str).replace(/<\/?[^>]+>/g, '');
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
},{"./helper/makeString":19}],52:[function(_dereq_,module,exports){
|
|
853
|
+
var adjacent = _dereq_('./helper/adjacent');
|
|
854
|
+
|
|
855
|
+
module.exports = function succ(str) {
|
|
856
|
+
return adjacent(str, 1);
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
},{"./helper/adjacent":15}],53:[function(_dereq_,module,exports){
|
|
860
|
+
module.exports = function surround(str, wrapper) {
|
|
861
|
+
return [wrapper, str, wrapper].join('');
|
|
862
|
+
};
|
|
863
|
+
|
|
864
|
+
},{}],54:[function(_dereq_,module,exports){
|
|
865
|
+
var makeString = _dereq_('./helper/makeString');
|
|
866
|
+
|
|
867
|
+
module.exports = function swapCase(str) {
|
|
868
|
+
return makeString(str).replace(/\S/g, function(c) {
|
|
869
|
+
return c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase();
|
|
870
|
+
});
|
|
871
|
+
};
|
|
872
|
+
|
|
873
|
+
},{"./helper/makeString":19}],55:[function(_dereq_,module,exports){
|
|
874
|
+
var makeString = _dereq_('./helper/makeString');
|
|
875
|
+
|
|
876
|
+
module.exports = function titleize(str) {
|
|
877
|
+
return makeString(str).toLowerCase().replace(/(?:^|\s|-)\S/g, function(c) {
|
|
878
|
+
return c.toUpperCase();
|
|
879
|
+
});
|
|
880
|
+
};
|
|
881
|
+
|
|
882
|
+
},{"./helper/makeString":19}],56:[function(_dereq_,module,exports){
|
|
883
|
+
var trim = _dereq_('./trim');
|
|
884
|
+
|
|
885
|
+
function boolMatch(s, matchers) {
|
|
886
|
+
var i, matcher, down = s.toLowerCase();
|
|
887
|
+
matchers = [].concat(matchers);
|
|
888
|
+
for (i = 0; i < matchers.length; i += 1) {
|
|
889
|
+
matcher = matchers[i];
|
|
890
|
+
if (!matcher) continue;
|
|
891
|
+
if (matcher.test && matcher.test(s)) return true;
|
|
892
|
+
if (matcher.toLowerCase() === down) return true;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
module.exports = function toBoolean(str, trueValues, falseValues) {
|
|
897
|
+
if (typeof str === "number") str = "" + str;
|
|
898
|
+
if (typeof str !== "string") return !!str;
|
|
899
|
+
str = trim(str);
|
|
900
|
+
if (boolMatch(str, trueValues || ["true", "1"])) return true;
|
|
901
|
+
if (boolMatch(str, falseValues || ["false", "0"])) return false;
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
},{"./trim":60}],57:[function(_dereq_,module,exports){
|
|
905
|
+
var trim = _dereq_('./trim');
|
|
906
|
+
var parseNumber = function(source) {
|
|
907
|
+
return source * 1 || 0;
|
|
908
|
+
};
|
|
909
|
+
|
|
910
|
+
module.exports = function toNumber(num, precision) {
|
|
911
|
+
if (num == null) return 0;
|
|
912
|
+
var factor = Math.pow(10, isFinite(precision) ? precision : 0);
|
|
913
|
+
return Math.round(num * factor) / factor;
|
|
914
|
+
};
|
|
915
|
+
|
|
916
|
+
},{"./trim":60}],58:[function(_dereq_,module,exports){
|
|
917
|
+
var rtrim = _dereq_('./rtrim');
|
|
918
|
+
|
|
919
|
+
module.exports = function toSentence(array, separator, lastSeparator, serial) {
|
|
920
|
+
separator = separator || ', ';
|
|
921
|
+
lastSeparator = lastSeparator || ' and ';
|
|
922
|
+
var a = array.slice(),
|
|
923
|
+
lastMember = a.pop();
|
|
924
|
+
|
|
925
|
+
if (array.length > 2 && serial) lastSeparator = rtrim(separator) + lastSeparator;
|
|
926
|
+
|
|
927
|
+
return a.length ? a.join(separator) + lastSeparator + lastMember : lastMember;
|
|
928
|
+
};
|
|
929
|
+
|
|
930
|
+
},{"./rtrim":42}],59:[function(_dereq_,module,exports){
|
|
931
|
+
var toSentence = _dereq_('./toSentence');
|
|
932
|
+
|
|
933
|
+
module.exports = function toSentenceSerial(array, sep, lastSep) {
|
|
934
|
+
return toSentence(array, sep, lastSep, true);
|
|
935
|
+
};
|
|
936
|
+
|
|
937
|
+
},{"./toSentence":58}],60:[function(_dereq_,module,exports){
|
|
938
|
+
var makeString = _dereq_('./helper/makeString');
|
|
939
|
+
var defaultToWhiteSpace = _dereq_('./helper/defaultToWhiteSpace');
|
|
940
|
+
var nativeTrim = String.prototype.trim;
|
|
941
|
+
|
|
942
|
+
module.exports = function trim(str, characters) {
|
|
943
|
+
str = makeString(str);
|
|
944
|
+
if (!characters && nativeTrim) return nativeTrim.call(str);
|
|
945
|
+
characters = defaultToWhiteSpace(characters);
|
|
946
|
+
return str.replace(new RegExp('^' + characters + '+|' + characters + '+$', 'g'), '');
|
|
947
|
+
};
|
|
948
|
+
|
|
949
|
+
},{"./helper/defaultToWhiteSpace":16,"./helper/makeString":19}],61:[function(_dereq_,module,exports){
|
|
950
|
+
var makeString = _dereq_('./helper/makeString');
|
|
951
|
+
|
|
952
|
+
module.exports = function truncate(str, length, truncateStr) {
|
|
953
|
+
str = makeString(str);
|
|
954
|
+
truncateStr = truncateStr || '...';
|
|
955
|
+
length = ~~length;
|
|
956
|
+
return str.length > length ? str.slice(0, length) + truncateStr : str;
|
|
957
|
+
};
|
|
958
|
+
|
|
959
|
+
},{"./helper/makeString":19}],62:[function(_dereq_,module,exports){
|
|
960
|
+
var trim = _dereq_('./trim');
|
|
961
|
+
|
|
962
|
+
module.exports = function underscored(str) {
|
|
963
|
+
return trim(str).replace(/([a-z\d])([A-Z]+)/g, '$1_$2').replace(/[-\s]+/g, '_').toLowerCase();
|
|
964
|
+
};
|
|
965
|
+
|
|
966
|
+
},{"./trim":60}],63:[function(_dereq_,module,exports){
|
|
967
|
+
var makeString = _dereq_('./helper/makeString');
|
|
968
|
+
var escapeChars = _dereq_('./helper/escapeChars');
|
|
969
|
+
|
|
970
|
+
module.exports = function unescapeHTML(str) {
|
|
971
|
+
return makeString(str).replace(/\&([^;]+);/g, function(entity, entityCode) {
|
|
972
|
+
var match;
|
|
973
|
+
|
|
974
|
+
if (entityCode in escapeChars) {
|
|
975
|
+
return escapeChars[entityCode];
|
|
976
|
+
} else if (match = entityCode.match(/^#x([\da-fA-F]+)$/)) {
|
|
977
|
+
return String.fromCharCode(parseInt(match[1], 16));
|
|
978
|
+
} else if (match = entityCode.match(/^#(\d+)$/)) {
|
|
979
|
+
return String.fromCharCode(~~match[1]);
|
|
980
|
+
} else {
|
|
981
|
+
return entity;
|
|
982
|
+
}
|
|
983
|
+
});
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
},{"./helper/escapeChars":17,"./helper/makeString":19}],64:[function(_dereq_,module,exports){
|
|
987
|
+
module.exports = function unquote(str, quoteChar) {
|
|
988
|
+
quoteChar = quoteChar || '"';
|
|
989
|
+
if (str[0] === quoteChar && str[str.length - 1] === quoteChar)
|
|
990
|
+
return str.slice(1, str.length - 1);
|
|
991
|
+
else return str;
|
|
992
|
+
};
|
|
993
|
+
|
|
994
|
+
},{}],65:[function(_dereq_,module,exports){
|
|
995
|
+
var sprintf = _dereq_('./sprintf');
|
|
996
|
+
|
|
997
|
+
module.exports = function vsprintf(fmt, argv) {
|
|
998
|
+
argv.unshift(fmt);
|
|
999
|
+
return sprintf.apply(null, argv);
|
|
1000
|
+
};
|
|
1001
|
+
|
|
1002
|
+
},{"./sprintf":45}],66:[function(_dereq_,module,exports){
|
|
1003
|
+
var isBlank = _dereq_('./isBlank');
|
|
1004
|
+
var trim = _dereq_('./trim');
|
|
1005
|
+
|
|
1006
|
+
module.exports = function words(str, delimiter) {
|
|
1007
|
+
if (isBlank(str)) return [];
|
|
1008
|
+
return trim(str, delimiter).split(delimiter || /\s+/);
|
|
1009
|
+
};
|
|
1010
|
+
|
|
1011
|
+
},{"./isBlank":25,"./trim":60}]},{},[14])
|
|
1012
|
+
(14)
|
|
1013
|
+
});
|