twitter_cldr 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (473) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -22
  3. data/History.txt +3 -0
  4. data/NOTICE +3 -96
  5. data/README.md +23 -40
  6. data/Rakefile +12 -24
  7. data/lib/twitter_cldr.rb +1 -2
  8. data/lib/twitter_cldr/localized/localized_date.rb +1 -1
  9. data/lib/twitter_cldr/localized/localized_datetime.rb +1 -1
  10. data/lib/twitter_cldr/localized/localized_string.rb +7 -2
  11. data/lib/twitter_cldr/parsers/unicode_regex/component.rb +1 -4
  12. data/lib/twitter_cldr/resources/locales_resources_importer.rb +3 -7
  13. data/lib/twitter_cldr/resources/readme_renderer.rb +0 -7
  14. data/lib/twitter_cldr/shared/calendar.rb +2 -2
  15. data/lib/twitter_cldr/shared/postal_codes.rb +1 -9
  16. data/lib/twitter_cldr/shared/unicode_regex.rb +1 -9
  17. data/lib/twitter_cldr/tokenizers/numbers/rbnf_tokenizer.rb +1 -5
  18. data/lib/twitter_cldr/utils.rb +0 -2
  19. data/lib/twitter_cldr/utils/yaml.rb +0 -2
  20. data/lib/twitter_cldr/version.rb +1 -1
  21. data/resources/locales/af/calendars.yml +181 -181
  22. data/resources/locales/af/currencies.yml +166 -166
  23. data/resources/locales/af/languages.yml +217 -217
  24. data/resources/locales/af/layout.yml +1 -1
  25. data/resources/locales/af/numbers.yml +30 -30
  26. data/resources/locales/af/rbnf.yml +52 -52
  27. data/resources/locales/af/territories.yml +210 -210
  28. data/resources/locales/ar/calendars.yml +181 -181
  29. data/resources/locales/ar/currencies.yml +190 -190
  30. data/resources/locales/ar/languages.yml +413 -413
  31. data/resources/locales/ar/layout.yml +1 -1
  32. data/resources/locales/ar/numbers.yml +84 -84
  33. data/resources/locales/ar/rbnf.yml +59 -59
  34. data/resources/locales/ar/territories.yml +179 -179
  35. data/resources/locales/be/calendars.yml +125 -125
  36. data/resources/locales/be/currencies.yml +99 -99
  37. data/resources/locales/be/languages.yml +119 -119
  38. data/resources/locales/be/layout.yml +1 -1
  39. data/resources/locales/be/numbers.yml +24 -24
  40. data/resources/locales/be/rbnf.yml +157 -157
  41. data/resources/locales/be/territories.yml +185 -185
  42. data/resources/locales/bg/calendars.yml +171 -171
  43. data/resources/locales/bg/currencies.yml +170 -170
  44. data/resources/locales/bg/languages.yml +437 -437
  45. data/resources/locales/bg/layout.yml +1 -1
  46. data/resources/locales/bg/numbers.yml +35 -35
  47. data/resources/locales/bg/rbnf.yml +34 -34
  48. data/resources/locales/bg/territories.yml +181 -181
  49. data/resources/locales/bn/calendars.yml +188 -188
  50. data/resources/locales/bn/currencies.yml +168 -168
  51. data/resources/locales/bn/languages.yml +417 -417
  52. data/resources/locales/bn/layout.yml +1 -1
  53. data/resources/locales/bn/numbers.yml +35 -35
  54. data/resources/locales/bn/territories.yml +185 -185
  55. data/resources/locales/ca/calendars.yml +177 -177
  56. data/resources/locales/ca/currencies.yml +302 -302
  57. data/resources/locales/ca/languages.yml +439 -439
  58. data/resources/locales/ca/layout.yml +1 -1
  59. data/resources/locales/ca/numbers.yml +35 -35
  60. data/resources/locales/ca/rbnf.yml +160 -160
  61. data/resources/locales/ca/territories.yml +179 -179
  62. data/resources/locales/cs/calendars.yml +150 -150
  63. data/resources/locales/cs/currencies.yml +314 -314
  64. data/resources/locales/cs/languages.yml +506 -506
  65. data/resources/locales/cs/layout.yml +1 -1
  66. data/resources/locales/cs/numbers.yml +60 -60
  67. data/resources/locales/cs/rbnf.yml +40 -40
  68. data/resources/locales/cs/territories.yml +188 -188
  69. data/resources/locales/cy/calendars.yml +149 -149
  70. data/resources/locales/cy/currencies.yml +105 -105
  71. data/resources/locales/cy/languages.yml +330 -330
  72. data/resources/locales/cy/layout.yml +1 -1
  73. data/resources/locales/cy/numbers.yml +83 -83
  74. data/resources/locales/cy/rbnf.yml +54 -54
  75. data/resources/locales/cy/territories.yml +164 -164
  76. data/resources/locales/da/calendars.yml +182 -182
  77. data/resources/locales/da/currencies.yml +177 -177
  78. data/resources/locales/da/languages.yml +484 -484
  79. data/resources/locales/da/layout.yml +1 -1
  80. data/resources/locales/da/numbers.yml +35 -35
  81. data/resources/locales/da/rbnf.yml +38 -38
  82. data/resources/locales/da/territories.yml +206 -206
  83. data/resources/locales/de-CH/calendars.yml +192 -192
  84. data/resources/locales/de-CH/currencies.yml +428 -428
  85. data/resources/locales/de-CH/languages.yml +575 -575
  86. data/resources/locales/de-CH/layout.yml +1 -1
  87. data/resources/locales/de-CH/numbers.yml +35 -35
  88. data/resources/locales/de-CH/territories.yml +209 -209
  89. data/resources/locales/de/calendars.yml +192 -192
  90. data/resources/locales/de/currencies.yml +428 -428
  91. data/resources/locales/de/languages.yml +575 -575
  92. data/resources/locales/de/layout.yml +1 -1
  93. data/resources/locales/de/numbers.yml +35 -35
  94. data/resources/locales/de/rbnf.yml +80 -80
  95. data/resources/locales/de/territories.yml +207 -207
  96. data/resources/locales/el/calendars.yml +179 -179
  97. data/resources/locales/el/currencies.yml +162 -162
  98. data/resources/locales/el/languages.yml +441 -441
  99. data/resources/locales/el/layout.yml +1 -1
  100. data/resources/locales/el/numbers.yml +35 -35
  101. data/resources/locales/el/rbnf.yml +98 -98
  102. data/resources/locales/el/territories.yml +182 -182
  103. data/resources/locales/en-150/calendars.yml +105 -105
  104. data/resources/locales/en-150/currencies.yml +103 -103
  105. data/resources/locales/en-150/languages.yml +503 -503
  106. data/resources/locales/en-150/layout.yml +1 -1
  107. data/resources/locales/en-150/numbers.yml +35 -35
  108. data/resources/locales/en-150/territories.yml +182 -182
  109. data/resources/locales/en-AU/calendars.yml +105 -105
  110. data/resources/locales/en-AU/currencies.yml +103 -103
  111. data/resources/locales/en-AU/languages.yml +503 -503
  112. data/resources/locales/en-AU/layout.yml +1 -1
  113. data/resources/locales/en-AU/numbers.yml +35 -35
  114. data/resources/locales/en-AU/territories.yml +182 -182
  115. data/resources/locales/en-CA/calendars.yml +105 -105
  116. data/resources/locales/en-CA/currencies.yml +103 -103
  117. data/resources/locales/en-CA/languages.yml +503 -503
  118. data/resources/locales/en-CA/layout.yml +1 -1
  119. data/resources/locales/en-CA/numbers.yml +35 -35
  120. data/resources/locales/en-CA/territories.yml +182 -182
  121. data/resources/locales/en-GB/calendars.yml +109 -109
  122. data/resources/locales/en-GB/currencies.yml +250 -250
  123. data/resources/locales/en-GB/languages.yml +503 -503
  124. data/resources/locales/en-GB/layout.yml +1 -1
  125. data/resources/locales/en-GB/numbers.yml +35 -35
  126. data/resources/locales/en-GB/territories.yml +181 -181
  127. data/resources/locales/en-IE/calendars.yml +105 -105
  128. data/resources/locales/en-IE/currencies.yml +103 -103
  129. data/resources/locales/en-IE/languages.yml +503 -503
  130. data/resources/locales/en-IE/layout.yml +1 -1
  131. data/resources/locales/en-IE/numbers.yml +35 -35
  132. data/resources/locales/en-IE/territories.yml +182 -182
  133. data/resources/locales/en-SG/calendars.yml +105 -105
  134. data/resources/locales/en-SG/currencies.yml +103 -103
  135. data/resources/locales/en-SG/languages.yml +503 -503
  136. data/resources/locales/en-SG/layout.yml +1 -1
  137. data/resources/locales/en-SG/numbers.yml +35 -35
  138. data/resources/locales/en-SG/territories.yml +182 -182
  139. data/resources/locales/en-ZA/calendars.yml +105 -105
  140. data/resources/locales/en-ZA/currencies.yml +103 -103
  141. data/resources/locales/en-ZA/languages.yml +503 -503
  142. data/resources/locales/en-ZA/layout.yml +1 -1
  143. data/resources/locales/en-ZA/numbers.yml +36 -36
  144. data/resources/locales/en-ZA/territories.yml +182 -182
  145. data/resources/locales/en/calendars.yml +105 -105
  146. data/resources/locales/en/currencies.yml +103 -103
  147. data/resources/locales/en/languages.yml +503 -503
  148. data/resources/locales/en/layout.yml +1 -1
  149. data/resources/locales/en/numbers.yml +35 -35
  150. data/resources/locales/en/rbnf.yml +94 -94
  151. data/resources/locales/en/territories.yml +182 -182
  152. data/resources/locales/es-419/calendars.yml +170 -170
  153. data/resources/locales/es-419/currencies.yml +258 -258
  154. data/resources/locales/es-419/languages.yml +439 -439
  155. data/resources/locales/es-419/layout.yml +1 -1
  156. data/resources/locales/es-419/numbers.yml +33 -33
  157. data/resources/locales/es-419/territories.yml +178 -178
  158. data/resources/locales/es-CO/calendars.yml +182 -182
  159. data/resources/locales/es-CO/currencies.yml +258 -258
  160. data/resources/locales/es-CO/languages.yml +439 -439
  161. data/resources/locales/es-CO/layout.yml +1 -1
  162. data/resources/locales/es-CO/numbers.yml +35 -35
  163. data/resources/locales/es-CO/territories.yml +179 -179
  164. data/resources/locales/es-MX/calendars.yml +181 -181
  165. data/resources/locales/es-MX/currencies.yml +194 -194
  166. data/resources/locales/es-MX/languages.yml +441 -441
  167. data/resources/locales/es-MX/layout.yml +1 -1
  168. data/resources/locales/es-MX/numbers.yml +35 -35
  169. data/resources/locales/es-MX/territories.yml +178 -178
  170. data/resources/locales/es-US/calendars.yml +185 -185
  171. data/resources/locales/es-US/currencies.yml +258 -258
  172. data/resources/locales/es-US/languages.yml +439 -439
  173. data/resources/locales/es-US/layout.yml +1 -1
  174. data/resources/locales/es-US/numbers.yml +35 -35
  175. data/resources/locales/es-US/territories.yml +179 -179
  176. data/resources/locales/es/calendars.yml +183 -183
  177. data/resources/locales/es/currencies.yml +258 -258
  178. data/resources/locales/es/languages.yml +439 -439
  179. data/resources/locales/es/layout.yml +1 -1
  180. data/resources/locales/es/numbers.yml +35 -35
  181. data/resources/locales/es/rbnf.yml +123 -123
  182. data/resources/locales/es/territories.yml +179 -179
  183. data/resources/locales/eu/calendars.yml +185 -185
  184. data/resources/locales/eu/currencies.yml +160 -160
  185. data/resources/locales/eu/languages.yml +213 -213
  186. data/resources/locales/eu/layout.yml +1 -1
  187. data/resources/locales/eu/numbers.yml +29 -29
  188. data/resources/locales/eu/territories.yml +184 -184
  189. data/resources/locales/fa/calendars.yml +191 -191
  190. data/resources/locales/fa/currencies.yml +107 -107
  191. data/resources/locales/fa/languages.yml +412 -412
  192. data/resources/locales/fa/layout.yml +1 -1
  193. data/resources/locales/fa/numbers.yml +36 -36
  194. data/resources/locales/fa/rbnf.yml +28 -28
  195. data/resources/locales/fa/territories.yml +187 -187
  196. data/resources/locales/fi/calendars.yml +186 -186
  197. data/resources/locales/fi/currencies.yml +316 -316
  198. data/resources/locales/fi/languages.yml +590 -590
  199. data/resources/locales/fi/layout.yml +1 -1
  200. data/resources/locales/fi/numbers.yml +37 -37
  201. data/resources/locales/fi/rbnf.yml +39 -39
  202. data/resources/locales/fi/territories.yml +213 -213
  203. data/resources/locales/fil/calendars.yml +182 -182
  204. data/resources/locales/fil/currencies.yml +118 -118
  205. data/resources/locales/fil/languages.yml +214 -214
  206. data/resources/locales/fil/layout.yml +1 -1
  207. data/resources/locales/fil/numbers.yml +35 -35
  208. data/resources/locales/fil/rbnf.yml +35 -35
  209. data/resources/locales/fil/territories.yml +180 -180
  210. data/resources/locales/fr-BE/calendars.yml +198 -198
  211. data/resources/locales/fr-BE/currencies.yml +246 -246
  212. data/resources/locales/fr-BE/languages.yml +448 -448
  213. data/resources/locales/fr-BE/layout.yml +1 -1
  214. data/resources/locales/fr-BE/numbers.yml +35 -35
  215. data/resources/locales/fr-BE/rbnf.yml +140 -140
  216. data/resources/locales/fr-BE/territories.yml +195 -195
  217. data/resources/locales/fr-CA/calendars.yml +199 -199
  218. data/resources/locales/fr-CA/currencies.yml +252 -252
  219. data/resources/locales/fr-CA/languages.yml +449 -449
  220. data/resources/locales/fr-CA/layout.yml +1 -1
  221. data/resources/locales/fr-CA/numbers.yml +36 -36
  222. data/resources/locales/fr-CA/territories.yml +196 -196
  223. data/resources/locales/fr-CH/calendars.yml +200 -200
  224. data/resources/locales/fr-CH/currencies.yml +246 -246
  225. data/resources/locales/fr-CH/languages.yml +448 -448
  226. data/resources/locales/fr-CH/layout.yml +1 -1
  227. data/resources/locales/fr-CH/numbers.yml +36 -36
  228. data/resources/locales/fr-CH/rbnf.yml +139 -139
  229. data/resources/locales/fr-CH/territories.yml +195 -195
  230. data/resources/locales/fr/calendars.yml +198 -198
  231. data/resources/locales/fr/currencies.yml +246 -246
  232. data/resources/locales/fr/languages.yml +448 -448
  233. data/resources/locales/fr/layout.yml +1 -1
  234. data/resources/locales/fr/numbers.yml +36 -36
  235. data/resources/locales/fr/rbnf.yml +145 -145
  236. data/resources/locales/fr/territories.yml +195 -195
  237. data/resources/locales/ga/calendars.yml +162 -162
  238. data/resources/locales/ga/currencies.yml +250 -250
  239. data/resources/locales/ga/languages.yml +247 -247
  240. data/resources/locales/ga/layout.yml +1 -1
  241. data/resources/locales/ga/numbers.yml +71 -71
  242. data/resources/locales/ga/rbnf.yml +115 -115
  243. data/resources/locales/ga/territories.yml +78 -78
  244. data/resources/locales/gl/calendars.yml +183 -183
  245. data/resources/locales/gl/currencies.yml +169 -169
  246. data/resources/locales/gl/languages.yml +213 -213
  247. data/resources/locales/gl/layout.yml +1 -1
  248. data/resources/locales/gl/numbers.yml +35 -35
  249. data/resources/locales/gl/territories.yml +180 -180
  250. data/resources/locales/he/calendars.yml +129 -129
  251. data/resources/locales/he/currencies.yml +173 -173
  252. data/resources/locales/he/languages.yml +443 -443
  253. data/resources/locales/he/layout.yml +1 -1
  254. data/resources/locales/he/numbers.yml +60 -60
  255. data/resources/locales/he/rbnf.yml +133 -133
  256. data/resources/locales/he/territories.yml +179 -179
  257. data/resources/locales/hi/calendars.yml +185 -185
  258. data/resources/locales/hi/currencies.yml +160 -160
  259. data/resources/locales/hi/languages.yml +420 -420
  260. data/resources/locales/hi/layout.yml +1 -1
  261. data/resources/locales/hi/numbers.yml +35 -35
  262. data/resources/locales/hi/rbnf.yml +137 -137
  263. data/resources/locales/hi/territories.yml +183 -183
  264. data/resources/locales/hr/calendars.yml +173 -173
  265. data/resources/locales/hr/currencies.yml +315 -315
  266. data/resources/locales/hr/languages.yml +457 -457
  267. data/resources/locales/hr/layout.yml +1 -1
  268. data/resources/locales/hr/numbers.yml +47 -47
  269. data/resources/locales/hr/rbnf.yml +63 -63
  270. data/resources/locales/hr/territories.yml +181 -181
  271. data/resources/locales/hu/calendars.yml +175 -175
  272. data/resources/locales/hu/currencies.yml +171 -171
  273. data/resources/locales/hu/languages.yml +455 -455
  274. data/resources/locales/hu/layout.yml +1 -1
  275. data/resources/locales/hu/numbers.yml +36 -36
  276. data/resources/locales/hu/rbnf.yml +91 -91
  277. data/resources/locales/hu/territories.yml +212 -212
  278. data/resources/locales/id/calendars.yml +182 -182
  279. data/resources/locales/id/currencies.yml +297 -297
  280. data/resources/locales/id/languages.yml +457 -457
  281. data/resources/locales/id/layout.yml +1 -1
  282. data/resources/locales/id/numbers.yml +22 -22
  283. data/resources/locales/id/rbnf.yml +25 -25
  284. data/resources/locales/id/territories.yml +181 -181
  285. data/resources/locales/is/calendars.yml +182 -182
  286. data/resources/locales/is/currencies.yml +194 -194
  287. data/resources/locales/is/languages.yml +443 -443
  288. data/resources/locales/is/layout.yml +1 -1
  289. data/resources/locales/is/numbers.yml +35 -35
  290. data/resources/locales/is/rbnf.yml +45 -45
  291. data/resources/locales/is/territories.yml +212 -212
  292. data/resources/locales/it-CH/calendars.yml +183 -183
  293. data/resources/locales/it-CH/currencies.yml +168 -168
  294. data/resources/locales/it-CH/languages.yml +501 -501
  295. data/resources/locales/it-CH/layout.yml +1 -1
  296. data/resources/locales/it-CH/numbers.yml +29 -29
  297. data/resources/locales/it-CH/territories.yml +184 -184
  298. data/resources/locales/it/calendars.yml +180 -180
  299. data/resources/locales/it/currencies.yml +168 -168
  300. data/resources/locales/it/languages.yml +501 -501
  301. data/resources/locales/it/layout.yml +1 -1
  302. data/resources/locales/it/numbers.yml +29 -29
  303. data/resources/locales/it/rbnf.yml +368 -368
  304. data/resources/locales/it/territories.yml +184 -184
  305. data/resources/locales/ja/calendars.yml +195 -195
  306. data/resources/locales/ja/currencies.yml +353 -353
  307. data/resources/locales/ja/languages.yml +602 -602
  308. data/resources/locales/ja/layout.yml +1 -1
  309. data/resources/locales/ja/numbers.yml +35 -35
  310. data/resources/locales/ja/rbnf.yml +49 -49
  311. data/resources/locales/ja/territories.yml +260 -260
  312. data/resources/locales/ko/calendars.yml +180 -180
  313. data/resources/locales/ko/currencies.yml +168 -168
  314. data/resources/locales/ko/languages.yml +455 -455
  315. data/resources/locales/ko/layout.yml +1 -1
  316. data/resources/locales/ko/numbers.yml +33 -33
  317. data/resources/locales/ko/rbnf.yml +136 -136
  318. data/resources/locales/ko/territories.yml +219 -219
  319. data/resources/locales/lv/calendars.yml +179 -179
  320. data/resources/locales/lv/currencies.yml +166 -166
  321. data/resources/locales/lv/languages.yml +473 -473
  322. data/resources/locales/lv/layout.yml +1 -1
  323. data/resources/locales/lv/numbers.yml +48 -48
  324. data/resources/locales/lv/rbnf.yml +45 -45
  325. data/resources/locales/lv/territories.yml +202 -202
  326. data/resources/locales/ms/calendars.yml +181 -181
  327. data/resources/locales/ms/currencies.yml +163 -163
  328. data/resources/locales/ms/languages.yml +257 -257
  329. data/resources/locales/ms/layout.yml +1 -1
  330. data/resources/locales/ms/numbers.yml +23 -23
  331. data/resources/locales/ms/rbnf.yml +27 -27
  332. data/resources/locales/ms/territories.yml +179 -179
  333. data/resources/locales/nb/calendars.yml +190 -190
  334. data/resources/locales/nb/currencies.yml +313 -313
  335. data/resources/locales/nb/languages.yml +480 -480
  336. data/resources/locales/nb/layout.yml +1 -1
  337. data/resources/locales/nb/numbers.yml +37 -37
  338. data/resources/locales/nb/rbnf.yml +38 -38
  339. data/resources/locales/nb/territories.yml +213 -213
  340. data/resources/locales/nl/calendars.yml +182 -182
  341. data/resources/locales/nl/currencies.yml +319 -319
  342. data/resources/locales/nl/languages.yml +555 -555
  343. data/resources/locales/nl/layout.yml +1 -1
  344. data/resources/locales/nl/numbers.yml +35 -35
  345. data/resources/locales/nl/rbnf.yml +81 -81
  346. data/resources/locales/nl/territories.yml +215 -215
  347. data/resources/locales/pl/calendars.yml +176 -176
  348. data/resources/locales/pl/currencies.yml +175 -175
  349. data/resources/locales/pl/languages.yml +537 -537
  350. data/resources/locales/pl/layout.yml +1 -1
  351. data/resources/locales/pl/numbers.yml +60 -60
  352. data/resources/locales/pl/rbnf.yml +58 -58
  353. data/resources/locales/pl/territories.yml +191 -191
  354. data/resources/locales/pt/calendars.yml +187 -187
  355. data/resources/locales/pt/currencies.yml +172 -172
  356. data/resources/locales/pt/languages.yml +442 -442
  357. data/resources/locales/pt/layout.yml +1 -1
  358. data/resources/locales/pt/numbers.yml +35 -35
  359. data/resources/locales/pt/rbnf.yml +75 -75
  360. data/resources/locales/pt/territories.yml +178 -178
  361. data/resources/locales/ro/calendars.yml +170 -170
  362. data/resources/locales/ro/currencies.yml +165 -165
  363. data/resources/locales/ro/languages.yml +443 -443
  364. data/resources/locales/ro/layout.yml +1 -1
  365. data/resources/locales/ro/numbers.yml +47 -47
  366. data/resources/locales/ro/rbnf.yml +34 -34
  367. data/resources/locales/ro/territories.yml +178 -178
  368. data/resources/locales/ru/calendars.yml +174 -174
  369. data/resources/locales/ru/currencies.yml +176 -176
  370. data/resources/locales/ru/languages.yml +469 -469
  371. data/resources/locales/ru/layout.yml +1 -1
  372. data/resources/locales/ru/numbers.yml +60 -60
  373. data/resources/locales/ru/rbnf.yml +40 -40
  374. data/resources/locales/ru/territories.yml +197 -197
  375. data/resources/locales/sk/calendars.yml +170 -170
  376. data/resources/locales/sk/currencies.yml +168 -168
  377. data/resources/locales/sk/languages.yml +439 -439
  378. data/resources/locales/sk/layout.yml +1 -1
  379. data/resources/locales/sk/numbers.yml +60 -60
  380. data/resources/locales/sk/rbnf.yml +40 -40
  381. data/resources/locales/sk/territories.yml +191 -191
  382. data/resources/locales/sq/calendars.yml +157 -157
  383. data/resources/locales/sq/currencies.yml +102 -102
  384. data/resources/locales/sq/languages.yml +188 -188
  385. data/resources/locales/sq/layout.yml +1 -1
  386. data/resources/locales/sq/numbers.yml +36 -36
  387. data/resources/locales/sq/rbnf.yml +26 -26
  388. data/resources/locales/sq/territories.yml +180 -180
  389. data/resources/locales/sr/calendars.yml +185 -185
  390. data/resources/locales/sr/currencies.yml +171 -171
  391. data/resources/locales/sr/languages.yml +430 -430
  392. data/resources/locales/sr/layout.yml +1 -1
  393. data/resources/locales/sr/numbers.yml +47 -47
  394. data/resources/locales/sr/rbnf.yml +80 -80
  395. data/resources/locales/sr/territories.yml +184 -184
  396. data/resources/locales/sv/calendars.yml +189 -189
  397. data/resources/locales/sv/currencies.yml +212 -212
  398. data/resources/locales/sv/languages.yml +541 -541
  399. data/resources/locales/sv/layout.yml +1 -1
  400. data/resources/locales/sv/numbers.yml +37 -37
  401. data/resources/locales/sv/rbnf.yml +149 -149
  402. data/resources/locales/sv/territories.yml +207 -207
  403. data/resources/locales/ta/calendars.yml +185 -185
  404. data/resources/locales/ta/currencies.yml +160 -160
  405. data/resources/locales/ta/languages.yml +422 -422
  406. data/resources/locales/ta/layout.yml +1 -1
  407. data/resources/locales/ta/numbers.yml +35 -35
  408. data/resources/locales/ta/rbnf.yml +54 -54
  409. data/resources/locales/ta/territories.yml +184 -184
  410. data/resources/locales/th/calendars.yml +176 -176
  411. data/resources/locales/th/currencies.yml +695 -695
  412. data/resources/locales/th/languages.yml +594 -594
  413. data/resources/locales/th/layout.yml +1 -1
  414. data/resources/locales/th/numbers.yml +23 -23
  415. data/resources/locales/th/rbnf.yml +29 -29
  416. data/resources/locales/th/territories.yml +253 -253
  417. data/resources/locales/tr/calendars.yml +179 -179
  418. data/resources/locales/tr/currencies.yml +268 -268
  419. data/resources/locales/tr/languages.yml +443 -443
  420. data/resources/locales/tr/layout.yml +1 -1
  421. data/resources/locales/tr/numbers.yml +33 -33
  422. data/resources/locales/tr/rbnf.yml +61 -61
  423. data/resources/locales/tr/territories.yml +179 -179
  424. data/resources/locales/uk/calendars.yml +175 -175
  425. data/resources/locales/uk/currencies.yml +175 -175
  426. data/resources/locales/uk/languages.yml +467 -467
  427. data/resources/locales/uk/layout.yml +1 -1
  428. data/resources/locales/uk/numbers.yml +60 -60
  429. data/resources/locales/uk/rbnf.yml +40 -40
  430. data/resources/locales/uk/territories.yml +193 -193
  431. data/resources/locales/ur/calendars.yml +162 -162
  432. data/resources/locales/ur/currencies.yml +160 -160
  433. data/resources/locales/ur/languages.yml +203 -203
  434. data/resources/locales/ur/layout.yml +1 -1
  435. data/resources/locales/ur/numbers.yml +36 -36
  436. data/resources/locales/ur/territories.yml +166 -166
  437. data/resources/locales/vi/calendars.yml +80 -80
  438. data/resources/locales/vi/currencies.yml +295 -295
  439. data/resources/locales/vi/languages.yml +1 -1
  440. data/resources/locales/vi/layout.yml +1 -1
  441. data/resources/locales/vi/numbers.yml +23 -23
  442. data/resources/locales/vi/rbnf.yml +39 -39
  443. data/resources/locales/vi/territories.yml +158 -158
  444. data/resources/locales/zh-Hant/calendars.yml +200 -200
  445. data/resources/locales/zh-Hant/currencies.yml +789 -789
  446. data/resources/locales/zh-Hant/languages.yml +607 -607
  447. data/resources/locales/zh-Hant/layout.yml +1 -1
  448. data/resources/locales/zh-Hant/numbers.yml +34 -34
  449. data/resources/locales/zh-Hant/rbnf.yml +197 -197
  450. data/resources/locales/zh-Hant/territories.yml +260 -260
  451. data/resources/locales/zh/calendars.yml +204 -204
  452. data/resources/locales/zh/currencies.yml +740 -740
  453. data/resources/locales/zh/languages.yml +515 -515
  454. data/resources/locales/zh/layout.yml +1 -1
  455. data/resources/locales/zh/numbers.yml +35 -35
  456. data/resources/locales/zh/rbnf.yml +231 -231
  457. data/resources/locales/zh/territories.yml +260 -260
  458. data/resources/shared/numbering_systems.yml +118 -118
  459. data/resources/shared/rbnf_root.yml +239 -239
  460. data/resources/shared/segments/segments_root.yml +143 -143
  461. data/resources/shared/territories_containment.yml +304 -304
  462. data/spec/bidi/bidi_spec.rb +0 -1
  463. data/spec/core_ext_spec.rb +1 -2
  464. data/spec/parsers/segmentation_parser_spec.rb +8 -4
  465. data/spec/parsers/symbol_table_spec.rb +1 -5
  466. data/spec/parsers/unicode_regex/character_class_spec.rb +5 -3
  467. data/spec/parsers/unicode_regex/unicode_string_spec.rb +1 -1
  468. data/spec/shared/unicode_regex_spec.rb +14 -14
  469. data/spec/spec_helper.rb +3 -12
  470. data/spec/utils/yaml/yaml_spec.rb +10 -26
  471. metadata +14 -15
  472. data/lib/twitter_cldr/utils/interpolation.rb +0 -105
  473. data/spec/utils/interpolation_spec.rb +0 -124
