br_danfe 2.1.0 → 3.0.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: 262bed0c378422071afeb0a12ce50e4c4f4a5633266dd7893f2d0c280316a55e
4
- data.tar.gz: 412bdf1269d5d8c542d1ce5504e3b219621215da71019c3e37b0441ddb06d28f
3
+ metadata.gz: 1dc56c9e0a8e9af673a10afd8a3a2119ec9ba30e812c0e1fb3fea3af011fdeb1
4
+ data.tar.gz: 94ad7e6a029b10d402592d44641604ab70866fb475557263d4de52a90b455cf1
5
5
  SHA512:
6
- metadata.gz: 811c26b219e61e7a125e9c212ee3750c3ab6016ae6937456397acafd9dce1a03da762f2f50b645b8784ed6c6f8334159933f9aae7b681857e9b439816936cc51
7
- data.tar.gz: f396a32db9d675a68b87d62aa12d412e73930251c6278d3361cd34db6b7ba7a76048f4c8250335663dca19bac263dddde56f1a6a7506855469a8b715d09daa13
6
+ metadata.gz: 8a190a8b4d59d7d6f92c95221b238a26bf6df6bf572ad23f63c271875647fac1784c593935a7e0b85a28b122580a4f92e8c0c9945a45424701328bc2603b4388
7
+ data.tar.gz: c3d07094ba6483b6380ecca1c9da357f24ae9a24b47933e6e2de6a538078691337fcc3ee1159af3320d3a8fc23e27b211c7800b5516044bcc72aae76a5743946
@@ -1,13 +1,16 @@
1
1
  name: Tests
2
2
 
3
- on: [push]
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
4
7
 
5
8
  jobs:
6
9
  linter:
7
10
  strategy:
8
11
  fail-fast: false # I understand this is to run on all versions.
9
12
  matrix:
10
- ruby: ['3.3.5']
13
+ ruby: ['4.0']
11
14
 
12
15
  runs-on: ubuntu-latest
13
16
 
@@ -25,10 +28,15 @@ jobs:
25
28
  strategy:
26
29
  fail-fast: false # I understand this is to run on all versions.
27
30
  matrix:
28
- ruby: ['3.3.5']
31
+ ruby: ['4.0']
29
32
 
30
33
  runs-on: ubuntu-latest
31
34
 
35
+ permissions:
36
+ contents: read
37
+ pull-requests: write
38
+ actions: read
39
+
32
40
  steps:
33
41
  - uses: actions/checkout@v3
34
42
 
@@ -37,11 +45,12 @@ jobs:
37
45
  ruby-version: ${{ matrix.ruby }}
38
46
  bundler-cache: true
39
47
 
40
- - run: |
41
- curl https://qlty.sh | sh
48
+ - run: bundle exec rspec
49
+
50
+ - uses: actions/upload-artifact@v4
51
+ with:
52
+ name: coverage-html
53
+ path: coverage/
42
54
 
43
- - run: |
44
- bundle exec rspec
45
- ~/.qlty/bin/qlty coverage publish coverage/coverage.json
46
- env:
47
- QLTY_COVERAGE_TOKEN: ${{secrets.QLTY_COVERAGE_TOKEN}}
55
+ - uses: k1LoW/octocov-action@v1
56
+ if: ${{ !github.event.pull_request.head.repo.fork }}
data/.octocov.yml ADDED
@@ -0,0 +1,18 @@
1
+ coverage:
2
+ paths:
3
+ - coverage/.resultset.json
4
+
5
+ comment:
6
+ if: is_pull_request
7
+
8
+ summary:
9
+ if: is_pull_request
10
+
11
+ report:
12
+ if: is_default_branch
13
+ datastores:
14
+ - artifact://${GITHUB_REPOSITORY}
15
+
16
+ diff:
17
+ datastores:
18
+ - artifact://${GITHUB_REPOSITORY}
data/Gemfile CHANGED
@@ -14,5 +14,4 @@ group :development, :test do
14
14
  gem 'rubocop-rspec', '~> 2.25.0'
