parse_date 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -0
- data/.rubocop_todo.yml +1 -16
- data/README.md +2 -2
- data/lib/parse_date/int_from_string.rb +5 -5
- data/lib/parse_date/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd2ee682788fbcb97d1f5e51256590401689aa3b73d1197996b3ff5344211bad
|
4
|
+
data.tar.gz: b5e66c06a91ebf4db8065bd1652426485de434f873634f6e6d28a28b12efca8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fc0ad6ca69236e294f082cd80a9193680690d19f183210b54b71ad99edb851d2ca64d49f3df9b77b8baae3c673f0835dac4a174c65965c3282fcb7a0946b4d3
|
7
|
+
data.tar.gz: 6a0b356e2be0fcb6bf427339af0cbc356f5b9b90ad070421cea7a480884ed13e269b413874559f10376bcbdd938e1837a4dfe71778a2387b427c93b958ca66c4
|
data/.rubocop.yml
CHANGED
@@ -9,6 +9,10 @@ Layout/EmptyLinesAroundClassBody:
|
|
9
9
|
Layout/EmptyLinesAroundModuleBody:
|
10
10
|
Enabled: false
|
11
11
|
|
12
|
+
Metrics/BlockLength:
|
13
|
+
Exclude:
|
14
|
+
- spec/**/*
|
15
|
+
|
12
16
|
Metrics/LineLength:
|
13
17
|
Max: 120
|
14
18
|
|
@@ -22,6 +26,10 @@ Style/TrailingCommaInHashLiteral:
|
|
22
26
|
Exclude:
|
23
27
|
- spec/**/*
|
24
28
|
|
29
|
+
Style/TrailingCommaInArrayLiteral:
|
30
|
+
Exclude:
|
31
|
+
- spec/**/*
|
32
|
+
|
25
33
|
Style/WordArray:
|
26
34
|
Enabled: false
|
27
35
|
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2019-10-
|
3
|
+
# on 2019-10-22 09:04:50 -0700 using RuboCop version 0.74.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -10,12 +10,6 @@
|
|
10
10
|
Metrics/AbcSize:
|
11
11
|
Max: 37
|
12
12
|
|
13
|
-
# Offense count: 8
|
14
|
-
# Configuration parameters: CountComments, ExcludedMethods.
|
15
|
-
# ExcludedMethods: refine
|
16
|
-
Metrics/BlockLength:
|
17
|
-
Max: 812
|
18
|
-
|
19
13
|
# Offense count: 4
|
20
14
|
Metrics/CyclomaticComplexity:
|
21
15
|
Max: 12
|
@@ -51,12 +45,3 @@ Style/NumericLiteralPrefix:
|
|
51
45
|
Style/RegexpLiteral:
|
52
46
|
Exclude:
|
53
47
|
- 'lib/parse_date/int_from_string.rb'
|
54
|
-
|
55
|
-
# Offense count: 3
|
56
|
-
# Cop supports --auto-correct.
|
57
|
-
# Configuration parameters: EnforcedStyleForMultiline.
|
58
|
-
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
|
59
|
-
Style/TrailingCommaInArrayLiteral:
|
60
|
-
Exclude:
|
61
|
-
- 'spec/parse_date/int_from_string_spec.rb'
|
62
|
-
- 'spec/parse_date_spec.rb'
|
data/README.md
CHANGED
@@ -61,12 +61,12 @@ ParseDate.parse_range('1975 - 1905') # last year > first year
|
|
61
61
|
ParseDate.parse_range('-100 - -150') # last year > first year, raises error
|
62
62
|
ParseDate.parse_range('1975 or 1905') # last year > first year, raises error
|
63
63
|
ParseDate.parse_range('2050') # year later than current year + 1, raises error
|
64
|
-
ParseDate.parse_range('12345') # year later than current year + 1, raises error
|
65
64
|
ParseDate.parse_range('random text') # can't parse years, raises error
|
66
65
|
ParseDate.parse_range(nil) # can't parse years, raises error
|
67
66
|
|
68
67
|
ParseDate.earliest_year('12/25/00') # 2000
|
69
68
|
ParseDate.earliest_year('5-1-21') # 1921
|
69
|
+
ParseDate.earliest_year('19990211') # 1999
|
70
70
|
ParseDate.earliest_year('1666 B.C.') # -1666
|
71
71
|
ParseDate.earliest_year('-914') # -914
|
72
72
|
ParseDate.earliest_year('[c1926]') # 1926
|
@@ -91,6 +91,7 @@ ParseDate.earliest_year('ca. 9th–8th century B.C.') # -999
|
|
91
91
|
ParseDate.earliest_year('ca. 13th–12th century B.C.') # -1399
|
92
92
|
ParseDate.earliest_year('5th century B.C.') # -599
|
93
93
|
|
94
|
+
ParseDate.latest_year('20000222') # 2000
|
94
95
|
ParseDate.latest_year('195-') # 1959
|
95
96
|
ParseDate.latest_year('199u') # 1999
|
96
97
|
ParseDate.latest_year('197?') # 1979
|
@@ -124,7 +125,6 @@ ParseDate.range_array(-100, '-99') # [-100, -99]
|
|
124
125
|
ParseDate.range_array('98', 101) # [98, 99, 100, 101]
|
125
126
|
ParseDate.range_array('word1', 'word2') # throws ArgumentError
|
126
127
|
ParseDate.range_array('1993', 1990) # throws StandardError - bad range
|
127
|
-
ParseDate.range_array('12345', 12345) # throws StandardError - bad range
|
128
128
|
|
129
129
|
ParseDate.year_range_valid?(1975, 1905) # false, first year > last year
|
130
130
|
ParseDate.year_range_valid?(-100, -150) # false, first year > last year
|
@@ -138,7 +138,7 @@ class ParseDate
|
|
138
138
|
YY_YY_CENTURY_REGEX = Regexp.new(/(?<first>\d{1,2})[a-z]{2}?\s*(-|–|or)\s*(?<last>\d{1,2})[a-z]{2}?\s+centur.*/im)
|
139
139
|
|
140
140
|
# Integer value for latest year if we have nth-nth century pattern
|
141
|
-
# @return [Integer, nil]
|
141
|
+
# @return [Integer, nil] yy99 if date_str matches pattern; nil otherwise
|
142
142
|
def last_year_mult_centuries(date_str)
|
143
143
|
matches = date_str.match(YY_YY_CENTURY_REGEX)
|
144
144
|
return unless matches
|
@@ -150,7 +150,7 @@ class ParseDate
|
|
150
150
|
YY_YY_CENTURY_BC_REGEX = Regexp.new("#{YY_YY_CENTURY_REGEX}#{BC_REGEX}", REGEX_OPTS)
|
151
151
|
|
152
152
|
# Integer value for earliest year if we have nth-nth century BC pattern
|
153
|
-
# @return [Integer, nil]
|
153
|
+
# @return [Integer, nil] -yy99 if date_str matches pattern; nil otherwise
|
154
154
|
def earliest_century_bc(date_str)
|
155
155
|
matches = date_str.match(YY_YY_CENTURY_BC_REGEX)
|
156
156
|
return unless matches
|
@@ -160,7 +160,7 @@ class ParseDate
|
|
160
160
|
end
|
161
161
|
|
162
162
|
# Integer value for latest year if we have nth-nth century BC pattern
|
163
|
-
# @return [Integer, nil]
|
163
|
+
# @return [Integer, nil] -yy00 if date_str matches pattern; nil otherwise
|
164
164
|
def last_year_mult_centuries_bc(date_str)
|
165
165
|
matches = date_str.match(YY_YY_CENTURY_BC_REGEX)
|
166
166
|
return unless matches
|
@@ -172,7 +172,7 @@ class ParseDate
|
|
172
172
|
# looks for 4 consecutive digits in date_str and returns first occurrence if found
|
173
173
|
# @return [String, nil] 4 digit year (e.g. 1865, 0950) if date_str has yyyy, nil otherwise
|
174
174
|
def first_four_digits(date_str)
|
175
|
-
Regexp.last_match(1) if date_str.match(/(\d{4})
|
175
|
+
Regexp.last_match(1) if date_str.match(/(\d{4})/)
|
176
176
|
end
|
177
177
|
|
178
178
|
# returns 4 digit year as String if we have a x/x/yy or x-x-yy pattern
|
@@ -236,7 +236,7 @@ class ParseDate
|
|
236
236
|
end
|
237
237
|
|
238
238
|
# last year of century (as String) if we have: nth century BC
|
239
|
-
# @return [Integer, nil]
|
239
|
+
# @return [Integer, nil] -yy00 if date_str matches pattern, nil otherwise; also nil if B.C. in pattern
|
240
240
|
def last_year_for_bc_century(date_str)
|
241
241
|
Regexp.last_match(1).to_i * -100 if date_str.match(BC_CENTURY_REGEX)
|
242
242
|
end
|
data/lib/parse_date/version.rb
CHANGED