reckon 0.9.1 → 0.9.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 +6 -8
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +1 -1
- data/bin/build-new-version.sh +9 -4
- data/lib/reckon/date_column.rb +34 -19
- data/lib/reckon/version.rb +1 -1
- 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: 9ddc247a822ee229bd5530bdfd0b4ec72f9022712ac10b15174e30dceb452bef
|
4
|
+
data.tar.gz: '069982cf8f6c5e899c93fe02a746561011beb968e34dcbdde69622143ff272e7'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 893a0734cfbfe3cc575f426677ecc5d4f80a08b2e35901962aa64cb4ae7c17e9671e181446647f5c6a97ce4ce8bea9ef11bfda5978e9f051b2442410f449b316
|
7
|
+
data.tar.gz: 2a2993018406fecff07d1b61b1371ea9eea16e816312cbb67f6c2dc097086fef1dd253658249b17f105ef415b9c0744e6ca6ad8f29d3c91456e3cbddd8046508
|
data/.github/workflows/ruby.yml
CHANGED
@@ -9,13 +9,10 @@ name: Build Status
|
|
9
9
|
|
10
10
|
on:
|
11
11
|
push:
|
12
|
-
branches: [ master ]
|
13
12
|
pull_request:
|
14
|
-
branches: [ master ]
|
15
13
|
|
16
14
|
jobs:
|
17
15
|
test:
|
18
|
-
|
19
16
|
runs-on: ubuntu-latest
|
20
17
|
strategy:
|
21
18
|
matrix:
|
@@ -26,17 +23,18 @@ jobs:
|
|
26
23
|
- 3.0
|
27
24
|
# Ubuntu 20.04
|
28
25
|
- 2.7
|
26
|
+
# For date_column errors
|
27
|
+
- 2.6
|
29
28
|
steps:
|
30
|
-
- uses: actions/checkout@
|
29
|
+
- uses: actions/checkout@v3
|
31
30
|
- name: Update package
|
32
31
|
run: sudo apt-get update
|
33
32
|
- name: Install packages
|
34
33
|
run: sudo apt-get -y install ledger hledger
|
35
|
-
- name: Set up Ruby
|
36
|
-
|
37
|
-
|
34
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
35
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
36
|
+
# use ruby/setup-ruby@v1 (see https://github.com/ruby/setup-ruby#versioning):
|
38
37
|
uses: ruby/setup-ruby@v1
|
39
|
-
# uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
40
38
|
with:
|
41
39
|
ruby-version: ${{ matrix.ruby-version }}
|
42
40
|
bundler-cache: true # runs 'bundle install' and caches installed gems
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v0.9.2](https://github.com/cantino/reckon/tree/v0.9.2) (2023-04-14)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/cantino/reckon/compare/v0.9.1...v0.9.2)
|
6
|
+
|
7
|
+
**Closed issues:**
|
8
|
+
|
9
|
+
- reckon fails any csv with Date::Error [\#121](https://github.com/cantino/reckon/issues/121)
|
10
|
+
- \[FEATURE REQUEST\] Use ledger files as input source in addition to csv's [\#92](https://github.com/cantino/reckon/issues/92)
|
11
|
+
|
12
|
+
**Merged pull requests:**
|
13
|
+
|
14
|
+
- 121 require date [\#122](https://github.com/cantino/reckon/pull/122) ([benprew](https://github.com/benprew))
|
15
|
+
|
3
16
|
## [v0.9.1](https://github.com/cantino/reckon/tree/v0.9.1) (2023-03-19)
|
4
17
|
|
5
18
|
[Full Changelog](https://github.com/cantino/reckon/compare/v0.9.0...v0.9.1)
|
data/Gemfile.lock
CHANGED
data/bin/build-new-version.sh
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
|
3
|
-
set -
|
3
|
+
set -e
|
4
4
|
|
5
5
|
VERSION=$1
|
6
6
|
|
7
|
+
if [ -z "$TOKEN" ]; then
|
8
|
+
echo "\$TOKEN var must be your github api token"
|
9
|
+
exit 1
|
10
|
+
fi
|
11
|
+
|
7
12
|
echo "Install github_changelog_generator"
|
8
13
|
gem install --user github_changelog_generator
|
9
14
|
|
@@ -12,16 +17,16 @@ echo -e "module Reckon\n VERSION = \"$VERSION\"\nend" > lib/reckon/version.rb
|
|
12
17
|
echo "Run `bundle install` to build updated Gemfile.lock"
|
13
18
|
bundle install
|
14
19
|
echo "Run changelog generator (requires $TOKEN to be your github token)"
|
15
|
-
github_changelog_generator -u cantino -p reckon -t $TOKEN --future-release v$VERSION
|
20
|
+
github_changelog_generator -u cantino -p reckon -t "$TOKEN" --future-release "v$VERSION"
|
16
21
|
echo "Commit changes"
|
17
22
|
git add CHANGELOG.md lib/reckon/version.rb Gemfile.lock
|
18
23
|
git commit -m "Release $VERSION"
|
19
24
|
echo "Tag release"
|
20
|
-
git tag v$VERSION
|
25
|
+
git tag "v$VERSION"
|
21
26
|
echo "Build new gem"
|
22
27
|
gem build reckon.gemspec
|
23
28
|
echo "Push changes and tags"
|
24
29
|
echo "git push && git push --tags"
|
25
30
|
echo "Push new gem"
|
26
31
|
echo "gem push reckon-$VERSION.gem"
|
27
|
-
gh release create v$VERSION reckon-$VERSION.gem --draft --generate-notes
|
32
|
+
gh release create "v$VERSION" "reckon-$VERSION.gem" --draft --generate-notes
|
data/lib/reckon/date_column.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
|
1
5
|
module Reckon
|
6
|
+
# Handle date columns in csv
|
2
7
|
class DateColumn < Array
|
3
8
|
attr_accessor :endian_precedence
|
4
|
-
|
9
|
+
|
10
|
+
def initialize(arr = [], options = {})
|
5
11
|
# output date format
|
6
12
|
@ledger_date_format = options[:ledger_date_format]
|
7
13
|
|
@@ -11,7 +17,9 @@ module Reckon
|
|
11
17
|
if date_format
|
12
18
|
begin
|
13
19
|
value = Date.strptime(value, date_format)
|
14
|
-
|
20
|
+
# ruby 2.6.0 doesn't have Date::Error, but Date::Error is a subclass of
|
21
|
+
# ArgumentError
|
22
|
+
rescue ArgumentError
|
15
23
|
puts "I'm having trouble parsing '#{value}' with the desired format: #{date_format}"
|
16
24
|
exit 1
|
17
25
|
end
|
@@ -22,12 +30,11 @@ module Reckon
|
|
22
30
|
value = [$1, $2, $3].join("/") if value =~ /^(\d{4})\-(\d{2})\-(\d{2})$/ # yyyy-mm-dd format
|
23
31
|
value = [$1, $2, $3].join("/") if value =~ /^(\d{4})(\d{2})(\d{2})/ # yyyymmdd format
|
24
32
|
|
25
|
-
|
26
33
|
unless @endian_precedence # Try to detect endian_precedence
|
27
|
-
reg_match = value.match(
|
34
|
+
reg_match = value.match(%r{^(\d\d)/(\d\d)/\d\d\d?\d?})
|
28
35
|
# If first one is not \d\d/\d\d/\d\d\d?\d set it to default
|
29
36
|
if !reg_match
|
30
|
-
@endian_precedence = [
|
37
|
+
@endian_precedence = %i[middle little]
|
31
38
|
elsif reg_match[1].to_i > 12
|
32
39
|
@endian_precedence = [:little]
|
33
40
|
elsif reg_match[2].to_i > 12
|
@@ -35,23 +42,24 @@ module Reckon
|
|
35
42
|
end
|
36
43
|
end
|
37
44
|
end
|
38
|
-
|
45
|
+
push(value)
|
39
46
|
end
|
47
|
+
|
40
48
|
# if endian_precedence still nil, raise error
|
41
|
-
|
42
|
-
|
43
|
-
|
49
|
+
return if @endian_precedence || date_format
|
50
|
+
|
51
|
+
raise("Unable to determine date format. Please specify using --date-format")
|
44
52
|
end
|
45
53
|
|
46
|
-
def for(
|
47
|
-
value =
|
48
|
-
guess = Chronic.parse(value, :
|
49
|
-
|
50
|
-
if guess.to_i <
|
51
|
-
guess = Chronic.parse((value.split("/")[0...-1] + [(2000 + value.split("/").last.to_i).to_s]).join("/"), :
|
52
|
-
|
54
|
+
def for(index)
|
55
|
+
value = at(index)
|
56
|
+
guess = Chronic.parse(value, contex: :past,
|
57
|
+
endian_precedence: @endian_precedence)
|
58
|
+
if guess.to_i < 953_236_800 && value =~ %r{/}
|
59
|
+
guess = Chronic.parse((value.split("/")[0...-1] + [(2000 + value.split("/").last.to_i).to_s]).join("/"), context: :past,
|
60
|
+
endian_precedence: @endian_precedence)
|
53
61
|
end
|
54
|
-
guess
|
62
|
+
guess&.to_date
|
55
63
|
end
|
56
64
|
|
57
65
|
def pretty_for(index)
|
@@ -65,7 +73,10 @@ module Reckon
|
|
65
73
|
date_score = 0
|
66
74
|
date_score += 10 if entry =~ /\b(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i
|
67
75
|
date_score += 5 if entry =~ /^[\-\/\.\d:\[\]]+$/
|
68
|
-
|
76
|
+
# add points for columns that start with date-like characters -/.\d:[]
|
77
|
+
date_score += entry.gsub(/[^\-\/\.\d:\[\]]/, '').length if entry.gsub(
|
78
|
+
/[^\-\/\.\d:\[\]]/, ''
|
79
|
+
).length > 3
|
69
80
|
date_score -= entry.gsub(/[\-\/\.\d:\[\]]/, '').length
|
70
81
|
date_score += 30 if entry =~ /^\d+[:\/\.-]\d+[:\/\.-]\d+([ :]\d+[:\/\.]\d+)?$/
|
71
82
|
date_score += 10 if entry =~ /^\d+\[\d+:GMT\]$/i
|
@@ -73,7 +84,11 @@ module Reckon
|
|
73
84
|
begin
|
74
85
|
DateTime.parse(entry)
|
75
86
|
date_score += 20
|
76
|
-
|
87
|
+
# ruby 2.6.0 doesn't have Date::Error, but Date::Error is a subclass of
|
88
|
+
# ArgumentError
|
89
|
+
rescue ArgumentError
|
90
|
+
# we don't need do anything here since the column didn't parse as a date
|
91
|
+
nil
|
77
92
|
end
|
78
93
|
|
79
94
|
date_score
|
data/lib/reckon/version.rb
CHANGED
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.2
|
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-04-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|