money 6.7.1 → 6.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -1
  3. data/.travis.yml +15 -6
  4. data/AUTHORS +5 -0
  5. data/CHANGELOG.md +98 -3
  6. data/Gemfile +13 -4
  7. data/LICENSE +2 -0
  8. data/README.md +64 -44
  9. data/config/currency_backwards_compatible.json +30 -0
  10. data/config/currency_iso.json +135 -59
  11. data/config/currency_non_iso.json +66 -2
  12. data/lib/money.rb +0 -13
  13. data/lib/money/bank/variable_exchange.rb +9 -22
  14. data/lib/money/currency.rb +33 -39
  15. data/lib/money/currency/heuristics.rb +1 -144
  16. data/lib/money/currency/loader.rb +1 -1
  17. data/lib/money/locale_backend/base.rb +7 -0
  18. data/lib/money/locale_backend/errors.rb +6 -0
  19. data/lib/money/locale_backend/i18n.rb +24 -0
  20. data/lib/money/locale_backend/legacy.rb +28 -0
  21. data/lib/money/money.rb +106 -139
  22. data/lib/money/money/allocation.rb +37 -0
  23. data/lib/money/money/arithmetic.rb +31 -28
  24. data/lib/money/money/constructors.rb +1 -2
  25. data/lib/money/money/formatter.rb +397 -0
  26. data/lib/money/money/formatting_rules.rb +120 -0
  27. data/lib/money/money/locale_backend.rb +20 -0
  28. data/lib/money/rates_store/memory.rb +1 -2
  29. data/lib/money/version.rb +1 -1
  30. data/money.gemspec +10 -16
  31. data/spec/bank/variable_exchange_spec.rb +7 -3
  32. data/spec/currency/heuristics_spec.rb +2 -153
  33. data/spec/currency_spec.rb +44 -3
  34. data/spec/locale_backend/i18n_spec.rb +62 -0
  35. data/spec/locale_backend/legacy_spec.rb +74 -0
  36. data/spec/money/allocation_spec.rb +130 -0
  37. data/spec/money/arithmetic_spec.rb +184 -90
  38. data/spec/money/constructors_spec.rb +0 -12
  39. data/spec/money/formatting_spec.rb +296 -179
  40. data/spec/money/locale_backend_spec.rb +14 -0
  41. data/spec/money_spec.rb +159 -26
  42. data/spec/rates_store/memory_spec.rb +13 -2
  43. data/spec/spec_helper.rb +2 -0
  44. data/spec/support/shared_examples/money_examples.rb +14 -0
  45. metadata +32 -40
  46. data/lib/money/money/formatting.rb +0 -418
@@ -30,6 +30,36 @@
30
30
  "iso_numeric": "288",
31
31
  "smallest_denomination": 1
32
32
  },
