outbanker 0.1.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 +15 -0
- data/.gitignore +17 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +36 -0
- data/Rakefile +21 -0
- data/lib/outbanker/money_string_parser.rb +14 -0
- data/lib/outbanker/statement_line.rb +78 -0
- data/lib/outbanker/statement_lines.rb +50 -0
- data/lib/outbanker/version.rb +3 -0
- data/lib/outbanker.rb +7 -0
- data/outbanker.gemspec +21 -0
- data/test/fixtures/outbank-cc.csv +3 -0
- data/test/fixtures/outbank-fixture.csv +5 -0
- data/test/outbanker/money_string_parser_test.rb +75 -0
- data/test/outbanker/statement_line_test.rb +88 -0
- data/test/outbanker/statement_lines_test.rb +47 -0
- data/test/test_helper.rb +6 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MGE0OTE3YTI0NWE1YzFiMDRkYWY4MDllOGFjNDIwZTEyYTMzODk4Ng==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NDczY2VkNTcwY2Q5YjE5MDVjMDA2ZDVkZmUwYjU0ODBhNGZjMTExNA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZjM0MWQxZWZkMzVmZDFlZDk1NjA5YTJiYzk4NjU5YTk1YmM2YmQyNDM2NzVj
|
10
|
+
ODY1MjcyZDgzYWQwODU2NWVlMWYxYzgzMzUzODRkMjU3ZDRjYzVlYjFiNGI3
|
11
|
+
MjczYjE5ZjcyNWFiMWUzZjYxNTA4NGU5YWQzMDY0OTI0NmNiZTQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NTUwMGUwOGZmNjBlZWE1MmZmODk1Mjk5NjRjOWVlZTRiMzM4YWVhZGNiMTQ4
|
14
|
+
YThlMTczYmIxMWEzMGY5NDE3YWQ3ZTI3Mzg0ZTI2YmI3NzNjYzU3ZjJiYmJm
|
15
|
+
OGJhZDYxZmY4OGIxZDhhMmU3ZDBhZjNmZjdlNjdkMTgyMzQyNTI=
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Phillip Oertel
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
[](https://travis-ci.org/phillipoertel/outbanker)
|
2
|
+
|
3
|
+
# Outbanker
|
4
|
+
|
5
|
+
Outbanker reads a CSV file exported from [Outbank](http://www.outbank.de) and converts the types to Ruby, as well as doing some cleanups.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'outbanker'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install outbanker
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
lines = Outbanker::StatementLines.read('outbank.csv')
|
24
|
+
lines.each do |line|
|
25
|
+
puts line.amount
|
26
|
+
end
|
27
|
+
|
28
|
+
See the class +StatementLine+ for all available fields.
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
1. Fork it
|
33
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
35
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
|
4
|
+
task :default => :test
|
5
|
+
|
6
|
+
Rake::TestTask.new do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.test_files = FileList['test/outbanker/**/*_test.rb']
|
9
|
+
t.verbose = true
|
10
|
+
end
|
11
|
+
|
12
|
+
desc 'parse a file given as FILE for testing purposes, show the FIELDS given on the cli'
|
13
|
+
task :parse_file do
|
14
|
+
require 'outbanker'
|
15
|
+
require 'yaml'
|
16
|
+
file = ENV['FILE']
|
17
|
+
fields = ENV['FIELDS'].split(',')
|
18
|
+
Outbanker::StatementLines.read(file).each do |line|
|
19
|
+
puts fields.map { |f| "#{f}: #{line.send(f)}" }.join("\n")
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Outbanker
|
2
|
+
module MoneyStringParser
|
3
|
+
def to_cents(string)
|
4
|
+
matches = string.match(/(?<separator>\.|\,)(?<cents>[0-9]{1,2})\Z/)
|
5
|
+
if !matches
|
6
|
+
string.to_i * 100
|
7
|
+
elsif matches[:cents].length == 1
|
8
|
+
string.gsub(matches[:separator], '').to_i * 10
|
9
|
+
elsif matches[:cents].length == 2
|
10
|
+
string.gsub(matches[:separator], '').to_i
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
|
3
|
+
module Outbanker
|
4
|
+
|
5
|
+
#
|
6
|
+
# this is a representation of one line in an outbank csv statement
|
7
|
+
# with translated, parsed attributes (cents, date, etc.).
|
8
|
+
#
|
9
|
+
class StatementLine
|
10
|
+
|
11
|
+
include MoneyStringParser
|
12
|
+
|
13
|
+
ATTRIBUTE_MAPPING = {
|
14
|
+
:currency => "Währung",
|
15
|
+
:amount => "Betrag",
|
16
|
+
:booked_on => "Buchungstag",
|
17
|
+
:valuta_on => "Valuta-Datum",
|
18
|
+
:recipient => "Empfänger/Auftraggeber",
|
19
|
+
:bank_code => "Bankleitzahl",
|
20
|
+
:account_number => "Kontonummer",
|
21
|
+
:description => "Verwendungszweck",
|
22
|
+
:category => "Kategorie"
|
23
|
+
}
|
24
|
+
|
25
|
+
def initialize(csv_row)
|
26
|
+
@row = csv_row
|
27
|
+
end
|
28
|
+
|
29
|
+
def amount
|
30
|
+
to_cents(@row['Betrag'])
|
31
|
+
end
|
32
|
+
|
33
|
+
def booked_on
|
34
|
+
Date.parse(@row['Buchungstag'])
|
35
|
+
end
|
36
|
+
|
37
|
+
def charged?
|
38
|
+
# in different cases I get either "Abgerechnet" or "" when a line was charged.
|
39
|
+
@row['Buchungstext'] != "Nicht abgerechnet"
|
40
|
+
end
|
41
|
+
|
42
|
+
def valuta_on
|
43
|
+
Date.parse(@row['Valuta-Datum'])
|
44
|
+
end
|
45
|
+
|
46
|
+
def description
|
47
|
+
@row['Verwendungszweck'].to_s.gsub(/\s+/, ' ')
|
48
|
+
end
|
49
|
+
|
50
|
+
def payee
|
51
|
+
desc_lines = @row['Verwendungszweck'].split(" ").reject { |row| row =~ /\A\s*\Z/ }.map { |row| row.strip }
|
52
|
+
desc_lines[1] || desc_lines[0] || nil
|
53
|
+
end
|
54
|
+
|
55
|
+
def category
|
56
|
+
[nil, ''].include?(@row['Kategorie']) ? nil : @row['Kategorie']
|
57
|
+
end
|
58
|
+
|
59
|
+
def prebooking?
|
60
|
+
@row['Vormerkung'] == 'Ja'
|
61
|
+
end
|
62
|
+
|
63
|
+
def method_missing(arg)
|
64
|
+
super unless ATTRIBUTE_MAPPING.keys.include?(arg)
|
65
|
+
@row.send(:[], ATTRIBUTE_MAPPING[arg])
|
66
|
+
end
|
67
|
+
|
68
|
+
def unique_id
|
69
|
+
unique_string = [amount, booked_on, description].join('-')
|
70
|
+
Digest::MD5.hexdigest(unique_string)
|
71
|
+
end
|
72
|
+
|
73
|
+
def to_s
|
74
|
+
"Buchung vom: #{booked_on}, Betrag: #{amount}, Beschreibung: #{description}"
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'csv'
|
2
|
+
|
3
|
+
module Outbanker
|
4
|
+
class StatementLines
|
5
|
+
|
6
|
+
attr_reader :earliest_booking, :latest_booking, :num_statements
|
7
|
+
|
8
|
+
# required for testing only
|
9
|
+
attr_reader :csv
|
10
|
+
|
11
|
+
def self.read(file = 'data/outbank.csv')
|
12
|
+
instance = new
|
13
|
+
instance.read(file)
|
14
|
+
instance
|
15
|
+
end
|
16
|
+
|
17
|
+
def read(file)
|
18
|
+
@csv = read_csv(file)
|
19
|
+
get_csv_metadata
|
20
|
+
@lines = @csv.map { |row| Outbanker::StatementLine.new(row) }
|
21
|
+
end
|
22
|
+
|
23
|
+
# delegate stuff to the @lines array
|
24
|
+
def method_missing(method, *args, &block)
|
25
|
+
delegated_methods = [:size, :each, :map, :[]]
|
26
|
+
return super unless delegated_methods.include?(method)
|
27
|
+
@lines.send(method, *args, &block)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def read_csv(file)
|
33
|
+
options = {
|
34
|
+
:col_sep => ';',
|
35
|
+
:headers => true,
|
36
|
+
:converters => [:all]
|
37
|
+
}
|
38
|
+
CSV.new(File.read(file), options)
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_csv_metadata
|
42
|
+
rows = @csv.read
|
43
|
+
@earliest_booking = Date.parse(rows[rows.size - 1]['Buchungstag'])
|
44
|
+
@latest_booking = Date.parse(rows[0]['Buchungstag'])
|
45
|
+
@num_statements = rows.size
|
46
|
+
@csv.rewind
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
data/lib/outbanker.rb
ADDED
data/outbanker.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'outbanker/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "outbanker"
|
8
|
+
gem.version = Outbanker::VERSION
|
9
|
+
gem.authors = ["Phillip Oertel"]
|
10
|
+
gem.email = ["me@phillipoertel.com"]
|
11
|
+
gem.description = %q{outbanker is Ruby wrapper for Outbank CSV files.}
|
12
|
+
gem.summary = %q{outbanker reads a CSV file exported from Outbanker/MAC and converts the types to Ruby, as well as doing some cleanups.}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.add_dependency('rake')
|
20
|
+
gem.add_dependency('turn')
|
21
|
+
end
|
@@ -0,0 +1,3 @@
|
|
1
|
+
"Buchungstext";"Währung";"Betrag";"Buchungstag";"Valuta-Datum";"Empfänger/Auftraggeber";"Bankleitzahl";"Kontonummer";"Verwendungszweck";"Vormerkung";"Buchungsschlüssel";"Kommentar";"Kategorie";"PayPal Empfänger/Auftraggeber";"PayPal An E-Mail";"PayPal Von E-Mail";"PayPal Gebühr";"PayPal Transaktionscode";"PayPal Status"
|
2
|
+
"Nicht abgerechnet";"EUR";"-105,90";"22.01.2013";"23.01.2013";;;;"Paypal Foo Bar";"Nein";;;"Some category";;;;;;
|
3
|
+
"Abgerechnet";"EUR";"-6,84";"19.01.2013";"21.01.2013";;;;"Some service 541-2264551";"Nein";;;"Weiterbildung";;;;;;
|
@@ -0,0 +1,5 @@
|
|
1
|
+
"Buchungstext";"Währung";"Betrag";"Buchungstag";"Valuta-Datum";"Empfänger/Auftraggeber";"Bankleitzahl";"Kontonummer";"Verwendungszweck";"Vormerkung";"Buchungsschlüssel";"Kommentar";"Kategorie";"PayPal Empfänger/Auftraggeber";"PayPal An E-Mail";"PayPal Von E-Mail";"PayPal Gebühr";"PayPal Transaktionscode";"PayPal Status"
|
2
|
+
;"EUR";"-15,42";"31.12.2012";"02.01.2013";;;;"Saldo der Abschlussposten QM - Support 04082 Leipzig";"Nein";"835";;"Bankgebühren";;;;;;
|
3
|
+
;"EUR";"-17,97";"31.12.2012";"31.12.2012";;;;"Saldo der Abschlussposten QM - Support 04082 Leipzig Kontoabschluss 4. Quartal 12 Foo 14,97 8 kostenfreie Poste";"Nein";"835";;"";;;;;;
|
4
|
+
;"EUR";"-15,00";"28.12.2012";"28.12.2012";;;;"12.2012 VNR. 42-4444 PO XY LV PO ";"Ja";"835";;"Altersvorsorge";;;;;;
|
5
|
+
;"EUR";"20,15";"28.12.2012";"28.12.2012";;;;"GELDKARTEBLABLAERSTATTUNG UNTER VORBEHALT SNR.0 KNR.424242 BLZ.42424242 672219500001343382 ";"Nein";"835";;"Bus & Bahn";;;;;;
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Outbanker::MoneyStringParserTest < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
class Tester
|
6
|
+
include ::Outbanker::MoneyStringParser
|
7
|
+
end
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@tester = Tester.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_full_value
|
14
|
+
assert_equal 1200, @tester.to_cents("12")
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_full_value_negative
|
18
|
+
assert_equal -1200, @tester.to_cents("-12")
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# COMMAS
|
23
|
+
#
|
24
|
+
def test_comma_full_euros
|
25
|
+
assert_equal 1200, @tester.to_cents("12,00")
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_comma_euros_and_cents
|
29
|
+
assert_equal 1212, @tester.to_cents("12,12")
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_comma_euros_and_cents_one_digit
|
33
|
+
assert_equal 1210, @tester.to_cents("12,1")
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_comma_zero
|
37
|
+
assert_equal 0, @tester.to_cents("0,00")
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_comma_negative_full_euros
|
41
|
+
assert_equal -1200, @tester.to_cents("-12,00")
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_comma_negative_euros_and_cents
|
45
|
+
assert_equal -1212, @tester.to_cents("-12,12")
|
46
|
+
end
|
47
|
+
|
48
|
+
#
|
49
|
+
# DOT
|
50
|
+
#
|
51
|
+
def test_dot_full_euros
|
52
|
+
assert_equal 1200, @tester.to_cents("12.00")
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_dot_euros_and_cents
|
56
|
+
assert_equal 1212, @tester.to_cents("12.12")
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_dot_euros_and_cents_one_digit
|
60
|
+
assert_equal 1210, @tester.to_cents("12.1")
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_dot_zero
|
64
|
+
assert_equal 0, @tester.to_cents("0.00")
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_dot_negative_full_euros
|
68
|
+
assert_equal -1200, @tester.to_cents("-12.00")
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_dot_negative_euros_and_cents
|
72
|
+
assert_equal -1212, @tester.to_cents("-12.12")
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Outbanker::StatementLineTest < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
fixture = File.join(File.dirname(__FILE__), '../fixtures/outbank-fixture.csv')
|
7
|
+
@lines = Outbanker::StatementLines.read(fixture)
|
8
|
+
end
|
9
|
+
|
10
|
+
def setup_cc_fixture
|
11
|
+
fixture = File.join(File.dirname(__FILE__), '../fixtures/outbank-cc.csv')
|
12
|
+
@lines = Outbanker::StatementLines.read(fixture)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_attribute_mapping_works
|
16
|
+
line = @lines[0]
|
17
|
+
assert_equal "EUR", line.currency
|
18
|
+
assert_equal -1542, line.amount
|
19
|
+
assert_equal Date.parse("31.12.2012"), line.booked_on
|
20
|
+
assert_equal Date.parse("02.01.2013"), line.valuta_on
|
21
|
+
assert_equal nil, line.recipient
|
22
|
+
assert_equal nil, line.bank_code
|
23
|
+
assert_equal nil, line.account_number
|
24
|
+
assert_equal "Saldo der Abschlussposten QM - Support 04082 Leipzig", line.description
|
25
|
+
assert_equal "Bankgebühren", line.category
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_empty_category_is_returned_as_nil
|
29
|
+
line = @lines[1]
|
30
|
+
assert_equal nil, line.category
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# Unique Ids
|
35
|
+
#
|
36
|
+
def test_unique_id_exists
|
37
|
+
line = @lines[0]
|
38
|
+
assert_equal "218d1ee8478cbb5b697fe77962424817", line.unique_id
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_unique_id_depends_on_amount
|
42
|
+
line = @lines[0]
|
43
|
+
row = @lines.csv.read # get the raw first csv line
|
44
|
+
row['Betrag'] = "1#{row['Betrag']}"
|
45
|
+
refute_equal Outbanker::StatementLine.new(row), line.unique_id
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_unique_id_depends_on_booked_on
|
49
|
+
line = @lines[0]
|
50
|
+
row = @lines.csv.read # get the raw first csv line
|
51
|
+
row['Buchungstag'] = "01.01.1971"
|
52
|
+
refute_equal Outbanker::StatementLine.new(row), line.unique_id
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_unique_id_depends_on_description
|
56
|
+
line = @lines[0]
|
57
|
+
row = @lines.csv.read # get the raw first csv line
|
58
|
+
row['Verwendungszweck'] = "#{row['Verwendungszweck']} Bla bla"
|
59
|
+
refute_equal Outbanker::StatementLine.new(row), line.unique_id
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_was_charged_when_empty
|
63
|
+
line = @lines[0]
|
64
|
+
assert_equal true, line.charged?
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_was_charged_when_filled
|
68
|
+
setup_cc_fixture
|
69
|
+
line = @lines[1]
|
70
|
+
assert_equal true, line.charged?
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_was_not_charged
|
74
|
+
setup_cc_fixture
|
75
|
+
line = @lines[0]
|
76
|
+
assert_equal false, line.charged?
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_prebooking_false
|
80
|
+
line = @lines[0]
|
81
|
+
assert_equal false, line.prebooking?
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_prebooking_true
|
85
|
+
line = @lines[2]
|
86
|
+
assert_equal true, line.prebooking?
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Outbanker::StatementLinesTest < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
fixture = File.join(File.dirname(__FILE__), '../fixtures/outbank-fixture.csv')
|
7
|
+
@lines = Outbanker::StatementLines.read(fixture)
|
8
|
+
end
|
9
|
+
|
10
|
+
#
|
11
|
+
# test array behaviour
|
12
|
+
#
|
13
|
+
def test_size
|
14
|
+
assert_equal 4, @lines.size
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_each
|
18
|
+
count = 0
|
19
|
+
@lines.each { |l| count += 1 }
|
20
|
+
assert_equal 4, count
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_map
|
24
|
+
out = @lines.map { |l| l }
|
25
|
+
assert_equal 4, out.size
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_array_access
|
29
|
+
assert_equal Outbanker::StatementLine, @lines[0].class
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# test metadata
|
34
|
+
#
|
35
|
+
def test_num_statements
|
36
|
+
assert_equal 4, @lines.num_statements
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_latest_booking
|
40
|
+
assert_equal Date.parse("31.12.2012"), @lines.latest_booking
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_earliest_booking
|
44
|
+
assert_equal Date.parse("28.12.2012"), @lines.earliest_booking
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: outbanker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Phillip Oertel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
version_requirements: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ! '>='
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
prerelease: false
|
20
|
+
name: rake
|
21
|
+
requirement: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ! '>='
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
26
|
+
type: :runtime
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
prerelease: false
|
34
|
+
name: turn
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :runtime
|
41
|
+
description: outbanker is Ruby wrapper for Outbank CSV files.
|
42
|
+
email:
|
43
|
+
- me@phillipoertel.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- .travis.yml
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/outbanker.rb
|
55
|
+
- lib/outbanker/money_string_parser.rb
|
56
|
+
- lib/outbanker/statement_line.rb
|
57
|
+
- lib/outbanker/statement_lines.rb
|
58
|
+
- lib/outbanker/version.rb
|
59
|
+
- outbanker.gemspec
|
60
|
+
- test/fixtures/outbank-cc.csv
|
61
|
+
- test/fixtures/outbank-fixture.csv
|
62
|
+
- test/outbanker/money_string_parser_test.rb
|
63
|
+
- test/outbanker/statement_line_test.rb
|
64
|
+
- test/outbanker/statement_lines_test.rb
|
65
|
+
- test/test_helper.rb
|
66
|
+
homepage: ''
|
67
|
+
licenses: []
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 2.2.2
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: outbanker reads a CSV file exported from Outbanker/MAC and converts the types
|
89
|
+
to Ruby, as well as doing some cleanups.
|
90
|
+
test_files:
|
91
|
+
- test/fixtures/outbank-cc.csv
|
92
|
+
- test/fixtures/outbank-fixture.csv
|
93
|
+
- test/outbanker/money_string_parser_test.rb
|
94
|
+
- test/outbanker/statement_line_test.rb
|
95
|
+
- test/outbanker/statement_lines_test.rb
|
96
|
+
- test/test_helper.rb
|