catalogos_sat 0.0.92 → 0.0.93

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 +22 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c83c1267e5be95fcf193c99ef4a7c783e529d37
4
- data.tar.gz: ee3a719022beda64b93d44c6eb7903e4371e550f
3
+ metadata.gz: ba4b244da4d01607e54088440618523f178e4ba8
4
+ data.tar.gz: 36365a4c02ffc90f0a5bf6b95992acd016772fbb
5
5
  SHA512:
6
- metadata.gz: b5084e6325e90fed75c2a16d6cdd704efcdec3307c13500ec12e2843959d4a449fb727004faff5a13ec45bddfe9375fc23447a36b39a72484f07428f0958b9c3
7
- data.tar.gz: 4f7fc4c2c59d96e9e167698d42092a5f288e92d089e7f3d9da6d4bdb5550acff4a87aab283ef1ed17303dc582579df52f9beddc442fb3a6e7336aa4c1f8479f3
6
+ metadata.gz: e0d4cd0c51e4310a9c3891843131a9551f59a81157dff75aa71b781110db79b6eb9753434bc75e2bc7aded8c8b9d4dffffc35687c2b019908bfbb68591d08b11
7
+ data.tar.gz: e28d6d63a2449aed49046a6b232f04ebbc47d558eb925428c5d977388f5ca5be09d9d3361bfa06d1c8f1a68a46516c8cffcff065998598f6bdb23bcf533ddf02
data/lib/catalogos_sat.rb CHANGED
@@ -36,6 +36,7 @@ class Catalogos
36
36
  },
37
37
  }
38
38
  @last_eTag = nil
39
+ @local_last = nil
39
40
  end
40
41
 
41
42
  def is_header?(row)
@@ -82,7 +83,7 @@ class Catalogos
82
83
  |http|
83
84
  response = http.request_head(url_excel.path)
84
85
  totalSize = response['content-length'].to_i
85
- @local_eTag = response['etag']
86
+ @local_last = response['Last-Modified']
86
87
  pbar = ProgressBar.create(:title => "Descargando:", :format => "%t %B %p%% %E")
87
88
 
88
89
  tempdir = Dir.tmpdir()
@@ -294,18 +295,33 @@ class Catalogos
294
295
 
295
296
 
296
297
 
297
- =begin
298
- def nueva(url_excel = "http://www.sat.gob.mx/informacion_fiscal/factura_electronica/Documents/catCFDI.xls")
298
+
299
+
300
+ def nueva_last(url_excel = "http://www.sat.gob.mx/informacion_fiscal/factura_electronica/Documents/catCFDI.xls")
299
301
  url_excel = URI.parse(url_excel)
300
- last_modified = nil
302
+ new_last = nil
301
303
  httpWork = Net::HTTP.start(url_excel.host) do
302
304
  |http|
303
305
  response = http.request_head(url_excel.path)
304
- last_modified = response['Last-Modified']
306
+ new_last = response['Last-Modified']
305
307
  end
306
- return last_modified
308
+ return new_last
307
309
  end
308
310
 
311
+ # Compara el eTag del .xls en la pagina del SAT con el @last_eTag
312
+ # @param local_eTag [String] siempre intentara utilizar el @last_eTag a menos que se mande explicitamente un eTag, este se puede
313
+ # obtener de @last_eTag en una iteracion previa del programa.
314
+ # @param url_excel [String] el url donde el SAT tiene los catalogos, valor default "http://www.sat.gob.mx/informacion_fiscal/factura_electronica/Documents/catCFDI.xls"
315
+ # @return [Bool] verdadero si los eTags son distintos, es decir, si hay una nueva version disponible.
316
+ def nuevo_xls?(local_last = nil, url_excel = "http://www.sat.gob.mx/informacion_fiscal/factura_electronica/Documents/catCFDI.xls")
317
+ local_last = @local_last if local_last.nil?
318
+ new_Last = nueva_last(url_excel)
319
+
320
+ return new_Last != local_last
321
+
322
+ end
323
+
324
+ =begin
309
325
  def nueva_eTag(url_excel = "http://www.sat.gob.mx/informacion_fiscal/factura_electronica/Documents/catCFDI.xls")
310
326
  url_excel = URI.parse(url_excel)
311
327
  new_eTag = nil
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.92
4
+ version: 0.0.93
5
5
  platform: ruby
6
6
  authors:
7
7
  - BambuCode
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-11-22 00:00:00.000000000 Z
12
+ date: 2017-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby-progressbar