33
+ "ltl": {
34
+ "priority": 100,
35
+ "iso_code": "LTL",
36
+ "name": "Lithuanian Litas",
37
+ "symbol": "Lt",
38
+ "alternate_symbols": [],
39
+ "subunit": "Centas",
40
+ "subunit_to_unit": 100,
41
+ "symbol_first": false,
42
+ "html_entity": "",
43
+ "decimal_mark": ".",
44
+ "thousands_separator": ",",
45
+ "iso_numeric": "440",
46
+ "smallest_denomination": 1
47
+ },
48
+ "lvl": {
49
+ "priority": 100,
50
+ "iso_code": "LVL",
51
+ "name": "Latvian Lats",
52
+ "symbol": "Ls",
53
+ "alternate_symbols": [],
54
+ "subunit": "Santīms",
55
+ "subunit_to_unit": 100,
56
+ "symbol_first": true,
57
+ "html_entity": "",
58
+ "decimal_mark": ".",
59
+ "thousands_separator": ",",
60
+ "iso_numeric": "428",
61
+ "smallest_denomination": 1
62
+ },
33
63
  "mtl": {
34
64
  "priority": 100,
35
65
  "iso_code": "MTL",
@@ -100,7 +100,7 @@
100
100
  "subunit": "Centavo",
101
101
  "subunit_to_unit": 100,
102
102
  "symbol_first": true,
103
- "html_entity": "₱",
103
+ "html_entity": "$",
104
104
  "decimal_mark": ",",
105
105
  "thousands_separator": ".",
106
106
  "iso_numeric": "032",
@@ -176,7 +176,7 @@
176
176
  "alternate_symbols": ["Bds$"],
177
177
  "subunit": "Cent",
178
178
  "subunit_to_unit": 100,
179
- "symbol_first": false,
179
+ "symbol_first": true,
180
180
  "html_entity": "$",
181
181
  "decimal_mark": ".",
182
182
  "thousands_separator": ",",
@@ -236,7 +236,7 @@
236
236
  "disambiguate_symbol": "FBu",
237
237
  "alternate_symbols": ["FBu"],
238
238
  "subunit": "Centime",
239
- "subunit_to_unit": 100,
239
+ "subunit_to_unit": 1,
240
240
  "symbol_first": false,
241
241
  "html_entity": "",
242
242
  "decimal_mark": ".",
@@ -501,7 +501,7 @@
501
501
  "subunit": "Centavo",
502
502
  "subunit_to_unit": 100,
503
503
  "symbol_first": true,
504
- "html_entity": "₱",
504
+ "html_entity": "$",
505
505
  "decimal_mark": ",",
506
506
  "thousands_separator": ".",
507
507
  "iso_numeric": "170",
@@ -581,7 +581,7 @@
581
581
  "symbol_first": false,
582
582
  "html_entity": "",
583
583
  "decimal_mark": ",",
584
- "thousands_separator": ".",
584
+ "thousands_separator": " ",
585
585
  "iso_numeric": "203",
586
586
  "smallest_denomination": 100
587
587
  },
@@ -592,7 +592,7 @@
592
592
  "symbol": "Fdj",
593
593
  "alternate_symbols": [],
594
594
  "subunit": "Centime",
595
- "subunit_to_unit": 100,
595
+ "subunit_to_unit": 1,
596
596
  "symbol_first": false,
597
597
  "html_entity": "",
598
598
  "decimal_mark": ".",
@@ -824,7 +824,7 @@
824
824
  "disambiguate_symbol": "FG",
825
825
  "alternate_symbols": ["FG", "GFr"],
826
826
  "subunit": "Centime",
827
- "subunit_to_unit": 100,
827
+ "subunit_to_unit": 1,
828
828
  "symbol_first": false,
829
829
  "html_entity": "",
830
830
  "decimal_mark": ".",
@@ -931,14 +931,14 @@
931
931
  "name": "Hungarian Forint",
932
932
  "symbol": "Ft",
933
933
  "alternate_symbols": [],
934
- "subunit": "Fillér",
935
- "subunit_to_unit": 100,
934
+ "subunit": "",
935
+ "subunit_to_unit": 1,
936
936
  "symbol_first": false,
937
937
  "html_entity": "",
938
938
  "decimal_mark": ",",
939
- "thousands_separator": ".",
939
+ "thousands_separator": " ",
940
940
  "iso_numeric": "348",
941
- "smallest_denomination": 500
941
+ "smallest_denomination": 5
942
942
  },
