exchangerate_api_ruby 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fbe7771b1aa28edcc232103d1d249138f1a949a19a184f8d48af122738d6ed57
4
+ data.tar.gz: 39134635f9bfddb6dad215762a55d865b48f852b03c2c9776e0093837746a554
5
+ SHA512:
6
+ metadata.gz: 8a9cfdbdcf67f04d1ac5cf5a920653d5802229260d8ab8e5e0875886f2db30d1548e2884ea59b6c7d43a4fb6655a25bf8f38ad28eef176f4b40c5e492166f733
7
+ data.tar.gz: d946d4eb443464d516ae3e86437e731f4856bda71716ed7110ab3516c1aeb27b1b2136627328fc0e86d1cd9b55228bf79bdd30a1d0c9e37966cec9c8f05fa436
@@ -0,0 +1 @@
1
+ .DS_Store
data/CHANGES ADDED
@@ -0,0 +1 @@
1
+ 1.0.0 Initial Release
@@ -0,0 +1,76 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at andreimerlescu@protonmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
+
73
+ [homepage]: https://www.contributor-covenant.org
74
+
75
+ For answers to common questions about this code of conduct, see
76
+ https://www.contributor-covenant.org/faq
@@ -0,0 +1 @@
1
+ Open a pull request.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Merlescu Codez
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,301 @@
1
+ # ExhangeRate API Gem
2
+
3
+ Easily access the ExchangeRate API service with a gem that actually works.
4
+
5
+ ## Installation
6
+
7
+ Add this to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem 'exchangerate_api_ruby', '~> 1.0'
11
+ ```
12
+
13
+ Or install it locally to your system:
14
+
15
+ ```bash
16
+ gem install exchangerate_api_ruby
17
+ ```
18
+
19
+ ## Configuration
20
+
21
+ If you're using Rails, then add a new file `config/initializers/exchangerate_api_ruby.rb` with:
22
+
23
+ ```ruby
24
+ require 'exchangerate_api_ruby'
25
+ ExchangeRate.configure do |config|
26
+ config.api_key = "<api_key>"
27
+ end
28
+ ```
29
+
30
+ > Replace `<api_key>` with your access token, which can be found **[On ExchangeRate API](https://www.exchangerate-api.com/)**.
31
+
32
+ ## Usage
33
+
34
+ Make a request:
35
+
36
+ ```ruby
37
+ class BullionController < ActionController::Base
38
+
39
+ def index
40
+ @exchanges = ExchangeRate::API.fetch("USD")
41
+ end #/def
42
+
43
+ end #/class
44
+ ```
45
+
46
+ ## Response from API
47
+
48
+ Request `ExchangeRate::API.fetch("USD")` and you will return with the following type of result:
49
+
50
+ ```json
51
+ {
52
+ "result": "success",
53
+ "documentation": "https://www.exchangerate-api.com/docs",
54
+ "terms_of_use": "https://www.exchangerate-api.com/terms",
55
+ "time_last_update_unix": 1610323201,
56
+ "time_last_update_utc": "Mon, 11 Jan 2021 00:00:01 +0000",
57
+ "time_next_update_unix": 1610409616,
58
+ "time_next_update_utc": "Tue, 12 Jan 2021 00:00:16 +0000",
59
+ "base_code": "USD",
60
+ "conversion_rates": {
61
+ "USD": 1,
62
+ "AED": 3.6725,
63
+ "AFN": 77.1137,
64
+ "ALL": 100.8482,
65
+ "AMD": 522.7525,
66
+ "ANG": 1.79,
67
+ "AOA": 652.1647,
68
+ "ARS": 84.8427,
69
+ "AUD": 1.2896,
70
+ "AWG": 1.79,
71
+ "AZN": 1.6972,
72
+ "BAM": 1.5993,
73
+ "BBD": 2.0,
74
+ "BDT": 84.7385,
75
+ "BGN": 1.5991,
76
+ "BHD": 0.376,
77
+ "BIF": 1933.0206,
78
+ "BMD": 1.0,
79
+ "BND": 1.3242,
80
+ "BOB": 6.8721,
81
+ "BRL": 5.3782,
82
+ "BSD": 1.0,
83
+ "BTN": 73.3456,
84
+ "BWP": 10.8675,
85
+ "BYN": 2.5602,
86
+ "BZD": 2.0,
87
+ "CAD": 1.2691,
88
+ "CDF": 1972.1532,
89
+ "CHF": 0.886,
90
+ "CLP": 712.1382,
91
+ "CNY": 6.4719,
92
+ "COP": 3490.8059,
93
+ "CRC": 610.9705,
94
+ "CUC": 1.0,
95
+ "CUP": 25.0,
96
+ "CVE": 90.1648,
97
+ "CZK": 21.4684,
98
+ "DJF": 177.721,
99
+ "DKK": 6.1004,
100
+ "DOP": 58.1603,
101
+ "DZD": 132.0685,
102
+ "EGP": 15.6751,
103
+ "ERN": 15.0,
104
+ "ETB": 39.4011,
105
+ "EUR": 0.8178,
106
+ "FJD": 2.011,
107
+ "FKP": 0.7376,
108
+ "FOK": 6.1004,
109
+ "GBP": 0.7376,
110
+ "GEL": 3.3022,
111
+ "GGP": 0.7376,
112
+ "GHS": 5.8496,
113
+ "GIP": 0.7376,
114
+ "GMD": 52.0183,
115
+ "GNF": 10259.567,
116
+ "GTQ": 7.7873,
117
+ "GYD": 212.9611,
118
+ "HKD": 7.7553,
119
+ "HNL": 24.1025,
120
+ "HRK": 6.161,
121
+ "HTG": 72.0307,
122
+ "HUF": 295.5243,
123
+ "IDR": 14116.4758,
124
+ "ILS": 3.2107,
125
+ "IMP": 0.7376,
126
+ "INR": 73.3463,
127
+ "IQD": 1460.451,
128
+ "IRR": 42126.1812,
129
+ "ISK": 126.8764,
130
+ "JMD": 142.2029,
131
+ "JOD": 0.709,
132
+ "JPY": 103.9528,
133
+ "KES": 109.3873,
134
+ "KGS": 83.2448,
135
+ "KHR": 4052.1922,
136
+ "KID": 1.2894,
137
+ "KMF": 402.287,
138
+ "KRW": 1093.414,
139
+ "KWD": 0.2996,
140
+ "KYD": 0.8333,
141
+ "KZT": 419.0247,
142
+ "LAK": 9293.5588,
143
+ "LBP": 1507.5,
144
+ "LKR": 186.9689,
145
+ "LRD": 166.6719,
146
+ "LSL": 15.2899,
147
+ "LYD": 4.4398,
148
+ "MAD": 8.8071,
149
+ "MDL": 17.1775,
150
+ "MGA": 3785.7674,
151
+ "MKD": 50.2014,
152
+ "MMK": 1326.5885,
153
+ "MNT": 2849.0028,
154
+ "MOP": 7.9879,
155
+ "MRU": 36.8161,
156
+ "MUR": 39.4817,
157
+ "MVR": 15.3499,
158
+ "MWK": 770.9804,
159
+ "MXN": 20.0388,
160
+ "MYR": 4.028,
161
+ "MZN": 74.3672,
162
+ "NAD": 15.2899,
163
+ "NGN": 384.9229,
164
+ "NIO": 34.8315,
165
+ "NOK": 8.4271,
166
+ "NPR": 117.353,
167
+ "NZD": 1.3827,
168
+ "OMR": 0.3845,
169
+ "PAB": 1.0,
170
+ "PEN": 3.6168,
171
+ "PGK": 3.5129,
172
+ "PHP": 48.1373,
173
+ "PKR": 160.069,
174
+ "PLN": 3.6954,
175
+ "PYG": 6928.4254,
176
+ "QAR": 3.64,
177
+ "RON": 3.9679,
178
+ "RSD": 95.9664,
179
+ "RUB": 74.2139,
180
+ "RWF": 988.0752,
181
+ "SAR": 3.75,
182
+ "SBD": 8.0021,
183
+ "SCR": 21.1564,
184
+ "SDG": 55.1146,
185
+ "SEK": 8.2305,
186
+ "SGD": 1.3239,
187
+ "SHP": 0.7376,
188
+ "SLL": 10175.0102,
189
+ "SOS": 578.7037,
190
+ "SRD": 14.1579,
191
+ "SSP": 175.3938,
192
+ "STN": 20.0339,
193
+ "SYP": 519.9499,
194
+ "SZL": 15.2899,
195
+ "THB": 30.2021,
196
+ "TJS": 11.3048,
197
+ "TMT": 3.4996,
198
+ "TND": 2.671,
199
+ "TOP": 2.2382,
200
+ "TRY": 7.3572,
201
+ "TTD": 6.7825,
202
+ "TVD": 1.2894,
203
+ "TWD": 27.9259,
204
+ "TZS": 2311.1391,
205
+ "UAH": 28.2427,
206
+ "UGX": 3682.2818,
207
+ "UYU": 42.3445,
208
+ "UZS": 10456.5505,
209
+ "VES": 1429072.0331,
210
+ "VND": 23097.9631,
211
+ "VUV": 108.6442,
212
+ "WST": 2.4741,
213
+ "XAF": 536.3826,
214
+ "XCD": 2.7,
215
+ "XDR": 0.6931,
216
+ "XOF": 536.3826,
217
+ "XPF": 97.579,
218
+ "YER": 250.1264,
219
+ "ZAR": 15.2899,
220
+ "ZMW": 21.1561
221
+ }
222
+ }
223
+ ```
224
+
225
+
226
+ ## Testing
227
+
228
+ ```bash
229
+ ruby spec/exchangerate_api_ruby_spec.rb
230
+ ```
231
+
232
+ Expected output should be:
233
+
234
+ ```
235
+ Run options: --seed 46441
236
+
237
+ # Running:
238
+
239
+ .
240
+
241
+ Finished in 0.204663s, 4.8861 runs/s, 4.8861 assertions/s.
242
+ 1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
243
+ ```
244
+
245
+ ## Errors
246
+
247
+ If you are missing the `api_key`, then if you attempt to run the tests, you might get the following kind of output:
248
+
249
+ ```
250
+ Run options: --seed 59022
251
+
252
+ # Running:
253
+
254
+ E
255
+
256
+ Error:
257
+ ExchangeRate::Interact with ExchangeRate-API.com#test_0001_should return the current exchange rates for USD:
258
+ URI::InvalidURIError: bad URI(is not URI?): "https://v6.exchangerate-api.com/v6/<your_api_key>/latest/USD"
259
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/2.6.0/uri/rfc3986_parser.rb:67:in `split'
260
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/2.6.0/uri/rfc3986_parser.rb:73:in `parse'
261
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/2.6.0/uri/common.rb:234:in `parse'
262
+ /Users/username/workspace/exchangerate-api/lib/exchangerate_api/api.rb:12:in `fetch'
263
+ spec/exchangerate_api_ruby_spec.rb:14:in `block (3 levels) in <main>'
264
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest/test.rb:98:in `block (3 levels) in run'
265
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest/test.rb:195:in `capture_exceptions'
266
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest/test.rb:95:in `block (2 levels) in run'
267
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest.rb:272:in `time_it'
268
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest/test.rb:94:in `block in run'
269
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest.rb:367:in `on_signal'
270
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest/test.rb:211:in `with_info_handler'
271
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest/test.rb:93:in `run'
272
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest.rb:1029:in `run_one_method'
273
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest.rb:341:in `run_one_method'
274
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest.rb:328:in `block (2 levels) in run'
275
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest.rb:327:in `each'
276
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest.rb:327:in `block in run'
277
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest.rb:367:in `on_signal'
278
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest.rb:354:in `with_info_handler'
279
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest.rb:326:in `run'
280
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest.rb:164:in `block in __run'
281
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest.rb:164:in `map'
282
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest.rb:164:in `__run'
283
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest.rb:141:in `run'
284
+ /Users/username/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/minitest-5.14.2/lib/minitest.rb:68:in `block in autorun'
285
+
286
+
287
+ rails test spec/exchangerate_api_ruby_spec.rb:13
288
+
289
+
290
+
291
+ Finished in 0.001091s, 916.5902 runs/s, 0.0000 assertions/s.
292
+ 1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
293
+ ```
294
+
295
+ ## Credit
296
+
297
+ This gem was created by [Andrei Merlescu](https://github.com/sponsors/patriotphoenix).
298
+
299
+ ## License
300
+
301
+ [MIT License](LICENSE)
@@ -0,0 +1,18 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Use this section to tell people about which versions of your project are
6
+ currently being supported with security updates.
7
+
8
+ | Version | Supported |
9
+ | ------- | ------------------ |
10
+ | > 1.0.1 | :x: |
11
+
12
+ ## Reporting a Vulnerability
13
+
14
+ Use this section to tell people how to report a vulnerability.
15
+
16
+ Tell them where to go, how often they can expect to get an update on a
17
+ reported vulnerability, what to expect if the vulnerability is accepted or
18
+ declined, etc.
@@ -0,0 +1,17 @@
1
+ # require File.expand_path('../lib/exchangerate_api_ruby/version', __FILE__)
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "exchangerate_api_ruby/version"
4
+
5
+
6
+ Gem::Specification.new do |s|
7
+ s.authors = ["Andrei Merlescu"]
8
+ s.email = ["andrei+github@merlescu.net"]
9
+ s.description = s.summary = "Simple interface to access ExchangeRate-API.com"
10
+ s.homepage = "https://github.com/amerlescucodez/exchangerate_api_ruby"
11
+ s.license = "MIT"
12
+ s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
13
+ s.name = "exchangerate_api_ruby"
14
+ s.require_paths = ["lib"]
15
+ s.version = ExchangeRate::VERSION
16
+ s.add_runtime_dependency 'logging', '~> 2.2', '>= 2.2.2'
17
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+ require 'logging'
3
+
4
+ module ExchangeRate
5
+ end
6
+
7
+ begin
8
+ require 'rails'
9
+ rescue LoadError
10
+ # do nothing
11
+ end #/begin-rescue
12
+
13
+ require_relative 'exchangerate_api_ruby/config'
14
+ require_relative 'exchangerate_api_ruby/logger'
15
+ require_relative 'exchangerate_api_ruby/api'
16
+
17
+ if defined? ::Rails::Railtie
18
+ require_relative 'exchangerate_api_ruby/railtie'
19
+ end #/if
@@ -0,0 +1,36 @@
1
+ require 'net/http'
2
+ require 'json'
3
+ require_relative "consts"
4
+
5
+ module ExchangeRate
6
+ class API
7
+ class << self
8
+ def fetch currency
9
+ raise ArgumentError, "missing currency argument" if currency.nil?
10
+ raise ArgumentError, "invalid currency argument" unless EXCHANGERATE_API_CURRENCY_CODES.keys.include?(currency)
11
+
12
+ uri = URI.parse("https://v6.exchangerate-api.com/v6/#{ExchangeRate.config.api_key}/latest/#{currency.upcase}")
13
+
14
+ response = nil
15
+ result = nil
16
+ Net::HTTP.start(uri.host, uri.port, use_ssl: ExchangeRate.config.use_ssl) do |http|
17
+ req = Net::HTTP::Get.new(uri)
18
+ req['Content-Type'] = 'application/json'
19
+ response = http.request(req)
20
+ result = response&.body
21
+ end #/block
22
+
23
+ {
24
+ success: response.instance_of?(Net::HTTPOK),
25
+ response: response,
26
+ result: JSON.parse(result)
27
+ }
28
+ rescue
29
+ {
30
+ success: false,
31
+ response: nil
32
+ }
33
+ end #/def
34
+ end #/class
35
+ end #/class
36
+ end #/class
@@ -0,0 +1,21 @@
1
+ module ExchangeRate
2
+ class << self
3
+ def configure
4
+ yield config
5
+ end #/def
6
+
7
+ def config
8
+ @_config ||= Config.new
9
+ end #/def
10
+ end #/class
11
+
12
+ class Config
13
+ attr_accessor :api_key
14
+ attr_accessor :use_ssl
15
+
16
+ def initialize
17
+ @api_key = nil
18
+ @use_ssl = true
19
+ end #/def
20
+ end #/class
21
+ end #/module
@@ -0,0 +1,74 @@
1
+ EXCHANGERATE_API_CURRENCY_CODES = {
2
+ 'AED' => { name: 'UAE Dirham', countries: ['United Arab Emirates'] },
3
+ 'ARS' => { name: 'Argentine Peso', countries: ['Argentina'] },
4
+ 'AUD' => { name: 'Australian Dollar', countries: ['Australia'] },
5
+ 'BGN' => { name: 'Bulgarian Lev', countries: ['Bulgaria'] },
6
+ 'BRL' => { name: 'Brazilian Real', countries: ['Brazil'] },
7
+ 'BSD' => { name: 'Bahamian Dollar', countries: ['Bahamas'] },
8
+ 'CAD' => { name: 'Canadian Dollar', countries: ['Canada'] },
9
+ 'CHF' => { name: 'Swiss Franc', countries: ['Switzerland'] },
10
+ 'CLP' => { name: 'Chilean Peso', countries: ['Chile'] },
11
+ 'CNY' => { name: 'Chinese Renminbi', countries: ['China'] },
12
+ 'COP' => { name: 'Colombian Peso', countries: ['Colombia'] },
13
+ 'CZK' => { name: 'Czech Koruna', countries: ['Czech Republic'] },
14
+ 'DKK' => { name: 'Danish Krone', countries: ['Denmark'] },
15
+ 'DOP' => { name: 'Dominican Peso', countries: ['Dominican Republic'] },
16
+ 'EGP' => { name: 'Egyptian Pound', countries: ['Egypt'] },
17
+ 'EUR' =>
18
+ { name: 'Euro',
19
+ countries: %w[Germany
20
+ Austria
21
+ Belgium
22
+ Cyprus
23
+ Estonia
24
+ Finland
25
+ France
26
+ Greece
27
+ Ireland
28
+ Italy
29
+ Latvia
30
+ Lithuania
31
+ Luxembourg
32
+ Malta
33
+ Netherlands
34
+ Portugal
35
+ Slovakia
36
+ Slovenia
37
+ Spain] },
38
+ 'FJD' => { name: 'Fiji Dollar', countries: ['Fiji'] },
39
+ 'GBP' => { name: 'Pound Sterling', countries: ['United Kingdom'] },
40
+ 'GTQ' => { name: 'Guatemalan Quetzal', countries: ['Guatemala'] },
41
+ 'HKD' => { name: 'Hong Kong Dollar', countries: ['Hong Kong'] },
42
+ 'HRK' => { name: 'Croatian Kuna', countries: ['Croatian'] },
43
+ 'HUF' => { name: 'Hungarian Forint', countries: ['Hungary'] },
44
+ 'IDR' => { name: 'Indonesian Rupiah', countries: ['Indonesia'] },
45
+ 'ILS' => { name: 'Israeli Shekel', countries: ['Israel'] },
46
+ 'INR' => { name: 'Indian Rupee', countries: ['India'] },
47
+ 'ISK' => { name: 'Icelandic Krona', countries: ['Iceland'] },
48
+ 'JPY' => { name: 'Japanese Yen', countries: ['Japan'] },
49
+ 'KRW' => { name: 'South Korean Won', countries: ['Korea'] },
50
+ 'KZT' => { name: 'Kazakhstani Tenge', countries: ['Kazakhstan'] },
51
+ 'MXN' => { name: 'Mexican Peso', countries: ['Mexico'] },
52
+ 'MYR' => { name: 'Malaysian Ringgit', countries: ['Malaysia'] },
53
+ 'NOK' => { name: 'Norwegian Krone', countries: ['Norway'] },
54
+ 'NZD' => { name: 'New Zealand Dollar', countries: ['New Zealand'] },
55
+ 'PAB' => { name: 'Panamanian Balboa', countries: ['Panama'] },
56
+ 'PEN' => { name: 'Peruvian Nuevo Sol', countries: ['Peru'] },
57
+ 'PHP' => { name: 'Philippine Peso', countries: ['Philippines'] },
58
+ 'PKR' => { name: 'Pakistani Rupee', countries: ['Pakistan'] },
59
+ 'PLN' => { name: 'Polish Zloty', countries: ['Poland'] },
60
+ 'PYG' => { name: 'Paraguayan Guarani', countries: ['Paraguay'] },
61
+ 'RON' => { name: 'Romanian Leu', countries: ['Romania'] },
62
+ 'RUB' => { name: 'Russian Ruble', countries: ['Russian Federation'] },
63
+ 'SAR' => { name: 'Saudi Riyal', countries: ['Saudi Arabia'] },
64
+ 'SEK' => { name: 'Swedish Krona', countries: ['Sweden'] },
65
+ 'SGD' => { name: 'Singapore Dollar', countries: ['Singapore'] },
66
+ 'THB' => { name: 'Thai Baht', countries: ['Thailand'] },
67
+ 'TRY' => { name: 'Turkish Lira', countries: ['Turkey'] },
68
+ 'TWD' => { name: 'New Taiwan Dollar', countries: ['Taiwan'] },
69
+ 'UAH' => { name: 'Ukrainian Hryvnia', countries: ['Ukraine'] },
70
+ 'USD' => { name: 'US Dollar', countries: ['United States'] },
71
+ 'UYU' => { name: 'Uruguayan Peso', countries: ['Uruguay'] },
72
+ 'VND' => { name: 'Vietnamese Dong', countries: ['Vietnam'] },
73
+ 'ZAR' => { name: 'South African Rand', countries: ['South Africa'] }
74
+ }
@@ -0,0 +1,10 @@
1
+ require 'logging'
2
+ module ExchangeRate
3
+ class << self
4
+ def logger
5
+ @logger ||= Logging.logger(STDOUT)
6
+ @logger.level = :warn
7
+ return @logger
8
+ end #/def
9
+ end #/class
10
+ end #/module
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ExchangeRate
4
+ class Railtie < ::Rails::Railtie #:nodoc:
5
+ # Doesn't actually do anything. Just keeping this hook point, mainly for compatibility
6
+ initializer 'exchangerate_api_ruby' do
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ExchangeRate
4
+ VERSION = '1.0.0'
5
+ end #/module
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exchangerate_api_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrei Merlescu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-01-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logging
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.2'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.2.2
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.2'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.2.2
33
+ description: Simple interface to access ExchangeRate-API.com
34
+ email:
35
+ - andrei+github@merlescu.net
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - ".gitignore"
41
+ - CHANGES
42
+ - CODE_OF_CONDUCT.md
43
+ - CONTRIBUTING.md
44
+ - LICENSE
45
+ - README.md
46
+ - SECURITY.md
47
+ - exchangerate_api_ruby.gemspec
48
+ - lib/exchangerate_api_ruby.rb
49
+ - lib/exchangerate_api_ruby/api.rb
50
+ - lib/exchangerate_api_ruby/config.rb
51
+ - lib/exchangerate_api_ruby/consts.rb
52
+ - lib/exchangerate_api_ruby/logger.rb
53
+ - lib/exchangerate_api_ruby/railtie.rb
54
+ - lib/exchangerate_api_ruby/version.rb
55
+ homepage: https://github.com/amerlescucodez/exchangerate_api_ruby
56
+ licenses:
57
+ - MIT
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubygems_version: 3.0.3
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Simple interface to access ExchangeRate-API.com
78
+ test_files: []