15
15
  gem 'simplecov', '0.22.0'
16
16
  gem 'simplecov-html', '0.13.1'
17
- gem 'simplecov-json', '0.2.3'
18
17
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- br_danfe (2.1.0)
4
+ br_danfe (3.0.0)
5
5
  barby (= 0.6.9)
6
6
  br_documents (>= 0.1.3)
7
7
  i18n (>= 0.8.6)
@@ -14,35 +14,37 @@ GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
16
  Ascii85 (1.1.0)
17
- activemodel (7.1.3)
18
- activesupport (= 7.1.3)
19
- activesupport (7.1.3)
17
+ activemodel (8.1.4.1)
18
+ activesupport (= 8.1.4.1)
19
+ activesupport (8.1.4.1)
20
20
  base64
21
21
  bigdecimal
22
- concurrent-ruby (~> 1.0, >= 1.0.2)
22
+ concurrent-ruby (~> 1.0, >= 1.3.1)
23
23
  connection_pool (>= 2.2.5)
24
24
  drb
25
25
  i18n (>= 1.6, < 2)
26
+ json
27
+ logger (>= 1.4.2)
26
28
  minitest (>= 5.1)
27
- mutex_m
28
- tzinfo (~> 2.0)
29
+ securerandom (>= 0.3)
30
+ tzinfo (~> 2.0, >= 2.0.5)
31
+ uri (>= 0.13.1)
29
32
  afm (0.2.2)
30
33
  ast (2.4.3)
31
34
  barby (0.6.9)
32
- base64 (0.2.0)
33
- bigdecimal (3.1.6)
35
+ base64 (0.3.0)
36
+ bigdecimal (3.3.1)
34
37
  br_documents (0.2.5)
35
38
  activemodel (>= 4.0.0)
36
39
  i18n (>= 0.6.5)
37
40
  byebug (11.1.3)
38
41
  chunky_png (1.4.0)
39
42
  coderay (1.1.3)
40
- concurrent-ruby (1.3.1)
41
- connection_pool (2.4.1)
43
+ concurrent-ruby (1.3.8)
44
+ connection_pool (3.0.3)
42
45
  diff-lcs (1.5.1)
43
46
  docile (1.4.1)
44
- drb (2.2.0)
45
- ruby2_keywords
47
+ drb (2.2.3)
46
48
  ffi (1.17.0)
47
49
  formatador (1.1.0)
48
50
  guard (2.19.0)
@@ -60,7 +62,7 @@ GEM
60
62
  guard-compat (~> 1.1)
61
63
  rspec (>= 2.99.0, < 4.0)
62
64
  hashery (2.1.2)
63
- i18n (1.14.5)
65
+ i18n (1.15.2)
64
66
  concurrent-ruby (~> 1.0)
65
67
  json (2.11.3)
66
68
  language_server-protocol (3.17.0.4)
@@ -68,12 +70,12 @@ GEM
68
70
  listen (3.9.0)
69
71
  rb-fsevent (~> 0.10, >= 0.10.3)
70
72
  rb-inotify (~> 0.9, >= 0.9.10)
73
+ logger (1.7.0)
71
74
  lumberjack (1.2.10)
72
75
  matrix (0.4.2)
73
76
  method_source (1.1.0)
74
77
  mini_portile2 (2.8.7)
75
- minitest (5.21.2)
76
- mutex_m (0.2.0)
78
+ minitest (5.27.0)
77
79
  nenv (0.3.0)
78
80
  nokogiri (1.16.7)
79
81
  mini_portile2 (~> 2.8.2)
@@ -157,25 +159,23 @@ GEM
157
159
  rubocop-factory_bot (~> 2.22)
158
160
  ruby-progressbar (1.13.0)
159
161
  ruby-rc4 (0.1.5)
160
- ruby2_keywords (0.0.5)
162
+ securerandom (0.4.1)
161
163
  shellany (0.0.1)
162
164
  simplecov (0.22.0)