@@ -28,7 +28,6 @@ describe Bidi do
28
28
  File.open(BIDI_TEST_PATH, 'r').each_line do |s|
29
29
  cur_line = s.strip
30
30
  first_char = cur_line[0]
31
- first_char = first_char.chr if first_char.is_a?(Fixnum) # conversion for ruby 1.8
32
31
 
33
32
  case first_char
34
33
  when "#"
@@ -10,8 +10,7 @@ describe 'Core classes localization' do
10
10
  [Array, Bignum, DateTime, Fixnum, Float, String, Symbol, Time].each do |klass|
11
11
  describe klass do
12
12
  it 'has public instance method #localize' do
13
- # convert methods names to symbols (they're strings in 1.8)
14
- expect(klass.public_instance_methods.map(&:to_sym)).to include(:localize)
13
+ expect(klass.public_instance_methods).to include(:localize)
15
14
  end
16
15
  end
17
16
  end
@@ -30,20 +30,24 @@ describe "Segmentation" do
30
30
  describe "#parse" do
31
31
  it "should parse a rule with a break" do
32
32
  rule = parse(tokenize("[a-z] ÷ [0-9]"))
33
- expect(rule.left.to_regexp_str).to eq("\\A(?:[\\141-\\172])")
34
- expect(rule.right.to_regexp_str).to eq("\\A(?:[\\60-\\71])")
33
+ expect(rule.left.to_regexp_str).to eq("\\A(?:[\\u{0061}-\\u{007a}])")
34
+ expect(rule.right.to_regexp_str).to eq("\\A(?:[\\u{0030}-\\u{0039}])")
35
35
  expect(rule.boundary_symbol).to eq(:break)
