teodoro 0.0.8 → 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/lib/teodoro/arquivo_de_evento.rb +1 -27
- data/lib/teodoro/arquivo_de_evento_de_tabela.rb +4 -4
- data/lib/teodoro/arquivo_de_evento_exceto_de_exclusao.rb +27 -0
- data/lib/teodoro/arquivo_de_evento_nao_periodico.rb +4 -4
- data/lib/teodoro/arquivo_xml.rb +63 -20
- data/lib/teodoro/empresa.rb +3 -1
- data/lib/teodoro/leiaute_2_4_1.rb +1 -0
- data/lib/teodoro/leiaute_2_4_1/arquivo_s3000.rb +45 -0
- metadata +3 -1
    
        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
         | 
| @@ -2,13 +2,7 @@ module Teodoro | |
| 2 2 | 
             
              module ArquivoDeEvento
         | 
| 3 3 | 
             
                private
         | 
| 4 4 |  | 
| 5 | 
            -
                attr_reader : | 
| 6 | 
            -
             | 
| 7 | 
            -
                def criar_arquivo_data
         | 
| 8 | 
            -
                  raise caminho_do_arquivo_data if File.exist?(caminho_do_arquivo_data)
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                  File.write(caminho_do_arquivo_data, conteudo_do_arquivo_data)
         | 
| 11 | 
            -
                end
         | 
| 5 | 
            +
                attr_reader :evento, :destino_dos_arquivos_data
         | 
| 12 6 |  | 
| 13 7 | 
             
                def criar_caminho_do_arquivo_data(nome_do_arquivo)
         | 
