reckon 0.6.0 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +50 -0
- data/.gitignore +3 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +75 -7
- data/Gemfile.lock +1 -1
- data/README.md +85 -24
- data/Rakefile +17 -1
- data/bin/build-new-version.sh +26 -0
- data/bin/reckon +9 -1
- data/lib/reckon.rb +1 -0
- data/lib/reckon/app.rb +18 -141
- data/lib/reckon/cosine_similarity.rb +67 -62
- data/lib/reckon/csv_parser.rb +2 -7
- data/lib/reckon/date_column.rb +10 -0
- data/lib/reckon/money.rb +59 -52
- data/lib/reckon/options.rb +153 -0
- data/lib/reckon/version.rb +1 -1
- data/spec/cosine_training_and_test.rb +52 -0
- data/spec/integration/another_bank_example/input.csv +9 -0
- data/spec/integration/another_bank_example/output.ledger +36 -0
- data/spec/integration/another_bank_example/test_args +1 -0
- data/spec/integration/ask_for_account/cli_input.exp +33 -0
- data/spec/integration/ask_for_account/expected_output +11 -0
- data/spec/integration/ask_for_account/input.csv +9 -0
- data/spec/integration/ask_for_account/test_args +1 -0
- data/spec/integration/austrian_example/input.csv +13 -0
- data/spec/integration/austrian_example/output.ledger +52 -0
- data/spec/integration/austrian_example/test_args +2 -0
- data/spec/integration/bom_utf8_file/input.csv +3 -0
- data/spec/integration/bom_utf8_file/output.ledger +4 -0
- data/spec/integration/bom_utf8_file/test_args +3 -0
- data/spec/integration/broker_canada_example/input.csv +12 -0
- data/spec/integration/broker_canada_example/output.ledger +48 -0
- data/spec/integration/broker_canada_example/test_args +1 -0
- data/spec/integration/chase/account_tokens_and_regex/output.ledger +36 -0
- data/spec/integration/chase/account_tokens_and_regex/test_args +2 -0
- data/spec/integration/chase/account_tokens_and_regex/tokens.yml +16 -0
- data/spec/integration/chase/default_account_names/output.ledger +36 -0
- data/spec/integration/chase/default_account_names/test_args +3 -0
- data/spec/integration/chase/input.csv +9 -0
- data/spec/integration/chase/learn_from_existing/learn.ledger +7 -0
- data/spec/integration/chase/learn_from_existing/output.ledger +36 -0
- data/spec/integration/chase/learn_from_existing/test_args +1 -0
- data/spec/integration/chase/simple/output.ledger +36 -0
- data/spec/integration/chase/simple/test_args +1 -0
- data/spec/integration/danish_kroner_nordea_example/input.csv +6 -0
- data/spec/integration/danish_kroner_nordea_example/output.ledger +24 -0
- data/spec/integration/danish_kroner_nordea_example/test_args +1 -0
- data/spec/integration/english_date_example/input.csv +3 -0
- data/spec/integration/english_date_example/output.ledger +12 -0
- data/spec/integration/english_date_example/test_args +1 -0
- data/spec/integration/extratofake/input.csv +24 -0
- data/spec/integration/extratofake/output.ledger +92 -0
- data/spec/integration/extratofake/test_args +1 -0
- data/spec/integration/french_example/input.csv +9 -0
- data/spec/integration/french_example/output.ledger +36 -0
- data/spec/integration/french_example/test_args +2 -0
- data/spec/integration/german_date_example/input.csv +3 -0
- data/spec/integration/german_date_example/output.ledger +12 -0
- data/spec/integration/german_date_example/test_args +1 -0
- data/spec/integration/harder_date_example/input.csv +5 -0
- data/spec/integration/harder_date_example/output.ledger +20 -0
- data/spec/integration/harder_date_example/test_args +1 -0
- data/spec/integration/ing/input.csv +3 -0
- data/spec/integration/ing/output.ledger +12 -0
- data/spec/integration/ing/test_args +1 -0
- data/spec/integration/intuit_mint_example/input.csv +7 -0
- data/spec/integration/intuit_mint_example/output.ledger +28 -0
- data/spec/integration/intuit_mint_example/test_args +1 -0
- data/spec/integration/invalid_header_example/input.csv +6 -0
- data/spec/integration/invalid_header_example/output.ledger +8 -0
- data/spec/integration/invalid_header_example/test_args +1 -0
- data/spec/integration/inversed_credit_card/input.csv +16 -0
- data/spec/integration/inversed_credit_card/output.ledger +64 -0
- data/spec/integration/inversed_credit_card/test_args +1 -0
- data/spec/integration/nationwide/input.csv +4 -0
- data/spec/integration/nationwide/output.ledger +16 -0
- data/spec/integration/nationwide/test_args +1 -0
- data/spec/integration/regression/issue_51_account_tokens/input.csv +8 -0
- data/spec/integration/regression/issue_51_account_tokens/output.ledger +32 -0
- data/spec/integration/regression/issue_51_account_tokens/test_args +4 -0
- data/spec/integration/regression/issue_51_account_tokens/tokens.yml +9 -0
- data/spec/integration/regression/issue_64_date_column/input.csv +3 -0
- data/spec/integration/regression/issue_64_date_column/output.ledger +8 -0
- data/spec/integration/regression/issue_64_date_column/test_args +1 -0
- data/spec/integration/regression/issue_73_account_token_matching/input.csv +2 -0
- data/spec/integration/regression/issue_73_account_token_matching/output.ledger +4 -0
- data/spec/integration/regression/issue_73_account_token_matching/test_args +6 -0
- data/spec/integration/regression/issue_73_account_token_matching/tokens.yml +8 -0
- data/spec/integration/regression/issue_85_date_example/input.csv +2 -0
- data/spec/integration/regression/issue_85_date_example/output.ledger +8 -0
- data/spec/integration/regression/issue_85_date_example/test_args +1 -0
- data/spec/integration/spanish_date_example/input.csv +3 -0
- data/spec/integration/spanish_date_example/output.ledger +12 -0
- data/spec/integration/spanish_date_example/test_args +1 -0
- data/spec/integration/suntrust/input.csv +7 -0
- data/spec/integration/suntrust/output.ledger +28 -0
- data/spec/integration/suntrust/test_args +1 -0
- data/spec/integration/test.sh +123 -0
- data/spec/integration/test_money_column/input.csv +3 -0
- data/spec/integration/test_money_column/output.ledger +8 -0
- data/spec/integration/test_money_column/test_args +1 -0
- data/spec/integration/two_money_columns/input.csv +5 -0
- data/spec/integration/two_money_columns/output.ledger +20 -0
- data/spec/integration/two_money_columns/test_args +1 -0
- data/spec/integration/yyyymmdd_date_example/input.csv +1 -0
- data/spec/integration/yyyymmdd_date_example/output.ledger +4 -0
- data/spec/integration/yyyymmdd_date_example/test_args +1 -0
- data/spec/reckon/app_spec.rb +24 -6
- data/spec/reckon/csv_parser_spec.rb +3 -3
- data/spec/reckon/money_column_spec.rb +24 -24
- data/spec/reckon/money_spec.rb +15 -34
- data/spec/reckon/options_spec.rb +17 -0
- data/spec/spec_helper.rb +6 -1
- metadata +102 -7
- data/.travis.yml +0 -13
@@ -0,0 +1 @@
|
|
1
|
+
-f input.csv --unattended --account Assets:Bank:Checking
|
@@ -0,0 +1,5 @@
|
|
1
|
+
4/1/2008,Check - 0000000122,122,-$76.00,"","$1,750.06"
|
2
|
+
3/28/2008,BLARG R SH 456930,"","",+$327.49,"$1,826.06"
|
3
|
+
3/27/2008,Check - 0000000112,112,-$800.00,"","$1,498.57"
|
4
|
+
3/26/2008,Check - 0000000251,251,-$88.55,"","$1,298.57"
|
5
|
+
3/26/2008,Check - 0000000251,251,"","+$88.55","$1,298.57"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
2008-03-26 Check - 0000000251; 251; $1,298.57
|
2
|
+
Assets:Bank:Checking $88.55
|
3
|
+
Income:Unknown
|
4
|
+
|
5
|
+
2008-03-26 Check - 0000000251; 251; $1,298.57
|
6
|
+
Income:Unknown
|
7
|
+
Assets:Bank:Checking -$88.55
|
8
|
+
|
9
|
+
2008-03-27 Check - 0000000112; 112; $1,498.57
|
10
|
+
Income:Unknown
|
11
|
+
Assets:Bank:Checking -$800.00
|
12
|
+
|
13
|
+
2008-03-28 BLARG R SH 456930; $1,826.06
|
14
|
+
Assets:Bank:Checking $327.49
|
15
|
+
Income:Unknown
|
16
|
+
|
17
|
+
2008-04-01 Check - 0000000122; 122; $1,750.06
|
18
|
+
Income:Unknown
|
19
|
+
Assets:Bank:Checking -$76.00
|
20
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
-f input.csv --unattended --account Assets:Bank:Checking
|
@@ -0,0 +1 @@
|
|
1
|
+
DEBIT,20121231,"ODESK***BAL-27DEC12 650-12345 CA 12/28",-123.45
|
@@ -0,0 +1 @@
|
|
1
|
+
-f input.csv --unattended --account Assets:Bank:Checking
|
data/spec/reckon/app_spec.rb
CHANGED
@@ -16,10 +16,10 @@ describe Reckon::App do
|
|
16
16
|
describe "each_row_backwards" do
|
17
17
|
it "should return rows with hashes" do
|
18
18
|
@rows[0][:pretty_date].should == "2009-12-10"
|
19
|
-
@rows[0][:pretty_money].should == " $
|
19
|
+
@rows[0][:pretty_money].should == " $2,105.00"
|
20
20
|
@rows[0][:description].should == "CREDIT; Some Company vendorpymt PPD ID: 5KL3832735"
|
21
21
|
@rows[1][:pretty_date].should == "2009-12-11"
|
22
|
-
@rows[1][:pretty_money].should == "
|
22
|
+
@rows[1][:pretty_money].should == " $116.22"
|
23
23
|
@rows[1][:description].should == "CREDIT; PAYPAL TRANSFER PPD ID: PAYPALSDSL"
|
24
24
|
end
|
25
25
|
end
|
@@ -37,14 +37,16 @@ describe Reckon::App do
|
|
37
37
|
|
38
38
|
context 'unattended mode with chase csv input' do
|
39
39
|
let(:output_file) { StringIO.new }
|
40
|
-
let(:chase)
|
40
|
+
let(:chase) do
|
41
41
|
Reckon::App.new(
|
42
42
|
string: BANK_CSV,
|
43
43
|
unattended: true,
|
44
44
|
output_file: output_file,
|
45
|
-
bank_account: 'Assets:Bank:Checking'
|
45
|
+
bank_account: 'Assets:Bank:Checking',
|
46
|
+
default_into_account: 'Expenses:Unknown',
|
47
|
+
default_outof_account: 'Income:Unknown',
|
46
48
|
)
|
47
|
-
|
49
|
+
end
|
48
50
|
|
49
51
|
describe 'walk backwards' do
|
50
52
|
it 'should assign Income:Unknown and Expenses:Unknown by default' do
|
@@ -86,6 +88,22 @@ describe Reckon::App do
|
|
86
88
|
expect(output_file.string.scan('Expenses:Websites').count).to eq(2)
|
87
89
|
end
|
88
90
|
end
|
91
|
+
|
92
|
+
it 'should fail-on-unknown-account' do
|
93
|
+
chase = Reckon::App.new(
|
94
|
+
string: BANK_CSV,
|
95
|
+
unattended: true,
|
96
|
+
output_file: output_file,
|
97
|
+
bank_account: 'Assets:Bank:Checking',
|
98
|
+
default_into_account: 'Expenses:Unknown',
|
99
|
+
default_outof_account: 'Income:Unknown',
|
100
|
+
fail_on_unknown_account: true
|
101
|
+
)
|
102
|
+
|
103
|
+
expect { chase.walk_backwards }.to(
|
104
|
+
raise_error(RuntimeError, /Couldn't find any matches/)
|
105
|
+
)
|
106
|
+
end
|
89
107
|
end
|
90
108
|
|
91
109
|
context "Issue #73 - regression test" do
|
@@ -146,7 +164,7 @@ describe Reckon::App do
|
|
146
164
|
CREDIT,20091223120000[0:GMT],"Blarg BLARG REVENUE PPD ID: 00jah78563",1558.52
|
147
165
|
DEBIT,20091221120000[0:GMT],"WEBSITE-BALANCE-17DEC09 12 12/17WEBSITE-BAL",-12.23
|
148
166
|
DEBIT,20091214120000[0:GMT],"WEBSITE-BALANCE-10DEC09 12 12/10WEBSITE-BAL",-20.96
|
149
|
-
CREDIT,20091211120000[0:GMT],"PAYPAL TRANSFER PPD ID: PAYPALSDSL"
|
167
|
+
CREDIT,20091211120000[0:GMT],"PAYPAL TRANSFER PPD ID: PAYPALSDSL",116.22
|
150
168
|
CREDIT,20091210120000[0:GMT],"Some Company vendorpymt PPD ID: 5KL3832735",2105.00
|
151
169
|
CSV
|
152
170
|
|
@@ -242,7 +242,7 @@ describe Reckon::CSVParser do
|
|
242
242
|
describe "pretty_money_for" do
|
243
243
|
it "work with negative and positive numbers" do
|
244
244
|
some_other_bank.pretty_money_for(1).should == "-$20.00"
|
245
|
-
some_other_bank.pretty_money_for(4).should == " $
|
245
|
+
some_other_bank.pretty_money_for(4).should == " $1,558.52"
|
246
246
|
some_other_bank.pretty_money_for(7).should == "-$116.22"
|
247
247
|
some_other_bank.pretty_money_for(5).should == " $0.23"
|
248
248
|
some_other_bank.pretty_money_for(6).should == "-$0.96"
|
@@ -251,7 +251,7 @@ describe Reckon::CSVParser do
|
|
251
251
|
it "work with other currencies such as €" do
|
252
252
|
euro_bank = Reckon::CSVParser.new(file: fixture_path('some_other.csv'), currency: "€", suffixed: false )
|
253
253
|
euro_bank.pretty_money_for(1).should == "-€20.00"
|
254
|
-
euro_bank.pretty_money_for(4).should == " €
|
254
|
+
euro_bank.pretty_money_for(4).should == " €1,558.52"
|
255
255
|
euro_bank.pretty_money_for(7).should == "-€116.22"
|
256
256
|
euro_bank.pretty_money_for(5).should == " €0.23"
|
257
257
|
euro_bank.pretty_money_for(6).should == "-€0.96"
|
@@ -260,7 +260,7 @@ describe Reckon::CSVParser do
|
|
260
260
|
it "work with suffixed currencies such as SEK" do
|
261
261
|
swedish_bank = Reckon::CSVParser.new(file: fixture_path('some_other.csv'), currency: 'SEK', suffixed: true )
|
262
262
|
swedish_bank.pretty_money_for(1).should == "-20.00 SEK"
|
263
|
-
swedish_bank.pretty_money_for(4).should == "
|
263
|
+
swedish_bank.pretty_money_for(4).should == " 1,558.52 SEK"
|
264
264
|
swedish_bank.pretty_money_for(7).should == "-116.22 SEK"
|
265
265
|
swedish_bank.pretty_money_for(5).should == " 0.23 SEK"
|
266
266
|
swedish_bank.pretty_money_for(6).should == "-0.96 SEK"
|
@@ -8,13 +8,13 @@ require 'reckon'
|
|
8
8
|
describe Reckon::MoneyColumn do
|
9
9
|
describe "initialize" do
|
10
10
|
it "should convert strings into Money" do
|
11
|
-
Reckon::MoneyColumn.new( ["1.00", "-2.00"] ).should == [
|
11
|
+
Reckon::MoneyColumn.new( ["1.00", "-2.00"] ).should == [
|
12
12
|
Reckon::Money.new( 1.00 ), Reckon::Money.new( -2.00 ) ]
|
13
13
|
end
|
14
14
|
it "should convert empty string into nil" do
|
15
|
-
Reckon::MoneyColumn.new( ["1.00", ""] ).should == [
|
15
|
+
Reckon::MoneyColumn.new( ["1.00", ""] ).should == [
|
16
16
|
Reckon::Money.new( 1.00 ), nil ]
|
17
|
-
Reckon::MoneyColumn.new( ["", "-2.00"] ).should == [
|
17
|
+
Reckon::MoneyColumn.new( ["", "-2.00"] ).should == [
|
18
18
|
nil, Reckon::Money.new( -2.00 ) ]
|
19
19
|
end
|
20
20
|
end
|
@@ -32,33 +32,33 @@ describe Reckon::MoneyColumn do
|
|
32
32
|
|
33
33
|
describe "merge" do
|
34
34
|
it "should merge two columns" do
|
35
|
-
Reckon::MoneyColumn.new(
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
Reckon::MoneyColumn.new(
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
35
|
+
m1 = Reckon::MoneyColumn.new(["1.00", ""])
|
36
|
+
m2 = Reckon::MoneyColumn.new(["", "-2.00"])
|
37
|
+
expect(m1.merge!(m2)).to(
|
38
|
+
eq([Reckon::Money.new(1.00), Reckon::Money.new(-2.00)])
|
39
|
+
)
|
40
|
+
|
41
|
+
m1 = Reckon::MoneyColumn.new(["1.00", "0"])
|
42
|
+
m2 = Reckon::MoneyColumn.new(["0", "-2.00"])
|
43
|
+
expect(m1.merge!(m2)).to(
|
44
|
+
eq([Reckon::Money.new(1.00), Reckon::Money.new(-2.00)])
|
45
|
+
)
|
46
|
+
end
|
48
47
|
|
49
48
|
it "should return nil if columns cannot be merged" do
|
50
|
-
Reckon::MoneyColumn.new(
|
51
|
-
|
49
|
+
m1 = Reckon::MoneyColumn.new(["1.00", ""])
|
50
|
+
m2 = Reckon::MoneyColumn.new(["1.00", "-2.00"])
|
51
|
+
expect(m1.merge!(m2)).to eq([Reckon::Money.new(0), Reckon::Money.new(-2)])
|
52
52
|
|
53
|
-
Reckon::MoneyColumn.new(
|
54
|
-
|
53
|
+
m1 = Reckon::MoneyColumn.new(["From1", "Names"])
|
54
|
+
m2 = Reckon::MoneyColumn.new(["Acc", "NL28 INGB 1200 3244 16,21817"])
|
55
|
+
expect(m1.merge!(m2)).to eq([Reckon::Money.new(-1), Reckon::Money.new("NL28 INGB 1200 3244 16,21817")])
|
55
56
|
end
|
56
57
|
|
57
58
|
it "should invert first column if both positive" do
|
58
|
-
|
59
|
-
Reckon::MoneyColumn.new( ["", "2.00"]
|
60
|
-
|
59
|
+
expect(
|
60
|
+
Reckon::MoneyColumn.new(["1.00", ""]).merge!(Reckon::MoneyColumn.new( ["", "2.00"]))
|
61
|
+
).to eq([Reckon::Money.new(-1.00), Reckon::Money.new(2.00)])
|
61
62
|
end
|
62
63
|
end
|
63
64
|
end
|
64
|
-
|
data/spec/reckon/money_spec.rb
CHANGED
@@ -6,68 +6,49 @@ require 'rubygems'
|
|
6
6
|
require 'reckon'
|
7
7
|
|
8
8
|
describe Reckon::Money do
|
9
|
-
describe "
|
9
|
+
describe "parse" do
|
10
10
|
it "should handle currency indicators" do
|
11
|
-
expect(Reckon::Money
|
12
|
-
expect(Reckon::Money
|
13
|
-
expect(Reckon::Money
|
11
|
+
expect(Reckon::Money.new( "$2.00" )).to eq(2.00)
|
12
|
+
expect(Reckon::Money.new("-$1025.67")).to eq(-1025.67)
|
13
|
+
expect(Reckon::Money.new("$-1025.67")).to eq(-1025.67)
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should handle the comma_separates_cents option correctly" do
|
17
|
-
expect(Reckon::Money
|
18
|
-
expect(Reckon::Money
|
19
|
-
expect(Reckon::Money
|
17
|
+
expect(Reckon::Money.new("$2,00", comma_separates_cents: true)).to eq(2.00)
|
18
|
+
expect(Reckon::Money.new("-$1025,67", comma_separates_cents: true)).to eq(-1025.67)
|
19
|
+
expect(Reckon::Money.new("$-1025,67", comma_separates_cents: true)).to eq(-1025.67)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should return 0 for an empty string" do
|
23
|
-
expect(Reckon::Money
|
23
|
+
expect(Reckon::Money.new("")).to eq(0)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should handle 1000 indicators correctly" do
|
27
|
-
expect(Reckon::Money
|
28
|
-
expect(Reckon::Money
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should keep numbers together" do
|
32
|
-
expect(Reckon::Money::from_s("1A1")).to eq(1)
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should prefer numbers with precision of two" do
|
36
|
-
expect(Reckon::Money::from_s("1A2.00")).to eq(2)
|
37
|
-
expect(Reckon::Money::from_s("2.00A1")).to eq(2)
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should handle arbitrary prefixes and postfixes" do
|
41
|
-
expect(Reckon::Money::from_s("AB1.00C")).to eq(1)
|
42
|
-
expect(Reckon::Money::from_s("AB0C")).to eq(0)
|
43
|
-
expect(Reckon::Money::from_s("AB-2.00C")).to eq(-2)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should return nil if no numbers are found" do
|
47
|
-
expect(Reckon::Money::from_s("BAC")).to be_nil()
|
27
|
+
expect(Reckon::Money.new("$2.000,00", comma_separates_cents: true)).to eq(2000.00)
|
28
|
+
expect(Reckon::Money.new("-$1,025.67")).to eq(-1025.67)
|
48
29
|
end
|
49
30
|
end
|
50
31
|
|
51
32
|
describe "pretty" do
|
52
33
|
it "work with negative and positive numbers" do
|
53
34
|
expect(Reckon::Money.new(-20.00).pretty).to eq("-$20.00")
|
54
|
-
expect(Reckon::Money.new(1558.52).pretty).to eq(" $
|
35
|
+
expect(Reckon::Money.new(1558.52).pretty).to eq(" $1,558.52")
|
55
36
|
end
|
56
37
|
|
57
38
|
it "work with other currencies such as €" do
|
58
39
|
expect(Reckon::Money.new(-20.00, currency: "€", suffixed: false).pretty).to eq("-€20.00")
|
59
|
-
expect(Reckon::Money.new(1558.52, currency: "€", suffixed: false).pretty).to eq(" €
|
40
|
+
expect(Reckon::Money.new(1558.52, currency: "€", suffixed: false).pretty).to eq(" €1,558.52")
|
60
41
|
end
|
61
42
|
|
62
43
|
it "work with suffixed currencies such as SEK" do
|
63
|
-
expect(Reckon::Money.new(
|
64
|
-
expect(Reckon::Money.new(
|
44
|
+
expect(Reckon::Money.new(-20.00, currency: "SEK", suffixed: true).pretty).to eq("-20.00 SEK")
|
45
|
+
expect(Reckon::Money.new(1558.52, currency: "SEK", suffixed: true).pretty).to eq(" 1,558.52 SEK")
|
65
46
|
end
|
66
47
|
end
|
67
48
|
|
68
49
|
describe "likelihood" do
|
69
50
|
it "should return the likelihood that a string represents money" do
|
70
|
-
expect(Reckon::Money::likelihood(
|
51
|
+
expect(Reckon::Money::likelihood("$20.00")).to eq(65)
|
71
52
|
end
|
72
53
|
|
73
54
|
it "should return neutral for empty string" do
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe '#parse_opts' do
|
4
|
+
it 'should assign to :string option' do
|
5
|
+
options = Reckon::Options.parse(
|
6
|
+
%w[-f - --unattended --account bank],
|
7
|
+
StringIO.new('foo,bar,baz')
|
8
|
+
)
|
9
|
+
expect(options[:string]).to eq('foo,bar,baz')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should require --unattended flag' do
|
13
|
+
expect { Reckon::Options.parse(%w[-f - --account bank]) }.to(
|
14
|
+
raise_error(RuntimeError, "--unattended is required to use STDIN as CSV source.")
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -16,13 +16,18 @@ public
|
|
16
16
|
def silence_output
|
17
17
|
# Store the original stderr and stdout in order to restore them later
|
18
18
|
@original_stdout = $stdout
|
19
|
+
@original_stderr = $stderr
|
19
20
|
|
20
21
|
# Redirect stderr and stdout
|
21
|
-
$
|
22
|
+
$stderr = File.new(File.join(File.dirname(__FILE__), 'test_log.txt'), 'w')
|
23
|
+
$stdout = $stderr
|
24
|
+
Reckon::LOGGER.reopen $stderr
|
22
25
|
end
|
23
26
|
|
24
27
|
# Replace stderr and stdout so anything else is output correctly
|
25
28
|
def enable_output
|
26
29
|
$stdout = @original_stdout
|
27
30
|
@original_stdout = nil
|
31
|
+
$stderr = @original_stderr
|
32
|
+
@original_stderr = nil
|
28
33
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reckon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Cantino
|
8
8
|
- BlackEdder
|
9
9
|
- Ben Prew
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-04-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -101,21 +101,23 @@ description: Reckon automagically converts CSV files for use with the command-li
|
|
101
101
|
with the CSV data using Bayesian machine learning.
|
102
102
|
email: andrew@iterationlabs.com
|
103
103
|
executables:
|
104
|
+
- build-new-version.sh
|
104
105
|
- reckon
|
105
106
|
extensions: []
|
106
107
|
extra_rdoc_files: []
|
107
108
|
files:
|
108
109
|
- ".document"
|
110
|
+
- ".github/workflows/ruby.yml"
|
109
111
|
- ".gitignore"
|
110
112
|
- ".ruby-gemset"
|
111
113
|
- ".ruby-version"
|
112
|
-
- ".travis.yml"
|
113
114
|
- CHANGELOG.md
|
114
115
|
- Gemfile
|
115
116
|
- Gemfile.lock
|
116
117
|
- LICENSE
|
117
118
|
- README.md
|
118
119
|
- Rakefile
|
120
|
+
- bin/build-new-version.sh
|
119
121
|
- bin/reckon
|
120
122
|
- lib/reckon.rb
|
121
123
|
- lib/reckon/app.rb
|
@@ -125,8 +127,10 @@ files:
|
|
125
127
|
- lib/reckon/ledger_parser.rb
|
126
128
|
- lib/reckon/logger.rb
|
127
129
|
- lib/reckon/money.rb
|
130
|
+
- lib/reckon/options.rb
|
128
131
|
- lib/reckon/version.rb
|
129
132
|
- reckon.gemspec
|
133
|
+
- spec/cosine_training_and_test.rb
|
130
134
|
- spec/data_fixtures/51-sample.csv
|
131
135
|
- spec/data_fixtures/51-tokens.yml
|
132
136
|
- spec/data_fixtures/73-sample.csv
|
@@ -156,19 +160,110 @@ files:
|
|
156
160
|
- spec/data_fixtures/tokens.yaml
|
157
161
|
- spec/data_fixtures/two_money_columns.csv
|
158
162
|
- spec/data_fixtures/yyyymmdd_date_example.csv
|
163
|
+
- spec/integration/another_bank_example/input.csv
|
164
|
+
- spec/integration/another_bank_example/output.ledger
|
165
|
+
- spec/integration/another_bank_example/test_args
|
166
|
+
- spec/integration/ask_for_account/cli_input.exp
|
167
|
+
- spec/integration/ask_for_account/expected_output
|
168
|
+
- spec/integration/ask_for_account/input.csv
|
169
|
+
- spec/integration/ask_for_account/test_args
|
170
|
+
- spec/integration/austrian_example/input.csv
|
171
|
+
- spec/integration/austrian_example/output.ledger
|
172
|
+
- spec/integration/austrian_example/test_args
|
173
|
+
- spec/integration/bom_utf8_file/input.csv
|
174
|
+
- spec/integration/bom_utf8_file/output.ledger
|
175
|
+
- spec/integration/bom_utf8_file/test_args
|
176
|
+
- spec/integration/broker_canada_example/input.csv
|
177
|
+
- spec/integration/broker_canada_example/output.ledger
|
178
|
+
- spec/integration/broker_canada_example/test_args
|
179
|
+
- spec/integration/chase/account_tokens_and_regex/output.ledger
|
180
|
+
- spec/integration/chase/account_tokens_and_regex/test_args
|
181
|
+
- spec/integration/chase/account_tokens_and_regex/tokens.yml
|
182
|
+
- spec/integration/chase/default_account_names/output.ledger
|
183
|
+
- spec/integration/chase/default_account_names/test_args
|
184
|
+
- spec/integration/chase/input.csv
|
185
|
+
- spec/integration/chase/learn_from_existing/learn.ledger
|
186
|
+
- spec/integration/chase/learn_from_existing/output.ledger
|
187
|
+
- spec/integration/chase/learn_from_existing/test_args
|
188
|
+
- spec/integration/chase/simple/output.ledger
|
189
|
+
- spec/integration/chase/simple/test_args
|
190
|
+
- spec/integration/danish_kroner_nordea_example/input.csv
|
191
|
+
- spec/integration/danish_kroner_nordea_example/output.ledger
|
192
|
+
- spec/integration/danish_kroner_nordea_example/test_args
|
193
|
+
- spec/integration/english_date_example/input.csv
|
194
|
+
- spec/integration/english_date_example/output.ledger
|
195
|
+
- spec/integration/english_date_example/test_args
|
196
|
+
- spec/integration/extratofake/input.csv
|
197
|
+
- spec/integration/extratofake/output.ledger
|
198
|
+
- spec/integration/extratofake/test_args
|
199
|
+
- spec/integration/french_example/input.csv
|
200
|
+
- spec/integration/french_example/output.ledger
|
201
|
+
- spec/integration/french_example/test_args
|
202
|
+
- spec/integration/german_date_example/input.csv
|
203
|
+
- spec/integration/german_date_example/output.ledger
|
204
|
+
- spec/integration/german_date_example/test_args
|
205
|
+
- spec/integration/harder_date_example/input.csv
|
206
|
+
- spec/integration/harder_date_example/output.ledger
|
207
|
+
- spec/integration/harder_date_example/test_args
|
208
|
+
- spec/integration/ing/input.csv
|
209
|
+
- spec/integration/ing/output.ledger
|
210
|
+
- spec/integration/ing/test_args
|
211
|
+
- spec/integration/intuit_mint_example/input.csv
|
212
|
+
- spec/integration/intuit_mint_example/output.ledger
|
213
|
+
- spec/integration/intuit_mint_example/test_args
|
214
|
+
- spec/integration/invalid_header_example/input.csv
|
215
|
+
- spec/integration/invalid_header_example/output.ledger
|
216
|
+
- spec/integration/invalid_header_example/test_args
|
217
|
+
- spec/integration/inversed_credit_card/input.csv
|
218
|
+
- spec/integration/inversed_credit_card/output.ledger
|
219
|
+
- spec/integration/inversed_credit_card/test_args
|
220
|
+
- spec/integration/nationwide/input.csv
|
221
|
+
- spec/integration/nationwide/output.ledger
|
222
|
+
- spec/integration/nationwide/test_args
|
223
|
+
- spec/integration/regression/issue_51_account_tokens/input.csv
|
224
|
+
- spec/integration/regression/issue_51_account_tokens/output.ledger
|
225
|
+
- spec/integration/regression/issue_51_account_tokens/test_args
|
226
|
+
- spec/integration/regression/issue_51_account_tokens/tokens.yml
|
227
|
+
- spec/integration/regression/issue_64_date_column/input.csv
|
228
|
+
- spec/integration/regression/issue_64_date_column/output.ledger
|
229
|
+
- spec/integration/regression/issue_64_date_column/test_args
|
230
|
+
- spec/integration/regression/issue_73_account_token_matching/input.csv
|
231
|
+
- spec/integration/regression/issue_73_account_token_matching/output.ledger
|
232
|
+
- spec/integration/regression/issue_73_account_token_matching/test_args
|
233
|
+
- spec/integration/regression/issue_73_account_token_matching/tokens.yml
|
234
|
+
- spec/integration/regression/issue_85_date_example/input.csv
|
235
|
+
- spec/integration/regression/issue_85_date_example/output.ledger
|
236
|
+
- spec/integration/regression/issue_85_date_example/test_args
|
237
|
+
- spec/integration/spanish_date_example/input.csv
|
238
|
+
- spec/integration/spanish_date_example/output.ledger
|
239
|
+
- spec/integration/spanish_date_example/test_args
|
240
|
+
- spec/integration/suntrust/input.csv
|
241
|
+
- spec/integration/suntrust/output.ledger
|
242
|
+
- spec/integration/suntrust/test_args
|
243
|
+
- spec/integration/test.sh
|
244
|
+
- spec/integration/test_money_column/input.csv
|
245
|
+
- spec/integration/test_money_column/output.ledger
|
246
|
+
- spec/integration/test_money_column/test_args
|
247
|
+
- spec/integration/two_money_columns/input.csv
|
248
|
+
- spec/integration/two_money_columns/output.ledger
|
249
|
+
- spec/integration/two_money_columns/test_args
|
250
|
+
- spec/integration/yyyymmdd_date_example/input.csv
|
251
|
+
- spec/integration/yyyymmdd_date_example/output.ledger
|
252
|
+
- spec/integration/yyyymmdd_date_example/test_args
|
159
253
|
- spec/reckon/app_spec.rb
|
160
254
|
- spec/reckon/csv_parser_spec.rb
|
161
255
|
- spec/reckon/date_column_spec.rb
|
162
256
|
- spec/reckon/ledger_parser_spec.rb
|
163
257
|
- spec/reckon/money_column_spec.rb
|
164
258
|
- spec/reckon/money_spec.rb
|
259
|
+
- spec/reckon/options_spec.rb
|
165
260
|
- spec/spec.opts
|
166
261
|
- spec/spec_helper.rb
|
167
262
|
homepage: https://github.com/cantino/reckon
|
168
263
|
licenses:
|
169
264
|
- MIT
|
170
265
|
metadata: {}
|
171
|
-
post_install_message:
|
266
|
+
post_install_message:
|
172
267
|
rdoc_options: []
|
173
268
|
require_paths:
|
174
269
|
- lib
|
@@ -183,8 +278,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
278
|
- !ruby/object:Gem::Version
|
184
279
|
version: '0'
|
185
280
|
requirements: []
|
186
|
-
rubygems_version: 3.
|
187
|
-
signing_key:
|
281
|
+
rubygems_version: 3.2.3
|
282
|
+
signing_key:
|
188
283
|
specification_version: 4
|
189
284
|
summary: Utility for interactively converting and labeling CSV files for the Ledger
|
190
285
|
accounting tool.
|