dolar-bna 1.0.9.3 → 1.0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dolar/bna/exchange.rb +3 -14
- data/lib/dolar/bna/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d9343fee1ffa21bb51f2aad7ef448281dc129a73b5b0118080fff7d036f1e21
|
4
|
+
data.tar.gz: 83568ea830cfeecf9b602402bec919b404c33e7c6e98a890b29b13e528c93772
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: add15d42604754a0c3ef1514322bf9504f17d86f7703235fb422f70f319d01c607ceb585925dea1ec4b72b0751454adcb0f97ee24386f82840d95ddf2576fcc5
|
7
|
+
data.tar.gz: acc6e416e7a9a89090924c855eec56b8f66da19ab2243984b2106107f73230016463090e53808c4bead23418cb9e73abe44870cfdcc341a8651a623287a81138
|
data/lib/dolar/bna/exchange.rb
CHANGED
@@ -63,7 +63,7 @@ module Dolar
|
|
63
63
|
ddolar = get_dolar()
|
64
64
|
end
|
65
65
|
else
|
66
|
-
ddolar = {compra: query.dolar_buy, venta: query.dolar_sell
|
66
|
+
ddolar = {compra: query.dolar_buy, venta: query.dolar_sell}
|
67
67
|
end
|
68
68
|
return ddolar
|
69
69
|
end
|
@@ -103,36 +103,25 @@ module Dolar
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def obtain_dolar_from_html(url, mechanize, data, d_type)
|
106
|
-
dolar_fecha = nil
|
107
106
|
page = mechanize.get(url)
|
108
107
|
doc = Nokogiri::HTML(page.body, "UTF-8")
|
109
108
|
doc.xpath("//td").each_with_index do |node, index|
|
110
109
|
data[index] = node.text
|
111
110
|
end
|
112
|
-
if d_type == "divisa"
|
113
|
-
divs_data = {}
|
114
|
-
doc.xpath("//div").each_with_index do |node, index|
|
115
|
-
divs_data[index] = node.text
|
116
|
-
end
|
117
|
-
dolar_fecha = divs_data[1]
|
118
|
-
end
|
119
111
|
correct_date = "#{@fecha.day.to_i}/#{@fecha.month.to_i}/#{@fecha.year.to_i}"
|
120
112
|
i = data.key(correct_date)
|
121
113
|
if !i.nil?
|
122
|
-
dolar_fecha = data[i - 3]
|
123
114
|
dolar_compra = BigDecimal(data[i - 2].tr(",", ".")).truncate(3).to_f
|
124
115
|
dolar_venta = BigDecimal(data[i - 1].tr(",", ".")).truncate(3).to_f
|
125
116
|
else
|
126
|
-
dolar_fecha = dolar_fecha.nil? ? data[3] : dolar_fecha
|
127
117
|
dolar_compra = BigDecimal(data[1].tr(",", ".")).truncate(3).to_f
|
128
118
|
dolar_venta = BigDecimal(data[2].tr(",", ".")).truncate(3).to_f
|
129
119
|
end
|
130
|
-
return {compra: dolar_compra, venta: dolar_venta
|
120
|
+
return {compra: dolar_compra, venta: dolar_venta}
|
131
121
|
end
|
132
122
|
|
133
123
|
def save_in_db data, dolar_type
|
134
|
-
|
135
|
-
dr = Dolar::Bna::DolarCotization.where(date: date, dolar_type: dolar_type, dolar_buy: data[:compra], dolar_sell: data[:venta]).first_or_initialize
|
124
|
+
dr = Dolar::Bna::DolarCotization.where(date: @fecha, dolar_type: dolar_type, dolar_buy: data[:compra], dolar_sell: data[:venta]).first_or_initialize
|
136
125
|
if dr.save
|
137
126
|
pp "todo ok"
|
138
127
|
else
|
data/lib/dolar/bna/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dolar-bna
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.9.
|
4
|
+
version: 1.0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LITECODE
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: factory_bot
|