Skip to content

Commit

Permalink
Adding Currency Symbol to Faker (#1201)
Browse files Browse the repository at this point in the history
* Adding Currency Symbols very useful for E-Commerce websites.

* Unit test (don't know unit test only only RSPEC test)
  • Loading branch information
SaimonL authored and vbrazo committed May 20, 2018
1 parent 9715dcc commit 2998b45
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doc/currency.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
Faker::Currency.name #=> "Swedish Krona"

Faker::Currency.code #=> "USD"

Faker::Currency.symbol #=> "$"

```
4 changes: 4 additions & 0 deletions lib/faker/currency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ def name
def code
fetch('currency.code')
end

def symbol
fetch('currency.symbol')
end
end
end
end
1 change: 1 addition & 0 deletions lib/locales/en/currency.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ en:
currency:
code: [AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BWP, BYR, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CUP, CVE, CZK, DJF, DKK, DOP, DZD, EEK, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, INR, INR, IQD, IRR, ISK, JMD, JOD, JPY, KES, KGS, KHR, KMF, KPW, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LTL, LVL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRO, MUR, MVR, MWK, MXN, MYR, MZN, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, STD, SVC, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, UYU, UZS, VEF, VND, VUV, WST, XAF, XAG, XAU, XBA, XBB, XBC, XBD, XCD, XDR, XFU, XOF, XPD, XPF, XPT, XTS, YER, ZAR, ZAR, ZAR, ZMK, ZWL]
name: ["UAE Dirham", "Afghani", "Lek", "Armenian Dram", "Netherlands Antillian Guilder", "Kwanza", "Argentine Peso", "Australian Dollar", "Aruban Guilder", "Azerbaijanian Manat", "Convertible Marks", "Barbados Dollar", "Taka", "Bulgarian Lev", "Bahraini Dinar", "Burundi Franc", "Bermudian Dollar (customarily known as Bermuda Dollar)", "Brunei Dollar", "Boliviano Mvdol", "Brazilian Real", "Bahamian Dollar", "Pula", "Belarussian Ruble", "Belize Dollar", "Canadian Dollar", "Congolese Franc", "Swiss Franc", "Chilean Peso Unidades de fomento", "Yuan Renminbi", "Colombian Peso Unidad de Valor Real", "Costa Rican Colon", "Cuban Peso Peso Convertible", "Cape Verde Escudo", "Czech Koruna", "Djibouti Franc", "Danish Krone", "Dominican Peso", "Algerian Dinar", "Kroon", "Egyptian Pound", "Nakfa", "Ethiopian Birr", "Euro", "Fiji Dollar", "Falkland Islands Pound", "Pound Sterling", "Lari", "Cedi", "Gibraltar Pound", "Dalasi", "Guinea Franc", "Quetzal", "Guyana Dollar", "Hong Kong Dollar", "Lempira", "Croatian Kuna", "Gourde US Dollar", "Forint", "Rupiah", "New Israeli Sheqel", "Indian Rupee", "Indian Rupee Ngultrum", "Iraqi Dinar", "Iranian Rial", "Iceland Krona", "Jamaican Dollar", "Jordanian Dinar", "Yen", "Kenyan Shilling", "Som", "Riel", "Comoro Franc", "North Korean Won", "Won", "Kuwaiti Dinar", "Cayman Islands Dollar", "Tenge", "Kip", "Lebanese Pound", "Sri Lanka Rupee", "Liberian Dollar", "Lithuanian Litas", "Latvian Lats", "Libyan Dinar", "Moroccan Dirham", "Moldovan Leu", "Malagasy Ariary", "Denar", "Kyat", "Tugrik", "Pataca", "Ouguiya", "Mauritius Rupee", "Rufiyaa", "Kwacha", "Mexican Peso Mexican Unidad de Inversion (UDI)", "Malaysian Ringgit", "Metical", "Naira", "Cordoba Oro", "Norwegian Krone", "Nepalese Rupee", "New Zealand Dollar", "Rial Omani", "Balboa US Dollar", "Nuevo Sol", "Kina", "Philippine Peso", "Pakistan Rupee", "Zloty", "Guarani", "Qatari Rial", "New Leu", "Serbian Dinar", "Russian Ruble", "Rwanda Franc", "Saudi Riyal", "Solomon Islands Dollar", "Seychelles Rupee", "Sudanese Pound", "Swedish Krona", "Singapore Dollar", "Saint Helena Pound", "Leone", "Somali Shilling", "Surinam Dollar", "Dobra", "El Salvador Colon US Dollar", "Syrian Pound", "Lilangeni", "Baht", "Somoni", "Manat", "Tunisian Dinar", "Pa'anga", "Turkish Lira", "Trinidad and Tobago Dollar", "New Taiwan Dollar", "Tanzanian Shilling", "Hryvnia", "Uganda Shilling", "US Dollar", "Peso Uruguayo Uruguay Peso en Unidades Indexadas", "Uzbekistan Sum", "Bolivar Fuerte", "Dong", "Vatu", "Tala", "CFA Franc BEAC", "Silver", "Gold", "Bond Markets Units European Composite Unit (EURCO)", "European Monetary Unit (E.M.U.-6)", "European Unit of Account 9(E.U.A.-9)", "European Unit of Account 17(E.U.A.-17)", "East Caribbean Dollar", "SDR", "UIC-Franc", "CFA Franc BCEAO", "Palladium", "CFP Franc", "Platinum", "Codes specifically reserved for testing purposes", "Yemeni Rial", "Rand", "Rand Loti", "Rand Namibia Dollar", "Zambian Kwacha", "Zimbabwe Dollar"]
symbol: ['HK$', 'Ft', '₪', '¥', '$', 'kr', 'PhP', 'zł', 'CHF', 'NT$', '฿', '£', '¢', 'Rp', 'ƒ']
4 changes: 4 additions & 0 deletions test/test_faker_currency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ def test_name
def test_code
assert @tester.code.match(/[A-Z]{3}/)
end

def test_symbol
assert @tester.symbol.length > 1
end
end

0 comments on commit 2998b45

Please sign in to comment.