36
36
  end
37
37
 
38
38
  it "should parse a rule with a non-break" do
39
39
  rule = parse(tokenize("[a-z] × [0-9]"))
40
- expect(rule.regex.to_regexp_str).to eq("\\A(?:[\\141-\\172])(?:[\\60-\\71])")
40
+ expect(rule.regex.to_regexp_str).to eq(
41
+ "\\A(?:[\\u{0061}-\\u{007a}])(?:[\\u{0030}-\\u{0039}])"
42
+ )
41
43
  expect(rule.boundary_symbol).to eq(:no_break)
42
44
  end
43
45
 
44
46
  it "should parse a rule containing a variable" do
45
47
  rule = parse(tokenize("$FOO × bar"), :symbol_table => symbol_table)
46
- expect(rule.regex.to_regexp_str).to eq("\\A(?:[\\141-\\143])(?:\\142)(?:\\141)(?:\\162)")
48
+ expect(rule.regex.to_regexp_str).to eq(
49
+ "\\A(?:[\\u{0061}-\\u{0063}])(?:\\u{0062})(?:\\u{0061})(?:\\u{0072})"
50
+ )
47
51
  expect(rule.boundary_symbol).to eq(:no_break)
48
52
  end
49
53
  end
@@ -15,11 +15,7 @@ describe SymbolTable do
15
15
  expect(table.fetch(:a)).to eq("b")