| 14 8 | 
             
                  File.join(
         | 
| @@ -20,25 +14,5 @@ module Teodoro | |
| 20 14 | 
             
                def windows?
         | 
| 21 15 | 
             
                  OS.windows?
         | 
| 22 16 | 
             
                end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
                def evento
         | 
| 25 | 
            -
                  @evento ||= XML.new(xml_do_evento)
         | 
| 26 | 
            -
                end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
                def conteudo_do_arquivo_data
         | 
| 29 | 
            -
                  (itens_do_conteudo_do_arquivo_data.map { "#{_1}=#{_2}" } + ['']).join("\n")
         | 
| 30 | 
            -
                end
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                def versao_do_aplicativo_de_processamento_do_evento
         | 
| 33 | 
            -
                  recibo['retornoEvento/processamento/versaoAppProcessamento']
         | 
| 34 | 
            -
                end
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                def tipo_de_inscricao_do_empregador
         | 
| 37 | 
            -
                  @tipo_de_inscricao_do_empregador ||= evento["#{noh_principal_do_evento}/ideEmpregador/tpInsc"]
         | 
| 38 | 
            -
                end
         | 
| 39 | 
            -
             | 
| 40 | 
            -
                def recibo
         | 
| 41 | 
            -
                  @recibo ||= XML.new(xml_do_recibo)
         | 
| 42 | 
            -
                end
         | 
| 43 17 | 
             
              end
         | 
| 44 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 |  | 
| @@ -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
         | 
    
        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,6 +40,10 @@ 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
         | 
| @@ -26,14 +51,29 @@ module Teodoro | |
| 26 51 | 
             
                def processar
         | 
| 27 52 | 
             
                  print "\e[2Kprocessando #{nome}.xml...\r"
         | 
| 28 53 |  | 
| 29 | 
            -
                  return unless  | 
| 30 | 
            -
                                .include?(tipo_de_evento)
         | 
| 54 | 
            +
                  return unless TIPOS_DE_EVENTO_PROCESSAVEIS.include?(tipo_de_evento)
         | 
| 31 55 |  | 
| 32 56 | 
             
                  arquivo.processar
         | 
| 33 57 | 
             
                end
         | 
| 34 58 |  | 
| 35 59 | 
             
                private
         | 
| 36 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 | 
            +
             | 
| 37 77 | 
             
                def tipo_de_evento
         | 
| 38 78 | 
             
                  nome[-6..].delete('-')
         | 
| 39 79 | 
             
                end
         | 
| @@ -43,6 +83,8 @@ module Teodoro | |
| 43 83 | 
             
                    evento_de_tabela
         | 
| 44 84 | 
             
                  elsif evento_nao_periodico?
         | 
| 45 85 | 
             
                    evento_nao_periodico
         | 
| 86 | 
            +
                  elsif evento_de_exclusao?
         | 
| 87 | 
            +
                    evento_de_exclusao
         | 
| 46 88 | 
             
                  end
         | 
| 47 89 | 
             
                end
         | 
| 48 90 |  | 
| @@ -52,8 +94,8 @@ module Teodoro | |
| 52 94 |  | 
| 53 95 | 
             
                def evento_de_tabela
         | 
| 54 96 | 
             
                  classe_do_arquivo.new(
         | 
| 55 | 
            -
                     | 
| 56 | 
            -
                     | 
| 97 | 
            +
                    evento: evento,
         | 
| 98 | 
            +
                    recibo: recibo,
         | 
| 57 99 | 
             
                    destino_dos_arquivos_data: destino_dos_arquivos_data
         | 
| 58 100 | 
             
                  )
         | 
| 59 101 | 
             
                end
         | 
| @@ -64,13 +106,25 @@ module Teodoro | |
| 64 106 |  | 
| 65 107 | 
             
                def evento_nao_periodico
         | 
| 66 108 | 
             
                  classe_do_arquivo.new(
         | 
| 67 | 
            -
                     | 
| 68 | 
            -
                     | 
| 109 | 
            +
                    evento: evento,
         | 
| 110 | 
            +
                    recibo: recibo,
         | 
| 69 111 | 
             
                    destino_dos_arquivos_data: destino_dos_arquivos_data,
         | 
| 70 112 | 
             
                    de_recibo_para_nome_do_arquivo_data: de_recibo_para_nome_do_arquivo_data
         | 
| 71 113 | 
             
                  )
         | 
| 72 114 | 
             
                end
         | 
| 73 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 | 
            +
             | 
| 74 128 | 
             
                def classe_do_arquivo
         | 
| 75 129 | 
             
                  modulo_do_leiaute.const_get("Arquivo#{tipo_de_evento}")
         | 
| 76 130 | 
             
                end
         | 
| @@ -96,19 +150,8 @@ module Teodoro | |
| 96 150 | 
             
                  @xml_do_evento ||= Nokogiri::XML(xml.css('eSocial/retornoProcessamentoDownload/evento/*').to_s)
         | 
| 97 151 | 
             
                end
         | 
| 98 152 |  | 
| 99 | 
            -
                def  | 
| 100 | 
            -
                   | 
| 101 | 
            -
                end
         | 
| 102 | 
            -
             | 
| 103 | 
            -
                def conteudo
         | 
| 104 | 
            -
                  File.read(caminho)
         | 
| 105 | 
            -
                end
         | 
| 106 | 
            -
             | 
| 107 | 
            -
                def xml_do_recibo
         | 
| 108 | 
            -
                  Nokogiri::XML(xml.css('eSocial/retornoProcessamentoDownload/recibo/*').to_s)
         | 
| 109 | 
            -
                end
         | 
| 110 | 
            -
             | 
| 111 | 
            -
                module Base
         | 
| 153 | 
            +
                def evento
         | 
| 154 | 
            +
                  XML.new(xml_do_evento)
         | 
| 112 155 | 
             
                end
         | 
| 113 156 | 
             
              end
         | 
| 114 157 | 
             
            end
         | 
    
        data/lib/teodoro/empresa.rb
    CHANGED
    
    
| @@ -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
         | 
| @@ -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,7 +1,7 @@ | |
| 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
         | 
| @@ -175,6 +175,7 @@ files: | |
| 175 175 | 
             
            - lib/teodoro.rb
         | 
| 176 176 | 
             
            - lib/teodoro/arquivo_de_evento.rb
         | 
| 177 177 | 
             
            - lib/teodoro/arquivo_de_evento_de_tabela.rb
         | 
| 178 | 
            +
            - lib/teodoro/arquivo_de_evento_exceto_de_exclusao.rb
         | 
| 178 179 | 
             
            - lib/teodoro/arquivo_de_evento_nao_periodico.rb
         | 
| 179 180 | 
             
            - lib/teodoro/arquivo_de_origem.rb
         | 
| 180 181 | 
             
            - lib/teodoro/arquivo_xml.rb
         | 
| @@ -198,6 +199,7 @@ files: | |
| 198 199 | 
             
            - lib/teodoro/leiaute_2_4_1/arquivo_s2250.rb
         | 
| 199 200 | 
             
            - lib/teodoro/leiaute_2_4_1/arquivo_s2300.rb
         | 
| 200 201 | 
             
            - lib/teodoro/leiaute_2_4_1/arquivo_s2306.rb
         | 
| 202 | 
            +
            - lib/teodoro/leiaute_2_4_1/arquivo_s3000.rb
         | 
| 201 203 | 
             
            - lib/teodoro/xml.rb
         | 
| 202 204 | 
             
            homepage:
         | 
| 203 205 | 
             
            licenses: []
         |