norma43 0.1 → 0.2

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.
Files changed (4) hide show
  1. data/README +62 -4
  2. data/lib/norma43/version.rb +1 -1
  3. data/lib/norma43.rb +10 -3
  4. metadata +4 -4
data/README CHANGED
@@ -1,11 +1,69 @@
1
1
  Parser for NORMA43 Files. (a standard from the spanish banking industry for account movements)
2
2
 
3
+ Install
4
+ =======
5
+
6
+ gem install norma43
7
+
8
+
3
9
  Usage
4
10
  =====
5
11
 
6
- require 'lib/norma43'
7
- data = Norma43.read(PATH_TO_FILE)
12
+ require 'rubygems'
13
+ require 'norma43'
14
+
15
+ data = Norma43.read(PATH_TO_FILE, "iso-8859-1")
16
+
17
+ Second parameter is the encoding of the .n43 file. As spanish banks continue in 20th Century, default is iso-8859-1.
18
+
19
+
20
+ Data format (excerpt from data.to_yaml)
21
+ ===========
22
+ :info:
23
+ :end_date: 2011-03-20
24
+ :account:
25
+ :bank: 1234
26
+ :office: "1234"
27
+ :number: 1234567890
28
+ :control: ??
29
+ :final_balance: 4469.33
30
+ :initial_balance: 10593.16
31
+ :account_owner: YOUR NAME OR COMPANY
32
+ :currency: "978"
33
+ :begin_date: 2011-03-01
34
+ :movements:
35
+ - :operation_date: 2011-03-01
36
+ :concept: TRANSFERENC. A MR. POSTMAN
37
+ :value_date: 2011-03-01
38
+ :office: 0901
39
+ :operation: "0000000000"
40
+ :reference_1: "000000000000"
41
+ :reference_2: ""
42
+ :amount: 927.0
43
+ - :operation_date: 2011-03-01
44
+ :concept: TRANSFERENC. A MRS. ROBINSON
45
+ :value_date: 2011-03-01
46
+ :office: 0901
47
+ :operation: "0000000000"
48
+ :reference_1: "000000000000"
49
+ :reference_2: ""
50
+ :amount: 1274.09
51
+ - :operation_date: 2011-03-04
52
+ :concept: TARJ.CREDITO SANDMAN
53
+ :value_date: 2011-03-04
54
+ :office: 0901
55
+ :operation: "0000000000"
56
+ :reference_1: "281034520913"
57
+ :reference_2: "1234123412341234"
58
+ :amount: 1177.81
59
+
60
+
61
+ CHANGELOG
62
+ =========
63
+
64
+ 0.2 - June 20, 2011
65
+ - Encoding of input files
8
66
 
9
- Until we write a better documentation, check what is being read with:
10
67
 
11
- puts data.to_yaml
68
+ 0.1 - June 15, 2011
69
+ - Initial version, most of parsing
@@ -1,3 +1,3 @@
1
1
  module Norma43
2
- VERSION = "0.1"
2
+ VERSION = "0.2"
3
3
  end
data/lib/norma43.rb CHANGED
@@ -1,11 +1,16 @@
1
+ require "iconv"
2
+
1
3
  module Norma43
2
4
 
3
5
  DATE_FORMAT = '%y%m%d'
4
6
 
5
- def self.read(path_to_file)
7
+ def self.read(path_to_file, encoding="iso-8859-1")
6
8
  data = Hash.new
7
9
  data[:movements] = Array.new
8
- File.open(path_to_file, "r").each_line do |line|
10
+
11
+ file = File.open(path_to_file, "r")
12
+ file.each do |encoded_line|
13
+ line = Iconv.iconv("UTF-8", "#{encoding}", encoded_line).to_s
9
14
  code = line[0..1]
10
15
  data[:info] = self.parse_header(line) if code == '11'
11
16
  data[:movements] << self.parse_movement_main(line) if code == '22'
@@ -14,7 +19,9 @@ module Norma43
14
19
  #TODO check amount values against those on record 33
15
20
  data[:info].merge!(self.parse_end(line)) if code == '33'
16
21
  #TODO parse record 88, end of file
17
- end
22
+ end
23
+ file.close
24
+
18
25
  data
19
26
  end
20
27
 
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: norma43
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- version: "0.1"
8
+ - 2
9
+ version: "0.2"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Linking Paths
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-06-16 00:00:00 +02:00
17
+ date: 2011-06-20 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency