exrates 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1659bbbd2fdd7cf649093aeaeb875ba389436b8e5926cdbde378ebd23f924a0
4
- data.tar.gz: d860447e7df0c895a351feb98cc83382ae3c83d4e6ad76ed5e0ff467c1ac5d85
3
+ metadata.gz: b607f2e746dcecb294367d6b0ab5ddae94be3dafaeb151157ed7c0ea64c1cf21
4
+ data.tar.gz: f158d53726bae2f0391885946f85430746896937ae60ce330dac6d4d76dc9328
5
5
  SHA512:
6
- metadata.gz: 160d2d7914a35d091578f70ef4fd06fc72888666e8e48d2046bb1cfb32197bf4cf53fd93157c86beed0003a7170570b6f18ea143deab51896ba11b086920488c
7
- data.tar.gz: 30ec35240a144bac726dc597f634d7d4857de9aec6608f193b1f9f89d4e543e24b4d7c50f6fadd65cb4e9ebfedbf63fa3f412c40306ba9abd29a2ae8ebfe3225
6
+ metadata.gz: 659ce3b8d0a9781eece278ac8eafcd46ad6a3d90318f58725ca08df945154b75678fd122c758a7442809bf8ac5b6c550c1aeab0c25800f3cf0d0946350127bb4
7
+ data.tar.gz: ce93974d5741d4356550a4861abf74453bac81664966507eb8f6a4f669a2b63069b380f84fa6b378d464316c7a98231d482778498adf33bbddcf5d41af608bfc
data/.gitignore CHANGED
@@ -7,4 +7,5 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
 
10
- .rspec_status
10
+ .rspec_status
11
+ *.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- exrates (0.1.0)
4
+ exrates (0.1.1)
5
5
  money (~> 6)
6
6
 
7
7
  GEM
@@ -36,5 +36,8 @@ DEPENDENCIES
36
36
  rake (~> 12.0)
37
37
  rspec (~> 3.0)
38
38
 
39
+ RUBY VERSION
40
+ ruby 2.7.6p219
41
+
39
42
  BUNDLED WITH
40
43
  2.1.4
@@ -4,4 +4,4 @@ cad = Money.new('1_50', 'CAD')
4
4
 
5
5
  result = ExRates.new.exchange(cad, 'USD')
6
6
 
7
- puts "1.5 USD -> CAD: #{result.format}"
7
+ puts "1.5 USD -> CAD: #{result.format}"
@@ -1,3 +1,3 @@
1
1
  class ExRates
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/exrates.rb CHANGED
@@ -11,7 +11,7 @@ class ExRates
11
11
 
12
12
  def initialize(date = Date.today)
13
13
  @refreshed_at = Time.now
14
-
14
+
15
15
  parse!(date)
16
16
  end
17
17
 
@@ -34,14 +34,14 @@ class ExRates
34
34
  url = "https://bank.gov.ua/NBU_Exchange/exchange?date=#{date_string}&json"
35
35
  response = URI.open(url).read
36
36
  json_doc = JSON.parse(response)
37
-
38
- result = json_doc.map do |node|
39
- [ node['CurrencyCodeL'], node['Amount'] ]
37
+
38
+ result = json_doc.map do |node|
39
+ [node['CurrencyCodeL'], node['Amount'] / node['Units']]
40
40
  end
41
41
 
42
42
  result.push(['UAH', 1])
43
-
43
+
44
44
  @rates = result.to_h
45
45
  end
46
46
 
47
- end
47
+ end
@@ -8,11 +8,15 @@ RSpec.describe ExRates do
8
8
  end
9
9
 
10
10
  describe '#rate' do
11
- it "returns currency's rate for certain date" do
11
+ it "returns currency rate of USD for certain date" do
12
12
  expect(rates.rate('USD')).to eq 36.5686
13
13
  end
14
+
15
+ it "returns currency rate of IRR for certain date" do
16
+ expect(rates.rate('IRR')).to eq 0.00069655
17
+ end
14
18
  end
15
-
19
+
16
20
  describe '#exchange' do
17
21
  it 'converts other currency into hryvnia' do
18
22
  usd = Money.new('1_00', 'USD')
@@ -26,8 +30,8 @@ RSpec.describe ExRates do
26
30
  aud = Money.new('1_50', 'AUD')
27
31
 
28
32
  result = rates.exchange(aud, 'USD')
29
-
33
+
30
34
  expect(result).to eq Money.new(83, 'USD')
31
35
  end
32
36
  end
33
- end
37
+ end
data/rspec/spec_helper.rb CHANGED
@@ -2,10 +2,10 @@ require 'bundler/setup'
2
2
 
3
3
  RSpec.configure do |config|
4
4
  config.example_status_persistence_file_path = ".rspec_status"
5
-
5
+
6
6
  config.disable_monkey_patching!
7
7
 
8
8
  config.expect_with :rspec do |c|
9
9
  c.syntax = :expect
10
10
  end
11
- end
11
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exrates
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maria Slashchilina
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-24 00:00:00.000000000 Z
11
+ date: 2022-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: money
@@ -42,7 +42,6 @@ files:
42
42
  - bin/setup
43
43
  - examples/usd_to_cad.rb
44
44
  - exrates.gemspec
45
- - lib/.DS_Store
46
45
  - lib/exrates.rb
47
46
  - lib/exrates/version.rb
48
47
  - rspec/exrates_spec.rb
data/lib/.DS_Store DELETED
Binary file