bai_parser 1.0.0 → 1.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 +8 -8
- data/README.md +2 -2
- data/lib/bai_parser/version.rb +1 -1
- data/lib/bai_parser.rb +27 -24
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjE5YWVlNjAxNGY0OWNlYjRlNTNlYTI5YTA4MjEzNmM3Y2QzZDBkNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTQ3ZDkzMWE1YTI0M2U3ZjM5ZWQ3ZDJjMzRkZWZkY2NlMDllMGZkMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTIxZjQ5Mzg3MjM2Y2IzNzk1YWIwYWViMzAwZmZlNmVlZmM3NGQzNDQ2OTU3
|
10
|
+
MzZhMjNlYzllZjA5ZjE2YjVhOGRjZDhiNWExZjAxZDM0ZWNkZjM3Y2I3MWYy
|
11
|
+
NWRmYjFhN2JlYmQ2OTk0OWYxYTNiNGJiZjY5NGQxOWUzZDQ3YjE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YWQ2YmE2NTY1MmMzNGVhM2YwOTQxOWNjNjZkZDE0OWZjNGU3MmQ0ZDMxOTBh
|
14
|
+
NmEzOGIwNGY2YTcxMTJhMzkyZjgwNDVmZGYwZmQ3YTNlZWVjNzJkYWRhMGE3
|
15
|
+
MjYyNDFiZmMyNWJkMjU4ZTE4ODY5MDk1ZmI4ZWQ4M2E0YjBlODQ=
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# BAI Parser
|
2
2
|
|
3
3
|
Ruby BAI2 Bank File parser. Takes a bank file as input and outputs the data as a Ruby hash. You can then use a custom writer class to output the data as needed for your purposes.
|
4
4
|
|
@@ -20,7 +20,7 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
``` ruby
|
22
22
|
require "bai_parser"
|
23
|
-
data =
|
23
|
+
data = BaiParser::Parser.parse "BAI-File-From-Bank.bai"
|
24
24
|
|
25
25
|
# Then you can use a custom writer to output the data as needed such as to a csv file
|
26
26
|
MyCustomBAIWriter.write data
|
data/lib/bai_parser/version.rb
CHANGED
data/lib/bai_parser.rb
CHANGED
@@ -31,6 +31,33 @@ module BaiParser
|
|
31
31
|
p.parse filename
|
32
32
|
end
|
33
33
|
|
34
|
+
def parse(filename)
|
35
|
+
f = File.open(filename)
|
36
|
+
record = next_line = f.gets.chomp
|
37
|
+
count = 1
|
38
|
+
loop do
|
39
|
+
loop do # gather continuation lines
|
40
|
+
next_line = f.gets
|
41
|
+
break if next_line.nil?
|
42
|
+
next_line.chomp!
|
43
|
+
count += 1
|
44
|
+
if next_line[0..1] == '88'
|
45
|
+
record.sub!(/\/\s*$/,',')
|
46
|
+
record += next_line[3..-1]
|
47
|
+
else
|
48
|
+
break
|
49
|
+
end
|
50
|
+
end
|
51
|
+
record.sub!(/\/\s*$/,'')
|
52
|
+
self.send RECORD_CODES[record[0..1]], record
|
53
|
+
break if next_line.nil?
|
54
|
+
record = next_line
|
55
|
+
end
|
56
|
+
return @data
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
34
61
|
def default_record_parse(type, record)
|
35
62
|
h = Hash.new
|
36
63
|
values = record.split(',')
|
@@ -125,30 +152,6 @@ module BaiParser
|
|
125
152
|
return [a, c]
|
126
153
|
end
|
127
154
|
|
128
|
-
def parse(filename)
|
129
|
-
f = File.open(filename)
|
130
|
-
record = next_line = f.gets.chomp
|
131
|
-
count = 1
|
132
|
-
loop do
|
133
|
-
loop do # gather continuation lines
|
134
|
-
next_line = f.gets
|
135
|
-
break if next_line.nil?
|
136
|
-
next_line.chomp!
|
137
|
-
count += 1
|
138
|
-
if next_line[0..1] == '88'
|
139
|
-
record.sub!(/\/\s*$/,',')
|
140
|
-
record += next_line[3..-1]
|
141
|
-
else
|
142
|
-
break
|
143
|
-
end
|
144
|
-
end
|
145
|
-
record.sub!(/\/\s*$/,'')
|
146
|
-
self.send RECORD_CODES[record[0..1]], record
|
147
|
-
break if next_line.nil?
|
148
|
-
record = next_line
|
149
|
-
end
|
150
|
-
return @data
|
151
|
-
end
|
152
155
|
end
|
153
156
|
|
154
157
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bai_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sanjiv Patel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,4 +81,3 @@ specification_version: 4
|
|
81
81
|
summary: Takes a bank file as input and outputs the data as a Ruby hash. You can
|
82
82
|
then use a custom writer class to output the data as needed for your purposes.
|
83
83
|
test_files: []
|
84
|
-
has_rdoc:
|