br_danfe 0.11.2 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/Gemfile.lock +31 -31
  4. data/br_danfe.gemspec +6 -5
  5. data/config/locales/pt-BR.yml +8 -0
  6. data/lib/br_danfe/danfe.rb +2 -2
  7. data/lib/br_danfe/danfe_lib/det_body.rb +1 -1
  8. data/lib/br_danfe/danfe_lib/document.rb +1 -1
  9. data/lib/br_danfe/danfe_lib/emit_header.rb +2 -2
  10. data/lib/br_danfe/danfe_lib/helper.rb +1 -27
  11. data/lib/br_danfe/danfe_lib/infadic.rb +1 -1
  12. data/lib/br_danfe/danfe_lib/xprod.rb +15 -15
  13. data/lib/br_danfe/danfe_nfce.rb +43 -0
  14. data/lib/br_danfe/danfe_nfce_lib/document.rb +35 -0
  15. data/lib/br_danfe/danfe_nfce_lib/footer.rb +15 -0
  16. data/lib/br_danfe/danfe_nfce_lib/header.rb +67 -0
  17. data/lib/br_danfe/danfe_nfce_lib/helper.rb +9 -0
  18. data/lib/br_danfe/danfe_nfce_lib/key.rb +18 -0
  19. data/lib/br_danfe/danfe_nfce_lib/nfce_identification.rb +20 -0
  20. data/lib/br_danfe/danfe_nfce_lib/product_list.rb +100 -0
  21. data/lib/br_danfe/danfe_nfce_lib/qr_code.rb +23 -0
  22. data/lib/br_danfe/danfe_nfce_lib/recipient.rb +72 -0
  23. data/lib/br_danfe/danfe_nfce_lib/total_list.rb +78 -0
  24. data/lib/br_danfe/helper.rb +29 -0
  25. data/lib/br_danfe/{danfe_lib/options.rb → logo_config.rb} +2 -2
  26. data/lib/br_danfe/{danfe_lib/logo_options.rb → logo_options.rb} +2 -2
  27. data/lib/br_danfe/version.rb +1 -1
  28. data/lib/br_danfe/xml.rb +36 -0
  29. data/spec/features/danfe_nfce_spec.rb +31 -0
  30. data/spec/fixtures/nfce/lib/document#render.pdf +99 -0
  31. data/spec/fixtures/nfce/lib/footer#render.pdf +74 -0
  32. data/spec/fixtures/nfce/lib/header#render-homologation.pdf +0 -0
  33. data/spec/fixtures/nfce/lib/header#render-long_name_with_logo.pdf +0 -0
  34. data/spec/fixtures/nfce/lib/header#render-long_name_without_logo.pdf +118 -0
  35. data/spec/fixtures/nfce/lib/header#render-short_name_with_logo.pdf +0 -0
  36. data/spec/fixtures/nfce/lib/header#render-short_name_without_logo.pdf +118 -0
  37. data/spec/fixtures/nfce/lib/key#render.pdf +104 -0
  38. data/spec/fixtures/nfce/lib/nfce_identification#render.pdf +118 -0
  39. data/spec/fixtures/nfce/lib/product_list#render-with_many_products.pdf +307 -0
  40. data/spec/fixtures/nfce/lib/product_list#render-with_many_products_and_long_names.pdf +335 -0
  41. data/spec/fixtures/nfce/lib/product_list#render-with_single_product.pdf +181 -0
  42. data/spec/fixtures/nfce/lib/product_list#render-with_single_product_and_long_name.pdf +195 -0
  43. data/spec/fixtures/nfce/lib/product_list_with_many_products.xml +367 -0
  44. data/spec/fixtures/nfce/lib/product_list_with_many_products_and_long_names.xml +367 -0
  45. data/spec/fixtures/nfce/lib/product_list_with_single_product.xml +238 -0
  46. data/spec/fixtures/nfce/lib/product_list_with_single_product_and_long_name.xml +238 -0
  47. data/spec/fixtures/nfce/lib/qr_code#render.pdf +0 -0
  48. data/spec/fixtures/nfce/lib/recipient#render-company.pdf +95 -0
  49. data/spec/fixtures/nfce/lib/recipient#render-consumer_without_document.pdf +88 -0
  50. data/spec/fixtures/nfce/lib/recipient#render-foreign.pdf +95 -0
  51. data/spec/fixtures/nfce/lib/recipient#render-individual.pdf +95 -0
  52. data/spec/fixtures/nfce/lib/recipient#render-unidentified_consumer.pdf +81 -0
  53. data/spec/fixtures/nfce/lib/total_list#does_not_render-payment_methods.pdf +139 -0
  54. data/spec/fixtures/nfce/lib/total_list#render-grouped_payment_methods.pdf +188 -0
  55. data/spec/fixtures/nfce/lib/total_list#render-totals.pdf +139 -0
  56. data/spec/fixtures/nfce/lib/total_list#render-without_payment.pdf +202 -0
  57. data/spec/fixtures/nfce/lib/total_list#render.pdf +202 -0
  58. data/spec/fixtures/nfce/v4.00/nfce.xml +367 -0
  59. data/spec/fixtures/nfce/v4.00/rendered_nfce.fixture.pdf +0 -0
  60. data/spec/fixtures/nfce/v4.00/saved_nfce.fixture.pdf +0 -0
  61. data/spec/lib/danfe_lib/dest_spec.rb +1 -1
  62. data/spec/lib/danfe_lib/det_body_spec.rb +1 -1
  63. data/spec/lib/danfe_lib/document_spec.rb +1 -1
  64. data/spec/lib/danfe_lib/dup_spec.rb +1 -1
  65. data/spec/lib/danfe_lib/emit_header_spec.rb +1 -1
  66. data/spec/lib/danfe_lib/helper_spec.rb +0 -54
  67. data/spec/lib/danfe_lib/icmstot_spec.rb +1 -1
  68. data/spec/lib/danfe_lib/infadic_spec.rb +1 -1
  69. data/spec/lib/danfe_lib/infadic_vol_spec.rb +1 -1
  70. data/spec/lib/danfe_lib/issqn_spec.rb +1 -1
  71. data/spec/lib/danfe_lib/ticket_spec.rb +1 -1
  72. data/spec/lib/danfe_lib/transp_spec.rb +1 -1
  73. data/spec/lib/danfe_lib/vol_spec.rb +1 -1
  74. data/spec/lib/danfe_nfce_lib/document_spec.rb +19 -0
  75. data/spec/lib/danfe_nfce_lib/footer_spec.rb +42 -0
  76. data/spec/lib/danfe_nfce_lib/header_spec.rb +117 -0
  77. data/spec/lib/danfe_nfce_lib/helper_spec.rb +28 -0
  78. data/spec/lib/danfe_nfce_lib/key_spec.rb +45 -0
  79. data/spec/lib/danfe_nfce_lib/nfce_identification_spec.rb +48 -0
  80. data/spec/lib/danfe_nfce_lib/product_list_spec.rb +66 -0
  81. data/spec/lib/danfe_nfce_lib/qr_code_spec.rb +35 -0
  82. data/spec/lib/danfe_nfce_lib/recipient_spec.rb +163 -0
  83. data/spec/lib/danfe_nfce_lib/total_list_spec.rb +188 -0
  84. data/spec/lib/helper_spec.rb +102 -0
  85. data/spec/lib/logo_config_spec.rb +21 -0
  86. data/spec/lib/{danfe_lib/logo_options_spec.rb → logo_options_spec.rb} +8 -22
  87. data/spec/lib/{danfe_lib/xml_spec.rb → xml_spec.rb} +2 -2
  88. metadata +87 -18
  89. data/lib/br_danfe/danfe_lib/xml.rb +0 -38
  90. data/spec/lib/danfe_lib/options_spec.rb +0 -17
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe BrDanfe::Logo::Config do
4
+ let(:options) { {} }
5
+
6
+ subject { described_class.new options }
7
+
8
+ it 'returns the default config set in the code' do
9
+ expect(subject.logo).to eq('')
10
+ expect(subject.logo_dimensions).to eq({})
11
+ end
12
+
13
+ context 'when there are custom options' do
14
+ let(:options) { { logo: '/fake/path/file.png', logo_dimensions: { width: 50, height: 50 } } }
15
+
16
+ it 'returns the config set in params' do
17
+ expect(subject.logo).to eq('/fake/path/file.png')
18
+ expect(subject.logo_dimensions).to eq({ width: 50, height: 50 })
19
+ end
20
+ end
21
+ end
@@ -1,10 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- RSpec.describe BrDanfe::DanfeLib::LogoOptions do
3
+ RSpec.describe BrDanfe::Logo::Options do
4
4
  let(:box_size) { 100 }
