teodoro 0.0.4 → 0.0.9
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/bin/teodoro +1 -1
- data/lib/teodoro.rb +77 -3
- data/lib/teodoro/arquivo_de_evento.rb +8 -21
- data/lib/teodoro/arquivo_de_evento_de_tabela.rb +5 -8
- data/lib/teodoro/arquivo_de_evento_exceto_de_exclusao.rb +27 -0
- data/lib/teodoro/arquivo_de_evento_nao_periodico.rb +6 -6
- data/lib/teodoro/arquivo_de_origem.rb +1 -1
- data/lib/teodoro/arquivo_xml.rb +65 -20
- data/lib/teodoro/empresa.rb +8 -2
- data/lib/teodoro/leiaute_2_4_1.rb +1 -0
- data/lib/teodoro/leiaute_2_4_1/arquivo_s1010.rb +6 -2
- data/lib/teodoro/leiaute_2_4_1/arquivo_s3000.rb +45 -0
- metadata +32 -3
- data/lib/teodoro/execucao.rb +0 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb5c4d48569ca39e7f8ef5498b4a66f76d236e5aa8d8ab94c5c648769e5c8968
|
4
|
+
data.tar.gz: 29d4363f9f97443cfc6f727cd83008b5b1d416f4e4b0af19429cd0a5af1ae911
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 874c4435734ba86267f19342c25e20a3b2b5fbcf030b284550a1f68ad66886f54f624a78f4ee88b39fd5b865c57234740e5a34f9b0e89e4cafffef93fd7366e8
|
7
|
+
data.tar.gz: 8dd3e540b5c26080612e79a0196f2a5eb9aa316a4d9e1f63c06bdf4cb4be79b51c9487174b35b30f84c861c1f9699f636aebb356f56d55a73fe5eac267fffbe4
|
data/bin/teodoro
CHANGED
data/lib/teodoro.rb
CHANGED
@@ -1,7 +1,81 @@
|
|
1
|
-
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'os'
|
3
|
+
require 'zip'
|
4
|
+
|
5
|
+
require_relative 'teodoro/console'
|
6
|
+
require_relative 'teodoro/empresa'
|
2
7
|
|
3
8
|
module Teodoro
|
4
|
-
def self.call
|
5
|
-
|
9
|
+
def self.call(args)
|
10
|
+
Execution.new(args).call
|
11
|
+
end
|
12
|
+
|
13
|
+
class Execution
|
14
|
+
NOME_DO_PROGRAMA = 'teodoro'.freeze
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def initialize(args)
|
19
|
+
@args = args
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_reader :args
|
23
|
+
|
24
|
+
public
|
25
|
+
|
26
|
+
def call
|
27
|
+
executar
|
28
|
+
rescue StandardError => e
|
29
|
+
Console.print e.message, *e.backtrace, color: :red
|
30
|
+
exit
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def executar
|
36
|
+
validar_argumentos
|
37
|
+
validar_existencia_do_diretorio_de_origem
|
38
|
+
validar_que_diretorio_de_origem_nao_esta_vazio
|
39
|
+
validar_que_diretorio_de_destino_esta_vazio
|
40
|
+
|
41
|
+
processar_empresas
|
42
|
+
end
|
43
|
+
|
44
|
+
def validar_argumentos
|
45
|
+
erro "#{NOME_DO_PROGRAMA} [diretório de origem] [diretório de destino]" unless args.size == 2
|
46
|
+
end
|
47
|
+
|
48
|
+
def validar_existencia_do_diretorio_de_origem
|
49
|
+
erro 'Diretório de origem não existe.' unless File.directory?(origem)
|
50
|
+
end
|
51
|
+
|
52
|
+
def origem
|
53
|
+
@origem ||= args[0]
|
54
|
+
end
|
55
|
+
|
56
|
+
def validar_que_diretorio_de_origem_nao_esta_vazio
|
57
|
+
erro 'Diretório de origem vazio.' if Dir.empty?(origem)
|
58
|
+
end
|
59
|
+
|
60
|
+
def validar_que_diretorio_de_destino_esta_vazio
|
61
|
+
erro 'Diretório de destino deve estar vazio.' unless Dir.empty?(destino)
|
62
|
+
end
|
63
|
+
|
64
|
+
def destino
|
65
|
+
@destino ||= args[1]
|
66
|
+
end
|
67
|
+
|
68
|
+
def erro(erro)
|
69
|
+
puts erro
|
70
|
+
exit
|
71
|
+
end
|
72
|
+
|
73
|
+
def processar_empresas
|
74
|
+
empresas.each(&:processar)
|
75
|
+
end
|
76
|
+
|
77
|
+
def empresas
|
78
|
+
Dir[File.join(origem, '*')].map { |caminho| Empresa.new(caminho: caminho, destino: destino) }
|
79
|
+
end
|
6
80
|
end
|
7
81
|
end
|
@@ -2,30 +2,17 @@ module Teodoro
|
|
2
2
|
module ArquivoDeEvento
|
3
3
|
private
|
4
4
|
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :evento, :destino_dos_arquivos_data
|
6
6
|
|
7
|
-
def
|
8
|
-
File.
|
7
|
+
def criar_caminho_do_arquivo_data(nome_do_arquivo)
|
8
|
+
File.join(
|
9
|
+
destino_dos_arquivos_data,
|
10
|
+
"#{windows? ? nome_do_arquivo.gsub(%r{[<|>:"/\\?*]}, '_') : nome_do_arquivo}.data"
|
11
|
+
)
|
9
12
|
end
|
10
13
|
|
11
|
-
def
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
def conteudo_do_arquivo_data
|
16
|
-
(itens_do_conteudo_do_arquivo_data.map { "#{_1}=#{_2}" } + ['']).join("\n")
|
17
|
-
end
|
18
|
-
|
19
|
-
def versao_do_aplicativo_de_processamento_do_evento
|
20
|
-
recibo['retornoEvento/processamento/versaoAppProcessamento']
|
21
|
-
end
|
22
|
-
|
23
|
-
def tipo_de_inscricao_do_empregador
|
24
|
-
@tipo_de_inscricao_do_empregador ||= evento["#{noh_principal_do_evento}/ideEmpregador/tpInsc"]
|
25
|
-
end
|
26
|
-
|
27
|
-
def recibo
|
28
|
-
@recibo ||= XML.new(xml_do_recibo)
|
14
|
+
def windows?
|
15
|
+
OS.windows?
|
29
16
|
end
|
30
17
|
end
|
31
18
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Teodoro
|
2
2
|
module ArquivoDeEventoDeTabela
|
3
|
-
include
|
3
|
+
include ArquivoDeEventoExcetoDeExclusao
|
4
4
|
|
5
5
|
private
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@
|
9
|
-
@
|
7
|
+
def initialize(evento:, recibo:, destino_dos_arquivos_data:)
|
8
|
+
@evento = evento
|
9
|
+
@recibo = recibo
|
10
10
|
@destino_dos_arquivos_data = destino_dos_arquivos_data
|
11
11
|
end
|
12
12
|
|
@@ -38,10 +38,7 @@ module Teodoro
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def obter_caminho_do_arquivo_data(inicio_da_validade)
|
41
|
-
|
42
|
-
destino_dos_arquivos_data,
|
43
|
-
"#{nome_base_do_arquivo_data}[#{inicio_da_validade.delete('-')}].data"
|
44
|
-
)
|
41
|
+
criar_caminho_do_arquivo_data("#{nome_base_do_arquivo_data}[#{inicio_da_validade.delete('-')}]")
|
45
42
|
end
|
46
43
|
|
47
44
|
def nome_base_do_arquivo_data
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Teodoro
|
2
|
+
module ArquivoDeEventoExcetoDeExclusao
|
3
|
+
include ArquivoDeEvento
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
attr_reader :recibo
|
8
|
+
|
9
|
+
def criar_arquivo_data
|
10
|
+
raise caminho_do_arquivo_data if File.exist?(caminho_do_arquivo_data)
|
11
|
+
|
12
|
+
File.write(caminho_do_arquivo_data, conteudo_do_arquivo_data)
|
13
|
+
end
|
14
|
+
|
15
|
+
def conteudo_do_arquivo_data
|
16
|
+
(itens_do_conteudo_do_arquivo_data.map { "#{_1}=#{_2}" } + ['']).join("\n")
|
17
|
+
end
|
18
|
+
|
19
|
+
def versao_do_aplicativo_de_processamento_do_evento
|
20
|
+
recibo['retornoEvento/processamento/versaoAppProcessamento']
|
21
|
+
end
|
22
|
+
|
23
|
+
def tipo_de_inscricao_do_empregador
|
24
|
+
@tipo_de_inscricao_do_empregador ||= evento["#{noh_principal_do_evento}/ideEmpregador/tpInsc"]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Teodoro
|
2
2
|
module ArquivoDeEventoNaoPeriodico
|
3
|
-
include
|
3
|
+
include ArquivoDeEventoExcetoDeExclusao
|
4
4
|
|
5
5
|
private
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@
|
9
|
-
@
|
7
|
+
def initialize(evento:, recibo:, destino_dos_arquivos_data:, de_recibo_para_nome_do_arquivo_data:)
|
8
|
+
@evento = evento
|
9
|
+
@recibo = recibo
|
10
10
|
@destino_dos_arquivos_data = destino_dos_arquivos_data
|
11
11
|
@de_recibo_para_nome_do_arquivo_data = de_recibo_para_nome_do_arquivo_data
|
12
12
|
end
|
@@ -32,7 +32,7 @@ module Teodoro
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def caminho_do_arquivo_data_original
|
35
|
-
|
35
|
+
criar_caminho_do_arquivo_data(nome_do_arquivo_original)
|
36
36
|
end
|
37
37
|
|
38
38
|
def nome_do_arquivo_original
|
@@ -52,7 +52,7 @@ module Teodoro
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def caminho_do_arquivo_data
|
55
|
-
|
55
|
+
criar_caminho_do_arquivo_data(nome_do_arquivo_data)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
data/lib/teodoro/arquivo_xml.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative 'arquivo_de_evento'
|
2
|
+
require_relative 'arquivo_de_evento_exceto_de_exclusao'
|
2
3
|
require_relative 'arquivo_de_evento_de_tabela'
|
3
4
|
require_relative 'arquivo_de_evento_nao_periodico'
|
4
5
|
require_relative 'cnpj'
|
@@ -6,7 +7,27 @@ require_relative 'leiaute_2_4_1'
|
|
6
7
|
require_relative 'xml'
|
7
8
|
|
8
9
|
module Teodoro
|
9
|
-
class ArquivoXML
|
10
|
+
class ArquivoXML # rubocop:disable Metrics/ClassLength
|
11
|
+
TIPOS_DE_EVENTO_PROCESSAVEIS = %w[
|
12
|
+
S1000
|
13
|
+
S1005
|
14
|
+
S1010
|
15
|
+
S1020
|
16
|
+
S1030
|
17
|
+
S1040
|
18
|
+
S1050
|
19
|
+
S1070
|
20
|
+
S2190
|
21
|
+
S2200
|
22
|
+
S2205
|
23
|
+
S2206
|
24
|
+
S2230
|
25
|
+
S2250
|
26
|
+
S2300
|
27
|
+
S2306
|
28
|
+
S3000
|
29
|
+
].freeze
|
30
|
+
|
10
31
|
private
|
11
32
|
|
12
33
|
def initialize(caminho:, destino_dos_arquivos_data:, de_recibo_para_nome_do_arquivo_data:)
|
@@ -19,19 +40,40 @@ module Teodoro
|
|
19
40
|
|
20
41
|
public
|
21
42
|
|
43
|
+
def momento_de_processamento_pelo_e_social
|
44
|
+
recibo['retornoEvento/processamento/dhProcessamento']
|
45
|
+
end
|
46
|
+
|
22
47
|
def nome
|
23
48
|
@nome ||= File.basename(caminho, '.xml')
|
24
49
|
end
|
25
50
|
|
26
51
|
def processar
|
27
|
-
|
28
|
-
|
52
|
+
print "\e[2Kprocessando #{nome}.xml...\r"
|
53
|
+
|
54
|
+
return unless TIPOS_DE_EVENTO_PROCESSAVEIS.include?(tipo_de_evento)
|
29
55
|
|
30
56
|
arquivo.processar
|
31
57
|
end
|
32
58
|
|
33
59
|
private
|
34
60
|
|
61
|
+
def recibo
|
62
|
+
@recibo ||= XML.new(xml_do_recibo)
|
63
|
+
end
|
64
|
+
|
65
|
+
def xml_do_recibo
|
66
|
+
Nokogiri::XML(xml.css('eSocial/retornoProcessamentoDownload/recibo/*').to_s)
|
67
|
+
end
|
68
|
+
|
69
|
+
def xml
|
70
|
+
@xml ||= Nokogiri::XML(conteudo)
|
71
|
+
end
|
72
|
+
|
73
|
+
def conteudo
|
74
|
+
File.read(caminho)
|
75
|
+
end
|
76
|
+
|
35
77
|
def tipo_de_evento
|
36
78
|
nome[-6..].delete('-')
|
37
79
|
end
|
@@ -41,6 +83,8 @@ module Teodoro
|
|
41
83
|
evento_de_tabela
|
42
84
|
elsif evento_nao_periodico?
|
43
85
|
evento_nao_periodico
|
86
|
+
elsif evento_de_exclusao?
|
87
|
+
evento_de_exclusao
|
44
88
|
end
|
45
89
|
end
|
46
90
|
|
@@ -50,8 +94,8 @@ module Teodoro
|
|
50
94
|
|
51
95
|
def evento_de_tabela
|
52
96
|
classe_do_arquivo.new(
|
53
|
-
|
54
|
-
|
97
|
+
evento: evento,
|
98
|
+
recibo: recibo,
|
55
99
|
destino_dos_arquivos_data: destino_dos_arquivos_data
|
56
100
|
)
|
57
101
|
end
|
@@ -62,13 +106,25 @@ module Teodoro
|
|
62
106
|
|
63
107
|
def evento_nao_periodico
|
64
108
|
classe_do_arquivo.new(
|
65
|
-
|
66
|
-
|
109
|
+
evento: evento,
|
110
|
+
recibo: recibo,
|
67
111
|
destino_dos_arquivos_data: destino_dos_arquivos_data,
|
68
112
|
de_recibo_para_nome_do_arquivo_data: de_recibo_para_nome_do_arquivo_data
|
69
113
|
)
|
70
114
|
end
|
71
115
|
|
116
|
+
def evento_de_exclusao?
|
117
|
+
tipo_de_evento == 'S3000'
|
118
|
+
end
|
119
|
+
|
120
|
+
def evento_de_exclusao
|
121
|
+
classe_do_arquivo.new(
|
122
|
+
evento: evento,
|
123
|
+
de_recibo_para_nome_do_arquivo_data: de_recibo_para_nome_do_arquivo_data,
|
124
|
+
destino_dos_arquivos_data: destino_dos_arquivos_data
|
125
|
+
)
|
126
|
+
end
|
127
|
+
|
72
128
|
def classe_do_arquivo
|
73
129
|
modulo_do_leiaute.const_get("Arquivo#{tipo_de_evento}")
|
74
130
|
end
|
@@ -94,19 +150,8 @@ module Teodoro
|
|
94
150
|
@xml_do_evento ||= Nokogiri::XML(xml.css('eSocial/retornoProcessamentoDownload/evento/*').to_s)
|
95
151
|
end
|
96
152
|
|
97
|
-
def
|
98
|
-
|
99
|
-
end
|
100
|
-
|
101
|
-
def conteudo
|
102
|
-
File.read(caminho)
|
103
|
-
end
|
104
|
-
|
105
|
-
def xml_do_recibo
|
106
|
-
Nokogiri::XML(xml.css('eSocial/retornoProcessamentoDownload/recibo/*').to_s)
|
107
|
-
end
|
108
|
-
|
109
|
-
module Base
|
153
|
+
def evento
|
154
|
+
XML.new(xml_do_evento)
|
110
155
|
end
|
111
156
|
end
|
112
157
|
end
|
data/lib/teodoro/empresa.rb
CHANGED
@@ -21,12 +21,12 @@ module Teodoro
|
|
21
21
|
descompactar_arquivos_de_origem
|
22
22
|
criar_diretorio_dos_arquivos_data
|
23
23
|
processar_arquivos_xml
|
24
|
+
limpar_linha_de_feedback
|
24
25
|
end
|
25
26
|
|
26
27
|
private
|
27
28
|
|
28
29
|
def dar_feedback_para_o_usuario
|
29
|
-
puts ''
|
30
30
|
Console.print nome_do_diretorio, color: :green
|
31
31
|
end
|
32
32
|
|
@@ -64,7 +64,9 @@ module Teodoro
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def processar_arquivos_xml
|
67
|
-
arquivos_xml
|
67
|
+
arquivos_xml
|
68
|
+
.sort_by { [_1.momento_de_processamento_pelo_e_social, _1.nome] }
|
69
|
+
.each(&:processar)
|
68
70
|
end
|
69
71
|
|
70
72
|
def arquivos_xml
|
@@ -81,5 +83,9 @@ module Teodoro
|
|
81
83
|
def de_recibo_para_nome_do_arquivo_data
|
82
84
|
@de_recibo_para_nome_do_arquivo_data ||= {}
|
83
85
|
end
|
86
|
+
|
87
|
+
def limpar_linha_de_feedback
|
88
|
+
print "\e[2K"
|
89
|
+
end
|
84
90
|
end
|
85
91
|
end
|
@@ -14,6 +14,7 @@ require_relative 'leiaute_2_4_1/arquivo_s2230'
|
|
14
14
|
require_relative 'leiaute_2_4_1/arquivo_s2250'
|
15
15
|
require_relative 'leiaute_2_4_1/arquivo_s2300'
|
16
16
|
require_relative 'leiaute_2_4_1/arquivo_s2306'
|
17
|
+
require_relative 'leiaute_2_4_1/arquivo_s3000'
|
17
18
|
|
18
19
|
module Teodoro
|
19
20
|
module Leiaute_2_4_1
|
@@ -18,7 +18,11 @@ module Teodoro
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def identificacao_do_arquivo_data
|
21
|
-
['RUB', codigo]
|
21
|
+
['RUB', "#{identificador_da_tabela_de_rubricas}_#{codigo}"] # FIXME: Tales
|
22
|
+
end
|
23
|
+
|
24
|
+
def identificador_da_tabela_de_rubricas
|
25
|
+
@identificador_da_tabela_de_rubricas ||= evento['evtTabRubrica/infoRubrica/*/ideRubrica/ideTabRubr']
|
22
26
|
end
|
23
27
|
|
24
28
|
def codigo
|
@@ -36,7 +40,7 @@ module Teodoro
|
|
36
40
|
['InicioValidade', inicio_da_validade],
|
37
41
|
['FimValidade', fim_da_validade],
|
38
42
|
['chkIdTabelaRubrica'],
|
39
|
-
['IdTabelaRubrica',
|
43
|
+
['IdTabelaRubrica', identificador_da_tabela_de_rubricas],
|
40
44
|
['IdTabelaRubricaText'],
|
41
45
|
['DadosRubrica_Descricao', evento['evtTabRubrica/infoRubrica/*/dadosRubrica/dscRubr']],
|
42
46
|
['DadosRubrica_Natureza', evento['evtTabRubrica/infoRubrica/*/dadosRubrica/natRubr']],
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Teodoro
|
2
|
+
module Leiaute_2_4_1
|
3
|
+
class ArquivoS3000
|
4
|
+
include ArquivoDeEvento
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def initialize(evento:, de_recibo_para_nome_do_arquivo_data:, destino_dos_arquivos_data:)
|
9
|
+
@evento = evento
|
10
|
+
@de_recibo_para_nome_do_arquivo_data = de_recibo_para_nome_do_arquivo_data
|
11
|
+
@destino_dos_arquivos_data = destino_dos_arquivos_data
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :de_recibo_para_nome_do_arquivo_data
|
15
|
+
|
16
|
+
public
|
17
|
+
|
18
|
+
def processar
|
19
|
+
excluir_arquivo_data_original if tipo_de_evento_processaveis?
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def tipo_de_evento_processaveis?
|
25
|
+
ArquivoXML::TIPOS_DE_EVENTO_PROCESSAVEIS.include?(tipo_de_evento)
|
26
|
+
end
|
27
|
+
|
28
|
+
def tipo_de_evento
|
29
|
+
evento['evtExclusao/infoExclusao/tpEvento'].delete('-')
|
30
|
+
end
|
31
|
+
|
32
|
+
def excluir_arquivo_data_original
|
33
|
+
File.delete(criar_caminho_do_arquivo_data(extrair_nome_do_arquivo_data_original))
|
34
|
+
end
|
35
|
+
|
36
|
+
def extrair_nome_do_arquivo_data_original
|
37
|
+
de_recibo_para_nome_do_arquivo_data.delete(numero_de_recibo_do_evento_a_excluir)
|
38
|
+
end
|
39
|
+
|
40
|
+
def numero_de_recibo_do_evento_a_excluir
|
41
|
+
evento['evtExclusao/infoExclusao/nrRecEvt']
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teodoro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clavius Tales
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: os
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rubyzip
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +52,20 @@ dependencies:
|
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '2.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: byebug
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,13 +175,13 @@ files:
|
|
147
175
|
- lib/teodoro.rb
|
148
176
|
- lib/teodoro/arquivo_de_evento.rb
|
149
177
|
- lib/teodoro/arquivo_de_evento_de_tabela.rb
|
178
|
+
- lib/teodoro/arquivo_de_evento_exceto_de_exclusao.rb
|
150
179
|
- lib/teodoro/arquivo_de_evento_nao_periodico.rb
|
151
180
|
- lib/teodoro/arquivo_de_origem.rb
|
152
181
|
- lib/teodoro/arquivo_xml.rb
|
153
182
|
- lib/teodoro/cnpj.rb
|
154
183
|
- lib/teodoro/console.rb
|
155
184
|
- lib/teodoro/empresa.rb
|
156
|
-
- lib/teodoro/execucao.rb
|
157
185
|
- lib/teodoro/leiaute_2_4_1.rb
|
158
186
|
- lib/teodoro/leiaute_2_4_1/arquivo_s1000.rb
|
159
187
|
- lib/teodoro/leiaute_2_4_1/arquivo_s1005.rb
|
@@ -171,6 +199,7 @@ files:
|
|
171
199
|
- lib/teodoro/leiaute_2_4_1/arquivo_s2250.rb
|
172
200
|
- lib/teodoro/leiaute_2_4_1/arquivo_s2300.rb
|
173
201
|
- lib/teodoro/leiaute_2_4_1/arquivo_s2306.rb
|
202
|
+
- lib/teodoro/leiaute_2_4_1/arquivo_s3000.rb
|
174
203
|
- lib/teodoro/xml.rb
|
175
204
|
homepage:
|
176
205
|
licenses: []
|
data/lib/teodoro/execucao.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
require 'zip'
|
3
|
-
|
4
|
-
require_relative 'console'
|
5
|
-
require_relative 'empresa'
|
6
|
-
|
7
|
-
module Teodoro
|
8
|
-
class Execucao
|
9
|
-
private
|
10
|
-
|
11
|
-
def initialize(origem:, destino:)
|
12
|
-
@origem = origem
|
13
|
-
@destino = destino
|
14
|
-
end
|
15
|
-
|
16
|
-
attr_reader :origem, :destino
|
17
|
-
|
18
|
-
public
|
19
|
-
|
20
|
-
def call
|
21
|
-
executar
|
22
|
-
rescue StandardError => e
|
23
|
-
Console.print e.message, *e.backtrace, color: :red
|
24
|
-
exit
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def executar
|
30
|
-
validar_existencia_do_diretorio_de_origem
|
31
|
-
validar_que_diretorio_de_origem_nao_esta_vazio
|
32
|
-
validar_que_diretorio_de_destino_esta_vazio
|
33
|
-
|
34
|
-
processar_empresas
|
35
|
-
end
|
36
|
-
|
37
|
-
def validar_existencia_do_diretorio_de_origem
|
38
|
-
erro 'Diretório de origem não existe.' unless File.directory?(origem)
|
39
|
-
end
|
40
|
-
|
41
|
-
def validar_que_diretorio_de_origem_nao_esta_vazio
|
42
|
-
erro 'Diretório de origem vazio.' if Dir.empty?(origem)
|
43
|
-
end
|
44
|
-
|
45
|
-
def validar_que_diretorio_de_destino_esta_vazio
|
46
|
-
erro 'Diretório de destino deve estar vazio.' unless Dir.empty?(destino)
|
47
|
-
end
|
48
|
-
|
49
|
-
def erro(erro)
|
50
|
-
puts erro
|
51
|
-
exit
|
52
|
-
end
|
53
|
-
|
54
|
-
def processar_empresas
|
55
|
-
empresas.each(&:processar)
|
56
|
-
end
|
57
|
-
|
58
|
-
def empresas
|
59
|
-
Dir[File.join(origem, '*')].map { |caminho| Empresa.new(caminho: caminho, destino: destino) }
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|