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.
- data/README.rst +42 -20
- data/lib/generators/templates/yellow_brick_road.rb.erb +19 -0
- data/lib/generators/yellow_brick_road/install_generator.rb +14 -0
- data/lib/yellow-brick-road/config.rb +41 -8
- data/lib/yellow-brick-road/directive_processor.rb +6 -5
- data/lib/yellow-brick-road/engine.rb +2 -3
- data/lib/yellow-brick-road/soy_processor.rb +1 -1
- data/lib/yellow-brick-road/version.rb +1 -1
- data/test/dummy/app/assets/javascripts/closure-deps.js +1 -1
- data/test/dummy/config/initializers/yellow_brick_road.rb +18 -1
- data/test/dummy/log/development.log +2208 -0
- data/test/dummy/tmp/cache/assets/C33/E00/sprockets%2F50c54266987e056bca666f8951752841 +2556 -0
- data/test/dummy/tmp/cache/assets/C48/990/sprockets%2F182c7921a46c3b8603c7f5595a111407 +823 -0
- data/test/dummy/tmp/cache/assets/C53/B40/sprockets%2F48cf0c035092dc945559526a279061c6 +204 -0
- data/test/dummy/tmp/cache/assets/C60/DB0/sprockets%2F3f00684578f2a3246581db667309ed89 +187 -0
- data/test/dummy/tmp/cache/assets/C60/E40/sprockets%2F3c5422f721521f492a5f02ca00b70009 +457 -0
- data/test/dummy/tmp/cache/assets/C73/DE0/sprockets%2F21f1f4574326846114a3c106873cebc3 +0 -0
- data/test/dummy/tmp/cache/assets/C7E/9F0/sprockets%2F89862076204c62c4593ac20de32da909 +4 -4
- data/test/dummy/tmp/cache/assets/C80/6F0/sprockets%2F56459a0713f8610d7d261f8be93073a2 +115 -0
- data/test/dummy/tmp/cache/assets/C8D/E10/sprockets%2F34b84bc4732937f885707002eda3896e +511 -0
- data/test/dummy/tmp/cache/assets/C93/CB0/sprockets%2F539b403b24833ca478a6f5877f37687c +239 -0
- data/test/dummy/tmp/cache/assets/C9A/C70/sprockets%2F10933dc6d342f604514713510b9ef0ab +806 -0
- data/test/dummy/tmp/cache/assets/CA0/7C0/sprockets%2Ff591bc0af8f085501241305c04907d3e +590 -0
- data/test/dummy/tmp/cache/assets/CA1/4A0/sprockets%2F5a9ad311e7d225b530b597041714b1e9 +2539 -0
- data/test/dummy/tmp/cache/assets/CA7/310/sprockets%2F45664cf816315200b574e029fde6f10a +0 -0
- data/test/dummy/tmp/cache/assets/CA7/A80/sprockets%2F1f32590957635a5a4f35442bc22f4ca4 +0 -0
- data/test/dummy/tmp/cache/assets/CAE/1D0/sprockets%2F2e62c7733d38a817a1532a744c6287bd +72 -0
- data/test/dummy/tmp/cache/assets/CB2/3C0/sprockets%2F9c35c290501a896b82c31448a39f3d5d +142 -0
- data/test/dummy/tmp/cache/assets/CB3/F20/sprockets%2F558b00e493fb501f7d95761e7eb40273 +2539 -0
- data/test/dummy/tmp/cache/assets/CBE/550/sprockets%2Fd680cac830e0b3408ba910f0b0421147 +2 -2
- data/test/dummy/tmp/cache/assets/CCD/480/sprockets%2Ffe7e11511634a2d03e1a20980b4593cf +0 -0
- data/test/dummy/tmp/cache/assets/CD0/080/sprockets%2Ffd5cbb87741244521d013d11c55573fa +204 -0
- data/test/dummy/tmp/cache/assets/CD2/020/sprockets%2Ff97740ba22118a2c91e992aac041843b +811 -0
- data/test/dummy/tmp/cache/assets/CD8/D90/sprockets%2F55dd841661d646f0024261a08ecf8ec0 +823 -0
- data/test/dummy/tmp/cache/assets/CE3/0D0/sprockets%2F301f97a178fd839a81bd663a6e22b616 +811 -0
- data/test/dummy/tmp/cache/assets/CE4/330/sprockets%2Fbd23466639af99164ab8e1c93721f14b +127 -0
- data/test/dummy/tmp/cache/assets/CE6/8A0/sprockets%2F3c0e7c5fa31563c8e820d6771e09918d +103 -0
- data/test/dummy/tmp/cache/assets/CEB/120/sprockets%2F857a0dde6829f7a27b93a840e1c60469 +522 -0
- data/test/dummy/tmp/cache/assets/CEE/CF0/sprockets%2F376f94b987d8156056c4e1d38ec06bf0 +0 -0
- data/test/dummy/tmp/cache/assets/CF2/C10/sprockets%2Fc64ef8a9dd0a1c3101d662750105c11a +806 -0
- data/test/dummy/tmp/cache/assets/CF3/CD0/sprockets%2F4bb42a5a6b504190f10d20b1c5f93d54 +1529 -0
- data/test/dummy/tmp/cache/assets/CF6/890/sprockets%2F36007a87f140155b5a04f2ca6b262dcc +494 -0
- data/test/dummy/tmp/cache/assets/CF6/9D0/sprockets%2F34b7199e9d33994c8ec7a442d60ca985 +173 -0
- data/test/dummy/tmp/cache/assets/CFA/A90/sprockets%2F901ba405a6d6747f6412ed4d0e0ac620 +256 -0
- data/test/dummy/tmp/cache/assets/CFC/E70/sprockets%2F8ee639668b5f0e629fbe0d62d1394689 +173 -0
- data/test/dummy/tmp/cache/assets/D04/1B0/sprockets%2F418f2b3b6b08b320f6db268a0991c54c +0 -0
- data/test/dummy/tmp/cache/assets/D05/920/sprockets%2F909507434dcc270db4853e4c147f0aac +5 -4
- data/test/dummy/tmp/cache/assets/D07/DB0/sprockets%2F0c17d7dac64290e385c91eb6f1570b31 +511 -0
- data/test/dummy/tmp/cache/assets/D07/EE0/sprockets%2F4999982b09e0b786894fce44f5d783cc +1371 -0
- data/test/dummy/tmp/cache/assets/D09/380/sprockets%2F14383e18fa2faac6b561a29d8e132863 +0 -0
- data/test/dummy/tmp/cache/assets/D0D/200/sprockets%2F545a7e34cce1d4272d83d58fd4215d42 +1277 -0
- data/test/dummy/tmp/cache/assets/D0E/870/sprockets%2F84996444f4f1f3fdc0248131cfb1a3b6 +794 -0
- data/test/dummy/tmp/cache/assets/D15/F60/sprockets%2Fa28394e3f80365b5bc86794dd46daa22 +0 -0
- data/test/dummy/tmp/cache/assets/D18/950/sprockets%2Fcf650d67c5d431ffdb38552e562299b2 +474 -0
- data/test/dummy/tmp/cache/assets/D18/E10/sprockets%2Fec7c58f640556b401fcd66528352dc9d +474 -0
- data/test/dummy/tmp/cache/assets/D20/660/sprockets%2F0d2875475ced01df962f3d758cda7792 +103 -0
- data/test/dummy/tmp/cache/assets/D22/AB0/sprockets%2F0b08e7f81651aaf739a93d61ae99779c +283 -0
- data/test/dummy/tmp/cache/assets/D2E/B20/sprockets%2Feed5412a17a52b1a335925e2af1f75d3 +0 -0
- data/test/dummy/tmp/cache/assets/D36/700/sprockets%2Fd219bf9db2eacc105bb294755093a437 +505 -0
- data/test/dummy/tmp/cache/assets/D3B/A10/sprockets%2Fcf38b51682d84a04da7b8a7313de52c6 +207 -0
- data/test/dummy/tmp/cache/assets/D3C/0E0/sprockets%2Fe9d7aba138d602c4a6ac701bc9615977 +505 -0
- data/test/dummy/tmp/cache/assets/D3E/FF0/sprockets%2F6bd8ccd3e02f397c20f349d5c0960e51 +0 -0
- data/test/dummy/tmp/cache/assets/D41/B30/sprockets%2Fba1b93913dd01d83ac9a96df334456f8 +0 -0
- data/test/dummy/tmp/cache/assets/D41/DA0/sprockets%2Fe8d00810698a9fcee032022fefd084f7 +0 -0
- data/test/dummy/tmp/cache/assets/D44/CF0/sprockets%2Ffa31a45f04884493c909c5a67fcbdf23 +1371 -0
- data/test/dummy/tmp/cache/assets/D47/BE0/sprockets%2F0b5ebdf6dec160a264698e7f745061e8 +142 -0
- data/test/dummy/tmp/cache/assets/D4C/F30/sprockets%2Ff90155c10f59a3fe44959ac09bf817fe +2556 -0
- data/test/dummy/tmp/cache/assets/D4E/7C0/sprockets%2Ff01b58512d01eda23fd5cb23a2b28b60 +1529 -0
- data/test/dummy/tmp/cache/assets/D4E/860/sprockets%2F86eed0c77c47d0970345bbabb58d8939 +1277 -0
- data/test/dummy/tmp/cache/assets/D4E/C30/sprockets%2F52420c10c73ca310d026565eafdadb4e +1545 -0
- data/test/dummy/tmp/cache/assets/D4E/F60/sprockets%2F9893a3c5aeb1a9e77469f4751b4d3c3f +115 -0
- data/test/dummy/tmp/cache/assets/D4F/E60/sprockets%2F17ee65de1f78c3dd5c165a9867e810b6 +165 -0
- data/test/dummy/tmp/cache/assets/D57/0D0/sprockets%2Fa29e6e8106d9d5ed1e2889126cfbf877 +300 -0
- data/test/dummy/tmp/cache/assets/D5C/650/sprockets%2Fe1c381da3cc213a639e956ae3315a2bd +607 -0
- data/test/dummy/tmp/cache/assets/D61/860/sprockets%2Fbf032a3b4aad2c2e25704e65c966cf45 +794 -0
- data/test/dummy/tmp/cache/assets/D63/B20/sprockets%2F31fc70ce66bb80fb9421be34eb3b0287 +0 -0
- data/test/dummy/tmp/cache/assets/D64/D60/sprockets%2Fa544ea03bf0a45948a053ba76ec2a79f +239 -0
- data/test/dummy/tmp/cache/assets/D6B/F90/sprockets%2F66636712ecb1fcc777dccf7643a0e1b1 +127 -0
- data/test/dummy/tmp/cache/assets/D6E/AD0/sprockets%2Fc91cdc6a72c729d7a64119198b3d2eab +0 -0
- data/test/dummy/tmp/cache/assets/D6F/140/sprockets%2F9ddc51f4388dd5243a28dba1ce47572b +53 -0
- data/test/dummy/tmp/cache/assets/D72/800/sprockets%2F92baa375d54e16fe0a5c7f079a1ce992 +165 -0
- data/test/dummy/tmp/cache/assets/D74/220/sprockets%2F3f888bda53179cb945eab35fbd31a708 +53 -0
- data/test/dummy/tmp/cache/assets/D78/5F0/sprockets%2F638ed6af667d4fc5147f72ff34aa2d33 +0 -0
- data/test/dummy/tmp/cache/assets/D7D/640/sprockets%2F95a7c5580f957c31e1ab9d0773ed5fde +607 -0
- data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +6 -5
- data/test/dummy/tmp/cache/assets/D89/020/sprockets%2Fa06df6166e70324e712e54b1cafca0ae +187 -0
- data/test/dummy/tmp/cache/assets/D8A/9F0/sprockets%2Fc06547ca33ee3d03be14ce045ae1c9e2 +207 -0
- data/test/dummy/tmp/cache/assets/D9E/B80/sprockets%2F9561df1d45c7ff4aa8ac3e2df0c99121 +0 -0
- data/test/dummy/tmp/cache/assets/DA3/F30/sprockets%2Fe015d6ccdfcf022e47c83d7906f728ae +457 -0
- data/test/dummy/tmp/cache/assets/DAE/190/sprockets%2F433c7b21968be8d1f9bfdbdf7a637c57 +0 -0
- data/test/dummy/tmp/cache/assets/DB3/600/sprockets%2F9b70ae73f15ba693886eeef4eb5d6c75 +0 -0
- data/test/dummy/tmp/cache/assets/DB4/510/sprockets%2F29cdae8e29c88fd9ddbd4831419560fe +1260 -0
- data/test/dummy/tmp/cache/assets/DC1/4A0/sprockets%2F0b63dfcf163f2faeb612724eb4545bcc +1354 -0
- data/test/dummy/tmp/cache/assets/DC4/C10/sprockets%2Fcf48f4cbad3db33146eab4c577c1d209 +300 -0
- data/test/dummy/tmp/cache/assets/DC4/CA0/sprockets%2Fd0da8a60ea4dc16b9fd3e2a50d88633c +0 -0
- data/test/dummy/tmp/cache/assets/DC7/8C0/sprockets%2F1ad68dcc9ef598d3811ba2ac5c0ea182 +1354 -0
- data/test/dummy/tmp/cache/assets/DC7/C00/sprockets%2Fba755ff3a81c3192f0e45a4f7c0c7dcb +0 -0
- data/test/dummy/tmp/cache/assets/DCA/760/sprockets%2F717c4cea10bf601090ffdfe4e668e4cb +283 -0
- data/test/dummy/tmp/cache/assets/DCA/DE0/sprockets%2F51dcced9ec2b3cd4b1cc2949f860c361 +590 -0
- data/test/dummy/tmp/cache/assets/DD7/E70/sprockets%2F2595d8c8d1d5f4deb096247fb3bfc7ab +256 -0
- data/test/dummy/tmp/cache/assets/DE1/9D0/sprockets%2F8befd77af580ee16ec42ec95b1766ff3 +1545 -0
- data/test/dummy/tmp/cache/assets/E00/D80/sprockets%2F9debc27161f7bccf2d84a36b8c36c4bf +522 -0
- data/test/dummy/tmp/cache/assets/E00/E60/sprockets%2Fac159b94b0a6d621e4f6cde9b4de87bb +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E1B/D00/sprockets%2F886dff4afe55f9d3f8abe434f2689add +72 -0
- data/test/dummy/tmp/cache/assets/E1B/F20/sprockets%2Fa4bbc04eb83ebf94fd8134c3abd220dd +494 -0
- data/test/dummy/tmp/cache/assets/E71/0C0/sprockets%2F5ffdc0daa0a1f9638c787897ceefcdee +1260 -0
- metadata +186 -10
- data/test/dummy/tmp/pids/server.pid +0 -1
@@ -0,0 +1,474 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1325549268.1178691:@value{I"
|
2
|
+
class:EFI"BundledAsset;
|
3
|
+
FI"id;
|
4
|
+
F"%388ae2f14aeefbca3921a1ef0758d2f0I"logical_path;
|
5
|
+
FI""closure/goog/format/format.js;
|
6
|
+
TI"
|
7
|
+
F"�/Users/ali/.rvm/gems/ruby-1.9.3-p0/bundler/gems/closure-library-wrapper-b30bab11ab83/vendor/closure-library/closure/goog/format/format.jsI"content_type;
|
8
|
+
FI"application/javascript;
|
9
|
+
FI"
|
10
|
+
mtime;
|
11
|
+
FI"2012-01-03T00:06:51+00:00;
|
12
|
+
FI" body;
|
13
|
+
FI":// 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 Provides utility functions for formatting strings, numbers etc.
|
29
|
+
*
|
30
|
+
*/
|
31
|
+
|
32
|
+
|
33
|
+
goog.provide('goog.format');
|
34
|
+
|
35
|
+
goog.require('goog.i18n.GraphemeBreak');
|
36
|
+
goog.require('goog.string');
|
37
|
+
goog.require('goog.userAgent');
|
38
|
+
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Formats a number of bytes in human readable form.
|
42
|
+
* 54, 450K, 1.3M, 5G etc.
|
43
|
+
* @param {number} bytes The number of bytes to show.
|
44
|
+
* @param {number=} opt_decimals The number of decimals to use. Defaults to 2.
|
45
|
+
* @return {string} The human readable form of the byte size.
|
46
|
+
*/
|
47
|
+
goog.format.fileSize = function(bytes, opt_decimals) {
|
48
|
+
return goog.format.numBytesToString(bytes, opt_decimals, false);
|
49
|
+
};
|
50
|
+
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Checks whether string value containing scaling units (K, M, G, T, P, m,
|
54
|
+
* u, n) can be converted to a number.
|
55
|
+
*
|
56
|
+
* Where there is a decimal, there must be a digit to the left of the
|
57
|
+
* decimal point.
|
58
|
+
*
|
59
|
+
* Negative numbers are valid.
|
60
|
+
*
|
61
|
+
* Examples:
|
62
|
+
* 0, 1, 1.0, 10.4K, 2.3M, -0.3P, 1.2m
|
63
|
+
*
|
64
|
+
* @param {string} val String value to check.
|
65
|
+
* @return {boolean} True if string could be converted to a numeric value.
|
66
|
+
*/
|
67
|
+
goog.format.isConvertableScaledNumber = function(val) {
|
68
|
+
return goog.format.SCALED_NUMERIC_RE_.test(val);
|
69
|
+
};
|
70
|
+
|
71
|
+
|
72
|
+
/**
|
73
|
+
* Converts a string to numeric value, taking into account the units.
|
74
|
+
* If string ends in 'B', use binary conversion.
|
75
|
+
* @param {string} stringValue String to be converted to numeric value.
|
76
|
+
* @return {number} Numeric value for string.
|
77
|
+
*/
|
78
|
+
goog.format.stringToNumericValue = function(stringValue) {
|
79
|
+
if (goog.string.endsWith(stringValue, 'B')) {
|
80
|
+
return goog.format.stringToNumericValue_(
|
81
|
+
stringValue, goog.format.NUMERIC_SCALES_BINARY_);
|
82
|
+
}
|
83
|
+
return goog.format.stringToNumericValue_(
|
84
|
+
stringValue, goog.format.NUMERIC_SCALES_SI_);
|
85
|
+
};
|
86
|
+
|
87
|
+
|
88
|
+
/**
|
89
|
+
* Converts a string to number of bytes, taking into account the units.
|
90
|
+
* Binary conversion.
|
91
|
+
* @param {string} stringValue String to be converted to numeric value.
|
92
|
+
* @return {number} Numeric value for string.
|
93
|
+
*/
|
94
|
+
goog.format.stringToNumBytes = function(stringValue) {
|
95
|
+
return goog.format.stringToNumericValue_(
|
96
|
+
stringValue, goog.format.NUMERIC_SCALES_BINARY_);
|
97
|
+
};
|
98
|
+
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Converts a numeric value to string representation. SI conversion.
|
102
|
+
* @param {number} val Value to be converted.
|
103
|
+
* @param {number=} opt_decimals The number of decimals to use. Defaults to 2.
|
104
|
+
* @return {string} String representation of number.
|
105
|
+
*/
|
106
|
+
goog.format.numericValueToString = function(val, opt_decimals) {
|
107
|
+
return goog.format.numericValueToString_(
|
108
|
+
val, goog.format.NUMERIC_SCALES_SI_, opt_decimals);
|
109
|
+
};
|
110
|
+
|
111
|
+
|
112
|
+
/**
|
113
|
+
* Converts number of bytes to string representation. Binary conversion.
|
114
|
+
* Default is to return the additional 'B' suffix, e.g. '10.5KB' to minimize
|
115
|
+
* confusion with counts that are scaled by powers of 1000.
|
116
|
+
* @param {number} val Value to be converted.
|
117
|
+
* @param {number=} opt_decimals The number of decimals to use. Defaults to 2.
|
118
|
+
* @param {boolean=} opt_suffix If true, include trailing 'B' in returned
|
119
|
+
* string. Default is true.
|
120
|
+
* @return {string} String representation of number of bytes.
|
121
|
+
*/
|
122
|
+
goog.format.numBytesToString = function(val, opt_decimals, opt_suffix) {
|
123
|
+
var suffix = '';
|
124
|
+
if (!goog.isDef(opt_suffix) || opt_suffix) {
|
125
|
+
suffix = 'B';
|
126
|
+
}
|
127
|
+
return goog.format.numericValueToString_(
|
128
|
+
val, goog.format.NUMERIC_SCALES_BINARY_, opt_decimals, suffix);
|
129
|
+
};
|
130
|
+
|
131
|
+
|
132
|
+
/**
|
133
|
+
* Converts a string to numeric value, taking into account the units.
|
134
|
+
* @param {string} stringValue String to be converted to numeric value.
|
135
|
+
* @param {Object} conversion Dictionary of conversion scales.
|
136
|
+
* @return {number} Numeric value for string. If it cannot be converted,
|
137
|
+
* returns NaN.
|
138
|
+
* @private
|
139
|
+
*/
|
140
|
+
goog.format.stringToNumericValue_ = function(stringValue, conversion) {
|
141
|
+
var match = stringValue.match(goog.format.SCALED_NUMERIC_RE_);
|
142
|
+
if (!match) {
|
143
|
+
return NaN;
|
144
|
+
}
|
145
|
+
var val = match[1] * conversion[match[2]];
|
146
|
+
return val;
|
147
|
+
};
|
148
|
+
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Converts a numeric value to string, using specified conversion
|
152
|
+
* scales.
|
153
|
+
* @param {number} val Value to be converted.
|
154
|
+
* @param {Object} conversion Dictionary of scaling factors.
|
155
|
+
* @param {number=} opt_decimals The number of decimals to use. Default is 2.
|
156
|
+
* @param {string=} opt_suffix Optional suffix to append.
|
157
|
+
* @return {string} The human readable form of the byte size.
|
158
|
+
* @private
|
159
|
+
*/
|
160
|
+
goog.format.numericValueToString_ = function(val, conversion,
|
161
|
+
opt_decimals, opt_suffix) {
|
162
|
+
var prefixes = goog.format.NUMERIC_SCALE_PREFIXES_;
|
163
|
+
var orig_val = val;
|
164
|
+
var symbol = '';
|
165
|
+
var scale = 1;
|
166
|
+
if (val < 0) {
|
167
|
+
val = -val;
|
168
|
+
}
|
169
|
+
for (var i = 0; i < prefixes.length; i++) {
|
170
|
+
var unit = prefixes[i];
|
171
|
+
scale = conversion[unit];
|
172
|
+
if (val >= scale || (scale <= 1 && val > 0.1 * scale)) {
|
173
|
+
// Treat values less than 1 differently, allowing 0.5 to be "0.5" rather
|
174
|
+
// than "500m"
|
175
|
+
symbol = unit;
|
176
|
+
break;
|
177
|
+
}
|
178
|
+
}
|
179
|
+
if (!symbol) {
|
180
|
+
scale = 1;
|
181
|
+
} else if (opt_suffix) {
|
182
|
+
symbol += opt_suffix;
|
183
|
+
}
|
184
|
+
var ex = Math.pow(10, goog.isDef(opt_decimals) ? opt_decimals : 2);
|
185
|
+
return Math.round(orig_val / scale * ex) / ex + symbol;
|
186
|
+
};
|
187
|
+
|
188
|
+
|
189
|
+
/**
|
190
|
+
* Regular expression for detecting scaling units, such as K, M, G, etc. for
|
191
|
+
* converting a string representation to a numeric value.
|
192
|
+
*
|
193
|
+
* Also allow 'k' to be aliased to 'K'. These could be used for SI (powers
|
194
|
+
* of 1000) or Binary (powers of 1024) conversions.
|
195
|
+
*
|
196
|
+
* Also allow final 'B' to be interpreted as byte-count, implicitly triggering
|
197
|
+
* binary conversion (e.g., '10.2MB').
|
198
|
+
*
|
199
|
+
* @type {RegExp}
|
200
|
+
* @private
|
201
|
+
*/
|
202
|
+
goog.format.SCALED_NUMERIC_RE_ = /^([-]?\d+\.?\d*)([K,M,G,T,P,k,m,u,n]?)[B]?$/;
|
203
|
+
|
204
|
+
|
205
|
+
/**
|
206
|
+
* Ordered list of scaling prefixes in decreasing order.
|
207
|
+
* @type {Array}
|
208
|
+
* @private
|
209
|
+
*/
|
210
|
+
goog.format.NUMERIC_SCALE_PREFIXES_ = [
|
211
|
+
'P', 'T', 'G', 'M', 'K', '', 'm', 'u', 'n'
|
212
|
+
];
|
213
|
+
|
214
|
+
|
215
|
+
/**
|
216
|
+
* Scaling factors for conversion of numeric value to string. SI conversion.
|
217
|
+
* @type {Object}
|
218
|
+
* @private
|
219
|
+
*/
|
220
|
+
goog.format.NUMERIC_SCALES_SI_ = {
|
221
|
+
'': 1,
|
222
|
+
'n': 1e-9,
|
223
|
+
'u': 1e-6,
|
224
|
+
'm': 1e-3,
|
225
|
+
'k': 1e3,
|
226
|
+
'K': 1e3,
|
227
|
+
'M': 1e6,
|
228
|
+
'G': 1e9,
|
229
|
+
'T': 1e12,
|
230
|
+
'P': 1e15
|
231
|
+
};
|
232
|
+
|
233
|
+
|
234
|
+
/**
|
235
|
+
* Scaling factors for conversion of numeric value to string. Binary
|
236
|
+
* conversion.
|
237
|
+
* @type {Object}
|
238
|
+
* @private
|
239
|
+
*/
|
240
|
+
goog.format.NUMERIC_SCALES_BINARY_ = {
|
241
|
+
'': 1,
|
242
|
+
'n': Math.pow(1024, -3),
|
243
|
+
'u': Math.pow(1024, -2),
|
244
|
+
'm': 1.0 / 1024,
|
245
|
+
'k': 1024,
|
246
|
+
'K': 1024,
|
247
|
+
'M': Math.pow(1024, 2),
|
248
|
+
'G': Math.pow(1024, 3),
|
249
|
+
'T': Math.pow(1024, 4),
|
250
|
+
'P': Math.pow(1024, 5)
|
251
|
+
};
|
252
|
+
|
253
|
+
|
254
|
+
/**
|
255
|
+
* First Unicode code point that has the Mark property.
|
256
|
+
* @type {number}
|
257
|
+
* @private
|
258
|
+
*/
|
259
|
+
goog.format.FIRST_GRAPHEME_EXTEND_ = 0x300;
|
260
|
+
|
261
|
+
|
262
|
+
/**
|
263
|
+
* Inserts word breaks into an HTML string at a given interval. The counter is
|
264
|
+
* reset if a space is encountered. WBRs aren't inserted into HTML tags or
|
265
|
+
* entities. Entites count towards the character count, HTML tags do not.
|
266
|
+
*
|
267
|
+
* With common strings aliased, objects allocations are constant based on the
|
268
|
+
* length of the string: N + 3. This guarantee does not hold if the string
|
269
|
+
* contains an element >= U+0300 and hasGraphemeBreak is non-trivial.
|
270
|
+
*
|
271
|
+
* @param {string} str HTML to insert word breaks into.
|
272
|
+
* @param {function(number, number, boolean): boolean} hasGraphemeBreak A
|
273
|
+
* function determining if there is a grapheme break between two characters,
|
274
|
+
* in the same signature as goog.i18n.GraphemeBreak.hasGraphemeBreak.
|
275
|
+
* @param {number=} opt_maxlen Maximum length after which to ensure
|
276
|
+
* there is a break. Default is 10 characters.
|
277
|
+
* @return {string} The string including word breaks.
|
278
|
+
* @private
|
279
|
+
*/
|
280
|
+
goog.format.insertWordBreaksGeneric_ = function(str, hasGraphemeBreak,
|
281
|
+
opt_maxlen) {
|
282
|
+
var maxlen = opt_maxlen || 10;
|
283
|
+
if (maxlen > str.length) return str;
|
284
|
+
|
285
|
+
var rv = [];
|
286
|
+
var n = 0; // The length of the current token
|
287
|
+
|
288
|
+
// This will contain the ampersand or less-than character if one of the
|
289
|
+
// two has been seen; otherwise, the value is zero.
|
290
|
+
var nestingCharCode = 0;
|
291
|
+
|
292
|
+
// First character position from input string that has not been outputted.
|
293
|
+
var lastDumpPosition = 0;
|
294
|
+
|
295
|
+
var charCode = 0;
|
296
|
+
for (var i = 0; i < str.length; i++) {
|
297
|
+
// Using charCodeAt versus charAt avoids allocating new string objects.
|
298
|
+
var lastCharCode = charCode;
|
299
|
+
charCode = str.charCodeAt(i);
|
300
|
+
|
301
|
+
// Don't add a WBR before characters that might be grapheme extending.
|
302
|
+
var isPotentiallyGraphemeExtending =
|
303
|
+
charCode >= goog.format.FIRST_GRAPHEME_EXTEND_ &&
|
304
|
+
!hasGraphemeBreak(lastCharCode, charCode, true);
|
305
|
+
|
306
|
+
// Don't add a WBR at the end of a word. For simplicity, all control
|
307
|
+
// characters are treated as whitespace.
|
308
|
+
if (n >= maxlen &&
|
309
|
+
charCode > goog.format.WbrToken_.SPACE &&
|
310
|
+
!isPotentiallyGraphemeExtending) {
|
311
|
+
// Flush everything seen so far, and append a word break.
|
312
|
+
rv.push(str.substring(lastDumpPosition, i), goog.format.WORD_BREAK_HTML);
|
313
|
+
lastDumpPosition = i;
|
314
|
+
n = 0;
|
315
|
+
}
|
316
|
+
|
317
|
+
if (!nestingCharCode) {
|
318
|
+
// Not currently within an HTML tag or entity
|
319
|
+
|
320
|
+
if (charCode == goog.format.WbrToken_.LT ||
|
321
|
+
charCode == goog.format.WbrToken_.AMP) {
|
322
|
+
|
323
|
+
// Entering an HTML Entity '&' or open tag '<'
|
324
|
+
nestingCharCode = charCode;
|
325
|
+
} else if (charCode <= goog.format.WbrToken_.SPACE) {
|
326
|
+
|
327
|
+
// A space or control character -- reset the token length
|
328
|
+
n = 0;
|
329
|
+
} else {
|
330
|
+
|
331
|
+
// A normal flow character - increment. For grapheme extending
|
332
|
+
// characters, this is not *technically* a new character. However,
|
333
|
+
// since the grapheme break detector might be overly conservative,
|
334
|
+
// we have to continue incrementing, or else we won't even be able
|
335
|
+
// to add breaks when we get to things like punctuation. For the
|
336
|
+
// case where we have a full grapheme break detector, it is okay if
|
337
|
+
// we occasionally break slightly early.
|
338
|
+
n++;
|
339
|
+
}
|
340
|
+
} else if (charCode == goog.format.WbrToken_.GT &&
|
341
|
+
nestingCharCode == goog.format.WbrToken_.LT) {
|
342
|
+
|
343
|
+
// Leaving an HTML tag, treat the tag as zero-length
|
344
|
+
nestingCharCode = 0;
|
345
|
+
} else if (charCode == goog.format.WbrToken_.SEMI_COLON &&
|
346
|
+
nestingCharCode == goog.format.WbrToken_.AMP) {
|
347
|
+
|
348
|
+
// Leaving an HTML entity, treat it as length one
|
349
|
+
nestingCharCode = 0;
|
350
|
+
n++;
|
351
|
+
}
|
352
|
+
}
|
353
|
+
|
354
|
+
// Take care of anything we haven't flushed so far.
|
355
|
+
rv.push(str.substr(lastDumpPosition));
|
356
|
+
|
357
|
+
return rv.join('');
|
358
|
+
};
|
359
|
+
|
360
|
+
|
361
|
+
/**
|
362
|
+
* Inserts word breaks into an HTML string at a given interval.
|
363
|
+
*
|
364
|
+
* This method is as aggressive as possible, using a full table of Unicode
|
365
|
+
* characters where it is legal to insert word breaks; however, this table
|
366
|
+
* comes at a 2.5k pre-gzip (~1k post-gzip) size cost. Consider using
|
367
|
+
* insertWordBreaksBasic to minimize the size impact.
|
368
|
+
*
|
369
|
+
* @param {string} str HTML to insert word breaks into.
|
370
|
+
* @param {number=} opt_maxlen Maximum length after which to ensure there is a
|
371
|
+
* break. Default is 10 characters.
|
372
|
+
* @return {string} The string including word breaks.
|
373
|
+
*/
|
374
|
+
goog.format.insertWordBreaks = function(str, opt_maxlen) {
|
375
|
+
return goog.format.insertWordBreaksGeneric_(str,
|
376
|
+
goog.i18n.GraphemeBreak.hasGraphemeBreak, opt_maxlen);
|
377
|
+
};
|
378
|
+
|
379
|
+
|
380
|
+
/**
|
381
|
+
* Determines conservatively if a character has a Grapheme break.
|
382
|
+
*
|
383
|
+
* Conforms to a similar signature as goog.i18n.GraphemeBreak, but is overly
|
384
|
+
* conservative, returning true only for characters in common scripts that
|
385
|
+
* are simple to account for.
|
386
|
+
*
|
387
|
+
* @param {number} lastCharCode The previous character code. Ignored.
|
388
|
+
* @param {number} charCode The character code under consideration. It must be
|
389
|
+
* at least \u0300 as a precondition -- this case is covered by
|
390
|
+
* insertWordBreaksGeneric_.
|
391
|
+
* @param {boolean=} opt_extended Ignored, to conform with the interface.
|
392
|
+
* @return {boolean} Whether it is one of the recognized subsets of characters
|
393
|
+
* with a grapheme break.
|
394
|
+
* @private
|
395
|
+
*/
|
396
|
+
goog.format.conservativelyHasGraphemeBreak_ = function(
|
397
|
+
lastCharCode, charCode, opt_extended) {
|
398
|
+
// Return false for everything except the most common Cyrillic characters.
|
399
|
+
// Don't worry about Latin characters, because insertWordBreaksGeneric_
|
400
|
+
// itself already handles those.
|
401
|
+
// TODO(gboyer): Also account for Greek, Armenian, and Georgian if it is
|
402
|
+
// simple to do so.
|
403
|
+
return charCode >= 0x400 && charCode < 0x523;
|
404
|
+
};
|
405
|
+
|
406
|
+
|
407
|
+
// TODO(gboyer): Consider using a compile-time flag to switch implementations
|
408
|
+
// rather than relying on the developers to toggle implementations.
|
409
|
+
/**
|
410
|
+
* Inserts word breaks into an HTML string at a given interval.
|
411
|
+
*
|
412
|
+
* This method is less aggressive than insertWordBreaks, only inserting
|
413
|
+
* breaks next to punctuation and between Latin or Cyrillic characters.
|
414
|
+
* However, this is good enough for the common case of URLs. It also
|
415
|
+
* works for all Latin and Cyrillic languages, plus CJK has no need for word
|
416
|
+
* breaks. When this method is used, goog.i18n.GraphemeBreak may be dead
|
417
|
+
* code eliminated.
|
418
|
+
*
|
419
|
+
* @param {string} str HTML to insert word breaks into.
|
420
|
+
* @param {number=} opt_maxlen Maximum length after which to ensure there is a
|
421
|
+
* break. Default is 10 characters.
|
422
|
+
* @return {string} The string including word breaks.
|
423
|
+
*/
|
424
|
+
goog.format.insertWordBreaksBasic = function(str, opt_maxlen) {
|
425
|
+
return goog.format.insertWordBreaksGeneric_(str,
|
426
|
+
goog.format.conservativelyHasGraphemeBreak_, opt_maxlen);
|
427
|
+
};
|
428
|
+
|
429
|
+
|
430
|
+
/**
|
431
|
+
* True iff the current userAgent is IE8 or above.
|
432
|
+
* @type {boolean}
|
433
|
+
* @private
|
434
|
+
*/
|
435
|
+
goog.format.IS_IE8_OR_ABOVE_ = goog.userAgent.IE &&
|
436
|
+
goog.userAgent.isVersion(8);
|
437
|
+
|
438
|
+
|
439
|
+
/**
|
440
|
+
* Constant for the WBR replacement used by insertWordBreaks. Safari requires
|
441
|
+
* <wbr></wbr>, Opera needs the ­ entity, though this will give a visible
|
442
|
+
* hyphen at breaks. IE8 uses a zero width space.
|
443
|
+
* Other browsers just use <wbr>.
|
444
|
+
* @type {string}
|
445
|
+
*/
|
446
|
+
goog.format.WORD_BREAK_HTML =
|
447
|
+
goog.userAgent.WEBKIT ?
|
448
|
+
'<wbr></wbr>' : goog.userAgent.OPERA ?
|
449
|
+
'­' : goog.format.IS_IE8_OR_ABOVE_ ?
|
450
|
+
'​' : '<wbr>';
|
451
|
+
|
452
|
+
|
453
|
+
/**
|
454
|
+
* Tokens used within insertWordBreaks.
|
455
|
+
* @private
|
456
|
+
* @enum {number}
|
457
|
+
*/
|
458
|
+
goog.format.WbrToken_ = {
|
459
|
+
LT: 60, // '<'.charCodeAt(0)
|
460
|
+
GT: 62, // '>'.charCodeAt(0)
|
461
|
+
AMP: 38, // '&'.charCodeAt(0)
|
462
|
+
SEMI_COLON: 59, // ';'.charCodeAt(0)
|
463
|
+
SPACE: 32 // ' '.charCodeAt(0)
|
464
|
+
};
|
465
|
+
;
|
466
|
+
FI"asset_paths;
|
467
|
+
F["�/Users/ali/.rvm/gems/ruby-1.9.3-p0/bundler/gems/closure-library-wrapper-b30bab11ab83/vendor/closure-library/closure/goog/format/format.jsI"dependency_paths;
|
468
|
+
F[{I" path;
|
469
|
+
F"�/Users/ali/.rvm/gems/ruby-1.9.3-p0/bundler/gems/closure-library-wrapper-b30bab11ab83/vendor/closure-library/closure/goog/format/format.jsI"
|
470
|
+
mtime;
|
471
|
+
FIu: Time
|
472
|
+
T:offsetiI"hexdigest;
|
473
|
+
F"%c560deeb65cec093f4e549106ed9b2ceI"
|
474
|
+
F"%46dde6621c301f4928e3b34efee9e3b5
|