5
- let(:logo_dimensions) do
6
- { width: 50, height: 50 }
7
- end
5
+ let(:logo_dimensions) {{ width: 50, height: 50 }}
8
6
 
9
7
  subject { described_class.new(box_size, logo_dimensions) }
10
8
 
@@ -17,9 +15,7 @@ RSpec.describe BrDanfe::DanfeLib::LogoOptions do
17
15
  end
18
16
 
19
17
  context 'when logo width is larger than logo height' do
20
- let(:logo_dimensions) do
21
- { width: 75, height: 50 }
22
- end
18
+ let(:logo_dimensions) {{ width: 75, height: 50 }}
23
19
 
24
20
  it 'returns the options with logo width' do
25
21
  expect(subject.options).to eq(width: 75, position: :center, vposition: :center)
@@ -27,9 +23,7 @@ RSpec.describe BrDanfe::DanfeLib::LogoOptions do
27
23
  end
28
24
 
29
25
  context 'when logo height is larger than logo width' do
30
- let(:logo_dimensions) do
31
- { width: 50, height: 75 }
32
- end
26
+ let(:logo_dimensions) {{ width: 50, height: 75 }}
33
27
 
34
28
  it 'returns the options with logo height' do
35
29
  expect(subject.options).to eq(height: 75, position: :center, vposition: :center)
