currency_wiz 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in currency_wiz.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Scott Chiang
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # CurrencyWiz
2
+
3
+ A gem to get the current exchange rate for another country.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'currency_wiz'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install currency_wiz
18
+
19
+ ## Usage
20
+
21
+ As of right now, you can only look up a country's code using the country name.
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'currency_wiz/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "currency_wiz"
8
+ spec.version = CurrencyWiz::VERSION
9
+ spec.authors = ["Scott Chiang"]
10
+ spec.email = ["scott.chiang1@gmail.com"]
11
+ spec.description = %q{A gem to get the current exchange rate. Sign up for an API key at https://openexchangerates.org/}
12
+ spec.summary = %q{Get the current exchange rate.}
13
+ spec.homepage = "https://github.com/scottchiang/currency_wiz"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ end
@@ -0,0 +1,182 @@
1
+ require "currency_wiz/version"
2
+
3
+ module CurrencyWiz
4
+ extend self
5
+
6
+ CURRENCY_CODES = {
7
+ "AED"=> "United Arab Emirates Dirham",
8
+ "AFN"=> "Afghan Afghani",
9
+ "ALL"=> "Albanian Lek",
10
+ "AMD"=> "Armenian Dram",
11
+ "ANG"=> "Netherlands Antillean Guilder",
12
+ "AOA"=> "Angolan Kwanza",
13
+ "ARS"=> "Argentine Peso",
14
+ "AUD"=> "Australian Dollar",
15
+ "AWG"=> "Aruban Florin",
16
+ "AZN"=> "Azerbaijani Manat",
17
+ "BAM"=> "Bosnia-Herzegovina Convertible Mark",
18
+ "BBD"=> "Barbadian Dollar",
19
+ "BDT"=> "Bangladeshi Taka",
20
+ "BGN"=> "Bulgarian Lev",
21
+ "BHD"=> "Bahraini Dinar",
22
+ "BIF"=> "Burundian Franc",
23
+ "BMD"=> "Bermudan Dollar",
24
+ "BND"=> "Brunei Dollar",
25
+ "BOB"=> "Bolivian Boliviano",
26
+ "BRL"=> "Brazilian Real",
27
+ "BSD"=> "Bahamian Dollar",
28
+ "BTC"=> "Bitcoin",
29
+ "BTN"=> "Bhutanese Ngultrum",
30
+ "BWP"=> "Botswanan Pula",
31
+ "BYR"=> "Belarusian Ruble",
32
+ "BZD"=> "Belize Dollar",
33
+ "CAD"=> "Canadian Dollar",
34
+ "CDF"=> "Congolese Franc",
35
+ "CHF"=> "Swiss Franc",
36
+ "CLF"=> "Chilean Unit of Account (UF)",
37
+ "CLP"=> "Chilean Peso",
38
+ "CNY"=> "Chinese Yuan",
39
+ "COP"=> "Colombian Peso",
40
+ "CRC"=> "Costa Rican Colon",
41
+ "CUP"=> "Cuban Peso",
42
+ "CVE"=> "Cape Verdean Escudo",
43
+ "CZK"=> "Czech Republic Koruna",
44
+ "DJF"=> "Djiboutian Franc",
45
+ "DKK"=> "Danish Krone",
46
+ "DOP"=> "Dominican Peso",
47
+ "DZD"=> "Algerian Dinar",
48
+ "EEK"=> "Estonian Kroon",
49
+ "EGP"=> "Egyptian Pound",
50
+ "ETB"=> "Ethiopian Birr",
51
+ "EUR"=> "Euro",
52
+ "FJD"=> "Fijian Dollar",
53
+ "FKP"=> "Falkland Islands Pound",
54
+ "GBP"=> "British Pound Sterling",
55
+ "GEL"=> "Georgian Lari",
56
+ "GHS"=> "Ghanaian Cedi",
57
+ "GIP"=> "Gibraltar Pound",
58
+ "GMD"=> "Gambian Dalasi",
59
+ "GNF"=> "Guinean Franc",
60
+ "GTQ"=> "Guatemalan Quetzal",
61
+ "GYD"=> "Guyanaese Dollar",
62
+ "HKD"=> "Hong Kong Dollar",
63
+ "HNL"=> "Honduran Lempira",
64
+ "HRK"=> "Croatian Kuna",
65
+ "HTG"=> "Haitian Gourde",
66
+ "HUF"=> "Hungarian Forint",
67
+ "IDR"=> "Indonesian Rupiah",
68
+ "ILS"=> "Israeli New Sheqel",
69
+ "INR"=> "Indian Rupee",
70
+ "IQD"=> "Iraqi Dinar",
71
+ "IRR"=> "Iranian Rial",
72
+ "ISK"=> "Icelandic Krona",
73
+ "JEP"=> "Jersey Pound",
74
+ "JMD"=> "Jamaican Dollar",
75
+ "JOD"=> "Jordanian Dinar",
76
+ "JPY"=> "Japanese Yen",
77
+ "KES"=> "Kenyan Shilling",
78
+ "KGS"=> "Kyrgystani Som",
79
+ "KHR"=> "Cambodian Riel",
80
+ "KMF"=> "Comorian Franc",
81
+ "KPW"=> "North Korean Won",
82
+ "KRW"=> "South Korean Won",
83
+ "KWD"=> "Kuwaiti Dinar",
84
+ "KYD"=> "Cayman Islands Dollar",
85
+ "KZT"=> "Kazakhstani Tenge",
86
+ "LAK"=> "Laotian Kip",
87
+ "LBP"=> "Lebanese Pound",
88
+ "LKR"=> "Sri Lankan Rupee",
89
+ "LRD"=> "Liberian Dollar",
90
+ "LSL"=> "Lesotho Loti",
91
+ "LTL"=> "Lithuanian Litas",
92
+ "LVL"=> "Latvian Lats",
93
+ "LYD"=> "Libyan Dinar",
94
+ "MAD"=> "Moroccan Dirham",
95
+ "MDL"=> "Moldovan Leu",
96
+ "MGA"=> "Malagasy Ariary",
97
+ "MKD"=> "Macedonian Denar",
98
+ "MMK"=> "Myanma Kyat",
99
+ "MNT"=> "Mongolian Tugrik",
100
+ "MOP"=> "Macanese Pataca",
101
+ "MRO"=> "Mauritanian Ouguiya",
102
+ "MTL"=> "Maltese Lira",
103
+ "MUR"=> "Mauritian Rupee",
104
+ "MVR"=> "Maldivian Rufiyaa",
105
+ "MWK"=> "Malawian Kwacha",
106
+ "MXN"=> "Mexican Peso",
107
+ "MYR"=> "Malaysian Ringgit",
108
+ "MZN"=> "Mozambican Metical",
109
+ "NAD"=> "Namibian Dollar",
110
+ "NGN"=> "Nigerian Naira",
111
+ "NIO"=> "Nicaraguan Cordoba",
112
+ "NOK"=> "Norwegian Krone",
113
+ "NPR"=> "Nepalese Rupee",
114
+ "NZD"=> "New Zealand Dollar",
115
+ "OMR"=> "Omani Rial",
116
+ "PAB"=> "Panamanian Balboa",
117
+ "PEN"=> "Peruvian Nuevo Sol",
118
+ "PGK"=> "Papua New Guinean Kina",
119
+ "PHP"=> "Philippine Peso",
120
+ "PKR"=> "Pakistani Rupee",
121
+ "PLN"=> "Polish Zloty",
122
+ "PYG"=> "Paraguayan Guarani",
123
+ "QAR"=> "Qatari Rial",
124
+ "RON"=> "Romanian Leu",
125
+ "RSD"=> "Serbian Dinar",
126
+ "RUB"=> "Russian Ruble",
127
+ "RWF"=> "Rwandan Franc",
128
+ "SAR"=> "Saudi Riyal",
129
+ "SBD"=> "Solomon Islands Dollar",
130
+ "SCR"=> "Seychellois Rupee",
131
+ "SDG"=> "Sudanese Pound",
132
+ "SEK"=> "Swedish Krona",
133
+ "SGD"=> "Singapore Dollar",
134
+ "SHP"=> "Saint Helena Pound",
135
+ "SLL"=> "Sierra Leonean Leone",
136
+ "SOS"=> "Somali Shilling",
137
+ "SRD"=> "Surinamese Dollar",
138
+ "STD"=> "Sao Tome and Principe Dobra",
139
+ "SVC"=> "Salvadoran Colon",
140
+ "SYP"=> "Syrian Pound",
141
+ "SZL"=> "Swazi Lilangeni",
142
+ "THB"=> "Thai Baht",
143
+ "TJS"=> "Tajikistani Somoni",
144
+ "TMT"=> "Turkmenistani Manat",
145
+ "TND"=> "Tunisian Dinar",
146
+ "TOP"=> "Tongan Paanga",
147
+ "TRY"=> "Turkish Lira",
148
+ "TTD"=> "Trinidad and Tobago Dollar",
149
+ "TWD"=> "New Taiwan Dollar",
150
+ "TZS"=> "Tanzanian Shilling",
151
+ "UAH"=> "Ukrainian Hryvnia",
152
+ "UGX"=> "Ugandan Shilling",
153
+ "USD"=> "United States Dollar",
154
+ "UYU"=> "Uruguayan Peso",
155
+ "UZS"=> "Uzbekistan Som",
156
+ "VEF"=> "Venezuelan Bolivar Fuerte",
157
+ "VND"=> "Vietnamese Dong",
158
+ "VUV"=> "Vanuatu Vatu",
159
+ "WST"=> "Samoan Tala",
160
+ "XAF"=> "CFA Franc BEAC",
161
+ "XAG"=> "Silver (troy ounce)",
162
+ "XAU"=> "Gold (troy ounce)",
163
+ "XCD"=> "East Caribbean Dollar",
164
+ "XDR"=> "Special Drawing Rights",
165
+ "XOF"=> "CFA Franc BCEAO",
166
+ "XPF"=> "CFP Franc",
167
+ "YER"=> "Yemeni Rial",
168
+ "ZAR"=> "South African Rand",
169
+ "ZMK"=> "Zambian Kwacha (pre-2013)",
170
+ "ZMW"=> "Zambian Kwacha",
171
+ "ZWL"=> "Zimbabwean Dollar"
172
+ }
173
+
174
+ def get_code(country)
175
+ CURRENCY_CODES.each do |k, v|
176
+ if v.downcase.include?(country.downcase)
177
+ return k
178
+ end
179
+ end
180
+ return "Invalid country name"
181
+ end
182
+ end
@@ -0,0 +1,3 @@
1
+ module CurrencyWiz
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require_relative '../lib/currency_wiz.rb'
4
+
5
+ describe CurrencyWiz do
6
+
7
+ describe "#get_code" do
8
+ it "should return the currency code given a country's name" do
9
+ CurrencyWiz.get_code("United States").should eq ("USD")
10
+ CurrencyWiz.get_code("taiwan").should eq("TWD")
11
+ end
12
+
13
+ it "should return 'Invalid country name' if country does not exist" do
14
+ CurrencyWiz.get_code("Apple").should eq("Invalid country name")
15
+ CurrencyWiz.get_code("ruby").should eq("Invalid country name")
16
+ end
17
+ end
18
+
19
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: currency_wiz
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Scott Chiang
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: A gem to get the current exchange rate. Sign up for an API key at https://openexchangerates.org/
63
+ email:
64
+ - scott.chiang1@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - currency_wiz.gemspec
75
+ - lib/currency_wiz.rb
76
+ - lib/currency_wiz/version.rb
77
+ - rspec/currency_wiz_spec.rb
78
+ homepage: https://github.com/scottchiang/currency_wiz
79
+ licenses:
80
+ - MIT
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 1.8.25
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: Get the current exchange rate.
103
+ test_files: []