16
16
  fetch = lambda { table.fetch(:z) }
17
17
 
18
- if RUBY_VERSION > "1.8.7"
19
- expect(fetch).to raise_error(KeyError)
20
- else
21
- expect(fetch).to raise_error(IndexError)
22
- end
18
+ expect(fetch).to raise_error(KeyError)
23
19
  end
24
20
  end
25
21
 
@@ -102,17 +102,19 @@ describe UnicodeRegexParser::CharacterClass do
102
102
  describe "#to_regexp_str" do
103
103
  it "wraps ranges in square brackets" do
104
104
  char_class = char_class_from(parse(tokenize("[a-z]")))
105
- expect(char_class.to_regexp_str).to eq("(?:[\\141-\\172])")
105
+ expect(char_class.to_regexp_str).to eq("(?:[\\u{0061}-\\u{007a}])")
106
106
  end
107
107
 
108
108
  it "octal-encodes and wraps sequential characters to isolate bytes" do
109
109
  char_class = char_class_from(parse(tokenize("[{foo}]")))
110
- expect(char_class.to_regexp_str).to eq("(?:(?:\\146)(?:\\157)(?:\\157))")
110
+ expect(char_class.to_regexp_str).to eq("(?:(?:\\u{0066})(?:\\u{006f})(?:\\u{006f}))")
111
111
  end