@@ -38,9 +32,7 @@ RSpec.describe BrDanfe::DanfeLib::LogoOptions do
38
32
  end
39
33
 
40
34
  context 'when the logo dimensions are equal to the dimensions of the box' do
41
- let(:logo_dimensions) do
42
- { width: 100, height: 100 }
43
- end
35
+ let(:logo_dimensions) {{ width: 100, height: 100 }}
44
36
 
45
37
  it 'returns the options with box size' do
46
38
  expect(subject.options).to eq(height: 100, position: :center, vposition: :center)
@@ -49,9 +41,7 @@ RSpec.describe BrDanfe::DanfeLib::LogoOptions do
49
41
 
50
42
  context 'when the logo dimensions are larger than the dimensions of the box' do
51
43
  context 'when the logo is square' do
52
- let(:logo_dimensions) do
53
- { width: 150, height: 150 }
54
- end
44
+ let(:logo_dimensions) {{ width: 150, height: 150 }}
55
45
 
56
46
  it 'returns the options with box size' do
57
47
  expect(subject.options).to eq(height: 100, position: :center, vposition: :center)
@@ -59,9 +49,7 @@ RSpec.describe BrDanfe::DanfeLib::LogoOptions do
59
49
  end
60
50
 
61
51
  context 'when logo width is larger than logo height' do
62
- let(:logo_dimensions) do
63
- { width: 175, height: 150 }
64
- end
52
+ let(:logo_dimensions) {{ width: 175, height: 150 }}
65
53
 
66
54
  it 'returns the options with box size' do
67
55
  expect(subject.options).to eq(width: 100, position: :center, vposition: :center)
@@ -69,9 +57,7 @@ RSpec.describe BrDanfe::DanfeLib::LogoOptions do
69
57
  end
70
58
 
71
59
  context 'when logo height is larger than logo width' do
72
- let(:logo_dimensions) do
73
- { width: 150, height: 175 }
74
- end
60
+ let(:logo_dimensions) {{ width: 150, height: 175 }}
75
61
 
76
62
  it 'returns the options with box size' do
