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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc9cf03c584638f19ffd111497105288a9002a71ec4dd649655a7fa1b8c6566c
4
- data.tar.gz: 75453fe81b3f131a72dae8ab1f592cf0bcfb61fb380c5486cb984ffb504fa64b
3
+ metadata.gz: 489081763b4a46c0bad41cb3ff3435c505a413e3e2cdf39984ff51b6488bbcc2
4
+ data.tar.gz: c4f6cfc6bec319fd8366c5effabb6c23b086bd0b90a57f9f9f64742805a03fc1
5
5
  SHA512:
6
- metadata.gz: 9cc31d230176f3d70609d7560ce5b948295d3eef33402ea12aa91749ecb48cf4c36e9885af4ea07e451c8641ae1acacd5421b093621cbde65f88da116992be30
7
- data.tar.gz: d4e743fa0f3104bc4fe14774ea5e7ce8b7862c0865b725f6e7fac5f0a68607c7baa45c95a99d755c46a03dd90389d69e6addfd06c990103e4bc12c9959e6bf65
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
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- reckon (0.9.3)
4
+ reckon (0.9.5)
5
5
  chronic (>= 0.3.0)
6
- highline (>= 1.5.2)
6
+ highline (~> 2.0)
7
7
  matrix (>= 0.4.2)
8
8
  rchardet (>= 1.8.0)
9
9
 
@@ -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
- # ruby 2.6.0 doesn't have Date::Error, but Date::Error is a subclass of
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
@@ -1,3 +1,3 @@
1
1
  module Reckon
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.5"
3
3
  end
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", ">= 1.5.2"
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
- # encoding: utf-8
2
+ # frozen_string_literal: true
3
3
 
4
4
  require "spec_helper"
5
- require 'rubygems'
6
- require 'reckon'
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
- it "should correctly use endian_precedence" do
35
- expect(Reckon::DateColumn.new(%w[01/02/2013 01/14/2013]).for(0))
36
- .to eq(Date.new(2013, 1, 2))
37
- expect(Reckon::DateColumn.new(%w[01/02/2013 14/01/2013]).for(0))
38
- .to eq(Date.new(2013, 2, 1))
39
- end
40
- end
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
- 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')
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
- it 'should default to is' do
49
- expect(Reckon::DateColumn.new(%w[13/12/2013]).pretty_for(0))
50
- .to eq('2013-12-13')
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
- describe "#likelihood" do
55
- it "should prefer numbers that looks like dates" do
56
- expect(Reckon::DateColumn.likelihood("123456789")).to be < Reckon::DateColumn.likelihood("20160102")
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.3
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: 2023-08-25 00:00:00.000000000 Z
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: 1.5.2
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: 1.5.2
84
+ version: '2.0'
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: rchardet
87
87
  requirement: !ruby/object:Gem::Requirement