112
112
 
113
113
  it "combines multiple components with 'or' pipe characters" do
114
114
  char_class = char_class_from(parse(tokenize("[{foo}abc]")))
115
- expect(char_class.to_regexp_str).to eq("(?:(?:\\146)(?:\\157)(?:\\157)|[\\141-\\143])")
115
+ expect(char_class.to_regexp_str).to eq(
116
+ "(?:(?:\\u{0066})(?:\\u{006f})(?:\\u{006f})|[\\u{0061}-\\u{0063}])"
117
+ )
116
118
  end
117
119
  end
118
120
  end
@@ -21,7 +21,7 @@ describe UnicodeRegexParser::UnicodeString do
21
21
 
22
22
  it "should covert the codepoints to a valid regex" do
23
23
  str = UnicodeRegexParser::UnicodeString.new(97)
24
- expect(str.to_regexp_str).to eq"(?:\\141)"
24
+ expect(str.to_regexp_str).to eq("(?:\\u{0061})")
25
25
  end
26
26
  end
27
27
  end
@@ -31,34 +31,34 @@ describe UnicodeRegex do
31
31
 
32
32
  describe "#to_regexp_str" do
33
33
  it "should return the string representation of this regex" do
34
- expect(regex.to_regexp_str).to eq("(?:[\\141-\\143])")
34
+ expect(regex.to_regexp_str).to eq("(?:[\\u{0061}-\\u{0063}])")
35
35
  end
36
36
  end
37
37
 
38
38
  describe "#to_regexp" do
39
39
  it "should return a ruby Regexp" do
40
- if RUBY_VERSION <= "1.8.7"
41
- expect(regex.to_regexp).to be_a(Oniguruma::ORegexp)
42
- else
43
- expect(regex.to_regexp).to be_a(Regexp)
44
- end
40
+ expect(regex.to_regexp).to be_a(Regexp)
45
41
  end
46
42
 
47
43
  it "should properly turn various basic regexes into strings" do
48
- expect(compile("^abc$").to_regexp_str).to eq("^(?:\\141)(?:\\142)(?:\\143)$")
49
- expect(compile("a(b)c").to_regexp_str).to eq("(?:\\141)((?:\\142))(?:\\143)")
50
- expect(compile("a(?:b)c").to_regexp_str).to eq("(?:\\141)(?:(?:\\142))(?:\\143)")
51
- expect(compile("a{1,3}").to_regexp_str).to eq("(?:\\141){1,3}")
52
- expect(compile("[abc]").to_regexp_str).to eq("(?:[\\141-\\143])")
44
+ expect(compile("^abc$").to_regexp_str).to eq("^(?:\\u{0061})(?:\\u{0062})(?:\\u{0063})$")
45
+ expect(compile("a(b)c").to_regexp_str).to eq("(?:\\u{0061})((?:\\u{0062}))(?:\\u{0063})")
46
+ expect(compile("a(?:b)c").to_regexp_str).to eq("(?:\\u{0061})(?:(?:\\u{0062}))(?:\\u{0063})")
47
+ expect(compile("a{1,3}").to_regexp_str).to eq("(?:\\u{0061}){1,3}")
48
+ expect(compile("[abc]").to_regexp_str).to eq("(?:[\\u{0061}-\\u{0063}])")
53
49
  end
54
50
 
55
51
  it "should properly turn various complex regexes into strings" do