77
63
  expect(subject.options).to eq(height: 100, position: :center, vposition: :center)
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BrDanfe::DanfeLib::XML do
4
- subject { BrDanfe::DanfeLib::XML.new(xml_as_string) }
3
+ describe BrDanfe::XML do
4
+ subject { described_class.new(xml_as_string) }
5
5
 
6
6
  describe '#version_is_310_or_newer?' do
7
7
  describe "when xml's version is equal 3.10" do
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.11.2
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ASSEINFO
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-23 00:00:00.000000000 Z
11
+ date: 2020-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: barby
@@ -94,48 +94,62 @@ dependencies:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.2.2
97
+ - !ruby/object:Gem::Dependency
98
+ name: rqrcode
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.1.1
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.1.1
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: byebug
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - '='
102
116
  - !ruby/object:Gem::Version
103
- version: 3.5.1
117
+ version: 11.1.1
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - '='
109
123
  - !ruby/object:Gem::Version
110
- version: 3.5.1
124
+ version: 11.1.1
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: rake
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - '='
116
130
  - !ruby/object:Gem::Version
117
- version: 12.0.0
131
+ version: 13.0.1
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
136
  - - '='
123
137
  - !ruby/object:Gem::Version
124
- version: 12.0.0
138
+ version: 13.0.1
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: rspec
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - '='
130
144
  - !ruby/object:Gem::Version
131
- version: 3.6.0
145
+ version: 3.9.0
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - '='
137
151
  - !ruby/object:Gem::Version
138
- version: 3.6.0
152
+ version: 3.9.0
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: rubocop
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -170,28 +184,28 @@ dependencies:
170
184
  requirements:
171
185
  - - '='
172
186
  - !ruby/object:Gem::Version
173
- version: 0.17.0
187
+ version: 0.17.1
174
188
  type: :development
175
189
  prerelease: false
176
190
  version_requirements: !ruby/object:Gem::Requirement
177
191
  requirements:
178
192
  - - '='
179
193
  - !ruby/object:Gem::Version
180
- version: 0.17.0
194
+ version: 0.17.1
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: simplecov-html
183
197
  requirement: !ruby/object:Gem::Requirement
184
198
  requirements:
185
199
  - - '='
186
200
  - !ruby/object:Gem::Version
187
- version: 0.10.1
201
+ version: 0.10.2
188
202
  type: :development
189
203
  prerelease: false
190
204
  version_requirements: !ruby/object:Gem::Requirement
191
205
  requirements:
192
206
  - - '='
193
207
  - !ruby/object:Gem::Version
194
- version: 0.10.1
208
+ version: 0.10.2
195
209
  description:
196
210
  email: asseinfo@asseinfo.com.br
197
211
  executables: []
@@ -234,18 +248,31 @@ files:
234
248
  - lib/br_danfe/danfe_lib/infadic.rb
235
249
  - lib/br_danfe/danfe_lib/infadic_vol.rb
236
250
  - lib/br_danfe/danfe_lib/issqn.rb
237
- - lib/br_danfe/danfe_lib/logo_options.rb
238
- - lib/br_danfe/danfe_lib/options.rb
239
251
  - lib/br_danfe/danfe_lib/phone.rb
240
252
  - lib/br_danfe/danfe_lib/plate.rb
241
253
  - lib/br_danfe/danfe_lib/ticket.rb
242
254
  - lib/br_danfe/danfe_lib/transp.rb
243
255
  - lib/br_danfe/danfe_lib/vol.rb
244
- - lib/br_danfe/danfe_lib/xml.rb
245
256
  - lib/br_danfe/danfe_lib/xprod.rb
