reckon 0.9.3 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/Gemfile.lock +2 -2
- data/lib/reckon/date_column.rb +6 -3
- data/lib/reckon/version.rb +1 -1
- data/reckon.gemspec +1 -1
- data/spec/reckon/date_column_spec.rb +58 -45
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 489081763b4a46c0bad41cb3ff3435c505a413e3e2cdf39984ff51b6488bbcc2
|
4
|
+
data.tar.gz: c4f6cfc6bec319fd8366c5effabb6c23b086bd0b90a57f9f9f64742805a03fc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b995bbf4939b6901fa769188a4f329a549d0ea20048a968c331fdce40c7e79174d65454d1805f5ba9a66717c7269afbdeef931af8e961a52e1327a7edbbc80e1
|
7
|
+
data.tar.gz: e5107209cf8e6da13c6484d064ec7e6e911502128d891d03590b04354ae5fa24670044e77aab2b90733882391cadb3a8adbd1a8645916b7dcb39d8811dba5070
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v0.9.5](https://github.com/cantino/reckon/tree/v0.9.5) (2024-01-08)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/cantino/reckon/compare/v0.9.4...v0.9.5)
|
6
|
+
|
7
|
+
**Closed issues:**
|
8
|
+
|
9
|
+
- Ruby Readline error [\#127](https://github.com/cantino/reckon/issues/127)
|
10
|
+
- Date formats [\#126](https://github.com/cantino/reckon/issues/126)
|
11
|
+
|
12
|
+
**Merged pull requests:**
|
13
|
+
|
14
|
+
- Pin highline to 2.x branch. Fixes \#127 [\#128](https://github.com/cantino/reckon/pull/128) ([benprew](https://github.com/benprew))
|
15
|
+
|
16
|
+
## [v0.9.4](https://github.com/cantino/reckon/tree/v0.9.4) (2023-11-24)
|
17
|
+
|
18
|
+
[Full Changelog](https://github.com/cantino/reckon/compare/v0.9.3...v0.9.4)
|
19
|
+
|
3
20
|
## [v0.9.3](https://github.com/cantino/reckon/tree/v0.9.3) (2023-08-25)
|
4
21
|
|
5
22
|
[Full Changelog](https://github.com/cantino/reckon/compare/v0.9.2...v0.9.3)
|
data/Gemfile.lock
CHANGED
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
data/reckon.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_development_dependency "pry", ">= 0.12.2"
|
21
21
|
s.add_development_dependency "rantly", "= 1.2.0"
|
22
22
|
s.add_runtime_dependency "chronic", ">= 0.3.0"
|
23
|
-
s.add_runtime_dependency "highline", "
|
23
|
+
s.add_runtime_dependency "highline", "~> 2.0" # 3.0 replaces readline with reline and breaks reckon
|
24
24
|
s.add_runtime_dependency "rchardet", ">= 1.8.0"
|
25
25
|
s.add_runtime_dependency "matrix", ">= 0.4.2"
|
26
26
|
end
|
@@ -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.5
|
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:
|
13
|
+
date: 2024-01-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -72,16 +72,16 @@ dependencies:
|
|
72
72
|
name: highline
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- - "
|
75
|
+
- - "~>"
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
77
|
+
version: '2.0'
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- - "
|
82
|
+
- - "~>"
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
84
|
+
version: '2.0'
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: rchardet
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|