56
- expect(compile("[a-z0-9]").to_regexp_str).to eq("(?:[\\60-\\71]|[\\141-\\172])")
57
- expect(compile("[\\u0067-\\u0071]").to_regexp_str).to eq("(?:[\\147-\\161])")
52
+ expect(compile("[a-z0-9]").to_regexp_str).to eq(
53
+ "(?:[\\u{0030}-\\u{0039}]|[\\u{0061}-\\u{007a}])"
54
+ )
55
+ expect(compile("[\\u0067-\\u0071]").to_regexp_str).to eq("(?:[\\u{0067}-\\u{0071}])")
58
56
  end
59
57
 
60
58
  it "should properly substitute variables" do
61
- expect(compile("$FOO$BAR", symbol_table).to_regexp_str).to eq("(?:[\\147-\\153])(?:[\\160-\\163])")
59
+ expect(compile("$FOO$BAR", symbol_table).to_regexp_str).to eq(
60
+ "(?:[\\u{0067}-\\u{006b}])(?:[\\u{0070}-\\u{0073}])"
61
+ )
62
62
  end
63
63
  end
64
64
  end
data/spec/spec_helper.rb CHANGED
@@ -6,19 +6,10 @@
6
6
  require 'rspec'
7
7
  require 'rspec/autorun' # somehow makes rcov work with rspec
8
8
  require 'twitter_cldr'
9
+ require 'pry-nav'
10
+ require 'coveralls'
9
11
 
10
- if defined?(RUBY_ENGINE)
11
- if RUBY_ENGINE == "rbx"
12
- require 'rubinius/debugger'
13
- elsif RUBY_ENGINE == "ruby"
14
- require 'pry-nav'
15
- end
16
- end
17
-
18
- if RUBY_VERSION <= "1.8.7"
19
- $KCODE = "UTF-8"
20
- require 'oniguruma'
21
- end
12
+ Coveralls.wear!
22
13
 
23
14
  if ENV['SCOV']
24
15
  require 'simplecov'
@@ -32,26 +32,14 @@ require 'yaml'
32
32
  # Psych doesn't handle Unicode characters properly, have to use Syck instead.
33
33
  if YAML.const_defined?(:ENGINE)
34
34
  # Fix undefined method `syck_to_yaml' for class `Object' error on MRI 1.9.3.
35
- # Target only MRI >= 1.9, because on other Rubies, e.g., JRuby, requiring 'syck' results in a LoadError.
36
- if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' && RUBY_VERSION >= "1.9.0" && RUBY_VERSION < "2.0.0"
35
+ # Target only MRI ~1.9, because on other Rubies, e.g., JRuby, requiring 'syck' results in a LoadError.
36
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' && RUBY_VERSION < "2.0.0"
37
37
  require 'syck'
38
38
  end
39
39
 
40
40
  YAML::ENGINE.yamler = 'syck'
41
41
  end
42
42
 
43
- # There's an incompatibility in how ruby handles struct dumps
44
- # between versions that's beyond our scope.
45
- # (One uses strings internally, the other symbols.)
46
- # This just enables tests to pass.
47
- class << Struct
48
- alias yaml_new_without_indifferent_keys yaml_new
49
- def yaml_new(klass, tag, val)
50
- val.keys.each { |k, v| val[k.to_sym] = val.delete(k) }
51
- yaml_new_without_indifferent_keys(klass, tag, val)
52
- end
53
- end if RUBY_VERSION >= "1.9" && RUBY_VERSION <= "1.9.1" # yaml_new is deprecated in 1.9.2 and later
54
-
55
43
  STRUCT_KLASS = Struct::new('Foo', :bar, :buz)
56
44
  class Moo
57
45
  attr_accessor :val1, :val2
@@ -140,11 +128,9 @@ describe TwitterCldr::Utils do
140
128
  end
141
129
  end
142
130
 
143
- if RUBY_VERSION >= "1.9"
144
- it "should preserve hash order" do
145
- h = { 'a' => 1, 'c' => 3, 'b' => 2 }
146
- expect(TwitterCldr::Utils::YAML.dump(h, :preserve_order => true)).to eq("--- \na: 1\nc: 3\nb: 2\n")
147
- end
131
+ it "should preserve hash order" do
132
+ h = { 'a' => 1, 'c' => 3, 'b' => 2 }
133
+ expect(TwitterCldr::Utils::YAML.dump(h, :preserve_order => true)).to eq("--- \na: 1\nc: 3\nb: 2\n")
148
134
  end
149
135
 
150
136
  it "tests normalization of line breaks" do
@@ -430,15 +416,13 @@ describe TwitterCldr::Utils do
430
416
  end
431
417
 
432
418
  it "tests binary dumps" do
433
- unless RUBY_VERSION < '1.9.0'
434
- y = nil
419
+ y = nil
435
420
 
436
- expect { y = TwitterCldr::Utils::YAML.dump('日本語'.force_encoding('ASCII-8BIT')) }.not_to raise_error
437
- expect(y).to eq("--- !binary |\n 5pel5pys6Kqe\n\n")
421
+ expect { y = TwitterCldr::Utils::YAML.dump('日本語'.force_encoding('ASCII-8BIT')) }.not_to raise_error
422
+ expect(y).to eq("--- !binary |\n 5pel5pys6Kqe\n\n")
438
423
 
439
- expect { y = TwitterCldr::Utils::YAML.dump('日本語'.encode('EUC-JP').force_encoding('UTF-8')) }.not_to raise_error
440
- expect(y).to eq("--- !binary |\n xvzL3Ljs\n\n")
441
- end
424
+ expect { y = TwitterCldr::Utils::YAML.dump('日本語'.encode('EUC-JP').force_encoding('UTF-8')) }.not_to raise_error
425
+ expect(y).to eq("--- !binary |\n xvzL3Ljs\n\n")
442
426
  end
443
427
 
444
428
  end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter_cldr
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-18 00:00:00.000000000 Z
11
+ date: 2015-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: camertron-eprun
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: tzinfo
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: cldr-plurals-runtime-rb
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.0.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.0.0
69
69
  description: Ruby implementation of the ICU (International Components for Unicode)
@@ -210,7 +210,6 @@ files:
210
210
  - lib/twitter_cldr/tokenizers/unicode_regex/unicode_regex_tokenizer.rb
211
211
  - lib/twitter_cldr/utils.rb
212
212
  - lib/twitter_cldr/utils/code_points.rb
