teodoro 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0420ba2d797c7218d8a11c5c6457bd8501e98d4b0173c837577208729b14331e
4
- data.tar.gz: 77bebe3f5a7a56a3f64951013edde6312d94515438fc4c7038bc30b8f2a5b724
3
+ metadata.gz: b847466dec2ee0dfa4debb804d5af16dd183dcceeeb28664d0adea46b3f4ec95
4
+ data.tar.gz: 4c7aacf5cfdaf9af17298538947fb59cdfa82fd069d1136f06300cde54d3f463
5
5
  SHA512:
6
- metadata.gz: e8c054279ffb44d97a167853f65282dffe44816d16d8d50452309b0924f473babe74f89e7d777d65c31c83acf21e653d2ce1891a33ca4d6f54d282b1b471a802
7
- data.tar.gz: a858db4b007cce3931a23078f3930572429b410c3d821433ecd5cdefce5f7e21b9c302cc7cb3911e72750b36226879d9e9aac14859c859291b508f8bfeb52582
6
+ metadata.gz: 2dc6d426102161726682f79f701f2b481bf14c9a65f4838663d808c31cdf804a1fd651bc4f3116cc8a82ba7efec16405e8d336ea4ae484e26b2e8c651cbfdbf9
7
+ data.tar.gz: 07ce6e6d6f2e57a3358dd77d6a218c28e09b92f8abe1420924dd79d4c22fe62cfb1695cd4b0b9630d7e6bbca9fab27caee932258bc6fc8dbba6b44f7dedff23e
data/bin/teodoro CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'teodoro'
3
- Teodoro.call
3
+ Teodoro::Execucao.new(ARGV).call
data/lib/teodoro.rb CHANGED
@@ -1,7 +1,8 @@
1
+ require 'nokogiri'
2
+ require 'os'
3
+ require 'zip'
4
+
1
5
  require_relative 'teodoro/execucao'
2
6
 
3
7
  module Teodoro
4
- def self.call
5
- Execucao.new(ARGV).call
6
- end
7
8
  end
@@ -5,9 +5,27 @@ module Teodoro
5
5
  attr_reader :xml_do_evento, :xml_do_recibo, :destino_dos_arquivos_data
6
6
 
7
7
  def criar_arquivo_data
8
+ raise if File.exist?(caminho_do_arquivo_data)
9
+
8
10
  File.write(caminho_do_arquivo_data, conteudo_do_arquivo_data)
9
11
  end
10
12
 
13
+ def caminho_do_arquivo_data
14
+ criar_caminho_do_arquivo_data(nome_do_arquivo_data)
15
+ end
16
+
17
+ def criar_caminho_do_arquivo_data(nome_do_arquivo)
18
+ # FIXME: Tales demais caracteres especiais
19
+ File.join(
20
+ destino_dos_arquivos_data,
21
+ "#{windows? ? nome_do_arquivo.gsub(%r{[<|>:"/\\?*]}, '_') : nome_do_arquivo}.data"
22
+ )
23
+ end
24
+
25
+ def windows?
26
+ OS.windows?
27
+ end
28
+
11
29
  def evento
12
30
  @evento ||= XML.new(xml_do_evento)
13
31
  end
@@ -38,10 +38,7 @@ module Teodoro
38
38
  end
39
39
 
40
40
  def obter_caminho_do_arquivo_data(inicio_da_validade)
41
- File.join(
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
@@ -32,7 +32,7 @@ module Teodoro
32
32
  end
33
33
 
34
34
  def caminho_do_arquivo_data_original
35
- File.join(destino_dos_arquivos_data, "#{nome_do_arquivo_original}.data")
35
+ criar_caminho_do_arquivo_data(nome_do_arquivo_original)
36
36
  end
37
37
 
38
38
  def nome_do_arquivo_original
@@ -50,9 +50,5 @@ module Teodoro
50
50
  def numero_do_recibo
51
51
  recibo['retornoEvento/recibo/nrRecibo']
52
52
  end
53
-
54
- def caminho_do_arquivo_data
55
- File.join(destino_dos_arquivos_data, "#{nome_do_arquivo_data}.data")
56
- end
57
53
  end
58
54
  end
@@ -1,6 +1,3 @@
1
- require 'nokogiri'
2
- require 'zip'
3
-
4
1
  require_relative 'console'
5
2
  require_relative 'empresa'
6
3
 
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.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clavius Tales
@@ -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