cfonb 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 057c580fc124d3731dc852832c8c6f601584bbd235604fd5c44605b4509429c0
4
- data.tar.gz: 037c88124d45e136b909660a8ef7f840a03fa5a7bc06c9e19e592e2eb67080a5
3
+ metadata.gz: dc4cf0c8e232fa1e00ee5bce36bd4c08c794c10f11c0ebdc003656acd76b55a9
4
+ data.tar.gz: b0cb3d056013926111232aee3d88405b39f828aa91fa2d1376f9352a25d7dd87
5
5
  SHA512:
6
- metadata.gz: b803bf7c0a2c0803e7ae54ea937d3ccb06eeeced3f7dcc033ce202a658137c41da085adf462c2ebcf9d76352cb3990467a45deeaf0a80ad6c86b713a9733248e
7
- data.tar.gz: 02c6b90c2732f5da3b481ec2c9b811b17377d0a7e602780d2048baf86499c3115abe4fcff98cd1cf454a80967565167aa6475fd53cc8442e43c14ddad79d89a4
6
+ metadata.gz: 778ef5f41ef6e3bbee2b9559027846b40075dc1550d54730bfb1af6d1f6760b44cb2b5b434dbf3e91734972d92e3668f2937b973a2d76e40207bff91d512f385
7
+ data.tar.gz: 3f1d6d72236faf46f2ff7ac120f31d7e6892498b2109e6c0b1bc4f5ed49a5bdf0063dc43bfc7a4342e756fd14edb83594a609b6fe3277ce214a502fab6e9bd22
@@ -7,7 +7,7 @@ module CFONB
7
7
  base.singleton_class.prepend(
8
8
  Module.new do
9
9
  def apply(details, line)
10
- code = :"@#{line.detail_code}"
10
+ code = :"@#{line.detail_code.gsub(' ', '_')}"
11
11
  details.instance_variable_set(code, instance_value(details, line, code))
12
12
 
13
13
  super
@@ -2,12 +2,15 @@
2
2
 
3
3
  module CFONB
4
4
  module OperationDetails
5
- class Unknown < Base
6
- ATTRIBUTES = %i[unknown].freeze
7
-
5
+ class Unknown
8
6
  def self.apply(details, line)
9
- details.unknown ||= {}
10
- code = line.detail_code
7
+ unless details.instance_variable_defined?(:@unknown)
8
+ details.instance_variable_set(:@unknown, {})
9
+
10
+ details.class.attr_accessor :unknown
11
+ end
12
+
13
+ code = line.detail_code.gsub(' ', '_')
11
14
 
12
15
  details.unknown[code] =
13
16
  if details.unknown[code] && line.detail.is_a?(String)
@@ -15,7 +15,7 @@ module CFONB
15
15
  end
16
16
 
17
17
  def self.for(line)
18
- return unless line.respond_to?(:detail_code)
18
+ return unless line.respond_to?(:detail_code) && line.detail_code != ''
19
19
 
20
20
  @details[line.detail_code] || Unknown
21
21
  end
@@ -276,8 +276,8 @@ describe CFONB::Operation do
276
276
  context 'with an unknown detail' do
277
277
  let(:detail) do
278
278
  OpenStruct.new(
279
- body: '0530004411001871EUR2 0001016255614090823 AAAEUR200000000000740',
280
- detail_code: 'AAA',
279
+ body: '0530004411001871EUR2 0001016255614090823 A AEUR200000000000740',
280
+ detail_code: 'A A',
281
281
  detail: 'EUR200000000000740',
282
282
  )
283
283
  end
@@ -285,14 +285,25 @@ describe CFONB::Operation do
285
285
  it 'adds the detail to the unknown details hash' do
286
286
  operation.merge_detail(detail)
287
287
 
288
- expect(operation.details.unknown).to eq({ 'AAA' => 'EUR200000000000740' })
288
+ expect(operation.details.unknown).to eq({ 'A_A' => 'EUR200000000000740' })
289
289
  end
290
290
 
291
291
  it 'updates the current details in case of duplicated codes' do
292
292
  operation.merge_detail(detail)
293
293
  operation.merge_detail(detail)
294
294
 
295
- expect(operation.details.unknown).to eq({ 'AAA' => "EUR200000000000740\nEUR200000000000740" })
295
+ expect(operation.details.unknown).to eq({ 'A_A' => "EUR200000000000740\nEUR200000000000740" })
296
+ end
297
+
298
+ it 'does not add any detail if they are empty' do
299
+ detail = OpenStruct.new(
300
+ body: '0530004411001871EUR2 0001016255614090823',
301
+ detail_code: '',
302
+ detail: 'EUR200000000000740',
303
+ )
304
+ operation.merge_detail(detail)
305
+
306
+ expect(operation.details.unknown).to be_nil
296
307
  end
297
308
  end
298
309
  end
@@ -53,6 +53,8 @@ describe CFONB::Parser do
53
53
  'AAA' => "INTERNETA AAA\nINTERNETA ABB",
54
54
  'BBB' => 'INTERNETE BBB',
55
55
  'CCC' => 'INTERNETI CCC',
56
+ 'N_Y' => 'EXAMPLE WITH EMPTY SPACE',
57
+ '2\'C' => 'EXAMPLE WITH OTHER COMBINATIONS',
56
58
  },
57
59
  )
58
60
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfonb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johan Le Bray
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-12-05 00:00:00.000000000 Z
12
+ date: 2025-01-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: license_finder