ccy-rates 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ccy-rates.gemspec +1 -1
- data/index.rb +20 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd64ad8ec255deaf5ed4b74b181ba2f230509d48
|
4
|
+
data.tar.gz: 0c07d12798c6d2223b09edd8f65a062d3e1e57d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a012665eeb7c8a9c9b3ca6859d7ad0c29a03c95e312af108b45df1e0ad3476d4429a71a928fc00747ee51090f84f4030ada9bf1a4650e830df2d1ffd3a4106f
|
7
|
+
data.tar.gz: 4f1cd048a2e09fdbea7abb24aed840a9c799b361241204416c1056ba17ccd3324d40ea504d4f729e97a5d72f118409fe7d183f9b267491a857990da927abdca3
|
data/ccy-rates.gemspec
CHANGED
data/index.rb
CHANGED
@@ -68,58 +68,73 @@ def print_rates(source, rates)
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def privatbank_exchange_office_rates
|
71
|
+
url = "https://api.privatbank.ua/p24api/pubinfo?json&exchange&coursid=5"
|
71
72
|
rates = {}
|
72
|
-
JSON.load(Faraday.get(
|
73
|
+
JSON.load(Faraday.get(url).body).tap do |x|
|
73
74
|
x.each do |y|
|
74
75
|
ccy = normalize_currency_name(y["ccy"])
|
75
76
|
rates[ccy] = { ccy: ccy, buy: y["sale"].to_f, sell: y["buy"].to_f }
|
76
77
|
end
|
77
78
|
end
|
78
79
|
print_rates("PrivatBank (currency exchange office)", rates)
|
80
|
+
rescue Faraday::Error => e
|
81
|
+
warn "Failed to load #{url}: #{e.inspect}."
|
79
82
|
end
|
80
83
|
|
81
84
|
def privatbank_cashless_rates
|
85
|
+
url = "https://api.privatbank.ua/p24api/pubinfo?json&exchange&coursid=11"
|
82
86
|
rates = {}
|
83
|
-
JSON.load(Faraday.get(
|
87
|
+
JSON.load(Faraday.get(url).body).tap do |x|
|
84
88
|
x.each do |y|
|
85
89
|
ccy = normalize_currency_name(y["ccy"])
|
86
90
|
rates[ccy] = { ccy: ccy, buy: y["sale"].to_f, sell: y["buy"].to_f }
|
87
91
|
end
|
88
92
|
end
|
89
93
|
print_rates("PrivatBank (cashless)", rates)
|
94
|
+
rescue Faraday::Error => e
|
95
|
+
warn "Failed to load #{url}: #{e.inspect}."
|
90
96
|
end
|
91
97
|
|
92
98
|
def national_bank_of_ukraine_rates
|
99
|
+
url = "https://bank.gov.ua/NBUStatService/v1/statdirectory/exchange?json"
|
93
100
|
rates = {}
|
94
|
-
JSON.load(Faraday.get(
|
101
|
+
JSON.load(Faraday.get(url).body).tap do |x|
|
95
102
|
x.each do |y|
|
96
103
|
ccy = normalize_currency_name(y["cc"])
|
97
104
|
rates[ccy] = { ccy: ccy, buy: y["rate"].to_f }
|
98
105
|
end
|
99
106
|
end
|
100
107
|
print_rates("National Bank of Ukraine", rates)
|
108
|
+
rescue Faraday::Error => e
|
109
|
+
warn "Failed to load #{url}: #{e.inspect}."
|
101
110
|
end
|
102
111
|
|
103
112
|
def finance_ua_black_market_rates
|
113
|
+
url = "https://finance.ua/"
|
104
114
|
rates = {}
|
105
|
-
document = Nokogiri::HTML.fragment(Faraday.get(
|
115
|
+
document = Nokogiri::HTML.fragment(Faraday.get(url).body) { |config| config.nonet.huge.nowarning.noerror }
|
106
116
|
td_els = document.at_css("#table-currency-tab0").css("> table > tbody > tr:nth-child(2n+1) > td")
|
107
117
|
td_els.to_a.in_groups_of 3, false do |group|
|
108
118
|
ccy = normalize_currency_name(group[0].text)
|
109
119
|
rates[ccy] = { ccy: ccy, buy: group[2].text.squish.to_f, sell: group[1].text.squish.to_f }
|
110
120
|
end
|
111
121
|
print_rates("Black Market (finance.ua)", rates)
|
122
|
+
rescue Faraday::Error => e
|
123
|
+
warn "Failed to load #{url}: #{e.inspect}."
|
112
124
|
end
|
113
125
|
|
114
126
|
def finance_i_ua_black_market_rates
|
127
|
+
url = "https://finance.i.ua/"
|
115
128
|
rates = {}
|
116
|
-
document = Nokogiri::HTML.fragment(Faraday.get(
|
129
|
+
document = Nokogiri::HTML.fragment(Faraday.get(url).body) { |config| config.nonet.huge.nowarning.noerror }
|
117
130
|
document.at_css(".widget-currency_cash").css("tbody tr").each do |tr|
|
118
131
|
ccy = normalize_currency_name(tr.at_css("th").text)
|
119
132
|
tds = tr.css("td")
|
120
133
|
rates[ccy] = { ccy: ccy, buy: tds[1].text.squish.to_f, sell: tds[0].text.squish.to_f }
|
121
134
|
end
|
122
135
|
print_rates("Black Market (finance.i.ua)", rates)
|
136
|
+
rescue Faraday::Error => e
|
137
|
+
warn "Failed to load #{url}: #{e.inspect}."
|
123
138
|
end
|
124
139
|
|
125
140
|
print "Today's currency exchange rates in Ukraine".colorize(:yellow),
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ccy-rates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaroslav Konoplov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|