213
- - lib/twitter_cldr/utils/interpolation.rb
214
213
  - lib/twitter_cldr/utils/range_set.rb
215
214
  - lib/twitter_cldr/utils/regexp_ast.rb
216
215
  - lib/twitter_cldr/utils/regexp_sampler.rb
@@ -1550,7 +1549,6 @@ files:
1550
1549
  - spec/tokenizers/unicode_regex/unicode_regex_tokenizer_spec.rb
1551
1550
  - spec/twitter_cldr_spec.rb
1552
1551
  - spec/utils/code_points_spec.rb
1553
- - spec/utils/interpolation_spec.rb
1554
1552
  - spec/utils/range_set_spec.rb
1555
1553
  - spec/utils/regexp_ast_spec.rb
1556
1554
  - spec/utils/regexp_sampler_spec.rb
@@ -1568,19 +1566,20 @@ require_paths:
1568
1566
  - lib
1569
1567
  required_ruby_version: !ruby/object:Gem::Requirement
1570
1568
  requirements:
1571
- - - '>='
1569
+ - - ">="
1572
1570
  - !ruby/object:Gem::Version
1573
1571
  version: '0'
1574
1572
  required_rubygems_version: !ruby/object:Gem::Requirement
1575
1573
  requirements:
1576
- - - '>='
1574
+ - - ">="
1577
1575
  - !ruby/object:Gem::Version
1578
1576
  version: '0'
1579
1577
  requirements: []
1580
1578
  rubyforge_project:
1581
- rubygems_version: 2.2.1
1579
+ rubygems_version: 2.2.2
1582
1580
  signing_key:
1583
1581
  specification_version: 4
1584
1582
  summary: Ruby implementation of the ICU (International Components for Unicode) that
1585
1583
  uses the Common Locale Data Repository to format dates, plurals, and more.
1586
1584
  test_files: []
1585
+ has_rdoc: true
@@ -1,105 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- # Copyright 2012 Twitter, Inc
4
- # http://www.apache.org/licenses/LICENSE-2.0
5
-
6
- # The implementation of the TwitterCldr.interpolate method that backports String interpolation capabilities
7
- # (originally implemented in String#% method) from Ruby 1.9 to Ruby 1.8 is heavily influenced by the
8
- # implementation of the same feature in i18n (https://github.com/svenfuchs/i18n/blob/89ea337f48562370988421e50caa7c2fe89452c7/lib/i18n/core_ext/string/interpolate.rb)
9
- # and gettext (https://github.com/mutoh/gettext/blob/11b8c1525ba9f00afb1942f7ebf34bec12f7558b/lib/gettext/core_ext/string.rb) gems.
10
- #
11
- # See NOTICE file for corresponding license agreements.
12
-
13
-
14
- # KeyError is raised during interpolation when there is a placeholder that doesn't have corresponding key in the
15
- # interpolation hash. KeyError is defined in 1.9. We define it for prior versions of Ruby to have the same behavior.
16
- #
17
- class KeyError < IndexError
18
- def initialize(message = nil)
19
- super(message || 'key not found')
20
- end
21
- end unless defined?(KeyError)
22
-
23
-
24
- module TwitterCldr
25
- module Utils
26
-
27
- HASH_INTERPOLATION_REGEXP = Regexp.union(
28
- /%\{(\w+)\}/,
29
- /%<(\w+)>(.*?\d*\.?\d*[bBdiouxXeEfgGcps])/
30
- )
31
-
32
- HASH_INTERPOLATION_WITH_ESCAPE_REGEXP = Regexp.union(
33
- /%%/,
34
- HASH_INTERPOLATION_REGEXP
35
- )
36
-
37
- class << self
38
-
39
- # Uses +string+ as a format specification and returns the result of applying it to +args+.
40
- #
41
- # There are three ways to use it:
42
- #
43
- # * Using a single argument or Array of arguments.
44
- #
45
- # This is the default behaviour of the String#% method. See Kernel#sprintf for more details about the format
46
- # specification.
47
- #
48
- # Example:
49
- #
50
- # TwitterCldr::Utils.interpolate('%d %s', [1, 'message'])
51
- # # => "1 message"
52
- #
53
- # * Using a Hash as an argument and unformatted, named placeholders (Ruby 1.9 syntax).
54
- #
55
- # When you pass a Hash as an argument and specify placeholders with %{foo} it will interpret the hash values as
56
- # named arguments.
57
- #
58
- # Example:
59
- #
60
- # TwitterCldr::Utils.interpolate('%{firstname}, %{lastname}', :firstname => 'Masao', :lastname => 'Mutoh')
61
- # # => "Masao Mutoh"
62
- #
63
- # * Using a Hash as an argument and formatted, named placeholders (Ruby 1.9 syntax).
64
- #
65
- # When you pass a Hash as an argument and specify placeholders with %<foo>d it will interpret the hash values
66
- # as named arguments and format the value according to the formatting instruction appended to the closing >.
67
- #
68
- # Example:
69
- #
70
- # TwitterCldr::Utils.interpolate('%<integer>d, %<float>.1f', :integer => 10, :float => 43.4)
71
- # # => "10, 43.3"
72
- #
73
- # An exception can be thrown in two cases when Ruby 1.9 interpolation syntax is used:
74
- #
75
- # * ArgumentError is thrown if Ruby 1.9. interpolation syntax is used in +string+, but +args+ is not a Hash;
76
- # * KeyError is thrown if the value for one of the placeholders in +string+ is missing in +args+ hash.
77
- #
78
- def interpolate(string, args)
79
- string =~ HASH_INTERPOLATION_REGEXP ? interpolate_hash(string, args) : interpolate_value_or_array(string, args)
80
- end
81
-
82
- private
83
-
84
- def interpolate_hash(string, args)
85
- raise ArgumentError.new('expected a Hash') unless args.is_a?(Hash)
86
-
87
- string.gsub(HASH_INTERPOLATION_WITH_ESCAPE_REGEXP) do |match|
88
- if match == '%%'
89
- '%'
90
- else
91
- key = ($1 || $2).to_sym
92
- raise KeyError unless args.has_key?(key)
93
- $3 ? sprintf("%#{$3}", args[key]) : args[key]
94
- end
95
- end
96
- end
97
-
98
- def interpolate_value_or_array(string, args)
99
- string.gsub(/%([{<])/, '%%\1') % args
100
- end
101
-
102
- end
103
-
104
- end
105
- end