reckon 0.6.2 → 0.8.0
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 +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +54 -3
- data/Gemfile.lock +1 -1
- data/README.md +23 -19
- data/Rakefile +2 -2
- data/bin/build-new-version.sh +26 -0
- data/bin/reckon +4 -1
- data/lib/reckon.rb +1 -0
- data/lib/reckon/app.rb +13 -150
- data/lib/reckon/cosine_similarity.rb +67 -62
- data/lib/reckon/date_column.rb +3 -2
- data/lib/reckon/ledger_parser.rb +1 -1
- data/lib/reckon/money.rb +12 -5
- data/lib/reckon/options.rb +157 -0
- data/lib/reckon/version.rb +1 -1
- data/spec/cosine_training_and_test.rb +52 -0
- data/spec/integration/another_bank_example/output.ledger +3 -3
- 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/broker_canada_example/output.ledger +2 -2
- data/spec/integration/chase/account_tokens_and_regex/output.ledger +3 -3
- data/spec/integration/chase/default_account_names/output.ledger +3 -3
- data/spec/integration/chase/learn_from_existing/output.ledger +3 -3
- data/spec/integration/chase/simple/output.ledger +3 -3
- data/spec/integration/danish_kroner_nordea_example/output.ledger +1 -1
- data/spec/integration/extratofake/output.ledger +1 -1
- data/spec/integration/harder_date_example/output.ledger +2 -2
- data/spec/integration/invalid_header_example/test_args +1 -1
- data/spec/integration/ledger_date_format/compare_cmds +1 -0
- data/spec/integration/ledger_date_format/input.csv +3 -0
- data/spec/integration/ledger_date_format/output.ledger +12 -0
- data/spec/integration/ledger_date_format/test_args +1 -0
- data/spec/integration/test.sh +78 -27
- data/spec/reckon/app_spec.rb +21 -19
- data/spec/reckon/csv_parser_spec.rb +3 -3
- data/spec/reckon/date_column_spec.rb +12 -0
- data/spec/reckon/money_spec.rb +3 -3
- data/spec/reckon/options_spec.rb +17 -0
- data/spec/spec_helper.rb +6 -1
- metadata +15 -2
@@ -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"
|
@@ -38,4 +38,16 @@ describe Reckon::DateColumn do
|
|
38
38
|
.to eq(Date.new(2013, 2, 1))
|
39
39
|
end
|
40
40
|
end
|
41
|
+
|
42
|
+
describe "#pretty_for" do
|
43
|
+
it 'should use ledger_date_format' do
|
44
|
+
expect(Reckon::DateColumn.new(%w[13/02/2013], {ledger_date_format: '%d/%m/%Y'}).pretty_for(0))
|
45
|
+
.to eq('13/02/2013')
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should default to is' do
|
49
|
+
expect(Reckon::DateColumn.new(%w[13/12/2013]).pretty_for(0))
|
50
|
+
.to eq('2013-12-13')
|
51
|
+
end
|
52
|
+
end
|
41
53
|
end
|
data/spec/reckon/money_spec.rb
CHANGED
@@ -32,17 +32,17 @@ describe Reckon::Money do
|
|
32
32
|
describe "pretty" do
|
33
33
|
it "work with negative and positive numbers" do
|
34
34
|
expect(Reckon::Money.new(-20.00).pretty).to eq("-$20.00")
|
35
|
-
expect(Reckon::Money.new(1558.52).pretty).to eq(" $
|
35
|
+
expect(Reckon::Money.new(1558.52).pretty).to eq(" $1,558.52")
|
36
36
|
end
|
37
37
|
|
38
38
|
it "work with other currencies such as €" do
|
39
39
|
expect(Reckon::Money.new(-20.00, currency: "€", suffixed: false).pretty).to eq("-€20.00")
|
40
|
-
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")
|
41
41
|
end
|
42
42
|
|
43
43
|
it "work with suffixed currencies such as SEK" do
|
44
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("
|
45
|
+
expect(Reckon::Money.new(1558.52, currency: "SEK", suffixed: true).pretty).to eq(" 1,558.52 SEK")
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -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,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reckon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Cantino
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-08-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -101,6 +101,7 @@ 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: []
|
@@ -116,6 +117,7 @@ files:
|
|
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
|
@@ -159,6 +163,10 @@ files:
|
|
159
163
|
- spec/integration/another_bank_example/input.csv
|
160
164
|
- spec/integration/another_bank_example/output.ledger
|
161
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
|
162
170
|
- spec/integration/austrian_example/input.csv
|
163
171
|
- spec/integration/austrian_example/output.ledger
|
164
172
|
- spec/integration/austrian_example/test_args
|
@@ -209,6 +217,10 @@ files:
|
|
209
217
|
- spec/integration/inversed_credit_card/input.csv
|
210
218
|
- spec/integration/inversed_credit_card/output.ledger
|
211
219
|
- spec/integration/inversed_credit_card/test_args
|
220
|
+
- spec/integration/ledger_date_format/compare_cmds
|
221
|
+
- spec/integration/ledger_date_format/input.csv
|
222
|
+
- spec/integration/ledger_date_format/output.ledger
|
223
|
+
- spec/integration/ledger_date_format/test_args
|
212
224
|
- spec/integration/nationwide/input.csv
|
213
225
|
- spec/integration/nationwide/output.ledger
|
214
226
|
- spec/integration/nationwide/test_args
|
@@ -248,6 +260,7 @@ files:
|
|
248
260
|
- spec/reckon/ledger_parser_spec.rb
|
249
261
|
- spec/reckon/money_column_spec.rb
|
250
262
|
- spec/reckon/money_spec.rb
|
263
|
+
- spec/reckon/options_spec.rb
|
251
264
|
- spec/spec.opts
|
252
265
|
- spec/spec_helper.rb
|
253
266
|
homepage: https://github.com/cantino/reckon
|