currency_coin_converter 0.2.2 → 0.2.4
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +1 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +3 -1
- data/README.md +17 -10
- data/currency_coin_converter.gemspec +2 -2
- data/lib/currency_coin_converter/version.rb +1 -1
- data/lib/currency_coin_converter.rb +2 -1
- data/spec/currency_coin_converter_spec.rb +5 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d1075c2ccce1bb397d4a219bcecd2d60c291eec8d73825119763781b67e9c63
|
4
|
+
data.tar.gz: a7ba25a815b3008c7df632099b8b6e29e87f0c8f768cbf8e69d6739c67d652cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a612e5347ed886e5768fbc2b332e0987482573562aba0650c47fdc3a9624aed17769ea5a323934cb8620d5cbc77acfdc9ecc8f0d223d1da828c5f2ff3be7318c
|
7
|
+
data.tar.gz: 25307919d3ee45aad6159c1e8b420fde3f5e58b4d201a261ce301db64eab19da32c936c9172e10778f3c417943db945be5f19f043996a6897b9f67bef15c6c4c
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
currency_coin_converter (0.
|
4
|
+
currency_coin_converter (0.2.2)
|
5
5
|
httparty (~> 0.18)
|
6
6
|
|
7
7
|
GEM
|
@@ -9,6 +9,7 @@ GEM
|
|
9
9
|
specs:
|
10
10
|
bigdecimal (3.1.8)
|
11
11
|
csv (3.3.0)
|
12
|
+
dotenv (3.1.2)
|
12
13
|
httparty (0.22.0)
|
13
14
|
csv
|
14
15
|
mini_mime (>= 1.0.0)
|
@@ -23,6 +24,7 @@ PLATFORMS
|
|
23
24
|
|
24
25
|
DEPENDENCIES
|
25
26
|
currency_coin_converter!
|
27
|
+
dotenv
|
26
28
|
httparty
|
27
29
|
rake (~> 13.0)
|
28
30
|
|
data/README.md
CHANGED
@@ -6,26 +6,33 @@ Install the gem and add to the application's Gemfile by executing:
|
|
6
6
|
$ bundle add currency_coin_converter
|
7
7
|
|
8
8
|
Or add in your Gemfile
|
9
|
-
|
9
|
+
```
|
10
|
+
gem 'currency_coin_converter'
|
11
|
+
```
|
10
12
|
Run in console
|
11
|
-
|
13
|
+
```
|
14
|
+
bundle install
|
15
|
+
```
|
12
16
|
|
13
17
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
14
18
|
|
15
19
|
$ gem install currency_coin_converter
|
16
20
|
|
17
21
|
## Usage
|
22
|
+
To use this gem, you need to set up an environment variable for the Exchange Rate API key:
|
18
23
|
|
19
|
-
|
24
|
+
```bash
|
25
|
+
export EXCHANGE_RATE_API_KEY='your_api_key_here'
|
26
|
+
```
|
27
|
+
<br>
|
20
28
|
|
21
|
-
|
22
|
-
|
29
|
+
In your main file you can use
|
30
|
+
```
|
31
|
+
require 'currency_coin_converter'
|
23
32
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
33
|
+
amount_in_euros = CurrencyCoinConverter.convert(100, from: "USD", to: "EUR")
|
34
|
+
puts amount_in_euros
|
35
|
+
```
|
29
36
|
|
30
37
|
## Contributing
|
31
38
|
|
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["Fernanda de Jesus"]
|
9
9
|
spec.email = ["fernandabussular@gmail.com"]
|
10
10
|
|
11
|
-
spec.summary = "
|
12
|
-
spec.description = "
|
11
|
+
spec.summary = "A gem for currency conversion using the ExchangeRate API."
|
12
|
+
spec.description = "This gem allows you to convert amounts between different currencies using the ExchangeRate API."
|
13
13
|
spec.homepage = 'https://github.com/bussularf/currency_coin_converter'
|
14
14
|
spec.license = "MIT"
|
15
15
|
spec.required_ruby_version = ">= 2.6.0"
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require_relative './currency_coin_converter/version'
|
2
2
|
require 'httparty'
|
3
|
+
require 'dotenv/load'
|
3
4
|
|
4
5
|
module CurrencyCoinConverter
|
5
6
|
class Error < StandardError; end
|
6
7
|
|
7
|
-
API_URL = "https://v6.exchangerate-api.com/v6/
|
8
|
+
API_URL = "https://v6.exchangerate-api.com/v6/#{ENV['EXCHANGE_RATE_API_KEY']}/latest/"
|
8
9
|
|
9
10
|
def self.convert(amount, from:, to:)
|
10
11
|
rates = fetch_rates(from)
|
@@ -1,7 +1,10 @@
|
|
1
|
-
# spec/currency_coin_converter_spec.rb
|
2
1
|
require 'currency_coin_converter'
|
3
2
|
|
4
3
|
RSpec.describe CurrencyCoinConverter do
|
4
|
+
before do
|
5
|
+
allow(ENV).to receive(:[]).with('EXCHANGE_RATE_API_KEY').and_return('fake_key')
|
6
|
+
end
|
7
|
+
|
5
8
|
it "converte corretamente entre duas moedas" do
|
6
9
|
allow(CurrencyCoinConverter).to receive(:fetch_rates).with("USD").and_return({"EUR" => 0.85})
|
7
10
|
|
@@ -9,3 +12,4 @@ RSpec.describe CurrencyCoinConverter do
|
|
9
12
|
expect(result).to eq(85.0)
|
10
13
|
end
|
11
14
|
end
|
15
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: currency_coin_converter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fernanda de Jesus
|
@@ -24,8 +24,8 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.18'
|
27
|
-
description:
|
28
|
-
|
27
|
+
description: This gem allows you to convert amounts between different currencies using
|
28
|
+
the ExchangeRate API.
|
29
29
|
email:
|
30
30
|
- fernandabussular@gmail.com
|
31
31
|
executables: []
|
@@ -72,5 +72,5 @@ requirements: []
|
|
72
72
|
rubygems_version: 3.4.10
|
73
73
|
signing_key:
|
74
74
|
specification_version: 4
|
75
|
-
summary:
|
75
|
+
summary: A gem for currency conversion using the ExchangeRate API.
|
76
76
|
test_files: []
|