943
943
  "idr": {
944
944
  "priority": 100,
@@ -1007,7 +1007,7 @@
1007
1007
  "symbol": "﷼",
1008
1008
  "alternate_symbols": [],
1009
1009
  "subunit": null,
1010
- "subunit_to_unit": 1,
1010
+ "subunit_to_unit": 100,
1011
1011
  "symbol_first": true,
1012
1012
  "html_entity": "﷼",
1013
1013
  "decimal_mark": ".",
@@ -1129,7 +1129,7 @@
1129
1129
  "disambiguate_symbol": "CF",
1130
1130
  "alternate_symbols": ["CF"],
1131
1131
  "subunit": "Centime",
1132
- "subunit_to_unit": 100,
1132
+ "subunit_to_unit": 1,
1133
1133
  "symbol_first": false,
1134
1134
  "html_entity": "",
1135
1135
  "decimal_mark": ".",
@@ -1202,7 +1202,7 @@
1202
1202
  "priority": 100,
1203
1203
  "iso_code": "KZT",
1204
1204
  "name": "Kazakhstani Tenge",
1205
- "symbol": "",
1205
+ "symbol": "",
1206
1206
  "alternate_symbols": [],
1207
1207
  "subunit": "Tiyn",
1208
1208
  "subunit_to_unit": 100,
@@ -1253,7 +1253,7 @@
1253
1253
  "subunit": "Cent",
1254
1254
  "subunit_to_unit": 100,
1255
1255
  "symbol_first": false,
1256
- "html_entity": "௹",
1256
+ "html_entity": "₨",
1257
1257
  "decimal_mark": ".",
1258
1258
  "thousands_separator": ",",
1259
1259
  "iso_numeric": "144",
@@ -1291,36 +1291,6 @@
1291
1291
  "iso_numeric": "426",
1292
1292
  "smallest_denomination": 1
1293
1293
  },
