currency-rate 1.7.0 → 2.0.6
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
- metadata +9 -125
- data/.document +0 -5
- data/.gitignore +0 -20
- data/.rspec +0 -1
- data/Gemfile +0 -6
- data/Gemfile.lock +0 -68
- data/LICENSE.txt +0 -20
- data/README.md +0 -73
- data/Rakefile +0 -43
- data/api_keys.yml.sample +0 -4
- data/currency-rate.gemspec +0 -41
- data/lib/adapter.rb +0 -71
- data/lib/adapters/crypto/binance_adapter.rb +0 -42
- data/lib/adapters/crypto/bitfinex_adapter.rb +0 -41
- data/lib/adapters/crypto/bitpay_adapter.rb +0 -29
- data/lib/adapters/crypto/bitstamp_adapter.rb +0 -26
- data/lib/adapters/crypto/btc_china_adapter.rb +0 -11
- data/lib/adapters/crypto/btc_e_adapter.rb +0 -18
- data/lib/adapters/crypto/coin_market_cap_adapter.rb +0 -31
- data/lib/adapters/crypto/coinbase_adapter.rb +0 -30
- data/lib/adapters/crypto/exmo_adapter.rb +0 -27
- data/lib/adapters/crypto/hit_btc_adapter.rb +0 -61
- data/lib/adapters/crypto/huobi_adapter.rb +0 -25
- data/lib/adapters/crypto/kraken_adapter.rb +0 -46
- data/lib/adapters/crypto/localbitcoins_adapter.rb +0 -25
- data/lib/adapters/crypto/okcoin_adapter.rb +0 -19
- data/lib/adapters/crypto/paxful_adapter.rb +0 -18
- data/lib/adapters/crypto/poloniex_adapter.rb +0 -33
- data/lib/adapters/crypto/yadio_adapter.rb +0 -19
- data/lib/adapters/fiat/bonbast_adapter.rb +0 -25
- data/lib/adapters/fiat/coinmonitor_adapter.rb +0 -14
- data/lib/adapters/fiat/currency_layer_adapter.rb +0 -32
- data/lib/adapters/fiat/fixer_adapter.rb +0 -18
- data/lib/adapters/fiat/forge_adapter.rb +0 -25
- data/lib/adapters/fiat/free_forex_adapter.rb +0 -32
- data/lib/adapters/fiat/yahoo_adapter.rb +0 -35
- data/lib/configuration.rb +0 -28
- data/lib/currency_rate.rb +0 -85
- data/lib/currency_rate/version.rb +0 -3
- data/lib/exceptions.rb +0 -9
- data/lib/fetcher.rb +0 -80
- data/lib/storage/file_storage.rb +0 -29
- data/lib/storage/serializers/yaml_serializer.rb +0 -15
- data/lib/synchronizer.rb +0 -54
@@ -1,25 +0,0 @@
|
|
1
|
-
module CurrencyRate
|
2
|
-
class LocalbitcoinsAdapter < Adapter
|
3
|
-
# No need to use it for fetching, just additional information about supported currencies
|
4
|
-
SUPPORTED_CURRENCIES = %w(
|
5
|
-
AED AOA ARS AUD BDT BRL BYN CAD CHF CLP CNY COP CRC CZK DKK DOP EGP ETH
|
6
|
-
EUR GBP GEL GHS HKD HUF IDR ILS INR IRR JOD JPY KES KRW KWD KZT LKR LTC
|
7
|
-
MAD MWK MXN MYR NGN NOK NZD OMR PAB PEN PHP PKR PLN QAR RON RSD RUB RWF
|
8
|
-
SAR SEK SGD SZL THB TRY TWD TZS UAH UGX USD UYU VES VND XAF XMR XOF XRP
|
9
|
-
ZAR ZMW
|
10
|
-
)
|
11
|
-
|
12
|
-
ANCHOR_CURRENCY = "BTC"
|
13
|
-
|
14
|
-
FETCH_URL = 'https://localbitcoins.com/bitcoinaverage/ticker-all-currencies/'
|
15
|
-
|
16
|
-
def normalize(data)
|
17
|
-
return nil unless super
|
18
|
-
data.reduce({ "anchor" => ANCHOR_CURRENCY }) do |result, (fiat, value)|
|
19
|
-
result["#{fiat.upcase}"] = BigDecimal(value["rates"]["last"].to_s)
|
20
|
-
result
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module CurrencyRate
|
2
|
-
class OkcoinAdapter < Adapter
|
3
|
-
FETCH_URL = {
|
4
|
-
'LTC_USD' => 'https://www.okcoin.com/api/v1/ticker.do?symbol=ltc_usd',
|
5
|
-
'BTC_USD' => 'https://www.okcoin.com/api/v1/ticker.do?symbol=btc_usd',
|
6
|
-
'LTC_CNY' => 'https://www.okcoin.cn/api/ticker.do?symbol=ltc_cny',
|
7
|
-
'BTC_CNY' => 'https://www.okcoin.cn/api/ticker.do?symbol=btc_cny'
|
8
|
-
}
|
9
|
-
|
10
|
-
def normalize(data)
|
11
|
-
return nil unless super
|
12
|
-
data.reduce({}) do |result, (pair, value)|
|
13
|
-
result[pair] = BigDecimal(value["ticker"]["last"].to_s)
|
14
|
-
result
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
@@ -1,18 +0,0 @@
|
|
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
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module CurrencyRate
|
2
|
-
class PoloniexAdapter < Adapter
|
3
|
-
SUPPORTED_CURRENCIES = %w(BTS DASH DOGE LTC NXT STR XEM XMR XRP USDT
|
4
|
-
ETH SC DCR LSK STEEM ETC REP ARDR ZEC STRAT
|
5
|
-
GNT ZRX CVC OMG GAS STORJ EOS SNT KNC BAT
|
6
|
-
LOOM QTUM USDC MANA BNT BCHABC BCHSV FOAM
|
7
|
-
NMR POLY LPT ATOM TRX ETHBNT LINK XTZ PAX
|
8
|
-
USDJ SNX MATIC MKR DAI NEO SWFTC FXC AVA
|
9
|
-
CHR BNB BUSD MDT XFIL LEND REN LRC WRX SXP
|
10
|
-
STPT SWAP EXE).freeze
|
11
|
-
|
12
|
-
ANCHOR_CURRENCY = "BTC".freeze
|
13
|
-
|
14
|
-
FETCH_URL = "https://poloniex.com/public?command=returnTicker".freeze
|
15
|
-
|
16
|
-
def normalize(data)
|
17
|
-
return nil unless super
|
18
|
-
|
19
|
-
data.each_with_object({ "anchor" => ANCHOR_CURRENCY }) do |(pair_name, pair_info), result|
|
20
|
-
next unless pair_name.include?(ANCHOR_CURRENCY)
|
21
|
-
|
22
|
-
key = pair_name.sub(ANCHOR_CURRENCY, "").sub("_", "")
|
23
|
-
|
24
|
-
result[key] =
|
25
|
-
if pair_name.index(ANCHOR_CURRENCY) == 0
|
26
|
-
1 / BigDecimal(pair_info["last"])
|
27
|
-
else
|
28
|
-
BigDecimal(pair_info["last"])
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module CurrencyRate
|
2
|
-
class YadioAdapter < Adapter
|
3
|
-
SUPPORTED_CURRENCIES = %w(VES)
|
4
|
-
|
5
|
-
ANCHOR_CURRENCY = "BTC"
|
6
|
-
|
7
|
-
FETCH_URL = "https://api.yadio.io/rate/BTC"
|
8
|
-
|
9
|
-
def normalize(data)
|
10
|
-
return nil unless super
|
11
|
-
|
12
|
-
{
|
13
|
-
"anchor" => ANCHOR_CURRENCY,
|
14
|
-
"USD" => BigDecimal(data["usd"].to_s),
|
15
|
-
"VES" => BigDecimal(data["rate"].to_s),
|
16
|
-
}
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module CurrencyRate
|
2
|
-
class BonbastAdapter < Adapter
|
3
|
-
# No need to use it for fetching, just additional information about supported currencies
|
4
|
-
SUPPORTED_CURRENCIES = %w(USD IRR)
|
5
|
-
ANCHOR_CURRENCY = "USD"
|
6
|
-
FETCH_URL = "https://www.bonbast.com/"
|
7
|
-
|
8
|
-
def normalize(data)
|
9
|
-
sell = data.match(/<td id="usd1"[^>]*>(\d+)<\/td>/)[1].to_f
|
10
|
-
buy = data.match(/<td id="usd2"[^>]*>(\d+)<\/td>/)[1].to_f
|
11
|
-
{ "anchor" => self.class::ANCHOR_CURRENCY, "IRR" => BigDecimal(([buy, sell].reduce(:+).fdiv(2)*10).to_s) }
|
12
|
-
end
|
13
|
-
|
14
|
-
def request(url)
|
15
|
-
|
16
|
-
http_client = HTTP.timeout(connect:
|
17
|
-
CurrencyRate.configuration.connect_timeout, read:
|
18
|
-
CurrencyRate.configuration.read_timeout
|
19
|
-
)
|
20
|
-
http_client.get(url).to_s
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module CurrencyRate
|
2
|
-
class CoinmonitorAdapter < Adapter
|
3
|
-
# No need to use it for fetching, just additional information about supported currencies
|
4
|
-
SUPPORTED_CURRENCIES = %w(ARS)
|
5
|
-
ANCHOR_CURRENCY = "USD"
|
6
|
-
FETCH_URL = "https://ar.coinmonitor.info/api/dolar_ar/"
|
7
|
-
|
8
|
-
def normalize(data)
|
9
|
-
return nil unless super
|
10
|
-
|
11
|
-
{ "anchor" => ANCHOR_CURRENCY }.merge({ SUPPORTED_CURRENCIES.first => BigDecimal(data["DOL_blue"].to_s) })
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module CurrencyRate
|
2
|
-
class CurrencyLayerAdapter < Adapter
|
3
|
-
# No need to use it for fetching, just additional information about supported currencies
|
4
|
-
SUPPORTED_CURRENCIES = %w(
|
5
|
-
AED AFN ALL AMD ANG AOA ARS AUD AWG AZN BAM BBD BDT BGN
|
6
|
-
BHD BIF BMD BND BOB BRL BSD BTC BTN BWP BYN BYR BZD CAD
|
7
|
-
CDF CHF CLF CLP CNY COP CRC CUC CUP CVE CZK DJF DKK DOP
|
8
|
-
DZD EGP ERN ETB EUR FJD FKP GBP GEL GGP GHS GIP GMD GNF
|
9
|
-
GTQ GYD HKD HNL HRK HTG HUF IDR ILS IMP INR IQD IRR ISK
|
10
|
-
JEP JMD JOD JPY KES KGS KHR KMF KPW KRW KWD KYD KZT LAK
|
11
|
-
LBP LKR LRD LSL LTL LVL LYD MAD MDL MGA MKD MMK MNT MOP
|
12
|
-
MRO MUR MVR MWK MXN MYR MZN NAD NGN NIO NOK NPR NZD OMR
|
13
|
-
PAB PEN PGK PHP PKR PLN PYG QAR RON RSD RUB RWF SAR SBD
|
14
|
-
SCR SDG SEK SGD SHP SLL SOS SRD STD SVC SYP SZL THB TJS
|
15
|
-
TMT TND TOP TRY TTD TWD TZS UAH UGX USD UYU UZS VEF VND
|
16
|
-
VUV WST XAF XAG XAU XCD XDR XOF XPF YER ZAR ZMK ZMW ZWL
|
17
|
-
)
|
18
|
-
|
19
|
-
ANCHOR_CURRENCY = "USD"
|
20
|
-
FETCH_URL = "http://www.apilayer.net/api/live"
|
21
|
-
API_KEY_PARAM = "access_key"
|
22
|
-
|
23
|
-
def normalize(data)
|
24
|
-
return nil unless super
|
25
|
-
rates = { "anchor" => self.class::ANCHOR_CURRENCY }
|
26
|
-
data["quotes"].each do |key, value|
|
27
|
-
rates[key.sub(self.class::ANCHOR_CURRENCY, "")] = BigDecimal(value.to_s)
|
28
|
-
end
|
29
|
-
rates
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module CurrencyRate
|
2
|
-
class FixerAdapter < Adapter
|
3
|
-
# EUR is the only currency available as a base on free plan
|
4
|
-
ANCHOR_CURRENCY = "EUR"
|
5
|
-
FETCH_URL = "http://data.fixer.io/latest"
|
6
|
-
API_KEY_PARAM = "access_key"
|
7
|
-
|
8
|
-
def normalize(data)
|
9
|
-
return nil unless super
|
10
|
-
rates = { "anchor" => ANCHOR_CURRENCY }
|
11
|
-
data["rates"].each do |k, v|
|
12
|
-
rates[k] = BigDecimal(v.to_s)
|
13
|
-
end
|
14
|
-
rates
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module CurrencyRate
|
2
|
-
class ForgeAdapter < Adapter
|
3
|
-
SUPPORTED_CURRENCIES = %w(
|
4
|
-
JPY CHF CAD SEK NOK MXN ZAR TRY CNH EUR GBP AUD NZD XAU XAG
|
5
|
-
)
|
6
|
-
|
7
|
-
ANCHOR_CURRENCY = "USD"
|
8
|
-
FETCH_URL = "https://forex.1forge.com/1.0.2/quotes?pairs=" + SUPPORTED_CURRENCIES.map { |c| "#{ANCHOR_CURRENCY}#{c}" }.join(",")
|
9
|
-
API_KEY_PARAM = "api_key"
|
10
|
-
|
11
|
-
def normalize(data)
|
12
|
-
return nil unless super
|
13
|
-
rates = { "anchor" => self.class::ANCHOR_CURRENCY }
|
14
|
-
data.each do |rate|
|
15
|
-
if rate["error"]
|
16
|
-
CurrencyRate.logger.error("Forge exchange returned error")
|
17
|
-
return nil
|
18
|
-
end
|
19
|
-
rates[rate["symbol"].sub(self.class::ANCHOR_CURRENCY, "")] = BigDecimal(rate["price"].to_s)
|
20
|
-
end
|
21
|
-
rates
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module CurrencyRate
|
2
|
-
class FreeForexAdapter < Adapter
|
3
|
-
SUPPORTED_CURRENCIES = %w(
|
4
|
-
AED AFN ALL AMD ANG AOA ARS ATS AUD AWG AZM AZN BAM BBD BDT
|
5
|
-
BEF BGN BHD BIF BMD BND BOB BRL BSD BTN BWP BYN BYR BZD CAD
|
6
|
-
CDF CLP CNH CNY COP CRC CUC CUP CVE CYP CZK DEM DJF DKK DOP
|
7
|
-
DZD EEK EGP ERN ESP ETB EUR FIM FJD FKP FRF GBP GEL GGP GHC
|
8
|
-
GHS GIP GMD GNF GRD GTQ GYD HKD HNL HRK HTG HUF IDR IEP ILS
|
9
|
-
IMP INR IQD IRR ISK ITL JEP JMD JOD KES KGS KHR KMF KPW KRW
|
10
|
-
KWD KYD KZT LAK LBP LKR LRD LSL LTL LUF LVL LYD MAD MDL MGA
|
11
|
-
MGF MKD MMK MNT MOP MRO MRU MTL MUR MVR MWK MXN MYR MZM MZN
|
12
|
-
NAD NGN NIO NLG NOK NPR NZD OMR PAB PEN PGK PHP PKR PLN PTE
|
13
|
-
PYG QAR ROL RON RSD RUB RWF SAR SBD SCR SDD SDG SEK SGD SHP
|
14
|
-
SIT SKK SLL SOS SPL SRD SRG STD STN SVC SYP SZL THB TJS TMM
|
15
|
-
TMT TND TOP TRL TRY TTD TVD TWD TZS UAH UGX UYU UZS VAL VEB
|
16
|
-
VEF VES VND VUV WST XAF XAG XAU XBT XCD XDR XOF XPD XPF XPT
|
17
|
-
YER ZAR ZMK ZMW ZWD
|
18
|
-
)
|
19
|
-
|
20
|
-
ANCHOR_CURRENCY = "USD"
|
21
|
-
FETCH_URL = "https://www.freeforexapi.com/api/live?pairs=" + SUPPORTED_CURRENCIES.map{|cur| "USD#{cur}"}.join(",")
|
22
|
-
|
23
|
-
def normalize(data)
|
24
|
-
return nil unless super
|
25
|
-
rates = { "anchor" => self.class::ANCHOR_CURRENCY }
|
26
|
-
data["rates"].each do |pair, payload|
|
27
|
-
rates[pair.sub(self.class::ANCHOR_CURRENCY, "")] = BigDecimal(payload["rate"].to_s)
|
28
|
-
end
|
29
|
-
rates
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module CurrencyRate
|
2
|
-
class YahooAdapter < Adapter
|
3
|
-
SUPPORTED_CURRENCIES = %w(
|
4
|
-
AED AFN ALL AMD ANG AOA ARS AUD AWG AZN BAM BBD BDT BGN BHD BIF BMD BND
|
5
|
-
BRL BSD BTN BWP BYR BZD CAD CHF CLF CLP CNY COP CRC CUC CUP CVE CZK DEM
|
6
|
-
DJF DKK DOP DZD ECS EGP ERN ETB EUR FJD FKP FRF GBP GEL GHS GIP GMD GNF
|
7
|
-
GTQ GYD HKD HNL HRK HTG HUF IDR IEP ILS INR IQD ISK ITL JMD JOD JPY KES
|
8
|
-
KGS KHR KMF KWD KYD KZT LAK LBP LKR LRD LSL LTL LVL LYD MAD MGA MMK MNT
|
9
|
-
MOP MRO MUR MVR MWK MXN MXV MYR MZN NAD NGN NIO NOK NPR NZD OMR PAB PEN
|
10
|
-
PGK PHP PKR PLN PYG QAR RON RSD RUB RWF SAR SBD SCR SDG SEK SGD SLL SOS
|
11
|
-
SRD STD SVC SYP SZL THB TJS TMT TND TOP TRY TTD UAH UGX USD UYU UZS VND
|
12
|
-
VUV WST XAF XAG XAU XCD XDR XOF XPD XPF XPT YER ZAR ZMW ZWL
|
13
|
-
)
|
14
|
-
|
15
|
-
ANCHOR_CURRENCY = "USD"
|
16
|
-
|
17
|
-
FETCH_URL = "http://query.yahooapis.com/v1/public/yql?" + URI.encode_www_form(
|
18
|
-
format: 'json',
|
19
|
-
env: "store://datatables.org/alltableswithkeys",
|
20
|
-
q: "SELECT * FROM yahoo.finance.xchange WHERE pair IN" +
|
21
|
-
# The following line is building array string in SQL: '("USDJPY", "USDRUB", ...)'
|
22
|
-
"(#{SUPPORTED_CURRENCIES.map{|x| '"' + ANCHOR_CURRENCY + x.upcase + '"'}.join(',')})"
|
23
|
-
)
|
24
|
-
|
25
|
-
def normalize(data)
|
26
|
-
return nil unless super
|
27
|
-
rates = { "anchor" => self.class::ANCHOR_CURRENCY }
|
28
|
-
data["query"]["results"]["rate"].each do |rate|
|
29
|
-
rates[rate["Name"].split("/")[1]] = BigDecimal(rate["Rate"].to_s)
|
30
|
-
end
|
31
|
-
rates
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
data/lib/configuration.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
module CurrencyRate
|
2
|
-
class Configuration
|
3
|
-
attr_accessor :api_keys
|
4
|
-
attr_accessor :logger
|
5
|
-
attr_accessor :crypto_adapters
|
6
|
-
attr_accessor :fiat_adapters
|
7
|
-
attr_accessor :connect_timeout
|
8
|
-
attr_accessor :read_timeout
|
9
|
-
attr_accessor :storage
|
10
|
-
attr_accessor :limit_sources_for_fiat_currencies
|
11
|
-
attr_accessor :crypto_currencies
|
12
|
-
|
13
|
-
def initialize
|
14
|
-
@api_keys = { }
|
15
|
-
@logger = {
|
16
|
-
device: $stdout,
|
17
|
-
level: :info,
|
18
|
-
formatter: nil,
|
19
|
-
}
|
20
|
-
@crypto_adapters = CurrencyRate.adapters :crypto
|
21
|
-
@fiat_adapters = CurrencyRate.adapters :fiat
|
22
|
-
@connect_timeout = 4
|
23
|
-
@read_timeout = 4
|
24
|
-
@limit_sources_for_fiat_currencies = {}
|
25
|
-
@crypto_currencies = []
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/lib/currency_rate.rb
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
require "bigdecimal"
|
2
|
-
require "logger"
|
3
|
-
require "singleton"
|
4
|
-
require "json"
|
5
|
-
require "http"
|
6
|
-
|
7
|
-
require_relative "exceptions"
|
8
|
-
require_relative "configuration"
|
9
|
-
require_relative "adapter"
|
10
|
-
require_relative "fetcher"
|
11
|
-
require_relative "synchronizer"
|
12
|
-
|
13
|
-
Dir["#{File.expand_path __dir__}/adapters/**/*.rb"].each { |f| require f }
|
14
|
-
Dir["#{File.expand_path __dir__}/storage/**/*.rb"].each { |f| require f }
|
15
|
-
|
16
|
-
module CurrencyRate
|
17
|
-
class << self
|
18
|
-
attr_writer :configuration
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.method_missing(m, *args, &block)
|
22
|
-
if m.to_s.end_with? "_adapters"
|
23
|
-
self.send(:adapters, m[0..-10])
|
24
|
-
else
|
25
|
-
super
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.adapters(type)
|
30
|
-
Dir[File.join self.root, "lib/adapters/#{type}/*"].map do |file|
|
31
|
-
File.basename(file, ".rb").split('_')[0...-1].map {|w| w.capitalize}.join
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.configuration
|
36
|
-
@configuration ||= Configuration.new
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.configure
|
40
|
-
yield(configuration)
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.fetcher
|
44
|
-
@fetcher ||= Fetcher.new(fiat_exchanges: configuration.fiat_adapters,
|
45
|
-
crypto_exchanges: configuration.crypto_adapters,
|
46
|
-
limit_sources_for_fiat_currencies: configuration.limit_sources_for_fiat_currencies)
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.fetch_crypto(exchange, from, to)
|
50
|
-
fetcher.fetch_crypto(exchange, from, to)
|
51
|
-
end
|
52
|
-
|
53
|
-
def self.fetch_fiat(from, to)
|
54
|
-
fetcher.fetch_fiat(from, to)
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.logger
|
58
|
-
return @logger if @logger
|
59
|
-
@logger = Logger.new(configuration.logger[:device])
|
60
|
-
@logger.progname = "CurrencyRate"
|
61
|
-
@logger.level = configuration.logger[:level]
|
62
|
-
@logger.formatter = configuration.logger[:formatter] if configuration.logger[:formatter]
|
63
|
-
@logger
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.synchronizer
|
67
|
-
@synchronizer ||= Synchronizer.new
|
68
|
-
end
|
69
|
-
|
70
|
-
def self.sync_crypto!
|
71
|
-
synchronizer.sync_crypto!
|
72
|
-
end
|
73
|
-
|
74
|
-
def self.sync_fiat!
|
75
|
-
synchronizer.sync_fiat!
|
76
|
-
end
|
77
|
-
|
78
|
-
def self.sync!
|
79
|
-
synchronizer.sync!
|
80
|
-
end
|
81
|
-
|
82
|
-
def self.root
|
83
|
-
File.expand_path("../", File.dirname(__FILE__))
|
84
|
-
end
|
85
|
-
end
|