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 +4 -4
- data/Gemfile.lock +5 -5
- data/lib/fafx.rb +2 -1
- data/lib/fafx/date_handler.rb +20 -0
- data/lib/fafx/{date_error.rb → error.rb} +0 -0
- data/lib/fafx/exchange_rate.rb +3 -9
- data/lib/fafx/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d27dba1cc52f91715a859be62830bc5be449bcdf
|
4
|
+
data.tar.gz: ce559df98ee8bfd2bd657e0ee44c1f3ae43201cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
12
|
-
nokogiri (1.
|
13
|
-
mini_portile2 (~> 2.
|
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
@@ -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
|
data/lib/fafx/exchange_rate.rb
CHANGED
@@ -1,16 +1,10 @@
|
|
1
1
|
module Fafx
|
2
2
|
module ExchangeRate
|
3
3
|
def at(date, base, other)
|
4
|
-
|
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
|
13
|
-
other = ex_rates.rates_at(date
|
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
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.
|
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-
|
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/
|
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
|