mt940parser 0.2.0 → 0.3.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.
- data/lib/mt940parser/document.treetop +7 -8
- data/lib/mt940parser/parser.rb +5 -1
- data/lib/mt940parser/version.rb +1 -1
- metadata +2 -2
@@ -6,7 +6,7 @@ grammar Document
|
|
6
6
|
end
|
7
7
|
|
8
8
|
rule record
|
9
|
-
date account_iban statement_number initial_balance transactions
|
9
|
+
date account_iban statement_number initial_balance transactions closing_balance closing_available_balance? <Record>
|
10
10
|
end
|
11
11
|
|
12
12
|
rule date
|
@@ -26,16 +26,16 @@ grammar Document
|
|
26
26
|
end
|
27
27
|
|
28
28
|
# Create captures for those if needed (not for now)
|
29
|
-
rule
|
30
|
-
|
29
|
+
rule closing_balance
|
30
|
+
codess (!(nl) .)* nl
|
31
31
|
end
|
32
32
|
|
33
|
-
rule
|
34
|
-
":64:" (!(
|
33
|
+
rule closing_available_balance
|
34
|
+
":64:" (!(nl) .)* nl
|
35
35
|
end
|
36
36
|
|
37
37
|
rule codess
|
38
|
-
(':61:' <Cods> / ":20:" <Cods> / ":28:" <Cods> / ":28C:" <Cods> / ":25:" <Cods> / ":60F:" <Cods> )
|
38
|
+
(':61:' <Cods> / ":20:" <Cods> / ":28:" <Cods> / ":28C:" <Cods> / ":25:" <Cods> / ":60F:" <Cods> /":62F:" <Cods> )
|
39
39
|
end
|
40
40
|
|
41
41
|
rule eof
|
@@ -51,8 +51,7 @@ grammar Document
|
|
51
51
|
end
|
52
52
|
|
53
53
|
rule base
|
54
|
-
|
55
|
-
codess valor account_date type amount swift (!(nl) .)* nl <Base>
|
54
|
+
codess valor account_date type amount swift (!(nl) .)* nl <Base> # ":61:"
|
56
55
|
end
|
57
56
|
# ========= Base ======== #
|
58
57
|
rule valor
|
data/lib/mt940parser/parser.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module MT940
|
2
|
+
class ParseError < StandardError; end
|
2
3
|
class Parser
|
3
4
|
|
4
5
|
base_path = File.dirname(__FILE__)
|
@@ -11,7 +12,10 @@ module MT940
|
|
11
12
|
def self.parse(data)
|
12
13
|
tree = @@parser.parse(data)
|
13
14
|
|
14
|
-
|
15
|
+
if tree.nil?
|
16
|
+
self.show_error(data)
|
17
|
+
raise ParseError, "Failed to parse file. See log for more information"
|
18
|
+
end
|
15
19
|
|
16
20
|
# clean up the tree by removing all nodes of default type 'SyntaxNode'
|
17
21
|
self.clean_tree(tree)
|
data/lib/mt940parser/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mt940parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: treetop
|