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.
- checksums.yaml +4 -4
- data/lib/catalogos_sat.rb +35 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa7e3051e8f148e939e0a3b330394b56e3cd587b
|
4
|
+
data.tar.gz: e1f23862c8ca1367b8cd4d975a06d4a93d00db17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
171
|
+
|
144
172
|
|
145
|
-
|
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
|