money-uphold-bank 0.0.2 → 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/bin/console +1 -1
- data/lib/money/bank/uphold.rb +26 -4
- data/money-uphold-bank.gemspec +2 -2
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cc8061d1a34bf6065387614358555cbe1e8b759c9ae3f639e61dd6afd1a84d6a
|
4
|
+
data.tar.gz: 644574eb832a8eedc4f5bcf089126fbab6f7bc545de5bf383469a28f911b06f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22fecdadeacf3882651526785772531021573ec6f2308d843af5aec414e5a37d2dcc5c20d1604b72c2be53e999d0dfb82094467fa51f15b82237435c6628e3fc
|
7
|
+
data.tar.gz: 4d3820c846d8c5efac4398c33754ba79a0cba2d87936ef7e2b3a434b29ed336afc57617d2a47486d047590adf0042d97eff9ac65f507c4aa802520cd4d221621
|
data/bin/console
CHANGED
data/lib/money/bank/uphold.rb
CHANGED
@@ -4,7 +4,7 @@ require "open-uri"
|
|
4
4
|
class Money
|
5
5
|
module Bank
|
6
6
|
class Uphold < Money::Bank::VariableExchange
|
7
|
-
|
7
|
+
UPHOLD_TICKERS_BASE_URL = "https://api.uphold.com/v0/ticker/".freeze
|
8
8
|
UPHOLD_BASE_CURRENCY = "USD".freeze
|
9
9
|
|
10
10
|
# Seconds after which the current rates are automatically expired
|
@@ -40,13 +40,31 @@ class Money
|
|
40
40
|
super || get_indirect_rate(iso_from, iso_to, opts)
|
41
41
|
end
|
42
42
|
|
43
|
+
# Set the base currency for all rates. By default, USD is used.
|
44
|
+
# @example
|
45
|
+
# uphold.source = 'USD'
|
46
|
+
#
|
47
|
+
# @param value [String] Currency code, ISO 3166-1 alpha-3
|
48
|
+
#
|
49
|
+
# @return [String] chosen base currency
|
50
|
+
def source=(value)
|
51
|
+
@source = Money::Currency.find(value.to_s).iso_code
|
52
|
+
end
|
53
|
+
|
54
|
+
# Get the base currency for all rates. By default, USD is used.
|
55
|
+
#
|
56
|
+
# @return [String] base currency
|
57
|
+
def source
|
58
|
+
@source ||= UPHOLD_BASE_CURRENCY
|
59
|
+
end
|
60
|
+
|
43
61
|
private
|
44
62
|
|
45
63
|
def get_indirect_rate(iso_from, iso_to, opts = {})
|
46
64
|
return 1 if Currency.wrap(iso_from).iso_code == Currency.wrap(iso_to).iso_code
|
47
65
|
|
48
|
-
rate_to_base = original_get_rate(iso_from,
|
49
|
-
rate_from_base = original_get_rate(
|
66
|
+
rate_to_base = original_get_rate(iso_from, source, opts)
|
67
|
+
rate_from_base = original_get_rate(source, iso_to, opts)
|
50
68
|
|
51
69
|
return unless rate_to_base && rate_from_base
|
52
70
|
|
@@ -87,7 +105,11 @@ class Money
|
|
87
105
|
end
|
88
106
|
|
89
107
|
def read_from_url
|
90
|
-
open(
|
108
|
+
open(source_url).read
|
109
|
+
end
|
110
|
+
|
111
|
+
def source_url
|
112
|
+
URI.join(UPHOLD_TICKERS_BASE_URL, source)
|
91
113
|
end
|
92
114
|
end
|
93
115
|
end
|
data/money-uphold-bank.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "money-uphold-bank"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.6"
|
8
8
|
spec.authors = ["Miguel Palhas"]
|
9
9
|
spec.email = ["miguel@subvisual.co"]
|
10
10
|
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_dependency "money", "~> 6.
|
20
|
+
spec.add_dependency "money", "~> 6.12"
|
21
21
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.11"
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: money-uphold-bank
|
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
|
- Miguel Palhas
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: money
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '6.
|
19
|
+
version: '6.12'
|
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: '6.
|
26
|
+
version: '6.12'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,7 +116,7 @@ files:
|
|
116
116
|
homepage: https://github.com/subvisual/money-uphold-bank
|
117
117
|
licenses: []
|
118
118
|
metadata: {}
|
119
|
-
post_install_message:
|
119
|
+
post_install_message:
|
120
120
|
rdoc_options: []
|
121
121
|
require_paths:
|
122
122
|
- lib
|
@@ -131,9 +131,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: '0'
|
133
133
|
requirements: []
|
134
|
-
|
135
|
-
|
136
|
-
signing_key:
|
134
|
+
rubygems_version: 3.0.3
|
135
|
+
signing_key:
|
137
136
|
specification_version: 4
|
138
137
|
summary: A gem that calculates the exchange rate using published rates from uphold.com.
|
139
138
|
test_files: []
|