257
+ - lib/br_danfe/danfe_nfce.rb
258
+ - lib/br_danfe/danfe_nfce_lib/document.rb
259
+ - lib/br_danfe/danfe_nfce_lib/footer.rb
260
+ - lib/br_danfe/danfe_nfce_lib/header.rb
261
+ - lib/br_danfe/danfe_nfce_lib/helper.rb
262
+ - lib/br_danfe/danfe_nfce_lib/key.rb
263
+ - lib/br_danfe/danfe_nfce_lib/nfce_identification.rb
264
+ - lib/br_danfe/danfe_nfce_lib/product_list.rb
265
+ - lib/br_danfe/danfe_nfce_lib/qr_code.rb
266
+ - lib/br_danfe/danfe_nfce_lib/recipient.rb
267
+ - lib/br_danfe/danfe_nfce_lib/total_list.rb
268
+ - lib/br_danfe/helper.rb
269
+ - lib/br_danfe/logo_config.rb
270
+ - lib/br_danfe/logo_options.rb
246
271
  - lib/br_danfe/uf.rb
247
272
  - lib/br_danfe/version.rb
273
+ - lib/br_danfe/xml.rb
248
274
  - spec/features/cce_spec.rb
275
+ - spec/features/danfe_nfce_spec.rb
249
276
  - spec/features/danfe_spec.rb
250
277
  - spec/fixtures/cce/lib/barcode#render.pdf
251
278
  - spec/fixtures/cce/lib/correction#render.pdf
@@ -263,6 +290,37 @@ files:
263
290
  - spec/fixtures/cce/v1.00/cce.fixture.pdf
264
291
  - spec/fixtures/cce/v1.00/cce.xml
265
292
  - spec/fixtures/logo.png
293
+ - spec/fixtures/nfce/lib/document#render.pdf
294
+ - spec/fixtures/nfce/lib/footer#render.pdf
295
+ - spec/fixtures/nfce/lib/header#render-homologation.pdf
296
+ - spec/fixtures/nfce/lib/header#render-long_name_with_logo.pdf
297
+ - spec/fixtures/nfce/lib/header#render-long_name_without_logo.pdf
298
+ - spec/fixtures/nfce/lib/header#render-short_name_with_logo.pdf
299
+ - spec/fixtures/nfce/lib/header#render-short_name_without_logo.pdf
300
+ - spec/fixtures/nfce/lib/key#render.pdf
301
+ - spec/fixtures/nfce/lib/nfce_identification#render.pdf
302
+ - spec/fixtures/nfce/lib/product_list#render-with_many_products.pdf
303
+ - spec/fixtures/nfce/lib/product_list#render-with_many_products_and_long_names.pdf
304
+ - spec/fixtures/nfce/lib/product_list#render-with_single_product.pdf
305
+ - spec/fixtures/nfce/lib/product_list#render-with_single_product_and_long_name.pdf
306
+ - spec/fixtures/nfce/lib/product_list_with_many_products.xml
307
+ - spec/fixtures/nfce/lib/product_list_with_many_products_and_long_names.xml
308
+ - spec/fixtures/nfce/lib/product_list_with_single_product.xml
309
+ - spec/fixtures/nfce/lib/product_list_with_single_product_and_long_name.xml
310
+ - spec/fixtures/nfce/lib/qr_code#render.pdf
311
+ - spec/fixtures/nfce/lib/recipient#render-company.pdf
312
+ - spec/fixtures/nfce/lib/recipient#render-consumer_without_document.pdf
313
+ - spec/fixtures/nfce/lib/recipient#render-foreign.pdf
314
+ - spec/fixtures/nfce/lib/recipient#render-individual.pdf
315
+ - spec/fixtures/nfce/lib/recipient#render-unidentified_consumer.pdf
316
+ - spec/fixtures/nfce/lib/total_list#does_not_render-payment_methods.pdf
317
+ - spec/fixtures/nfce/lib/total_list#render-grouped_payment_methods.pdf
318
+ - spec/fixtures/nfce/lib/total_list#render-totals.pdf
319
+ - spec/fixtures/nfce/lib/total_list#render-without_payment.pdf
320
+ - spec/fixtures/nfce/lib/total_list#render.pdf
321
+ - spec/fixtures/nfce/v4.00/nfce.xml
322
+ - spec/fixtures/nfce/v4.00/rendered_nfce.fixture.pdf
323
+ - spec/fixtures/nfce/v4.00/saved_nfce.fixture.pdf
266
324
  - spec/fixtures/nfe/lib/dest#render-v2.00.pdf
