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.
@@ -6,7 +6,7 @@ grammar Document
6
6
  end
7
7
 
8
8
  rule record
9
- date account_iban statement_number initial_balance transactions final_balance wololo? <Record>
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 final_balance
30
- ":62F:" (!(nl) .)* nl
29
+ rule closing_balance
30
+ codess (!(nl) .)* nl
31
31
  end
32
32
 
33
- rule wololo
34
- ":64:" (!('-' / nl) .)*
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
- # ":61:" valor date debit amount swift '//' reference (.)*
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
@@ -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
- self.show_error(data) if tree.nil?
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)
@@ -1,3 +1,3 @@
1
1
  module MT940
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
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.2.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-05 00:00:00.000000000 Z
12
+ date: 2013-08-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: treetop