bai2 2.0.0 → 2.0.1
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 +4 -4
- data/.circleci/config.yml +37 -0
- data/CHANGELOG.md +3 -0
- data/README.md +3 -0
- data/bai2.gemspec +1 -2
- data/lib/bai2.rb +5 -5
- data/lib/bai2/parser.rb +2 -2
- data/lib/bai2/record.rb +9 -2
- data/test/data/eod_with_slash_in_text.bai2 +18 -0
- data/test/tests/bai2.rb +3 -2
- metadata +4 -2
- data/lib/bai2/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2c135a421db2cecf82dd36a921239da5893f64f
|
4
|
+
data.tar.gz: 13b70262c5e59a5c0568fa4ddabddb3deb7176f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b23d85fe51f1ec6b4e75a9c9735c796dc2ba5249baba21d2b35663d0ccf0e747f57079df2d0b79965c6788d87fc24789c86e3683c0b78d078d1522082a872161
|
7
|
+
data.tar.gz: 045ebbb486134bde017a2d3de65a3a5ff21bcd92f217645e62171c35f0f36ba3b3e6a1930aa81db736b37b7dc183c812e70c0e8b34b62fddf3f23b63dce30eeb
|
@@ -0,0 +1,37 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
build:
|
4
|
+
parallelism: 1
|
5
|
+
resource_class: small
|
6
|
+
working_directory: "~/bai2"
|
7
|
+
docker:
|
8
|
+
- image: 207583270433.dkr.ecr.us-west-1.amazonaws.com/universe/ruby_24:0.15
|
9
|
+
steps:
|
10
|
+
- checkout
|
11
|
+
- run:
|
12
|
+
name: build gem
|
13
|
+
command: |
|
14
|
+
gem build bai2.gemspec
|
15
|
+
- run:
|
16
|
+
name: push gem
|
17
|
+
command: |
|
18
|
+
if [[ -n "${GEMFURY_USERNAME}" && -n "${GEMFURY_PASSWORD}" ]]; then
|
19
|
+
echo -e "machine api.fury.io\n login ${GEMFURY_USERNAME}\n password ${GEMFURY_PASSWORD}" >> ~/.netrc
|
20
|
+
chmod 600 ~/.netrc
|
21
|
+
version=$(parse-gemspec-cli bai2.gemspec | jq -r ".version")
|
22
|
+
grep -q "${version}" <(fury versions bai2) || EXIT_CODE=$? && true
|
23
|
+
if [[ $EXIT_CODE == 1 ]]; then
|
24
|
+
fury push bai2-${version}.gem
|
25
|
+
else
|
26
|
+
echo "bai2 version ${version} has previously been released to gemfury, increment the version for a new release"
|
27
|
+
fi
|
28
|
+
fi
|
29
|
+
workflows:
|
30
|
+
version: 2
|
31
|
+
build-and-push:
|
32
|
+
jobs:
|
33
|
+
- build:
|
34
|
+
context: org-global
|
35
|
+
filters:
|
36
|
+
branches:
|
37
|
+
only: master
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
Changelog
|
2
2
|
|
3
|
+
## 2.0.1
|
4
|
+
- Add `continuations_slash_delimit_end_of_line_only` to options. This option allows parsing continuation records that begin with a slash character (`/`).
|
5
|
+
|
3
6
|
## 2.0.0
|
4
7
|
- Add parameters for whether or not we use account summaries for account control checksum. We now include it by default. To disable it `account_control_ignores_summary_amounts` should passed into `options` This is the only breaking change.
|
5
8
|
- Allow for optional "as of" times on the Group header.
|
data/README.md
CHANGED
@@ -86,6 +86,9 @@ account control values.
|
|
86
86
|
* `options[:num_account_summary_continuation_records]` (Integer, Default: 0)
|
87
87
|
The number of continuation records the account summary.
|
88
88
|
|
89
|
+
* `options[:continuations_slash_delimit_end_of_line_only]` (Boolean, Default: False)
|
90
|
+
This allows continuation records to begin with `88,\` and still have the text including the slash to be processed.
|
91
|
+
|
89
92
|
|
90
93
|
##### Usage:
|
91
94
|
|
data/bai2.gemspec
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'bai2/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
6
|
spec.name = 'bai2'
|
8
|
-
spec.version =
|
7
|
+
spec.version = '2.0.1'
|
9
8
|
spec.authors = ['Kenneth Ballenegger']
|
10
9
|
spec.email = ['kenneth@ballenegger.com']
|
11
10
|
spec.summary = %q{Parse BAI2 files.}
|
data/lib/bai2.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'bai2/version'
|
2
1
|
require 'bai2/record'
|
3
2
|
require 'bai2/parser'
|
4
3
|
require 'bai2/integrity'
|
@@ -13,7 +12,8 @@ module Bai2
|
|
13
12
|
|
14
13
|
DEFAULT_OPTIONS = {
|
15
14
|
account_control_ignores_summary_amounts: false,
|
16
|
-
num_account_summary_continuation_records: 0
|
15
|
+
num_account_summary_continuation_records: 0,
|
16
|
+
continuations_slash_delimit_end_of_line_only: false,
|
17
17
|
}.freeze
|
18
18
|
|
19
19
|
# Parse a file on disk:
|
@@ -33,7 +33,7 @@ module Bai2
|
|
33
33
|
@raw = raw
|
34
34
|
@groups = []
|
35
35
|
@options = DEFAULT_OPTIONS.merge(options)
|
36
|
-
parse(raw)
|
36
|
+
parse(raw, options)
|
37
37
|
end
|
38
38
|
|
39
39
|
# This is the raw data. Probably not super important.
|
@@ -62,9 +62,9 @@ module Bai2
|
|
62
62
|
# This delegates most of the work to Bai2::Parser to build the ParseNode
|
63
63
|
# tree.
|
64
64
|
#
|
65
|
-
def parse(data)
|
65
|
+
def parse(data, options)
|
66
66
|
|
67
|
-
root = Parser.parse(data)
|
67
|
+
root = Parser.parse(data, options)
|
68
68
|
|
69
69
|
# parse the file node; will descend tree and parse children
|
70
70
|
parse_file_node(root)
|
data/lib/bai2/parser.rb
CHANGED
@@ -26,10 +26,10 @@ module Bai2
|
|
26
26
|
# 1. Build a tree
|
27
27
|
# 2. Parse the tree
|
28
28
|
#
|
29
|
-
def parse(data)
|
29
|
+
def parse(data, options)
|
30
30
|
|
31
31
|
# split records, handle stupid DOS-format files, instantiate records
|
32
|
-
records = data.split("\n").map(&:strip).map {|l| Record.new(l) }
|
32
|
+
records = data.split("\n").map(&:strip).map {|l| Record.new(l, options: options) }
|
33
33
|
|
34
34
|
# merge continuations
|
35
35
|
records = merge_continuations(records)
|
data/lib/bai2/record.rb
CHANGED
@@ -112,11 +112,18 @@ module Bai2
|
|
112
112
|
}
|
113
113
|
|
114
114
|
|
115
|
-
def initialize(line, physical_record_count = 1)
|
115
|
+
def initialize(line, physical_record_count = 1, options: {})
|
116
116
|
@code = RECORD_CODES[line[0..1]]
|
117
117
|
@physical_record_count = physical_record_count
|
118
118
|
# clean / delimiter
|
119
|
-
@raw =
|
119
|
+
@raw = if options[:continuations_slash_delimit_end_of_line_only]
|
120
|
+
# Continuation records for transaction details extend the text fields
|
121
|
+
# and they may begin with 88,/ but should include the rest of the line.
|
122
|
+
# A proper fix would involve each continuation record knowing what field it was extending.
|
123
|
+
line.sub(/\/$/, '')
|
124
|
+
else
|
125
|
+
line.sub(/,\/.+$/, '').sub(/\/$/, '')
|
126
|
+
end
|
120
127
|
end
|
121
128
|
|
122
129
|
attr_reader :code, :raw, :physical_record_count
|
@@ -0,0 +1,18 @@
|
|
1
|
+
01,121140399,3333333333,100831,1720,000001,80,1,2/
|
2
|
+
02,3333333333,121140399,1,100831,,USD,4/
|
3
|
+
03,3333333333,USD,,,,/
|
4
|
+
16,195,8325982,,,,FED NO: 20100831L1B77D1CDSDSDJSIO15608310954FT01
|
5
|
+
88,SENDER BNK:=ETRADE BANK
|
6
|
+
88,SENDER ID:=056073573
|
7
|
+
88,ORG:=OPTIONS LINK WIRE CLEARING
|
8
|
+
88,ORG ADDRESS:=2/AV MAIN 2/AVENUE DE ANGELLIST 3/MX
|
9
|
+
88,/MEXICO ;
|
10
|
+
88,BNF ID:=3300333333
|
11
|
+
88,BNF NAME:=YOUR NAME HERE INC
|
12
|
+
88,BNF ADDRESS:=185 B ST SAN FRAN, CA 94011
|
13
|
+
88,REC FI:=SIL VLY BK SCLA
|
14
|
+
88,REC ID:=121140399
|
15
|
+
88,OBI:=INVOICE 123456
|
16
|
+
49,8325982,14/
|
17
|
+
98,8325982,1,16/
|
18
|
+
99,8325982,1,18/
|
data/test/tests/bai2.rb
CHANGED
@@ -11,8 +11,10 @@ class Bai2Test < Minitest::Test
|
|
11
11
|
|
12
12
|
@eod = Bai2::BaiFile.parse(File.expand_path('../../data/eod.bai2', __FILE__))
|
13
13
|
@eod_no_as_of_time = Bai2::BaiFile.parse(File.expand_path('../../data/eod_without_as_of_time.bai2', __FILE__))
|
14
|
+
@eod_with_slash_in_continuation = Bai2::BaiFile.parse(File.expand_path('../../data/eod_with_slash_in_text.bai2', __FILE__),
|
15
|
+
continuations_slash_delimit_end_of_line_only: true)
|
14
16
|
|
15
|
-
@all_files = [@daily, @daily_with_summary, @eod, @eod_no_as_of_time]
|
17
|
+
@all_files = [@daily, @daily_with_summary, @eod, @eod_no_as_of_time, @eod_with_slash_in_continuation]
|
16
18
|
end
|
17
19
|
|
18
20
|
def test_parsing
|
@@ -73,5 +75,4 @@ class Bai2Test < Minitest::Test
|
|
73
75
|
Bai2::BaiFile.parse(File.expand_path('../../data/invalid_checksum_eod.bai2', __FILE__))
|
74
76
|
end
|
75
77
|
end
|
76
|
-
|
77
78
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bai2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenneth Ballenegger
|
@@ -73,6 +73,7 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".circleci/config.yml"
|
76
77
|
- ".gitignore"
|
77
78
|
- CHANGELOG.md
|
78
79
|
- Gemfile
|
@@ -86,11 +87,11 @@ files:
|
|
86
87
|
- lib/bai2/parser.rb
|
87
88
|
- lib/bai2/record.rb
|
88
89
|
- lib/bai2/type-code-data.rb
|
89
|
-
- lib/bai2/version.rb
|
90
90
|
- test/autorun.rb
|
91
91
|
- test/data/daily.bai2
|
92
92
|
- test/data/daily_with_summary.bai2
|
93
93
|
- test/data/eod.bai2
|
94
|
+
- test/data/eod_with_slash_in_text.bai2
|
94
95
|
- test/data/eod_without_as_of_time.bai2
|
95
96
|
- test/data/invalid_checksum_eod.bai2
|
96
97
|
- test/tests/bai2.rb
|
@@ -124,6 +125,7 @@ test_files:
|
|
124
125
|
- test/data/daily.bai2
|
125
126
|
- test/data/daily_with_summary.bai2
|
126
127
|
- test/data/eod.bai2
|
128
|
+
- test/data/eod_with_slash_in_text.bai2
|
127
129
|
- test/data/eod_without_as_of_time.bai2
|
128
130
|
- test/data/invalid_checksum_eod.bai2
|
129
131
|
- test/tests/bai2.rb
|
data/lib/bai2/version.rb
DELETED