currency-rate 1.5.4 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -2
- data/Gemfile.lock +68 -0
- data/Rakefile +10 -1
- data/lib/adapter.rb +7 -2
- data/lib/adapters/crypto/paxful_adapter.rb +18 -0
- data/lib/currency_rate/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c47a6075c17cd2607ff962c2eba930b5e6f9e829b67f684c2178dcabbaab3f9
|
4
|
+
data.tar.gz: 0fb833c095e7bd320ffea734b584c5ed31360891553b437d54599cbe560b5900
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d284b54c95ec1ecdb77f802899508156ccadb03aab16681c753ee3fa97f0bda71ee402aff6976156e8635e72703cc666b949403b0ab1805a316dbf3ce60184a
|
7
|
+
data.tar.gz: f9d7d5c458c76b93486007761f4d9e2777649bd22d5de13d78075afa4fd69334b0d91863fbc3bc6dbafd99235a7a2ff28f511b46940932c51f039a40e82af9ab
|
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
currency-rate (1.6.0)
|
5
|
+
http
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.7.0)
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
|
+
byebug (11.0.1)
|
13
|
+
crack (0.4.3)
|
14
|
+
safe_yaml (~> 1.0.0)
|
15
|
+
diff-lcs (1.3)
|
16
|
+
domain_name (0.5.20190701)
|
17
|
+
unf (>= 0.0.5, < 1.0.0)
|
18
|
+
ffi (1.12.2)
|
19
|
+
ffi-compiler (1.0.1)
|
20
|
+
ffi (>= 1.0.0)
|
21
|
+
rake
|
22
|
+
hashdiff (1.0.0)
|
23
|
+
http (4.3.0)
|
24
|
+
addressable (~> 2.3)
|
25
|
+
http-cookie (~> 1.0)
|
26
|
+
http-form_data (~> 2.2)
|
27
|
+
http-parser (~> 1.2.0)
|
28
|
+
http-cookie (1.0.3)
|
29
|
+
domain_name (~> 0.5)
|
30
|
+
http-form_data (2.3.0)
|
31
|
+
http-parser (1.2.1)
|
32
|
+
ffi-compiler (>= 1.0, < 2.0)
|
33
|
+
public_suffix (4.0.1)
|
34
|
+
rake (10.5.0)
|
35
|
+
rspec (3.9.0)
|
36
|
+
rspec-core (~> 3.9.0)
|
37
|
+
rspec-expectations (~> 3.9.0)
|
38
|
+
rspec-mocks (~> 3.9.0)
|
39
|
+
rspec-core (3.9.0)
|
40
|
+
rspec-support (~> 3.9.0)
|
41
|
+
rspec-expectations (3.9.0)
|
42
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
+
rspec-support (~> 3.9.0)
|
44
|
+
rspec-mocks (3.9.0)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.9.0)
|
47
|
+
rspec-support (3.9.0)
|
48
|
+
safe_yaml (1.0.5)
|
49
|
+
unf (0.1.4)
|
50
|
+
unf_ext
|
51
|
+
unf_ext (0.0.7.6)
|
52
|
+
webmock (3.7.6)
|
53
|
+
addressable (>= 2.3.6)
|
54
|
+
crack (>= 0.3.2)
|
55
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
56
|
+
|
57
|
+
PLATFORMS
|
58
|
+
ruby
|
59
|
+
|
60
|
+
DEPENDENCIES
|
61
|
+
byebug
|
62
|
+
currency-rate!
|
63
|
+
rake (~> 10.0)
|
64
|
+
rspec (~> 3.0)
|
65
|
+
webmock
|
66
|
+
|
67
|
+
BUNDLED WITH
|
68
|
+
2.0.2
|
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ RSpec::Core::RakeTask.new(:spec)
|
|
9
9
|
task :default => :spec
|
10
10
|
|
11
11
|
desc "Update rates for specified adapter"
|
12
|
-
task :update_rates, [:exchange] do |
|
12
|
+
task :update_rates, [:exchange] do |_, args|
|
13
13
|
api_keys = YAML.load_file("api_keys.yml")
|
14
14
|
|
15
15
|
CurrencyRate.configure do |config|
|
@@ -32,3 +32,12 @@ task :update_rates, [:exchange] do |t, args|
|
|
32
32
|
|
33
33
|
puts "#{args.exchange} fixtures update finished!"
|
34
34
|
end
|
35
|
+
|
36
|
+
desc "Update rates for all defined adapters"
|
37
|
+
task :update_all_rates do |_, _|
|
38
|
+
CurrencyRate.constants.grep(/.Adapter$/).each do |name|
|
39
|
+
short_name = name.to_s.sub("Adapter", "")
|
40
|
+
Rake::Task[:update_rates].invoke(short_name)
|
41
|
+
Rake::Task[:update_rates].reenable
|
42
|
+
end
|
43
|
+
end
|
data/lib/adapter.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
module CurrencyRate
|
3
2
|
class Adapter
|
4
3
|
include Singleton
|
@@ -59,7 +58,13 @@ module CurrencyRate
|
|
59
58
|
fetch_url << "#{param_symbol}#{self.class::API_KEY_PARAM}=#{api_key}" if api_key
|
60
59
|
end
|
61
60
|
http_client = HTTP.timeout(connect: CurrencyRate.configuration.connect_timeout, read: CurrencyRate.configuration.read_timeout)
|
62
|
-
JSON.parse(
|
61
|
+
JSON.parse(
|
62
|
+
http_client
|
63
|
+
.headers("Accept" => "application/json; version=1")
|
64
|
+
.headers("Content-Type" => "text/plain")
|
65
|
+
.get(fetch_url)
|
66
|
+
.to_s
|
67
|
+
)
|
63
68
|
end
|
64
69
|
|
65
70
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module CurrencyRate
|
2
|
+
class PaxfulAdapter < Adapter
|
3
|
+
SUPPORTED_CURRENCIES = %w(USD)
|
4
|
+
|
5
|
+
ANCHOR_CURRENCY = "BTC"
|
6
|
+
|
7
|
+
FETCH_URL = "https://paxful.com/api/currency/btc"
|
8
|
+
|
9
|
+
def normalize(data)
|
10
|
+
return nil unless super
|
11
|
+
|
12
|
+
{
|
13
|
+
"anchor" => ANCHOR_CURRENCY,
|
14
|
+
"USD" => BigDecimal(data["price"].to_s)
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: currency-rate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Snitko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- ".gitignore"
|
91
91
|
- ".rspec"
|
92
92
|
- Gemfile
|
93
|
+
- Gemfile.lock
|
93
94
|
- LICENSE.txt
|
94
95
|
- README.md
|
95
96
|
- Rakefile
|
@@ -111,6 +112,7 @@ files:
|
|
111
112
|
- lib/adapters/crypto/kraken_adapter.rb
|
112
113
|
- lib/adapters/crypto/localbitcoins_adapter.rb
|
113
114
|
- lib/adapters/crypto/okcoin_adapter.rb
|
115
|
+
- lib/adapters/crypto/paxful_adapter.rb
|
114
116
|
- lib/adapters/crypto/yadio_adapter.rb
|
115
117
|
- lib/adapters/fiat/bonbast_adapter.rb
|
116
118
|
- lib/adapters/fiat/coinmonitor_adapter.rb
|
@@ -147,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
149
|
- !ruby/object:Gem::Version
|
148
150
|
version: '0'
|
149
151
|
requirements: []
|
150
|
-
rubygems_version: 3.0.
|
152
|
+
rubygems_version: 3.0.6
|
151
153
|
signing_key:
|
152
154
|
specification_version: 4
|
153
155
|
summary: Converter for fiat and crypto currencies
|