nfse_issnet 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docker-compose.yml +1 -1
- data/lib/nfse_issnet/utils/assinatura.rb +26 -24
- data/lib/nfse_issnet/utils/utils.rb +15 -13
- data/lib/nfse_issnet/utils/xml.rb +23 -21
- data/lib/nfse_issnet/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b422ffc05a6a4544205307e28cdd4ad4e0a76111eda800be5ee3bcc8d7e532d
|
4
|
+
data.tar.gz: 83690395f48a3bfb6de1643082c2ebd1ac747d52a6e62d8d7b903f02ec5c3e49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf9931dac00fde20dab649cf7dd1926622de19f7ac66e262e0faff2eaa7891822e5ac1129103c843c660159f60634db59566f5f584deabba6a38ad68a2ac7c30
|
7
|
+
data.tar.gz: c4bc8b9c821086d981b0dba53774cf09831fb8ee3c056c9215291b4df2072eb5bb6eb305452a00d59ceaadb39df774628478ad992378eaf3f1675bf216b0ded3
|
data/docker-compose.yml
CHANGED
@@ -1,35 +1,37 @@
|
|
1
|
-
module
|
2
|
-
module
|
1
|
+
module NfseIssnet
|
2
|
+
module Utils
|
3
|
+
module Assinatura
|
3
4
|
|
4
|
-
|
5
|
-
|
5
|
+
class << self
|
6
|
+
attr_accessor :certificate, :certificate_key
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
def certificate
|
9
|
+
@certificate ||= certificate_pkcs12&.certificate
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
def certificate_key
|
13
|
+
@certificate_key ||= certificate_pkcs12&.key
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
+
private
|
16
17
|
|
17
|
-
|
18
|
+
attr_accessor :certificate_pkcs12_value, :certificate_pkcs12
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
def certificate_pkcs12_value
|
21
|
+
@certificate_pkcs12_value ||= File.read(NfseIssnet.configuration.certificate_pkcs12_path)
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
def certificate_pkcs12
|
25
|
+
return @certificate_pkcs12 if @certificate_pkcs12
|
26
|
+
@certificate_pkcs12 = nil
|
27
|
+
Thread.new do
|
28
|
+
@certificate_pkcs12 = OpenSSL::PKCS12.new(certificate_pkcs12_value, NfseIssnet.configuration.certificate_pkcs12_password)
|
29
|
+
end.join
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
@certificate_pkcs12
|
32
|
+
rescue
|
33
|
+
nil
|
34
|
+
end
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
@@ -1,18 +1,20 @@
|
|
1
|
-
module
|
1
|
+
module NfseIssnet
|
2
2
|
module Utils
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
gsub(/([
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
3
|
+
module Utils
|
4
|
+
class << self
|
5
|
+
def snakecase(key)
|
6
|
+
#gsub(/::/, '/').
|
7
|
+
key.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
|
8
|
+
gsub(/([a-z\d])([A-Z])/, '\1_\2').
|
9
|
+
tr('-', '_').
|
10
|
+
gsub(/\s/, '_').
|
11
|
+
gsub(/__+/, '_').
|
12
|
+
downcase
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
def remove_quebras(str)
|
16
|
+
str.gsub(/\n/, '').gsub(/\t/, '').strip
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
@@ -1,30 +1,32 @@
|
|
1
|
-
module
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
opts
|
6
|
-
|
1
|
+
module NfseIssnet
|
2
|
+
module Utils
|
3
|
+
module XML
|
4
|
+
class << self
|
5
|
+
def render(file_name, opts = {})
|
6
|
+
opts ||= {}
|
7
|
+
opts[:context] ||= self
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
# Inicializa a variavel xml com nil para comparar se oa rquivo foi de fato encontrado.
|
10
|
+
xml = find(file_name, "#{NfseIssnet.root}/lib/nfse_issnet/xml", opts[:context], opts)
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
# Lança uma excessão se não for encontrado o xml
|
13
|
+
# Deve verificar se é nil pois o arquivo xml pode estar vazio
|
14
|
+
if xml.nil?
|
15
|
+
raise "Arquivo #{file_name}.xml.slim não encontrado nos diretórios"
|
16
|
+
end
|
17
|
+
xml
|
15
18
|
end
|
16
|
-
xml
|
17
|
-
end
|
18
19
|
|
19
|
-
|
20
|
+
private
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
def namespace_for_tags
|
23
|
+
'tc:'
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
def find(file_name, dir, context = nil, options = {})
|
27
|
+
if File.exists?("#{dir}/#{file_name}.xml.slim")
|
28
|
+
%Q{#{Slim::Template.new("#{dir}/#{file_name}.xml.slim", disable_escape: true).render(context, options)}}
|
29
|
+
end
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
data/lib/nfse_issnet/version.rb
CHANGED