163
165
  docile (~> 1.1)
164
166
  simplecov-html (~> 0.11)
165
167
  simplecov_json_formatter (~> 0.1)
166
168
  simplecov-html (0.13.1)
167
- simplecov-json (0.2.3)
168
- json
169
- simplecov
170
169
  simplecov_json_formatter (0.1.4)
171
170
  thor (1.3.2)
172
171
  ttfunk (1.8.0)
173
172
  bigdecimal (~> 3.1)
174
173
  tzinfo (2.0.6)
175
174
  concurrent-ruby (~> 1.0)
176
- unicode-display_width (3.1.4)
177
- unicode-emoji (~> 4.0, >= 4.0.4)
178
- unicode-emoji (4.0.4)
175
+ unicode-display_width (3.3.0)
176
+ unicode-emoji (~> 4.3)
177
+ unicode-emoji (4.3.0)
178
+ uri (1.1.2)
179
179
 
180
180
  PLATFORMS
181
181
  ruby
@@ -193,7 +193,6 @@ DEPENDENCIES
193
193
  rubocop-rspec (~> 2.25.0)
194
194
  simplecov (= 0.22.0)
195
195
  simplecov-html (= 0.13.1)
196
- simplecov-json (= 0.2.3)
197
196
 
198
197
  BUNDLED WITH
199
198
  2.5.5
@@ -30,7 +30,7 @@ module BrDanfe
30
30
  @pdf.text_box cnpj(@xml['emit/CNPJ']), at: [x_position, @pdf.cursor], height: 9, size: 9, align: :left, overflow: :shrink_to_fit
31
31
  @pdf.move_down 9
32
32
 
33
- @pdf.text_box BrDanfe::DanfeLib::NfceLib::Helper.address(@xml.css('enderEmit')), at: [x_position, @pdf.cursor], height: 20, size: 9, align: :left, overflow: :shrink_to_fit
33
+ @pdf.text_box BrDanfe::Helper.address(@xml.css('enderEmit')), at: [x_position, @pdf.cursor], height: 20, size: 9, align: :left, overflow: :shrink_to_fit
34
34
  @pdf.move_down 20
35
35
  @pdf.render_blank_line if count_name_lines(@xml['emit/xNome']) == one_line
36
36
  end
@@ -39,10 +39,6 @@ module BrDanfe
39
39
  @logo.present? ? 2.2.cm : 0
40
40
  end
41
41
 
42
- def width_box
43
- @logo.present? ? 4.5.cm : 6.7.cm
44
- end
45
-
46
42
  def cnpj(info)
47
43
  cnpj = BrDocuments::CnpjCpf::Cnpj.new info
48
44
  "CNPJ: #{cnpj.valid? ? cnpj.formatted : ''}"
@@ -14,7 +14,7 @@ module BrDanfe
14
14
  render_document
15
15
 
16
16
  @pdf.text @xml['dest/xNome'], options
17
- @pdf.text BrDanfe::DanfeLib::NfceLib::Helper.address(@xml.css('enderDest')), options
17
+ @pdf.text BrDanfe::Helper.address(@xml.css('enderDest')), options
18
18
  else
19
19
  @pdf.text 'CONSUMIDOR NÃO IDENTIFICADO', options
20
20
  end
@@ -37,5 +37,9 @@ module BrDanfe
37
37
  def self.format_cep(cep)
38
38
  cep.sub(/(\d{2})(\d{3})(\d{3})/, '\\1.\\2-\\3')
39
39
  end
40
+
41
+ def self.address(ender_tag)
42
+ "#{ender_tag.css('xLgr').text}, #{ender_tag.css('nro').text}, #{ender_tag.css('xBairro').text}, #{ender_tag.css('xMun').text} - #{ender_tag.css('UF').text}"
43
+ end
40
44
  end
41
45
  end
@@ -1,3 +1,3 @@
1
1
  module BrDanfe
2
- VERSION = '2.1.0'.freeze
2
+ VERSION = '3.0.0'.freeze
3
3
  end
