catalogos_sat 0.0.6 → 0.0.7

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/catalogos_sat.rb +35 -5
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ecbcf5c7089cf433adfd4a89a7305a06cef4e99d
4
- data.tar.gz: 5e9770b3339c21eeed0391b3f5e24be54f2e0cd1
3
+ metadata.gz: aa7e3051e8f148e939e0a3b330394b56e3cd587b
4
+ data.tar.gz: e1f23862c8ca1367b8cd4d975a06d4a93d00db17
5
5
  SHA512:
6
- metadata.gz: 34021706826580eb6538c0599efcb15543f7495d6dab8a47f9c85d6c565bab51a72fc5e2287d7ab2908e81692b6f170420647a54dc85f7911f03bbd9fa71581b
7
- data.tar.gz: ec98129fa3a9fe7ee746d68f9b06c2da60542510cfeb869c8ad4dbfc269b86227b21a372c0277e5ab2701e759ce687649aeabc2a011b03461530a98b3cd51faa
6
+ metadata.gz: 4954a2532840a5e60948e0a5c3bf4d9ca0411e7e7316f4f8a1ca238b7ec74fb08c7492ca27f2aa66d1bbfcab48ee6c3476d71cdc57284cc79626d4ca77d8af4f
7
+ data.tar.gz: 6dce206f66e23c63a269080e2f052ccf1c9d09f9fa51e74fe8b7f8ab83b063a58bb1f78d6c46a4a308c30596f4e413a4189059b3f22d8925f023795d79c7ce62
data/lib/catalogos_sat.rb CHANGED
@@ -38,6 +38,34 @@ class Catalogos
38
38
  @last_eTag = nil
39
39
  end
40
40
 
41
+ def is_header?(row)
42
+
43
+ #verificando headers por color
44
+ if row.formats[0].pattern_fg_color == :silver
45
+ return true
46
+ end
47
+
48
+ #verificando headers por regex de nombre de hoja
49
+ title_regex = /^(c|C)_\w+/
50
+ if title_regex.match(row[0].to_s)
51
+
52
+
53
+ return true
54
+ end
55
+
56
+ # verificando headers por existencia de version
57
+ row.each{
58
+ |cell|
59
+ if cell == "Versión"
60
+
61
+ return true
62
+ end
63
+ }
64
+
65
+ return false
66
+
67
+ end
68
+
41
69
 
42
70
  # Descarga el .xls de los catalogos del SAT y lo guarda en el folder temporal del sistema operativo.
43
71
  # Despues de correr este metodo, se asigna la variable @last_eTag en base al archivo descargado.
@@ -128,7 +156,7 @@ class Catalogos
128
156
  ultima_parte = hoja.name.index("_Parte_2") != nil
129
157
  #TODO asume que hay como maximo 2 partes por archivo y que el identificador siempre es "_Parte_X"
130
158
  end
131
-
159
+
132
160
  # Recorremos todos los renglones de la hoja de Excel
133
161
  j = 0
134
162
  hoja.each do |row|
@@ -140,9 +168,11 @@ class Catalogos
140
168
  next if row.formats[0] == nil
141
169
  # Nos saltamos renglones vacios
142
170
  next if row.to_s.index("[nil") != nil
143
- next if (row.to_s.index('["Fecha inicio de vigencia", "Fecha fin de vigencia", "Versión", "Revisión"]') != nil) && (ultima_parte == true)
171
+
144
172
 
145
- if row.formats[0].pattern_fg_color == :silver then
173
+
174
+
175
+ if is_header?(row) then
146
176
  if renglones_json.nil? then
147
177
  #puts "Ignorando: #{row}"
148
178
  renglones_json = Array.new
@@ -176,7 +206,8 @@ class Catalogos
176
206
  next
177
207
  end
178
208
  end
179
-
209
+
210
+
180
211
  # Solo procedemos si ya hubo encabezados
181
212
  if encabezados.count > 0 then
182
213
  #puts encabezados.to_s
@@ -227,7 +258,6 @@ class Catalogos
227
258
 
228
259
 
229
260
 
230
- puts "---------------------------------------------------------"
231
261
  puts "Se finalizó creacion de JSONs en directorio: #{tempdir}"
232
262
 
233
263
  rescue => e
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: catalogos_sat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - BambuCode