cmxl 1.3.0 → 1.4.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: 4a9d2c6d5faed6e357abd5459811d43764a89448fc46763993938b1519b17a2a
4
- data.tar.gz: 3861abc066158de7c4468d9df01a57331d1913b1d84645b7618f2d146c419a47
3
+ metadata.gz: d5e0a335b0d8a997acf80ab578362f77f08880b0d7258f3c3af365b71eb53925
4
+ data.tar.gz: b2d3c8dd9925866da29d27cc43457652f2fdf377bcd1080feb87d654a88b37e4
5
5
  SHA512:
6
- metadata.gz: 716ee9967921b4539174032223aae5eb996ada741c2181b556e7bb8ec5355668aedd8167ba564836ee73a8a8fa7256d83a74c4f6d8309496cde600c7d631b66c
7
- data.tar.gz: 4395610ac7de16b264b309940eda9a2727cfce3c49f8cf051b91f4ab0f8f0486c2caf0528a8efd995fd327f31ccefc288a860f8e458b6ba7b0f1ffe7be85939e
6
+ metadata.gz: fa0be57b4e8643e1a20f4bb276d7953eb7cc3f16cc3c89286b5ca6fa7e2a9b285b1358424f6904d086315907d1ba77f2d89616980a82bb4360f162e91eaf2477
7
+ data.tar.gz: 2990c106239b3f65c35abdc662af7afdba0ba4d539e1e9f3838179d5f238e1b72fbf43b82743bce5a060b291a4a9f28031f3bc4aba9e39f76c155d178d1f1b83
data/CHANGELOG.mdown CHANGED
@@ -1,3 +1,8 @@
1
+ # 1.4.0
2
+
3
+ - [FEATURE] adds ability to parse non-numerical tags ([#23](https://github.com/railslove/cmxl/issues/23)) \
4
+ Thanks to [@prometh07](https://github.com/prometh07)
5
+
1
6
  # 1.3.0
2
7
 
3
8
  - [FEATURE] adds MT942 compatibility
data/lib/cmxl/field.rb CHANGED
@@ -47,7 +47,7 @@ module Cmxl
47
47
  # Cmxl::Field.parse(':60F:C031002PLN40000,00') #=> returns an AccountBalance instance
48
48
  #
49
49
  def self.parse(line)
50
- if line =~ /\A:(\d{2,2})(\w)?:(.*)\z/m
50
+ if line =~ /\A:(\w{2,2})(\w)?:(.*)\z/m
51
51
  tag = Regexp.last_match(1)
52
52
  modifier = Regexp.last_match(2)
53
53
  content = Regexp.last_match(3).delete("\r").gsub(/\n\z/, '') # remove trailing line break to prevent empty field parsing
data/lib/cmxl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cmxl
2
- VERSION = '1.3.0'.freeze
2
+ VERSION = '1.4.0'.freeze
3
3
  end
@@ -1,8 +1,24 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'Unknwn fields' do
4
- subject { Cmxl::Field.parse(':42F:C140908EUR000000000136,02') }
5
- it { expect(subject.tag).to eql('42') }
6
- it { expect(subject.source).to eql('C140908EUR000000000136,02') }
7
- it { expect(subject.to_h).to eql(tag: '42', modifier: 'F', source: 'C140908EUR000000000136,02') }
3
+ describe 'Unknown fields' do
4
+ context 'numerical fields' do
5
+ subject { Cmxl::Field.parse(':42F:C140908EUR000000000136,02') }
6
+ it { expect(subject.tag).to eql('42') }
7
+ it { expect(subject.source).to eql('C140908EUR000000000136,02') }
8
+ it { expect(subject.to_h).to eql(tag: '42', modifier: 'F', source: 'C140908EUR000000000136,02') }
9
+ end
10
+
11
+ context 'alphanumerical fields w/ modifier' do
12
+ subject { Cmxl::Field.parse(':NSF:SomethingSomethingDarkSide') }
13
+ it { expect(subject.tag).to eql('NS') }
14
+ it { expect(subject.source).to eql('SomethingSomethingDarkSide') }
15
+ it { expect(subject.to_h).to eql(tag: 'NS', modifier: 'F', source: 'SomethingSomethingDarkSide') }
16
+ end
17
+
18
+ context 'alphanumerical fields wo/ modifier' do
19
+ subject { Cmxl::Field.parse(':FO:oBar') }
20
+ it { expect(subject.tag).to eql('FO') }
21
+ it { expect(subject.source).to eql('oBar') }
22
+ it { expect(subject.to_h).to eql(tag: 'FO', modifier: nil, source: 'oBar') }
23
+ end
8
24
  end
@@ -49,6 +49,7 @@ GmbH?3050060400?31084756
49
49
  :20:TELEWIZORY S.A.
50
50
  :25:BPHKPLPK/320000546101
51
51
  :28C:00084/001
52
+ :NSF:HelloWorld
52
53
  :60F:C031002PLN40000,00
53
54
  :61:0310201020C20000,00FMSCNONREF//8327000090031789
54
55
  Card transaction
@@ -57,6 +57,8 @@ describe 'parsing a statement' do
57
57
  it { expect(subject.transactions.first.bic).to eql('10600076') }
58
58
  it { expect(subject.transactions.first.iban).to eql('PL08106000760000777777777777') }
59
59
  it { expect(subject.transactions.first.sepa).to eql({}) }
60
+
61
+ it { expect(subject.field('NS').to_h).to eql({tag: 'NS', modifier: 'F', source: 'HelloWorld'}) }
60
62
  end
61
63
 
62
64
  context 'statement separator as used by most banks' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmxl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bumann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-14 00:00:00.000000000 Z
11
+ date: 2019-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  - !ruby/object:Gem::Version
197
197
  version: '0'
198
198
  requirements: []
199
- rubygems_version: 3.0.1
199
+ rubygems_version: 3.0.2
200
200
  signing_key:
201
201
  specification_version: 4
202
202
  summary: Cmxl is your friendly MT940 bank statement parser