fafx 0.1.2 → 0.1.5

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
  SHA1:
3
- metadata.gz: ac94bcd60e427e6278a8e556d2c93b7e29bc8775
4
- data.tar.gz: b89876e35bb697d9c3c5c90a4086f85a2737b074
3
+ metadata.gz: d27dba1cc52f91715a859be62830bc5be449bcdf
4
+ data.tar.gz: ce559df98ee8bfd2bd657e0ee44c1f3ae43201cb
5
5
  SHA512:
6
- metadata.gz: 06a38db8b00a0512ba636c73669704f33e803f05b501e51f8cd9065b749ba79ff4924d8d5c9c804ce8a99b385d75304e852465140f8e1cbc4ab06ef75fbfe74c
7
- data.tar.gz: 5cce51dd705027f9893ec9ce160435c068e73da8466bedefc8261a42e0d9616cfaca5741072ab99fd68feaba311f3a52380f5228dd990c121fa0b832c776d786
6
+ metadata.gz: 4faa51d02cea954fa5df14d04da9a5ced884ae6d1b28fd1361b9af47adaba2330a401454f3e029c8ace7354d4f4df53775f706f923cd710e78ca1c7194e01f2d
7
+ data.tar.gz: a242ca6e26616879c051ba4910d79fbe6e920539b4642cc52ed8d75c535d5af2049b6ed817ba50647e88b71afdeafbff856c2616e817d401fb52a8ddfc9ac8c1
data/Gemfile.lock CHANGED
@@ -1,16 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fafx (0.1.1)
5
- nokogiri (~> 1.8.2)
4
+ fafx (0.1.5)
5
+ nokogiri (~> 1.8, >= 1.8.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  diff-lcs (1.3)
11
- mini_portile2 (2.3.0)
12
- nokogiri (1.8.2)
13
- mini_portile2 (~> 2.3.0)
11
+ mini_portile2 (2.4.0)
12
+ nokogiri (1.9.1)
13
+ mini_portile2 (~> 2.4.0)
14
14
  rake (10.5.0)
15
15
  rspec (3.7.0)
16
16
  rspec-core (~> 3.7.0)
data/lib/fafx.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'fafx/version'
2
2
  require 'fafx/core'
3
3
  require 'fafx/data_fetcher'
4
- require 'fafx/date_error'
4
+ require 'fafx/date_handler'
5
+ require 'fafx/error'
5
6
  require 'fafx/exchange_rate'
@@ -0,0 +1,20 @@
1
+ module DateHandler
2
+ def get(date)
3
+ raise Fafx::DateError, 'Not a valid Date object' unless date.class == Date
4
+ handle_weekend(date).to_s
5
+ end
6
+
7
+ private
8
+
9
+ def handle_weekend(date)
10
+ case date.wday
11
+ when 6 # Saturday
12
+ date -= 1
13
+ when 0 # Sunday
14
+ date -= 2
15
+ end
16
+ date
17
+ end
18
+
19
+ module_function :get, :handle_weekend
20
+ end
File without changes
@@ -1,16 +1,10 @@
1
1
  module Fafx
2
2
  module ExchangeRate
3
3
  def at(date, base, other)
4
- case date.wday
5
- when 6 # Saturday
6
- date -= 1
7
- when 0 # Sunday
8
- date -= 2
9
- end
10
-
4
+ date = DateHandler.get(date)
11
5
  ex_rates = Core.new
12
- base = ex_rates.rates_at(date.to_s, base)
13
- other = ex_rates.rates_at(date.to_s, other)
6
+ base = ex_rates.rates_at(date, base)
7
+ other = ex_rates.rates_at(date, other)
14
8
  other / base
15
9
  end
16
10
 
data/lib/fafx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fafx
2
- VERSION = '0.1.2'.freeze
2
+ VERSION = '0.1.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fafx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Kair
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-15 00:00:00.000000000 Z
11
+ date: 2019-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -95,7 +95,8 @@ files:
95
95
  - lib/fafx.rb
96
96
  - lib/fafx/core.rb
97
97
  - lib/fafx/data_fetcher.rb
98
- - lib/fafx/date_error.rb
98
+ - lib/fafx/date_handler.rb
99
+ - lib/fafx/error.rb
99
100
  - lib/fafx/exchange_rate.rb
100
101
  - lib/fafx/version.rb
101
102
  homepage: https://github.com/frankkair/fafx