exchange-rates 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/exchange_rates/rate.rb +9 -9
- data/lib/exchange_rates/version.rb +1 -1
- metadata +24 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7c7563c4e66008860d08428e8f1b748f68c0184c8f350676b25f325b2fd46584
|
4
|
+
data.tar.gz: 0c06cec674c0c7040f5b681eeeb37300a97a091f4ff3fed6a657b1083f66de38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f577cca84cb2fc0df29c55522de0df8cbad879e7c084b5130cb75fb18837ff718a3e378703e5e632c3d4677995e7d4fb88f0525407ce7e9e2e6aa4b4969c3a5
|
7
|
+
data.tar.gz: 032b889cd456c9d609c0a38b0be2b0f19aa234de6f71c8adf6fc8ae8f7083719b66b790b6b67fffaae31787db509961a18c65e7d45ee07687accc21b220a8e15
|
data/lib/exchange_rates/rate.rb
CHANGED
@@ -8,19 +8,19 @@ module ExchangeRates
|
|
8
8
|
# Country.all.map(&:currency_code).uniq - Money::Currency.table.map{|c| c[0].to_s.upcase}
|
9
9
|
NOT_SUPPORTED_CURRENCIES = [nil, '', 'IMP', 'TVD'].freeze
|
10
10
|
|
11
|
-
validates :from_currency, presence: true, length: { is: 3 }, format: { with: /\A[A-Z]+\z/}
|
11
|
+
validates :from_currency, presence: true, length: { is: 3 }, format: { with: /\A[A-Z]+\z/ }
|
12
12
|
validates :rate_to_base_currency, presence: true, numericality: { greater_than: 0 }
|
13
13
|
|
14
14
|
def self.convert(amount, from_currency, to_currency = BASE_CURRENCY)
|
15
15
|
case
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
16
|
+
when amount == 0
|
17
|
+
0
|
18
|
+
when to_currency == from_currency
|
19
|
+
amount
|
20
|
+
when to_currency == BASE_CURRENCY
|
21
|
+
amount * get_rate(from_currency)
|
22
|
+
else
|
23
|
+
amount * (get_rate(from_currency) / get_rate(to_currency))
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
metadata
CHANGED
@@ -1,57 +1,63 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exchange-rates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aloha
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: money
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.7'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: money
|
28
|
+
name: money-open-exchange-rates
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.2.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.2.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '4.2'
|
48
|
+
- - "<="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '5.2'
|
48
51
|
type: :runtime
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
|
-
- - "
|
55
|
+
- - ">="
|
53
56
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
57
|
+
version: '4.2'
|
58
|
+
- - "<="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '5.2'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: pg
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
149
|
version: '0'
|
144
150
|
requirements: []
|
145
151
|
rubyforge_project:
|
146
|
-
rubygems_version: 2.
|
152
|
+
rubygems_version: 2.7.7
|
147
153
|
signing_key:
|
148
154
|
specification_version: 4
|
149
155
|
summary: Rails ExchangeRates Helper
|