@@ -112,4 +112,16 @@ describe BrDanfe::CceLib::Document do
112
112
  end
113
113
  end
114
114
  end
115
+
116
+ describe 'delegating unknown methods to the underlying Prawn document' do
117
+ context 'when the underlying document also does not know the method' do
118
+ it 'raises NoMethodError' do
119
+ expect { subject.this_method_does_not_exist }.to raise_error(NoMethodError)
120
+ end
121
+
122
+ it 'does not respond to it' do
123
+ expect(subject.respond_to?(:this_method_does_not_exist)).to be_falsey
124
+ end
125
+ end
126
+ end
115
127
  end
@@ -16,4 +16,16 @@ describe BrDanfe::DanfeLib::NfceLib::ProductList do
16
16
 
17
17
  expect("#{base_dir}document#render.pdf").to have_same_content_of file: output_pdf
18
18
  end
19
+
20
+ describe 'delegating unknown methods to the underlying Prawn document' do
21
+ context 'when the underlying document also does not know the method' do
22
+ it 'raises NoMethodError' do
23
+ expect { subject.this_method_does_not_exist }.to raise_error(NoMethodError)
24
+ end
25
+
26
+ it 'does not respond to it' do
27
+ expect(subject.respond_to?(:this_method_does_not_exist)).to be_falsey
28
+ end
29
+ end
30
+ end
19
31
  end
@@ -194,4 +194,16 @@ describe BrDanfe::DanfeLib::NfeLib::Document do
194
194
  end
195
195
  end
196
196
  end
197
+
198
+ describe 'delegating unknown methods to the underlying Prawn document' do
199
+ context 'when the underlying document also does not know the method' do
200
+ it 'raises NoMethodError' do
201
+ expect { subject.this_method_does_not_exist }.to raise_error(NoMethodError)
202
+ end
203
+
204
+ it 'does not respond to it' do
205
+ expect(subject.respond_to?(:this_method_does_not_exist)).to be_falsey
206
+ end
207
+ end
208
+ end
197
209
  end
@@ -225,4 +225,29 @@ describe BrDanfe::Helper do
225
225
  expect(described_class.format_cep('12345678')).to eql '12.345-678'
226
226
  end
227
227
  end
228
+
229
+ describe '.address' do
230
+ let(:xml) do
231
+ xml = <<~XML
232
+ <enderDest>
233
+ <xLgr>Rua Tijucas</xLgr>
234
+ <nro>99</nro>
235
+ <xCpl>dwdwa</xCpl>
236
+ <xBairro>Centro</xBairro>
237
+ <cMun>4218004</cMun>
238
+ <xMun>TIJUCAS</xMun>
239
+ <UF>SC</UF>
240
+ <CEP>88200000</CEP>
241
+ <cPais>1058</cPais>
242
+ <xPais>Brasil</xPais>
243
+ </enderDest>
244
+ XML
245
+
246
+ BrDanfe::XML.new(xml)
247
+ end
248
+
249
+ it 'returns a formated address string' do
250
+ expect(described_class.address(xml)).to eql 'Rua Tijucas, 99, Centro, TIJUCAS - SC'
251
+ end
252
+ end
228
253
  end
data/spec/spec_helper.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  require 'simplecov'
2
- require 'simplecov-json'
3
2
 
4
3
  unless ENV["NO_COVERAGE"]
5
- SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([
6
- SimpleCov::Formatter::HTMLFormatter,
7
- SimpleCov::Formatter::JSONFormatter
8
- ])
9
- SimpleCov.start
4
+ SimpleCov.start do
5
+ add_filter '/spec/support/'
6
+
7
+ # Prawn internals monkey-patch, not br_danfe's own logic.
8
+ add_filter '/lib/prawn/'
9
+ end
10
10
  end
11
11
 
12
12
  require "bundler/setup"
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: br_danfe
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ASSEINFO
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-12-09 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: barby
@@ -114,7 +113,6 @@ dependencies:
114
113
  - - "<"
