dolar-bna 1.0.7 → 1.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbe21a0c2c587369d0cc7ba9b8cecead44949a4ce0ce21b39b6ac8cf2db4efb5
4
- data.tar.gz: c96a1e4cc48f9200be848e29d780a26c493299e94f04316793778071058b3e1b
3
+ metadata.gz: 3108e2c21aa48d68b93712bea13b69e2cf1cc4d31bc33632cbb172713f4f4d23
4
+ data.tar.gz: 0e22b4646b52d28a067c6748240c27325ec0c5035fcf252f15f3f4ca5617c395
5
5
  SHA512:
6
- metadata.gz: ff0b1db2aebaa03322314d248829603c4ef1f1a8ec8dac47453e0b5f74912afa70512a5a0dfe93d68ba0a0e367883decfcedde32167263ceee847d6e26cd2b91
7
- data.tar.gz: 8e3959749858041a66017badc1b1c0c18f7af237887e5de7f352fe3e119b2a5abed4907fcf8c41eccb4b261793cc91b1fc8249b91847b03c6b830b9203c27758
6
+ metadata.gz: dda16f2ff47129ea8a519dc056dbbf4713aa63c0431985e2dcba9cf290a6d8a0478291ca5d1cdfe6f8ba2d28c4cc2000f8eae9c9d6a31fc4095df2542e5e1d41
7
+ data.tar.gz: 1aa79fb3641655306efaaab1c0ea3cd9cfce63f779b8e94c839d29c64427a48d4341e83b2679e7186d6c26ab65e51de910534493967bd2e5a5a72829bfaa83d4
@@ -7,26 +7,47 @@ module Dolar
7
7
  end
8
8
 
9
9
  def perform_bna_billete
10
- data = check_cotization("Billete", @fecha)
11
- save_in_db(data, "Billete") unless data.blank?
12
- return data
10
+ begin
11
+ Timeout.timeout(15) do
12
+ data = check_cotization("Billete", @fecha)
13
+ save_in_db(data, "Billete") unless data.blank?
14
+ return data
15
+ end
16
+ rescue => ex
17
+ pp ex.message
18
+ return nil
19
+ end
13
20
  end
14
21
 
15
22
  def perform_bna_divisa
16
- data = check_cotization("Divisa", @fecha)
17
- save_in_db(data, "Divisa") unless data.blank?
18
- return data
23
+ begin
24
+ Timeout.timeout(15) do
25
+ data = check_cotization("Divisa", @fecha)
26
+ save_in_db(data, "Divisa") unless data.blank?
27
+ return data
28
+ end
29
+ rescue => ex
30
+ pp ex.message
31
+ return nil
32
+ end
19
33
  end
20
34
 
21
35
  def variation_billete
22
- today_dolar = check_cotization("Billete", @fecha)
23
- yesterday_dolar = check_cotization("Billete", (@fecha - 1.days))
24
- unless (today_dolar.nil? || yesterday_dolar.nil?)
25
- porcentual_variation = ((today_dolar[:venta] - yesterday_dolar[:venta]) / (yesterday_dolar[:venta]))
26
- porcentual_variation = "#{(porcentual_variation * 100).round(2)}%"
27
- return porcentual_variation
28
- else
29
- return "0%"
36
+ begin
37
+ Timeout.timeout(15) do
38
+ today_dolar = check_cotization("Billete", @fecha)
39
+ yesterday_dolar = check_cotization("Billete", (@fecha - 1.days))
40
+ unless (today_dolar.nil? || yesterday_dolar.nil?)
41
+ porcentual_variation = ((today_dolar[:venta] - yesterday_dolar[:venta]) / (yesterday_dolar[:venta]))
42
+ porcentual_variation = "#{(porcentual_variation * 100).round(2)}%"
43
+ return porcentual_variation
44
+ else
45
+ return "0%"
46
+ end
47
+ end
48
+ rescue => ex
49
+ pp ex.message
50
+ return nil
30
51
  end
31
52
  end
32
53
 
@@ -53,7 +74,7 @@ module Dolar
53
74
  mechanize = Mechanize.new
54
75
  mechanize.user_agent_alias = "Android"
55
76
  begin
56
- Timeout.timeout(20) do
77
+ Timeout.timeout(15) do
57
78
  url = "http://www.bna.com.ar/Cotizador/HistoricoPrincipales?id=billetes&fecha=#{@fecha.day}%2F#{@fecha.month}%2F#{@fecha.year}&filtroEuro=0&filtroDolar=1"
58
79
  value = obtain_dolar_from_html(url, mechanize, data)
59
80
  return value
@@ -70,7 +91,7 @@ module Dolar
70
91
  mechanize = Mechanize.new
71
92
  mechanize.user_agent_alias = "Android"
72
93
  begin
73
- Timeout.timeout(20) do
94
+ Timeout.timeout(15) do
74
95
  url = "http://www.bna.com.ar/Cotizador/MonedasHistorico"
75
96
  value = obtain_dolar_from_html(url, mechanize, data)
76
97
  return value
@@ -1,5 +1,5 @@
1
1
  module Dolar
2
2
  module Bna
3
- VERSION = "1.0.7"
3
+ VERSION = "1.0.8"
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.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - LITECODE
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-20 00:00:00.000000000 Z
11
+ date: 2019-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: factory_bot