reckon 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +17 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -4
- data/bin/build-new-version.sh +26 -0
- data/bin/reckon +1 -1
- data/lib/reckon.rb +1 -0
- data/lib/reckon/app.rb +7 -144
- data/lib/reckon/options.rb +147 -0
- data/lib/reckon/version.rb +1 -1
- data/spec/integration/invalid_header_example/test_args +1 -1
- data/spec/integration/test.sh +1 -0
- data/spec/reckon/app_spec.rb +20 -18
- data/spec/reckon/options_spec.rb +17 -0
- data/spec/spec_helper.rb +6 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e7bf4198ae8265e025b20821adea75c3acc7cc9493298ac6e7604b342e04bb1
|
4
|
+
data.tar.gz: 4e7e9be82a15f1aef0ab7667e4a751b7e52472673fe0f57359e5d7c5fdac80f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb4ce5f4bcb0b9663b5ab89c5071086bf6b13c157f4d45d1608dc1b530b076b82402b25003b4156882b8c56441f66c1cc97867cd781cb8a6b8386804eddb0673
|
7
|
+
data.tar.gz: ec5941351ad06d6bf029af5b47a9453a611c4a17aa14bddbe8b5b2cf4584bcdceb134a0c9016d32f046832ea507a611807a159a2f85a673374bbf591a063a42a
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,21 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## [0.
|
3
|
+
## [0.7.0](https://github.com/cantino/reckon/tree/0.7.0) (2021-02-06)
|
4
4
|
|
5
|
-
[Full Changelog](https://github.com/cantino/reckon/compare/v0.6.
|
5
|
+
[Full Changelog](https://github.com/cantino/reckon/compare/v0.6.2...0.7.0)
|
6
|
+
|
7
|
+
**Closed issues:**
|
8
|
+
|
9
|
+
- fail on unknown accounts [\#96](https://github.com/cantino/reckon/issues/96)
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- Fail on unknown account [\#102](https://github.com/cantino/reckon/pull/102) ([benprew](https://github.com/benprew))
|
14
|
+
- Joined split sentence to one [\#101](https://github.com/cantino/reckon/pull/101) ([RidaAyed](https://github.com/RidaAyed))
|
15
|
+
|
16
|
+
## [v0.6.2](https://github.com/cantino/reckon/tree/v0.6.2) (2021-01-25)
|
17
|
+
|
18
|
+
[Full Changelog](https://github.com/cantino/reckon/compare/v0.6.1...v0.6.2)
|
6
19
|
|
7
20
|
**Closed issues:**
|
8
21
|
|
@@ -168,7 +181,6 @@
|
|
168
181
|
**Merged pull requests:**
|
169
182
|
|
170
183
|
- Better ISO 8601 dates support [\#49](https://github.com/cantino/reckon/pull/49) ([vzctl](https://github.com/vzctl))
|
171
|
-
- Unattended mode and custom tokens support [\#47](https://github.com/cantino/reckon/pull/47) ([vzctl](https://github.com/vzctl))
|
172
184
|
- \[RFC\] Implement issue \#40: Tab completion [\#46](https://github.com/cantino/reckon/pull/46) ([BlackEdder](https://github.com/BlackEdder))
|
173
185
|
- set readline to allow for backspace in ask dialog [\#44](https://github.com/cantino/reckon/pull/44) ([mrtazz](https://github.com/mrtazz))
|
174
186
|
|
@@ -178,6 +190,7 @@
|
|
178
190
|
|
179
191
|
**Merged pull requests:**
|
180
192
|
|
193
|
+
- Fix --encoding option [\#41](https://github.com/cantino/reckon/pull/41) ([mamciek](https://github.com/mamciek))
|
181
194
|
- Bumped version number [\#37](https://github.com/cantino/reckon/pull/37) ([BlackEdder](https://github.com/BlackEdder))
|
182
195
|
|
183
196
|
## [v0.3.9](https://github.com/cantino/reckon/tree/v0.3.9) (2014-02-20)
|
@@ -191,7 +204,7 @@
|
|
191
204
|
|
192
205
|
**Merged pull requests:**
|
193
206
|
|
194
|
-
-
|
207
|
+
- Unattended mode and custom tokens support [\#47](https://github.com/cantino/reckon/pull/47) ([vzctl](https://github.com/vzctl))
|
195
208
|
- Added spec for csv files from Broker Canada [\#36](https://github.com/cantino/reckon/pull/36) ([BlackEdder](https://github.com/BlackEdder))
|
196
209
|
- Date format [\#35](https://github.com/cantino/reckon/pull/35) ([BlackEdder](https://github.com/BlackEdder))
|
197
210
|
- Added example from a french bank [\#34](https://github.com/cantino/reckon/pull/34) ([BlackEdder](https://github.com/BlackEdder))
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -135,11 +135,10 @@ We encourage you to contribute to Reckon! Here is some information to help you.
|
|
135
135
|
|
136
136
|
1. Fork the project.
|
137
137
|
2. Make your feature addition or bug fix.
|
138
|
-
3. Add tests for it. This is important so I don't break it in a
|
139
|
-
4.
|
140
|
-
5. Commit, do not mess with rakefile, version, or history.
|
138
|
+
3. Add tests for it. This is important so I don't break it in a future version unintentionally.
|
139
|
+
4. Commit, do not mess with rakefile, version, or history.
|
141
140
|
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
142
|
-
|
141
|
+
5. Send me a pull request. Bonus points for topic branches.
|
143
142
|
|
144
143
|
### Integration Tests
|
145
144
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
VERSION=$1
|
6
|
+
|
7
|
+
echo "Install github_changelog_generator"
|
8
|
+
gem install --user github_changelog_generator
|
9
|
+
|
10
|
+
echo "Update 'lib/reckon/version.rb'"
|
11
|
+
echo -e "module Reckon\n VERSION=\"$VERSION\"\nend" > lib/reckon/version.rb
|
12
|
+
echo "Run `bundle install` to build updated Gemfile.lock"
|
13
|
+
bundle install
|
14
|
+
echo "3. Run changelog generator (requires $TOKEN to be your github token)"
|
15
|
+
github_changelog_generator -u cantino -p reckon -t $TOKEN --future-release $VERSION
|
16
|
+
echo "4. Commit changes"
|
17
|
+
git add CHANGELOG.md lib/reckon/version.rb Gemfile.lock
|
18
|
+
git commit -m "Release $VERSION"
|
19
|
+
echo "7. Build new gem"
|
20
|
+
gem build reckon.gemspec
|
21
|
+
echo "5. Tag release"
|
22
|
+
git tag v$VERSION
|
23
|
+
echo "Push changes and tags"
|
24
|
+
echo git push && git push --tags
|
25
|
+
echo "Push new gem"
|
26
|
+
echo gem push reckon-$VERSION.gem
|
data/bin/reckon
CHANGED
data/lib/reckon.rb
CHANGED
data/lib/reckon/app.rb
CHANGED
@@ -193,11 +193,13 @@ module Reckon
|
|
193
193
|
LOGGER.info "possible_answers===> #{possible_answers.inspect}"
|
194
194
|
|
195
195
|
if options[:unattended]
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
196
|
+
if options[:fail_on_unknown_account] && possible_answers.empty?
|
197
|
+
raise %(Couldn't find any matches for '#{row[:description]}'
|
198
|
+
Try adding an account token with --account-tokens)
|
199
|
+
end
|
200
|
+
|
201
|
+
default = options[:default_outof_account]
|
202
|
+
default = options[:default_into_account] if row[:pretty_money][0] == '-'
|
201
203
|
return possible_answers[0] || default
|
202
204
|
end
|
203
205
|
|
@@ -285,144 +287,5 @@ module Reckon
|
|
285
287
|
end
|
286
288
|
print_transaction(rows)
|
287
289
|
end
|
288
|
-
|
289
|
-
def self.parse_opts(args=ARGV, stdin=STDIN)
|
290
|
-
options = { :output_file => STDOUT }
|
291
|
-
OptionParser.new do |opts|
|
292
|
-
opts.banner = "Usage: Reckon.rb [options]"
|
293
|
-
opts.separator ""
|
294
|
-
|
295
|
-
opts.on("-f", "--file FILE", "The CSV file to parse") do |file|
|
296
|
-
options[:file] = file
|
297
|
-
end
|
298
|
-
|
299
|
-
opts.on("-a", "--account NAME", "The Ledger Account this file is for") do |a|
|
300
|
-
options[:bank_account] = a
|
301
|
-
end
|
302
|
-
|
303
|
-
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
304
|
-
options[:verbose] = v
|
305
|
-
end
|
306
|
-
|
307
|
-
opts.on("-i", "--inverse", "Use the negative of each amount") do |v|
|
308
|
-
options[:inverse] = v
|
309
|
-
end
|
310
|
-
|
311
|
-
opts.on("-p", "--print-table", "Print out the parsed CSV in table form") do |p|
|
312
|
-
options[:print_table] = p
|
313
|
-
end
|
314
|
-
|
315
|
-
opts.on("-o", "--output-file FILE", "The ledger file to append to") do |o|
|
316
|
-
options[:output_file] = File.open(o, 'a')
|
317
|
-
end
|
318
|
-
|
319
|
-
opts.on("-l", "--learn-from FILE", "An existing ledger file to learn accounts from") do |l|
|
320
|
-
options[:existing_ledger_file] = l
|
321
|
-
end
|
322
|
-
|
323
|
-
opts.on("", "--ignore-columns 1,2,5", "Columns to ignore in the CSV file - the first column is column 1") do |ignore|
|
324
|
-
options[:ignore_columns] = ignore.split(",").map { |i| i.to_i }
|
325
|
-
end
|
326
|
-
|
327
|
-
opts.on("", "--money-column 2", Integer, "Specify the money column instead of letting Reckon guess - the first column is column 1") do |column_number|
|
328
|
-
options[:money_column] = column_number
|
329
|
-
end
|
330
|
-
|
331
|
-
opts.on("", "--raw-money", "Don't format money column (for stocks)") do |n|
|
332
|
-
options[:raw] = n
|
333
|
-
end
|
334
|
-
|
335
|
-
opts.on("", "--date-column 3", Integer, "Specify the date column instead of letting Reckon guess - the first column is column 1") do |column_number|
|
336
|
-
options[:date_column] = column_number
|
337
|
-
end
|
338
|
-
|
339
|
-
opts.on("", "--contains-header [N]", "The first row of the CSV is a header and should be skipped. Optionally add the number of rows to skip.") do |contains_header|
|
340
|
-
options[:contains_header] = 1
|
341
|
-
options[:contains_header] = contains_header.to_i if contains_header
|
342
|
-
end
|
343
|
-
|
344
|
-
opts.on("", "--csv-separator ','", "Separator for parsing the CSV - default is comma.") do |csv_separator|
|
345
|
-
options[:csv_separator] = csv_separator
|
346
|
-
end
|
347
|
-
|
348
|
-
opts.on("", "--comma-separates-cents", "Use comma instead of period to deliminate dollars from cents when parsing ($100,50 instead of $100.50)") do |c|
|
349
|
-
options[:comma_separates_cents] = c
|
350
|
-
end
|
351
|
-
|
352
|
-
opts.on("", "--encoding 'UTF-8'", "Specify an encoding for the CSV file; not usually needed") do |e|
|
353
|
-
options[:encoding] = e
|
354
|
-
end
|
355
|
-
|
356
|
-
opts.on("-c", "--currency '$'", "Currency symbol to use, defaults to $ (£, EUR)") do |e|
|
357
|
-
options[:currency] = e
|
358
|
-
end
|
359
|
-
|
360
|
-
opts.on("", "--date-format '%d/%m/%Y'", "Force the date format (see Ruby DateTime strftime)") do |d|
|
361
|
-
options[:date_format] = d
|
362
|
-
end
|
363
|
-
|
364
|
-
opts.on("-u", "--unattended", "Don't ask questions and guess all the accounts automatically. Used with --learn-from or --account-tokens options.") do |n|
|
365
|
-
options[:unattended] = n
|
366
|
-
end
|
367
|
-
|
368
|
-
opts.on("-t", "--account-tokens FILE", "YAML file with manually-assigned tokens for each account (see README)") do |a|
|
369
|
-
options[:account_tokens_file] = a
|
370
|
-
end
|
371
|
-
|
372
|
-
opts.on("", "--default-into-account NAME", "Default into account") do |a|
|
373
|
-
options[:default_into_account] = a
|
374
|
-
end
|
375
|
-
|
376
|
-
opts.on("", "--default-outof-account NAME", "Default 'out of' account") do |a|
|
377
|
-
options[:default_outof_account] = a
|
378
|
-
end
|
379
|
-
|
380
|
-
opts.on("", "--suffixed", "If --currency should be used as a suffix. Defaults to false.") do |e|
|
381
|
-
options[:suffixed] = e
|
382
|
-
end
|
383
|
-
|
384
|
-
opts.on_tail("-h", "--help", "Show this message") do
|
385
|
-
puts opts
|
386
|
-
exit
|
387
|
-
end
|
388
|
-
|
389
|
-
opts.on_tail("--version", "Show version") do
|
390
|
-
puts VERSION
|
391
|
-
exit
|
392
|
-
end
|
393
|
-
|
394
|
-
opts.parse!(args)
|
395
|
-
end
|
396
|
-
|
397
|
-
if options[:file] == '-'
|
398
|
-
unless options[:unattended]
|
399
|
-
raise "--unattended is required to use STDIN as CSV source."
|
400
|
-
end
|
401
|
-
|
402
|
-
puts "Reading csv from STDIN"
|
403
|
-
options[:string] = stdin.read
|
404
|
-
end
|
405
|
-
|
406
|
-
unless options[:file]
|
407
|
-
options[:file] = @@cli.ask("What CSV file should I parse? ")
|
408
|
-
unless options[:file].length > 0
|
409
|
-
puts "\nYou must provide a CSV file to parse.\n"
|
410
|
-
puts parser
|
411
|
-
exit
|
412
|
-
end
|
413
|
-
end
|
414
|
-
|
415
|
-
unless options[:bank_account]
|
416
|
-
fail "Please specify --account in unattended mode" if options[:unattended]
|
417
|
-
|
418
|
-
options[:bank_account] = @@cli.ask("What is the account name of this bank account in Ledger? ") do |q|
|
419
|
-
q.readline = true
|
420
|
-
q.validate = /^.{2,}$/
|
421
|
-
q.default = "Assets:Bank:Checking"
|
422
|
-
end
|
423
|
-
end
|
424
|
-
|
425
|
-
options
|
426
|
-
end
|
427
290
|
end
|
428
291
|
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
module Reckon
|
2
|
+
class Options
|
3
|
+
def self.parse(args = ARGV, stdin = $stdin)
|
4
|
+
options = { output_file: $stdout }
|
5
|
+
OptionParser.new do |opts|
|
6
|
+
opts.banner = "Usage: Reckon.rb [options]"
|
7
|
+
opts.separator ""
|
8
|
+
|
9
|
+
opts.on("-f", "--file FILE", "The CSV file to parse") do |file|
|
10
|
+
options[:file] = file
|
11
|
+
end
|
12
|
+
|
13
|
+
opts.on("-a", "--account NAME", "The Ledger Account this file is for") do |a|
|
14
|
+
options[:bank_account] = a
|
15
|
+
end
|
16
|
+
|
17
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
18
|
+
options[:verbose] = v
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on("-i", "--inverse", "Use the negative of each amount") do |v|
|
22
|
+
options[:inverse] = v
|
23
|
+
end
|
24
|
+
|
25
|
+
opts.on("-p", "--print-table", "Print out the parsed CSV in table form") do |p|
|
26
|
+
options[:print_table] = p
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on("-o", "--output-file FILE", "The ledger file to append to") do |o|
|
30
|
+
options[:output_file] = File.open(o, 'a')
|
31
|
+
end
|
32
|
+
|
33
|
+
opts.on("-l", "--learn-from FILE", "An existing ledger file to learn accounts from") do |l|
|
34
|
+
options[:existing_ledger_file] = l
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on("", "--ignore-columns 1,2,5", "Columns to ignore, starts from 1") do |ignore|
|
38
|
+
options[:ignore_columns] = ignore.split(",").map(&:to_i)
|
39
|
+
end
|
40
|
+
|
41
|
+
opts.on("", "--money-column 2", Integer, "Column number of the money column, starts from 1") do |col|
|
42
|
+
options[:money_column] = col
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on("", "--raw-money", "Don't format money column (for stocks)") do |n|
|
46
|
+
options[:raw] = n
|
47
|
+
end
|
48
|
+
|
49
|
+
opts.on("", "--date-column 3", Integer, "Column number of the date column, starts from 1") do |col|
|
50
|
+
options[:date_column] = col
|
51
|
+
end
|
52
|
+
|
53
|
+
opts.on("", "--contains-header [N]", Integer, "Skip N header rows - default 1") do |hdr|
|
54
|
+
options[:contains_header] = 1
|
55
|
+
options[:contains_header] = hdr.to_i
|
56
|
+
end
|
57
|
+
|
58
|
+
opts.on("", "--csv-separator ','", "CSV separator (default ',')") do |sep|
|
59
|
+
options[:csv_separator] = sep
|
60
|
+
end
|
61
|
+
|
62
|
+
opts.on("", "--comma-separates-cents", "Use comma to separate cents ($100,50 vs. $100.50)") do |c|
|
63
|
+
options[:comma_separates_cents] = c
|
64
|
+
end
|
65
|
+
|
66
|
+
opts.on("", "--encoding 'UTF-8'", "Specify an encoding for the CSV file") do |e|
|
67
|
+
options[:encoding] = e
|
68
|
+
end
|
69
|
+
|
70
|
+
opts.on("-c", "--currency '$'", "Currency symbol to use - default $ (ex £, EUR)") do |e|
|
71
|
+
options[:currency] = e
|
72
|
+
end
|
73
|
+
|
74
|
+
opts.on("", "--date-format '%d/%m/%Y'", "Force the date format (see Ruby DateTime strftime)") do |d|
|
75
|
+
options[:date_format] = d
|
76
|
+
end
|
77
|
+
|
78
|
+
opts.on("-u", "--unattended", "Don't ask questions and guess all the accounts automatically. Use with --learn-from or --account-tokens options.") do |n|
|
79
|
+
options[:unattended] = n
|
80
|
+
end
|
81
|
+
|
82
|
+
opts.on("-t", "--account-tokens FILE", "YAML file with manually-assigned tokens for each account (see README)") do |a|
|
83
|
+
options[:account_tokens_file] = a
|
84
|
+
end
|
85
|
+
|
86
|
+
options[:default_into_account] = 'Expenses:Unknown'
|
87
|
+
opts.on("", "--default-into-account NAME", "Default into account") do |a|
|
88
|
+
options[:default_into_account] = a
|
89
|
+
end
|
90
|
+
|
91
|
+
options[:default_outof_account] = 'Income:Unknown'
|
92
|
+
opts.on("", "--default-outof-account NAME", "Default 'out of' account") do |a|
|
93
|
+
options[:default_outof_account] = a
|
94
|
+
end
|
95
|
+
|
96
|
+
opts.on("", "--fail-on-unknown-account", "Fail on unmatched transactions.") do |n|
|
97
|
+
options[:fail_on_unknown_account] = n
|
98
|
+
end
|
99
|
+
|
100
|
+
opts.on("", "--suffixed", "Append currency symbol as a suffix.") do |e|
|
101
|
+
options[:suffixed] = e
|
102
|
+
end
|
103
|
+
|
104
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
105
|
+
puts opts
|
106
|
+
exit
|
107
|
+
end
|
108
|
+
|
109
|
+
opts.on_tail("--version", "Show version") do
|
110
|
+
puts VERSION
|
111
|
+
exit
|
112
|
+
end
|
113
|
+
|
114
|
+
opts.parse!(args)
|
115
|
+
end
|
116
|
+
|
117
|
+
if options[:file] == '-'
|
118
|
+
unless options[:unattended]
|
119
|
+
raise "--unattended is required to use STDIN as CSV source."
|
120
|
+
end
|
121
|
+
|
122
|
+
options[:string] = stdin.read
|
123
|
+
end
|
124
|
+
|
125
|
+
unless options[:file]
|
126
|
+
options[:file] = @@cli.ask("What CSV file should I parse? ")
|
127
|
+
unless options[:file].empty?
|
128
|
+
puts "\nYou must provide a CSV file to parse.\n"
|
129
|
+
puts parser
|
130
|
+
exit
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
unless options[:bank_account]
|
135
|
+
raise "Must specify --account in unattended mode" if options[:unattended]
|
136
|
+
|
137
|
+
options[:bank_account] = @@cli.ask("What is this account named in Ledger? ") do |q|
|
138
|
+
q.readline = true
|
139
|
+
q.validate = /^.{2,}$/
|
140
|
+
q.default = "Assets:Bank:Checking"
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
return options
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
data/lib/reckon/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
-f input.csv --unattended --account Assets:Bank:Checking --contains-header
|
1
|
+
-f input.csv --unattended --account Assets:Bank:Checking --contains-header 4
|
data/spec/integration/test.sh
CHANGED
data/spec/reckon/app_spec.rb
CHANGED
@@ -19,7 +19,7 @@ describe Reckon::App do
|
|
19
19
|
@rows[0][:pretty_money].should == " $2105.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
|
@@ -87,20 +89,20 @@ describe Reckon::App do
|
|
87
89
|
end
|
88
90
|
end
|
89
91
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
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
|
+
)
|
98
102
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
)
|
103
|
-
end
|
103
|
+
expect { chase.walk_backwards }.to(
|
104
|
+
raise_error(RuntimeError, /Couldn't find any matches/)
|
105
|
+
)
|
104
106
|
end
|
105
107
|
end
|
106
108
|
|
@@ -162,7 +164,7 @@ describe Reckon::App do
|
|
162
164
|
CREDIT,20091223120000[0:GMT],"Blarg BLARG REVENUE PPD ID: 00jah78563",1558.52
|
163
165
|
DEBIT,20091221120000[0:GMT],"WEBSITE-BALANCE-17DEC09 12 12/17WEBSITE-BAL",-12.23
|
164
166
|
DEBIT,20091214120000[0:GMT],"WEBSITE-BALANCE-10DEC09 12 12/10WEBSITE-BAL",-20.96
|
165
|
-
CREDIT,20091211120000[0:GMT],"PAYPAL TRANSFER PPD ID: PAYPALSDSL"
|
167
|
+
CREDIT,20091211120000[0:GMT],"PAYPAL TRANSFER PPD ID: PAYPALSDSL",116.22
|
166
168
|
CREDIT,20091210120000[0:GMT],"Some Company vendorpymt PPD ID: 5KL3832735",2105.00
|
167
169
|
CSV
|
168
170
|
|
@@ -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.7.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-02-06 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,6 +127,7 @@ 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
|
130
133
|
- spec/data_fixtures/51-sample.csv
|
@@ -248,6 +251,7 @@ files:
|
|
248
251
|
- spec/reckon/ledger_parser_spec.rb
|
249
252
|
- spec/reckon/money_column_spec.rb
|
250
253
|
- spec/reckon/money_spec.rb
|
254
|
+
- spec/reckon/options_spec.rb
|
251
255
|
- spec/spec.opts
|
252
256
|
- spec/spec_helper.rb
|
253
257
|
homepage: https://github.com/cantino/reckon
|