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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e5232627e8bdd9df550ab809d28b55a862ee219297a7ceb856c90c9efe0249c
4
- data.tar.gz: eac449c68301e01658b7c92881b692541258861bf8d78486552c3175ae1e0eb8
3
+ metadata.gz: 2d9343fee1ffa21bb51f2aad7ef448281dc129a73b5b0118080fff7d036f1e21
4
+ data.tar.gz: 83568ea830cfeecf9b602402bec919b404c33e7c6e98a890b29b13e528c93772
5
5
  SHA512:
6
- metadata.gz: 65299b32995ba7ce7c094af50ed05de14a67005144ee4f0108dcdeccecc8a65b90a181cd29d11c1f1818302fab554ad1f11d225e24fbb202d97b3db0521f4467
7
- data.tar.gz: 99e2bb0a7456fc132582c3f30dfc0eb38d54bafa8253b7cdeb8d7bab94adbaa5f15a4b970e29f5f618141685f22fc633f7c2c8bd9da706f00eebf10dc62dd2b0
6
+ metadata.gz: add15d42604754a0c3ef1514322bf9504f17d86f7703235fb422f70f319d01c607ceb585925dea1ec4b72b0751454adcb0f97ee24386f82840d95ddf2576fcc5
7
+ data.tar.gz: acc6e416e7a9a89090924c855eec56b8f66da19ab2243984b2106107f73230016463090e53808c4bead23418cb9e73abe44870cfdcc341a8651a623287a81138
@@ -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, fecha: query.date}
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, fecha: dolar_fecha}
120
+ return {compra: dolar_compra, venta: dolar_venta}
131
121
  end
132
122
 
133
123
  def save_in_db data, dolar_type
134
- date = data[:fecha].nil? ? @fecha : data[:fecha].to_date
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
@@ -1,5 +1,5 @@
1
1
  module Dolar
2
2
  module Bna
3
- VERSION = "1.0.9.3"
3
+ VERSION = "1.0.9.4"
4
4
  end
5
5
  end
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.3
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-17 00:00:00.000000000 Z
11
+ date: 2019-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: factory_bot