267
325
  - spec/fixtures/nfe/lib/dest#render-v3.10.pdf
268
326
  - spec/fixtures/nfe/lib/dest#render-v4.00.pdf
@@ -357,16 +415,27 @@ files:
357
415
  - spec/lib/danfe_lib/infadic_spec.rb
358
416
  - spec/lib/danfe_lib/infadic_vol_spec.rb
359
417
  - spec/lib/danfe_lib/issqn_spec.rb
360
- - spec/lib/danfe_lib/logo_options_spec.rb
361
- - spec/lib/danfe_lib/options_spec.rb
362
418
  - spec/lib/danfe_lib/phone_spec.rb
363
419
  - spec/lib/danfe_lib/plate_spec.rb
364
420
  - spec/lib/danfe_lib/ticket_spec.rb
365
421
  - spec/lib/danfe_lib/transp_spec.rb
366
422
  - spec/lib/danfe_lib/vol_spec.rb
367
- - spec/lib/danfe_lib/xml_spec.rb
368
423
  - spec/lib/danfe_lib/xprod_spec.rb
424
+ - spec/lib/danfe_nfce_lib/document_spec.rb
425
+ - spec/lib/danfe_nfce_lib/footer_spec.rb
426
+ - spec/lib/danfe_nfce_lib/header_spec.rb
427
+ - spec/lib/danfe_nfce_lib/helper_spec.rb
428
+ - spec/lib/danfe_nfce_lib/key_spec.rb
429
+ - spec/lib/danfe_nfce_lib/nfce_identification_spec.rb
430
+ - spec/lib/danfe_nfce_lib/product_list_spec.rb
431
+ - spec/lib/danfe_nfce_lib/qr_code_spec.rb
432
+ - spec/lib/danfe_nfce_lib/recipient_spec.rb
433
+ - spec/lib/danfe_nfce_lib/total_list_spec.rb
434
+ - spec/lib/helper_spec.rb
435
+ - spec/lib/logo_config_spec.rb
436
+ - spec/lib/logo_options_spec.rb
369
437
  - spec/lib/uf_spec.rb
438
+ - spec/lib/xml_spec.rb
370
439
  - spec/spec_helper.rb
371
440
  - spec/support/have_same_content_of.rb
372
441
  homepage: http://github.com/asseinfo/br_danfe
@@ -1,38 +0,0 @@
1
- module BrDanfe
2
- module DanfeLib
3
- class XML
4
- def css(xpath)
5
- @xml.css(xpath)
6
- end
7
-
8
- def initialize(xml)
9
- @xml = Nokogiri::XML(xml)
10
- end
11
-
12
- def [](xpath)
13
- node = @xml.css(xpath)
14
- node ? node.text : ''
15
- end
16
-
17
- def collect(ns, tag)
18
- result = []
19
- # With namespace
20
- begin
21
- @xml.xpath("//#{ns}:#{tag}").each do |det|
22
- result << yield(det)
23
- end
24
- rescue StandardError
25
- # Without namespace
26
- @xml.xpath("//#{tag}").each do |det|
27
- result << yield(det)
28
- end
29
- end
30
- result
31
- end
32
-
33
- def version_is_310_or_newer?
34
- @xml.css('infNFe').attr('versao').to_s.to_f >= 3.10
35
- end
36
- end
37
- end
38
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe BrDanfe::DanfeLib::Options do
4
- it 'returns the default config set in the code' do
5
- options = BrDanfe::DanfeLib::Options.new
6
- expect(options.logo).to eq('')
7
- expect(options.logo_dimensions).to eq({})
8
- end
9
-
10
- it 'returns the config set in params' do
11
- custom_options = { logo: '/fake/path/file.png', logo_dimensions: { width: 50, height: 50 } }
12
-
13
- options = BrDanfe::DanfeLib::Options.new(custom_options)
14
- expect(options.logo).to eq('/fake/path/file.png')
15
- expect(options.logo_dimensions).to eq({ width: 50, height: 50 })
16
- end
17
- end