reckon 0.9.2 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +1 -1
- data/lib/reckon/beancount_parser.rb +1 -1
- data/lib/reckon/date_column.rb +6 -3
- data/lib/reckon/version.rb +1 -1
- data/spec/reckon/date_column_spec.rb +58 -45
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 648b51c8481100983f8d8eff4d9b86ea2ad1962e0908268a6450f618d90f3267
|
4
|
+
data.tar.gz: fb19e70b53da00299caa495e24d8fa01ac20686306e383f598a8888f5118dae3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56a4558fe3aadfbf9a0a9f4399f8e70b549b90a08057235fafe5839203390c462b502511fc60b748490398c75f46b5a4d8ccbb4ac9b07b4e6058d72bf615f4ac
|
7
|
+
data.tar.gz: dc3acb9fdae98efc8cd4a8891037cc5bfff716b2c5db74f8b1f86edaa2da0e60843ffbcb0eeeef49358738e0a63bded19e2fa3f9955cce40566a3241cbc86aff
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v0.9.3](https://github.com/cantino/reckon/tree/v0.9.3) (2023-08-25)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/cantino/reckon/compare/v0.9.2...v0.9.3)
|
6
|
+
|
7
|
+
**Closed issues:**
|
8
|
+
|
9
|
+
- Can you choose to apply amounts against category instead of account name? [\#123](https://github.com/cantino/reckon/issues/123)
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- Fix end quote around note in beancount format [\#124](https://github.com/cantino/reckon/pull/124) ([stephas](https://github.com/stephas))
|
14
|
+
|
3
15
|
## [v0.9.2](https://github.com/cantino/reckon/tree/v0.9.2) (2023-04-14)
|
4
16
|
|
5
17
|
[Full Changelog](https://github.com/cantino/reckon/compare/v0.9.1...v0.9.2)
|
data/Gemfile.lock
CHANGED
@@ -65,7 +65,7 @@ module Reckon
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def format_row(row, line1, line2)
|
68
|
-
out = %Q{#{row[:pretty_date]} * "#{row[:description]}" "#{row[:note]}\n}
|
68
|
+
out = %Q{#{row[:pretty_date]} * "#{row[:description]}" "#{row[:note]}"\n}
|
69
69
|
out += "\t#{line1.first}\t\t\t#{line1.last}\n"
|
70
70
|
out += "\t#{line2.first}\t\t\t#{line2.last}\n\n"
|
71
71
|
out
|
data/lib/reckon/date_column.rb
CHANGED
@@ -81,12 +81,15 @@ module Reckon
|
|
81
81
|
date_score += 30 if entry =~ /^\d+[:\/\.-]\d+[:\/\.-]\d+([ :]\d+[:\/\.]\d+)?$/
|
82
82
|
date_score += 10 if entry =~ /^\d+\[\d+:GMT\]$/i
|
83
83
|
|
84
|
+
# ruby 2.6.0 doesn't have Date::Error, but Date::Error is a subclass of
|
85
|
+
# ArgumentError
|
86
|
+
#
|
87
|
+
# Sometimes DateTime.parse can throw a RangeError
|
88
|
+
# See https://github.com/cantino/reckon/issues/126
|
84
89
|
begin
|
85
90
|
DateTime.parse(entry)
|
86
91
|
date_score += 20
|
87
|
-
|
88
|
-
# ArgumentError
|
89
|
-
rescue ArgumentError
|
92
|
+
rescue StandardError
|
90
93
|
# we don't need do anything here since the column didn't parse as a date
|
91
94
|
nil
|
92
95
|
end
|
data/lib/reckon/version.rb
CHANGED
@@ -1,59 +1,72 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
2
|
+
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require "spec_helper"
|
5
|
-
require
|
6
|
-
require
|
7
|
-
|
8
|
-
describe Reckon::DateColumn do
|
9
|
-
describe "initialize" do
|
10
|
-
it "should detect us and world time" do
|
11
|
-
Reckon::DateColumn.new( ["01/02/2013", "01/14/2013"] ).endian_precedence.should == [:middle]
|
12
|
-
Reckon::DateColumn.new( ["01/02/2013", "14/01/2013"] ).endian_precedence.should == [:little]
|
13
|
-
end
|
14
|
-
it "should set endian_precedence to default when date format cannot be misinterpreted" do
|
15
|
-
Reckon::DateColumn.new( ["2013/01/02"] ).endian_precedence.should == [:middle,:little]
|
16
|
-
end
|
17
|
-
it "should raise an error when in doubt" do
|
18
|
-
expect{ Reckon::DateColumn.new( ["01/02/2013", "01/03/2013"] )}.to raise_error( StandardError )
|
19
|
-
end
|
20
|
-
end
|
21
|
-
describe "for" do
|
22
|
-
it "should detect the date" do
|
23
|
-
expect(Reckon::DateColumn.new(%w[13/12/2013]).for(0))
|
24
|
-
.to eq(Date.new(2013, 12, 13))
|
25
|
-
expect(Reckon::DateColumn.new(%w[01/14/2013]).for(0))
|
26
|
-
.to eq(Date.new(2013, 1, 14))
|
27
|
-
expect(Reckon::DateColumn.new(%w[13/12/2013 21/11/2013]).for(1))
|
28
|
-
.to eq(Date.new(2013, 11, 21))
|
29
|
-
expect(Reckon::DateColumn.new( ["2013-11-21"] ).for( 0 ))
|
30
|
-
.to eq(Date.new(2013, 11, 21))
|
5
|
+
require "rubygems"
|
6
|
+
require "reckon"
|
31
7
|
|
8
|
+
# datecolumn specs
|
9
|
+
module Reckon
|
10
|
+
describe DateColumn do
|
11
|
+
describe "#initialize" do
|
12
|
+
it "should detect us and world time" do
|
13
|
+
expect(DateColumn.new(%w[01/02/2013 01/14/2013]).endian_precedence)
|
14
|
+
.to eq [:middle]
|
15
|
+
expect(DateColumn.new(%w[01/02/2013 14/01/2013]).endian_precedence)
|
16
|
+
.to eq [:little]
|
17
|
+
end
|
18
|
+
it "should set endian_precedence to default when date format cannot be misinterpreted" do
|
19
|
+
expect(DateColumn.new(["2013/01/02"]).endian_precedence)
|
20
|
+
.to eq %i[middle little]
|
21
|
+
end
|
22
|
+
it "should raise an error when in doubt" do
|
23
|
+
expect { DateColumn.new(["01/02/2013", "01/03/2013"]) }
|
24
|
+
.to raise_error(StandardError)
|
25
|
+
end
|
32
26
|
end
|
33
27
|
|
34
|
-
|
35
|
-
|
36
|
-
.to eq(Date.new(2013,
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
28
|
+
describe "#for" do
|
29
|
+
it "should detect the date" do
|
30
|
+
expect(DateColumn.new(%w[13/12/2013]).for(0)).to eq(Date.new(2013, 12, 13))
|
31
|
+
expect(DateColumn.new(%w[01/14/2013]).for(0)).to eq(Date.new(2013, 1, 14))
|
32
|
+
expect(DateColumn.new(%w[13/12/2013 21/11/2013]).for(1))
|
33
|
+
.to eq(Date.new(2013, 11, 21))
|
34
|
+
expect(DateColumn.new(["2013-11-21"]).for(0)).to eq(Date.new(2013, 11, 21))
|
35
|
+
end
|
41
36
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
37
|
+
it "should correctly use endian_precedence" do
|
38
|
+
expect(DateColumn.new(%w[01/02/2013 01/14/2013]).for(0))
|
39
|
+
.to eq(Date.new(2013, 1, 2))
|
40
|
+
expect(DateColumn.new(%w[01/02/2013 14/01/2013]).for(0))
|
41
|
+
.to eq(Date.new(2013, 2, 1))
|
42
|
+
end
|
46
43
|
end
|
47
44
|
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
describe "#pretty_for" do
|
46
|
+
it "should use ledger_date_format" do
|
47
|
+
expect(
|
48
|
+
DateColumn.new(["13/02/2013"],
|
49
|
+
{ ledger_date_format: "%d/%m/%Y" }).pretty_for(0)
|
50
|
+
)
|
51
|
+
.to eq("13/02/2013")
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should default to is" do
|
55
|
+
expect(DateColumn.new(["13/12/2013"]).pretty_for(0))
|
56
|
+
.to eq("2013-12-13")
|
57
|
+
end
|
51
58
|
end
|
52
|
-
end
|
53
59
|
|
54
|
-
|
55
|
-
|
56
|
-
|
60
|
+
describe "#likelihood" do
|
61
|
+
it "should prefer numbers that looks like dates" do
|
62
|
+
expect(DateColumn.likelihood("123456789"))
|
63
|
+
.to be < DateColumn.likelihood("20160102")
|
64
|
+
end
|
65
|
+
|
66
|
+
# See https://github.com/cantino/reckon/issues/126
|
67
|
+
it "Issue #126 - it shouldn't fail on invalid dates" do
|
68
|
+
expect(DateColumn.likelihood("303909302970-07-2023")).to be > 0
|
69
|
+
end
|
57
70
|
end
|
58
71
|
end
|
59
72
|
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.9.
|
4
|
+
version: 0.9.4
|
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: 2023-
|
13
|
+
date: 2023-11-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|