br_danfe 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +9 -9
- data/br_danfe.gemspec +2 -2
- data/lib/br_danfe/danfe_lib/document.rb +1 -1
- data/lib/br_danfe/uf.rb +13 -0
- data/lib/br_danfe/version.rb +1 -1
- data/spec/fixtures/nfe/lib/document#lie-blank-uf-invalid.pdf +74 -0
- data/spec/lib/danfe_lib/document_spec.rb +25 -0
- data/spec/lib/uf_spec.rb +45 -0
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1b92d1cedbb5fcb47932116f49a73c2b6183870badaf03ea99774247cc63ed9
|
4
|
+
data.tar.gz: 8e7c107b2c9c028a17a069fa954400f81c152d47219c1dd53b2b8cfebc5c4e19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd8fc831d3f76e99549669514ff36c0ebc3542bce6332f802f8fabad8c6b5a69ffb1534cf45b297452e770c22243e331fc7a1661c6d8e62223d044ab5be82c15
|
7
|
+
data.tar.gz: 16a6b946593be866a6fa6d1bc23c17c4d66e9870bbf6da05b3e69390bf23a73f60d228055029ba03ec6139ac85a6a49a22b891cbc028cb956c01d8602cda1126
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
br_danfe (0.7.
|
4
|
+
br_danfe (0.7.4)
|
5
5
|
barby (= 0.5.1)
|
6
|
-
br_documents (= 0.0.
|
6
|
+
br_documents (= 0.0.15)
|
7
7
|
i18n (= 0.8.6)
|
8
|
-
nokogiri (= 1.8.
|
8
|
+
nokogiri (= 1.8.3)
|
9
9
|
prawn (= 2.1.0)
|
10
10
|
prawn-table (= 0.2.2)
|
11
11
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
-
activemodel (5.2.
|
16
|
-
activesupport (= 5.2.
|
17
|
-
activesupport (5.2.
|
15
|
+
activemodel (5.2.1)
|
16
|
+
activesupport (= 5.2.1)
|
17
|
+
activesupport (5.2.1)
|
18
18
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
19
|
i18n (>= 0.7, < 2)
|
20
20
|
minitest (~> 5.1)
|
21
21
|
tzinfo (~> 1.1)
|
22
22
|
barby (0.5.1)
|
23
|
-
br_documents (0.0.
|
23
|
+
br_documents (0.0.15)
|
24
24
|
activemodel (>= 4.0.0)
|
25
25
|
i18n (>= 0.6.5)
|
26
26
|
byebug (3.5.1)
|
@@ -38,7 +38,7 @@ GEM
|
|
38
38
|
json (1.8.6)
|
39
39
|
mini_portile2 (2.3.0)
|
40
40
|
minitest (5.11.3)
|
41
|
-
nokogiri (1.8.
|
41
|
+
nokogiri (1.8.3)
|
42
42
|
mini_portile2 (~> 2.3.0)
|
43
43
|
pdf-core (0.6.1)
|
44
44
|
prawn (2.1.0)
|
@@ -84,4 +84,4 @@ DEPENDENCIES
|
|
84
84
|
simplecov-html (= 0.10.1)
|
85
85
|
|
86
86
|
BUNDLED WITH
|
87
|
-
1.16.
|
87
|
+
1.16.3
|
data/br_danfe.gemspec
CHANGED
@@ -19,9 +19,9 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.required_ruby_version = '>= 2.1'
|
20
20
|
|
21
21
|
spec.add_dependency 'barby', '0.5.1'
|
22
|
-
spec.add_dependency 'br_documents', '0.0.
|
22
|
+
spec.add_dependency 'br_documents', '0.0.15'
|
23
23
|
spec.add_dependency 'i18n', '0.8.6'
|
24
|
-
spec.add_dependency 'nokogiri', '1.8.
|
24
|
+
spec.add_dependency 'nokogiri', '1.8.3'
|
25
25
|
spec.add_dependency 'prawn', '2.1.0'
|
26
26
|
spec.add_dependency 'prawn-table', '0.2.2'
|
27
27
|
|
@@ -68,7 +68,7 @@ module BrDanfe
|
|
68
68
|
i18n = xpath_ie.gsub("/", ".");
|
69
69
|
|
70
70
|
data = ""
|
71
|
-
if xml[xpath_uf]
|
71
|
+
if Uf.include?(xml[xpath_uf])
|
72
72
|
ie = BrDocuments::IE::Factory.create(xml[xpath_uf], xml[xpath_ie])
|
73
73
|
data = ie.formatted if ie.valid?
|
74
74
|
end
|
data/lib/br_danfe/uf.rb
ADDED
data/lib/br_danfe/version.rb
CHANGED
@@ -0,0 +1,74 @@
|
|
1
|
+
%PDF-1.3
|
2
|
+
%����
|
3
|
+
1 0 obj
|
4
|
+
<< /Creator <feff0050007200610077006e>
|
5
|
+
/Producer <feff0050007200610077006e>
|
6
|
+
>>
|
7
|
+
endobj
|
8
|
+
2 0 obj
|
9
|
+
<< /Type /Catalog
|
10
|
+
/Pages 3 0 R
|
11
|
+
>>
|
12
|
+
endobj
|
13
|
+
3 0 obj
|
14
|
+
<< /Type /Pages
|
15
|
+
/Count 1
|
16
|
+
/Kids [5 0 R]
|
17
|
+
>>
|
18
|
+
endobj
|
19
|
+
4 0 obj
|
20
|
+
<< /Length 153
|
21
|
+
>>
|
22
|
+
stream
|
23
|
+
q
|
24
|
+
0.3 w
|
25
|
+
Q
|
26
|
+
q
|
27
|
+
21.2598 802.7717 111.685 22.6772 re
|
28
|
+
S
|
29
|
+
|
30
|
+
BT
|
31
|
+
23.2598 819.3508 Td
|
32
|
+
/F1.0 6 Tf
|
33
|
+
[<494e53435249c7c2> 55 <4f20455354> 93 <414455> 40 <414c>] TJ
|
34
|
+
ET
|
35
|
+
|
36
|
+
Q
|
37
|
+
|
38
|
+
endstream
|
39
|
+
endobj
|
40
|
+
5 0 obj
|
41
|
+
<< /Type /Page
|
42
|
+
/Parent 3 0 R
|
43
|
+
/MediaBox [0 0 595.28 841.89]
|
44
|
+
/Contents 4 0 R
|
45
|
+
/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
|
46
|
+
/Font << /F1.0 6 0 R
|
47
|
+
>>
|
48
|
+
>>
|
49
|
+
>>
|
50
|
+
endobj
|
51
|
+
6 0 obj
|
52
|
+
<< /Type /Font
|
53
|
+
/Subtype /Type1
|
54
|
+
/BaseFont /Times-Roman
|
55
|
+
/Encoding /WinAnsiEncoding
|
56
|
+
>>
|
57
|
+
endobj
|
58
|
+
xref
|
59
|
+
0 7
|
60
|
+
0000000000 65535 f
|
61
|
+
0000000015 00000 n
|
62
|
+
0000000109 00000 n
|
63
|
+
0000000158 00000 n
|
64
|
+
0000000215 00000 n
|
65
|
+
0000000419 00000 n
|
66
|
+
0000000599 00000 n
|
67
|
+
trailer
|
68
|
+
<< /Size 7
|
69
|
+
/Root 2 0 R
|
70
|
+
/Info 1 0 R
|
71
|
+
>>
|
72
|
+
startxref
|
73
|
+
698
|
74
|
+
%%EOF
|
@@ -86,6 +86,31 @@ describe BrDanfe::DanfeLib::Document do
|
|
86
86
|
|
87
87
|
expect("#{base_dir}document#lie-blank.pdf").to have_same_content_of file: output_pdf
|
88
88
|
end
|
89
|
+
|
90
|
+
context "when UF is invalid" do
|
91
|
+
let(:xml_as_string) do
|
92
|
+
<<-eos
|
93
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
94
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
95
|
+
<transp>
|
96
|
+
<transporta>
|
97
|
+
<UF>SC</UF>
|
98
|
+
</transporta>
|
99
|
+
</transp>
|
100
|
+
</infNFe>
|
101
|
+
</NFe>
|
102
|
+
eos
|
103
|
+
end
|
104
|
+
|
105
|
+
it "renders a blank box to the pdf" do
|
106
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
107
|
+
|
108
|
+
subject.lie 0.80, 3.94, 0.75, 1.85, xml, "transporta/UF", "transporta/IE"
|
109
|
+
subject.render_file output_pdf
|
110
|
+
|
111
|
+
expect("#{base_dir}document#lie-blank-uf-invalid.pdf").to have_same_content_of file: output_pdf
|
112
|
+
end
|
113
|
+
end
|
89
114
|
end
|
90
115
|
end
|
91
116
|
|
data/spec/lib/uf_spec.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Uf do
|
4
|
+
describe '#include?' do
|
5
|
+
ufs =
|
6
|
+
[
|
7
|
+
'AC', 'AL', 'AP', 'AM', 'BA', 'CE', 'DF', 'ES', 'GO', 'MA', 'MT', 'MS', 'MG', 'PA', 'PB', 'PR', 'PE', 'PI', 'RJ',
|
8
|
+
'RN', 'RS', 'RO', 'RR', 'SC', 'SP', 'SE', 'TO'
|
9
|
+
]
|
10
|
+
|
11
|
+
context 'when uf is symbol' do
|
12
|
+
ufs.each do |uf|
|
13
|
+
it "returns true for uf #{uf}" do
|
14
|
+
expect(Uf.include? uf.to_sym).to be true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when uf is string' do
|
20
|
+
ufs.each do |uf|
|
21
|
+
it "returns true for uf #{uf}" do
|
22
|
+
expect(Uf.include? uf).to be true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when uf is not from Brazil' do
|
28
|
+
it "returns false" do
|
29
|
+
expect(Uf.include? 'EX').to be false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when uf is blank' do
|
34
|
+
it "returns false" do
|
35
|
+
expect(Uf.include? '').to be false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when uf is nil' do
|
40
|
+
it "returns false" do
|
41
|
+
expect(Uf.include? nil).to be false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: br_danfe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ASSEINFO
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: barby
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.0.
|
33
|
+
version: 0.0.15
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.0.
|
40
|
+
version: 0.0.15
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: i18n
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.8.
|
61
|
+
version: 1.8.3
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.8.
|
68
|
+
version: 1.8.3
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: prawn
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -227,6 +227,7 @@ files:
|
|
227
227
|
- lib/br_danfe/danfe_lib/vol.rb
|
228
228
|
- lib/br_danfe/danfe_lib/xml.rb
|
229
229
|
- lib/br_danfe/danfe_lib/xprod.rb
|
230
|
+
- lib/br_danfe/uf.rb
|
230
231
|
- lib/br_danfe/version.rb
|
231
232
|
- spec/features/cce_spec.rb
|
232
233
|
- spec/features/danfe_spec.rb
|
@@ -268,6 +269,7 @@ files:
|
|
268
269
|
- spec/fixtures/nfe/lib/document#lcnpj-blank.pdf
|
269
270
|
- spec/fixtures/nfe/lib/document#lcnpj-invalid.pdf
|
270
271
|
- spec/fixtures/nfe/lib/document#lcnpj-valid.pdf
|
272
|
+
- spec/fixtures/nfe/lib/document#lie-blank-uf-invalid.pdf
|
271
273
|
- spec/fixtures/nfe/lib/document#lie-blank.pdf
|
272
274
|
- spec/fixtures/nfe/lib/document#lie-invalid.pdf
|
273
275
|
- spec/fixtures/nfe/lib/document#lie-valid.pdf
|
@@ -343,6 +345,7 @@ files:
|
|
343
345
|
- spec/lib/danfe_lib/vol_spec.rb
|
344
346
|
- spec/lib/danfe_lib/xml_spec.rb
|
345
347
|
- spec/lib/danfe_lib/xprod_spec.rb
|
348
|
+
- spec/lib/uf_spec.rb
|
346
349
|
- spec/spec_helper.rb
|
347
350
|
- spec/support/have_same_content_of.rb
|
348
351
|
homepage: http://github.com/asseinfo/br_danfe
|