115
114
  - !ruby/object:Gem::Version
116
115
  version: '2.3'
117
- description:
118
116
  email: asseinfo@asseinfo.com.br
119
117
  executables: []
120
118
  extensions: []
@@ -124,6 +122,7 @@ files:
124
122
  - ".github/dependabot.yml"
125
123
  - ".github/workflows/config.yml"
126
124
  - ".gitignore"
125
+ - ".octocov.yml"
127
126
  - ".rspec"
128
127
  - ".rubocop.yml"
129
128
  - Dockerfile
@@ -155,7 +154,6 @@ files:
155
154
  - lib/br_danfe/danfe_lib/nfce_lib/document.rb
156
155
  - lib/br_danfe/danfe_lib/nfce_lib/footer.rb
157
156
  - lib/br_danfe/danfe_lib/nfce_lib/header.rb
158
- - lib/br_danfe/danfe_lib/nfce_lib/helper.rb
159
157
  - lib/br_danfe/danfe_lib/nfce_lib/key.rb
160
158
  - lib/br_danfe/danfe_lib/nfce_lib/nfce_identification.rb
161
159
  - lib/br_danfe/danfe_lib/nfce_lib/product_list.rb
@@ -212,7 +210,6 @@ files:
212
210
  - spec/br_danfe/danfe_lib/nfce_lib/document_spec.rb
213
211
  - spec/br_danfe/danfe_lib/nfce_lib/footer_spec.rb
214
212
  - spec/br_danfe/danfe_lib/nfce_lib/header_spec.rb
215
- - spec/br_danfe/danfe_lib/nfce_lib/helper_spec.rb
216
213
  - spec/br_danfe/danfe_lib/nfce_lib/key_spec.rb
217
214
  - spec/br_danfe/danfe_lib/nfce_lib/nfce_identification_spec.rb
218
215
  - spec/br_danfe/danfe_lib/nfce_lib/product_list_spec.rb
@@ -428,7 +425,6 @@ licenses:
428
425
  - MIT
429
426
  metadata:
430
427
  rubygems_mfa_required: 'true'
431
- post_install_message:
432
428
  rdoc_options: []
433
429
  require_paths:
434
430
  - lib
@@ -443,8 +439,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
443
439
  - !ruby/object:Gem::Version
444
440
  version: '0'
445
441
  requirements: []
446
- rubygems_version: 3.5.16
447
- signing_key:
442
+ rubygems_version: 3.6.9
448
443
  specification_version: 4
449
444
  summary: DANFE pdf generator for Brazilian invoices.
450
445
  test_files: []
@@ -1,11 +0,0 @@
1
- module BrDanfe
2
- module DanfeLib
3
- module NfceLib
4
- class Helper
5
- def self.address(ender_tag)
6
- "#{ender_tag.css('xLgr').text}, #{ender_tag.css('nro').text}, #{ender_tag.css('xBairro').text}, #{ender_tag.css('xMun').text} - #{ender_tag.css('UF').text}"
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,28 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe BrDanfe::DanfeLib::NfceLib::Helper do
4
- let(:xml) do
5
- xml = <<~XML
6
- <enderDest>
7
- <xLgr>Rua Tijucas</xLgr>
8
- <nro>99</nro>
9
- <xCpl>dwdwa</xCpl>
10
- <xBairro>Centro</xBairro>
11
- <cMun>4218004</cMun>
12
- <xMun>TIJUCAS</xMun>
13
- <UF>SC</UF>
14
- <CEP>88200000</CEP>
15
- <cPais>1058</cPais>
16
- <xPais>Brasil</xPais>
17
- </enderDest>
18
- XML
19
-
20
- BrDanfe::XML.new(xml)
21
- end
22
-
23
- describe '#address' do
24
- it 'returns a formated address string' do
25
- expect(described_class.address(xml)).to eql 'Rua Tijucas, 99, Centro, TIJUCAS - SC'
26
- end
27
- end
28
- end