1294
- "ltl": {
1295
- "priority": 100,
1296
- "iso_code": "LTL",
1297
- "name": "Lithuanian Litas",
1298
- "symbol": "Lt",
1299
- "alternate_symbols": [],
1300
- "subunit": "Centas",
1301
- "subunit_to_unit": 100,
1302
- "symbol_first": false,
1303
- "html_entity": "",
1304
- "decimal_mark": ".",
1305
- "thousands_separator": ",",
1306
- "iso_numeric": "440",
1307
- "smallest_denomination": 1
1308
- },
1309
- "lvl": {
1310
- "priority": 100,
1311
- "iso_code": "LVL",
1312
- "name": "Latvian Lats",
1313
- "symbol": "Ls",
1314
- "alternate_symbols": [],
1315
- "subunit": "Santīms",
1316
- "subunit_to_unit": 100,
1317
- "symbol_first": true,
1318
- "html_entity": "",
1319
- "decimal_mark": ".",
1320
- "thousands_separator": ",",
1321
- "iso_numeric": "428",
1322
- "smallest_denomination": 1
1323
- },
1324
1294
  "lyd": {
1325
1295
  "priority": 100,
1326
1296
  "iso_code": "LYD",
@@ -1584,10 +1554,11 @@
1584
1554
  "iso_code": "NIO",
1585
1555
  "name": "Nicaraguan Córdoba",
1586
1556
  "symbol": "C$",
1557
+ "disambiguate_symbol": "NIO$",
1587
1558
  "alternate_symbols": [],
1588
1559
  "subunit": "Centavo",
1589
1560
  "subunit_to_unit": 100,
1590
- "symbol_first": false,
1561
+ "symbol_first": true,
1591
1562
  "html_entity": "",
1592
1563
  "decimal_mark": ".",
1593
1564
  "thousands_separator": ",",
@@ -1665,7 +1636,7 @@
1665
1636
  "alternate_symbols": [],
1666
1637
  "subunit": "Centésimo",
1667
1638
  "subunit_to_unit": 100,
1668
- "symbol_first": false,
1639
+ "symbol_first": true,
1669
1640
  "html_entity": "",
1670
1641
  "decimal_mark": ".",
1671
1642
  "thousands_separator": ",",
@@ -1675,7 +1646,7 @@
1675
1646
  "pen": {
1676
1647
  "priority": 100,
1677
1648
  "iso_code": "PEN",
1678
- "name": "Peruvian Nuevo Sol",
1649
+ "name": "Peruvian Sol",
1679
1650
  "symbol": "S/.",
1680
1651
  "alternate_symbols": [],
1681
1652
  "subunit": "Céntimo",
@@ -1756,7 +1727,7 @@
1756
1727
  "symbol": "₲",
1757
1728
  "alternate_symbols": [],
1758
1729
  "subunit": "Céntimo",
1759
- "subunit_to_unit": 100,
1730
+ "subunit_to_unit": 1,
1760
1731
  "symbol_first": true,
1761
1732
  "html_entity": "₲",
1762
1733
  "decimal_mark": ".",
@@ -1787,7 +1758,7 @@
1787
1758
  "alternate_symbols": [],
1788
1759
  "subunit": "Bani",
1789
1760
  "subunit_to_unit": 100,
1790
- "symbol_first": true,
1761
+ "symbol_first": false,
1791
1762
  "html_entity": "",
1792
1763
  "decimal_mark": ",",
1793
1764
  "thousands_separator": ".",
@@ -1831,7 +1802,7 @@
1831
1802
  "symbol": "FRw",
1832
1803
  "alternate_symbols": ["RF", "R₣"],
1833
1804
  "subunit": "Centime",
1834
- "subunit_to_unit": 100,
1805
+ "subunit_to_unit": 1,
1835
1806
  "symbol_first": false,
1836
1807
  "html_entity": "",
1837
1808
  "decimal_mark": ".",
@@ -2246,7 +2217,7 @@
2246
2217
  "symbol": "USh",
2247
2218
  "alternate_symbols": [],
2248
2219
  "subunit": "Cent",
2249
- "subunit_to_unit": 100,
2220
+ "subunit_to_unit": 1,
2250
2221
  "symbol_first": false,
2251
2222
  "html_entity": "",
2252
2223
  "decimal_mark": ".",
@@ -2288,9 +2259,9 @@
2288
2259
  "uzs": {
2289
2260
  "priority": 100,
2290
2261
  "iso_code": "UZS",
2291
- "name": "Uzbekistani Som",
2292
- "symbol": null,
2293
- "alternate_symbols": [],
2262
+ "name": "Uzbekistan Som",
2263
+ "symbol": "",
2264
+ "alternate_symbols": ["so‘m", "сўм", "сум", "s", "с"],
2294
2265
  "subunit": "Tiyin",
2295
2266
  "subunit_to_unit": 100,
2296
2267
  "symbol_first": false,
@@ -2323,7 +2294,7 @@
2323
2294
  "alternate_symbols": [],
2324
2295
  "subunit": "Hào",
2325
2296
  "subunit_to_unit": 1,
2326
- "symbol_first": true,
2297
+ "symbol_first": false,
2327
2298
  "html_entity": "₫",
2328
2299
  "decimal_mark": ",",
2329
2300
  "thousands_separator": ".",
@@ -2369,7 +2340,7 @@
2369
2340
  "disambiguate_symbol": "FCFA",
2370
2341
  "alternate_symbols": ["FCFA"],
2371
2342
  "subunit": "Centime",
2372
- "subunit_to_unit": 100,
2343
+ "subunit_to_unit": 1,
2373
2344
  "symbol_first": false,
2374
2345
  "html_entity": "",
2375
2346
  "decimal_mark": ".",
@@ -2407,6 +2378,66 @@
2407
2378
  "thousands_separator": ",",
2408
2379
  "iso_numeric": "959"
2409
2380
  },
2381
+ "xba": {
2382
+ "priority": 100,
2383
+ "iso_code": "XBA",
2384
+ "name": "European Composite Unit",
2385
+ "symbol": "",
2386
+ "disambiguate_symbol": "XBA",
2387
+ "alternate_symbols": [],
2388
+ "subunit": "",
2389
+ "subunit_to_unit": 1,
2390
+ "symbol_first": false,
2391
+ "html_entity": "",
2392
+ "decimal_mark": ".",
2393
+ "thousands_separator": ",",
2394
+ "iso_numeric": "955"
2395
+ },
2396
+ "xbb": {
2397
+ "priority": 100,
2398
+ "iso_code": "XBB",
2399
+ "name": "European Monetary Unit",
2400
+ "symbol": "",
2401
+ "disambiguate_symbol": "XBB",
2402
+ "alternate_symbols": [],
2403
+ "subunit": "",
2404
+ "subunit_to_unit": 1,
2405
+ "symbol_first": false,
2406
+ "html_entity": "",
2407
+ "decimal_mark": ".",
2408
+ "thousands_separator": ",",
2409
+ "iso_numeric": "956"
2410
+ },
2411
+ "xbc": {
2412
+ "priority": 100,
2413
+ "iso_code": "XBC",
2414
+ "name": "European Unit of Account 9",
2415
+ "symbol": "",
2416
+ "disambiguate_symbol": "XBC",
2417
+ "alternate_symbols": [],
2418
+ "subunit": "",
2419
+ "subunit_to_unit": 1,
2420
+ "symbol_first": false,
2421
+ "html_entity": "",
2422
+ "decimal_mark": ".",
2423
+ "thousands_separator": ",",
2424
+ "iso_numeric": "957"
2425
+ },
2426
+ "xbd": {
2427
+ "priority": 100,
2428
+ "iso_code": "XBD",
2429
+ "name": "European Unit of Account 17",
2430
+ "symbol": "",
2431
+ "disambiguate_symbol": "XBD",
2432
+ "alternate_symbols": [],
2433
+ "subunit": "",
2434
+ "subunit_to_unit": 1,
2435
+ "symbol_first": false,
2436
+ "html_entity": "",
2437
+ "decimal_mark": ".",
2438
+ "thousands_separator": ",",
2439
+ "iso_numeric": "958"
2440
+ },
2410
2441
  "xcd": {
2411
2442
  "priority": 100,
2412
2443
  "iso_code": "XCD",
@@ -2445,7 +2476,7 @@
2445
2476
  "disambiguate_symbol": "CFA",
2446
2477
  "alternate_symbols": ["CFA"],
2447
2478
  "subunit": "Centime",
2448
- "subunit_to_unit": 100,
2479
+ "subunit_to_unit": 1,
2449
2480
  "symbol_first": false,
2450
2481
  "html_entity": "",
2451
2482
  "decimal_mark": ".",
@@ -2453,6 +2484,21 @@
2453
2484
  "iso_numeric": "952",
2454
2485
  "smallest_denomination": 100
2455
2486
  },
2487
+ "xpd": {
2488
+ "priority": 100,
2489
+ "iso_code": "XPD",
2490
+ "name": "Palladium",
2491
+ "symbol": "oz t",
2492
+ "disambiguate_symbol": "XPD",
2493
+ "alternate_symbols": [],
2494
+ "subunit": "oz",
2495
+ "subunit_to_unit": 1,
2496
+ "symbol_first": false,
2497
+ "html_entity": "",
2498
+ "decimal_mark": ".",
2499
+ "thousands_separator": ",",
2500
+ "iso_numeric": "964"
2501
+ },
2456
2502
  "xpf": {
2457
2503
  "priority": 100,
2458
2504
  "iso_code": "XPF",
@@ -2460,7 +2506,7 @@
2460
2506
  "symbol": "Fr",
2461
2507
  "alternate_symbols": ["F"],
2462
2508
  "subunit": "Centime",
2463
- "subunit_to_unit": 100,
2509
+ "subunit_to_unit": 1,
2464
2510
  "symbol_first": false,
2465
2511
  "html_entity": "",
2466
2512
  "decimal_mark": ".",
@@ -2468,6 +2514,36 @@
2468
2514
  "iso_numeric": "953",
2469
2515
  "smallest_denomination": 100
2470
2516
  },
2517
+ "xpt": {
2518
+ "priority": 100,
2519
+ "iso_code": "XPT",
2520
+ "name": "Platinum",
2521
+ "symbol": "oz t",
2522
+ "alternate_symbols": [],
2523
+ "subunit": "",
2524
+ "subunit_to_unit": 1,
2525
+ "symbol_first": false,
2526
+ "html_entity": "",
2527
+ "decimal_mark": ".",
2528
+ "thousands_separator": ",",
2529
+ "iso_numeric": "962",
2530
+ "smallest_denomination": ""
2531
+ },
2532
+ "xts": {
2533
+ "priority": 100,
2534
+ "iso_code": "XTS",
2535
+ "name": "Codes specifically reserved for testing purposes",
2536
+ "symbol": "",
2537
+ "alternate_symbols": [],
2538
+ "subunit": "",
2539
+ "subunit_to_unit": 1,
2540
+ "symbol_first": false,
2541
+ "html_entity": "",
2542
+ "decimal_mark": ".",
2543
+ "thousands_separator": ",",
2544
+ "iso_numeric": "963",
2545
+ "smallest_denomination": ""
2546
+ },
2471
2547
  "yer": {
2472
2548
  "priority": 100,
2473
2549
  "iso_code": "YER",
@@ -1,14 +1,30 @@
1
1
  {
2
+ "bch": {
3
+ "priority": 100,
4
+ "iso_code": "BCH",
5
+ "name": "Bitcoin Cash",
6
+ "symbol": "₿",
7
+ "disambiguate_symbol": "₿CH",
8
+ "alternate_symbols": ["BCH"],
9
+ "subunit": "Satoshi",
10
+ "subunit_to_unit": 100000000,
11
+ "symbol_first": false,
12
+ "html_entity": "₿",
13
+ "decimal_mark": ".",
14
+ "thousands_separator": ",",
15
+ "iso_numeric": "",
16
+ "smallest_denomination": 1
17
+ },
2
18
  "btc": {
3
19
  "priority": 100,
4
20
  "iso_code": "BTC",
5
21
  "name": "Bitcoin",
6
- "symbol": "B⃦",
22
+ "symbol": "",
7
23
  "alternate_symbols": [],
8
24
  "subunit": "Satoshi",
9
25
  "subunit_to_unit": 100000000,
10
26
  "symbol_first": true,
11
- "html_entity": "",
27
+ "html_entity": "₿",
12
28
  "decimal_mark": ".",
13
29
  "thousands_separator": ",",
14
30
  "iso_numeric": "",
@@ -61,5 +77,53 @@
61
77
  "thousands_separator": ",",
62
78
  "iso_numeric": "",
63
79
  "smallest_denomination": 1
80
+ },
81
+ "xfu": {
82
+ "priority": 100,
83
+ "iso_code": "XFU",
84
+ "name": "UIC Franc",
85
+ "symbol": "",
86
+ "disambiguate_symbol": "XFU",
87
+ "alternate_symbols": [],
88
+ "subunit": "",
89
+ "subunit_to_unit": 100,
90
+ "symbol_first": true,
91
+ "html_entity": "",
92
+ "decimal_mark": ".",
93
+ "thousands_separator": ",",
94
+ "iso_numeric": "",
95
+ "smallest_denomination": ""
96
+ },
97
+ "gbx": {
98
+ "priority": 100,
99
+ "iso_code": "GBX",
100
+ "name": "British Penny",
101
+ "symbol": "",
102
+ "disambiguate_symbol": "GBX",
103
+ "alternate_symbols": [],
104
+ "subunit": "",
105
+ "subunit_to_unit": 1,
106
+ "symbol_first": true,
107
+ "html_entity": "",
108
+ "decimal_mark": ".",
109
+ "thousands_separator": ",",
110
+ "iso_numeric": "",
111
+ "smallest_denomination": 1
112
+ },
113
+ "cnh": {
114
+ "priority": 100,
115
+ "iso_code": "CNH",
116
+ "name": "Chinese Renminbi Yuan Offshore",
117
+ "symbol": "¥",
118
+ "disambiguate_symbol": "CNH",
119
+ "alternate_symbols": ["CN¥", "元", "CN元"],
120
+ "subunit": "Fen",
121
+ "subunit_to_unit": 100,
122
+ "symbol_first": true,
123
+ "html_entity": "¥",
124
+ "decimal_mark": ".",
125
+ "thousands_separator": ",",
126
+ "iso_numeric": "",
127
+ "smallest_denomination": 1
64
128
  }
65
129
  }