teodoro 0.23.1 → 0.24.0

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: 584f3af06436c41d0237303db696dc2d059ff38952d12a98c019bbf74fa5928e
4
- data.tar.gz: b5806c434ef9241006a1c02fee7d470114e127dfd84c548bb58c44a0ee110349
3
+ metadata.gz: 52f4179a43e17d798fbd36211dd988a1c36f786b1711b6f5343024b6aa72af9a
4
+ data.tar.gz: 073650beb80a2873d2b07415f099d86118c9b98af361d75e1ee4f0c59603e251
5
5
  SHA512:
6
- metadata.gz: 39d35a2535ddfb7bfaf49a6637e5aedb1699ea80bdedef95470ff327bfc21234963ed81a7f0886d51375a83c2c5ae161904e2a3b10cbdb88db122f50ce1cf476
7
- data.tar.gz: 9a0bca26d759e02dbacb100b890ddae36b7f8fa7dd2f38498a5297e08ab4c4fc5ec92a37750759c042d08168bcda852483148d044c9c1692d8a3e07207a96ec2
6
+ metadata.gz: c918f762b3c72c9d61d6499b0ff2969f8da70d425437edfb931e009318c2b1f03522fa05af456ece56fe72ee51458737b334303bb9e57d7acec44394ccaa8eef
7
+ data.tar.gz: 0d237dfe156c588346c6c4eb0452ff97202d46077b6557348087c66d800e5289381e09d9a33adfe1d1902e1dced7463217859347a29986f94118d8599788b301
data/lib/teodoro.rb CHANGED
@@ -12,7 +12,7 @@ require_relative 'teodoro/empresa'
12
12
  require_relative 'teodoro/obj'
13
13
 
14
14
  module Teodoro
15
- VERSION = '0.23.1'.freeze
15
+ VERSION = '0.24.0'.freeze
16
16
 
17
17
  CBOs = __FILE__
18
18
  .then { File.dirname(_1) }
@@ -1,6 +1,8 @@
1
1
  require_relative 'arquivo_de_origem'
2
2
  require_relative 'arquivo_xml'
3
3
  require_relative 'empresa/arquivos_data'
4
+ require_relative 'empresa/arquivo_data_emp'
5
+ require_relative 'empresa/arquivo_data_rub'
4
6
  require_relative 'empresa/cargos_gerados'
5
7
  require_relative 'empresa/contratos_de_emprego'
6
8
  require_relative 'empresa/contratos_de_trabalho_sem_vinculo'
@@ -46,6 +48,7 @@ module Teodoro
46
48
  ordenar_arquivos_xml
47
49
  processar_arquivos_xml
48
50
  processar_cargos_gerados
51
+ setar_proximo_identificador_de_tabela_de_rubricas_nos_arquivos_data_emp
49
52
  ajustar_nome_do_ultimo_arquivo_emp_data
50
53
  end
51
54
 
@@ -149,6 +152,38 @@ module Teodoro
149
152
  cargos_gerados.each(&:processar)
150
153
  end
151
154
 
155
+ def setar_proximo_identificador_de_tabela_de_rubricas_nos_arquivos_data_emp
156
+ arquivos_data_emp.each(&:setar_proximo_identificador_de_tabela_de_rubricas)
157
+ end
158
+
159
+ def arquivos_data_emp
160
+ Dir[File.join(destino_dos_arquivos_data, 'EMP*.data')]
161
+ .map { ArquivoDataEMP.new(
162
+ caminho: _1,
163
+ proximo_identificador_de_tabela_de_rubricas: proximo_identificador_de_tabela_de_rubricas
164
+ ) }
165
+ end
166
+
167
+ def proximo_identificador_de_tabela_de_rubricas
168
+ (ultimo_identificador_de_tabela_de_rubricas || 0) + 1
169
+ end
170
+
171
+ def ultimo_identificador_de_tabela_de_rubricas
172
+ identificadores_de_tabela_de_rubrica
173
+ .select { _1&.match?(/^\d+$/) }
174
+ .map(&:to_i)
175
+ .max
176
+ end
177
+
178
+ def identificadores_de_tabela_de_rubrica
179
+ arquivos_data_rub.map(&:identificador_da_tabela_de_rubricas)
180
+ end
181
+
182
+ def arquivos_data_rub
183
+ Dir[File.join(destino_dos_arquivos_data, 'RUB*.data')]
184
+ .map { ArquivoDataRUB.new(_1) }
185
+ end
186
+
152
187
  def ajustar_nome_do_ultimo_arquivo_emp_data
153
188
  File.rename(caminho_do_ultimo_arquivo_emp_data, novo_caminho_do_ultimo_arquivo_emp_data)
154
189
  end
@@ -0,0 +1,33 @@
1
+ module Teodoro
2
+ class Empresa
3
+ class ArquivoDataEMP
4
+ private
5
+
6
+ def initialize(caminho:, proximo_identificador_de_tabela_de_rubricas:)
7
+ @caminho = caminho
8
+ @proximo_identificador_de_tabela_de_rubricas = proximo_identificador_de_tabela_de_rubricas
9
+ end
10
+
11
+ attr_reader :caminho, :proximo_identificador_de_tabela_de_rubricas
12
+
13
+ public
14
+
15
+ def setar_proximo_identificador_de_tabela_de_rubricas
16
+ File.write(caminho, novo_conteudo)
17
+ end
18
+
19
+ private
20
+
21
+ def novo_conteudo
22
+ conteudo_anterior.sub(
23
+ "\nESX_TABELARUBRICA=\n",
24
+ "\nESX_TABELARUBRICA=#{proximo_identificador_de_tabela_de_rubricas}\n"
25
+ )
26
+ end
27
+
28
+ def conteudo_anterior
29
+ File.read(caminho)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,30 @@
1
+ module Teodoro
2
+ class Empresa
3
+ class ArquivoDataRUB
4
+ private
5
+
6
+ def initialize(caminho)
7
+ @caminho = caminho
8
+ end
9
+
10
+ attr_reader :caminho
11
+
12
+ public
13
+
14
+ def identificador_da_tabela_de_rubricas
15
+ chaves_valores['IdTabelaRubrica']
16
+ end
17
+
18
+ private
19
+
20
+ def chaves_valores
21
+ File
22
+ .readlines(caminho)
23
+ .map(&:strip)
24
+ .map { _1.split('=') }
25
+ .map { _1.size == 2 ? _1 : [_1.first, nil] }
26
+ .to_h
27
+ end
28
+ end
29
+ end
30
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teodoro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.1
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clavius Tales
@@ -199,6 +199,8 @@ files:
199
199
  - lib/teodoro/cnpj.rb
200
200
  - lib/teodoro/console.rb
201
201
  - lib/teodoro/empresa.rb
202
+ - lib/teodoro/empresa/arquivo_data_emp.rb
203
+ - lib/teodoro/empresa/arquivo_data_rub.rb
202
204
  - lib/teodoro/empresa/arquivos_data.rb
203
205
  - lib/teodoro/empresa/cargos_gerados.rb
204
206
  - lib/teodoro/empresa/contratos_de_emprego.rb