edtf 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/edtf.rb +0 -5
- data/lib/edtf/parser.rb +707 -691
- data/lib/edtf/parser.y +13 -9
- data/lib/edtf/version.rb +1 -1
- data/spec/edtf/parser_spec.rb +6 -1
- metadata +2 -2
data/lib/edtf/parser.y
CHANGED
@@ -20,18 +20,12 @@ rule
|
|
20
20
|
| date_time
|
21
21
|
;
|
22
22
|
|
23
|
-
date :
|
24
|
-
| negative_date
|
25
|
-
;
|
26
|
-
|
27
|
-
positive_date :
|
23
|
+
date :
|
28
24
|
year { result = Date.new(val[0]).year_precision! }
|
29
25
|
| year_month { result = Date.new(*val.flatten).month_precision! }
|
30
26
|
| year_month_day { result = Date.new(*val.flatten).day_precision! }
|
31
27
|
;
|
32
28
|
|
33
|
-
negative_date : '-' positive_date { result = -val[1] }
|
34
|
-
|
35
29
|
|
36
30
|
date_time : date T time {
|
37
31
|
result = DateTime.new(val[0].year, val[0].month, val[0].day, *val[2])
|
@@ -61,7 +55,10 @@ rule
|
|
61
55
|
| '0' '0' ':' d01_59 { result = Rational(val[3], 1440) }
|
62
56
|
;
|
63
57
|
|
64
|
-
year :
|
58
|
+
year : positive_year
|
59
|
+
| '-' positive_year { result = -val[1] }
|
60
|
+
|
61
|
+
positive_year : digit digit digit digit {
|
65
62
|
result = val.zip([1000,100,10,1]).reduce(0) { |s,(a,b)| s += a * b }
|
66
63
|
}
|
67
64
|
|
@@ -108,7 +105,14 @@ rule
|
|
108
105
|
| unspecified_day_and_month
|
109
106
|
;
|
110
107
|
|
111
|
-
unspecified_year :
|
108
|
+
unspecified_year : positive_unspecified_year
|
109
|
+
| '-' positive_unspecified_year
|
110
|
+
{
|
111
|
+
result = val[1]
|
112
|
+
result[0] = -result[0]
|
113
|
+
}
|
114
|
+
|
115
|
+
positive_unspecified_year :
|
112
116
|
digit digit digit U
|
113
117
|
{
|
114
118
|
result = [val[0,3].zip([1000,100,10]).reduce(0) { |s,(a,b)| s += a * b }, [false,true]]
|
data/lib/edtf/version.rb
CHANGED
data/spec/edtf/parser_spec.rb
CHANGED
@@ -50,7 +50,12 @@ module EDTF
|
|
50
50
|
expect(Parser.new.parse('199u')).to be_unspecified
|
51
51
|
expect(Parser.new.parse('1999-uu-uu')).to be_unspecified
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
|
+
it 'parses negative unspecified dates' do
|
55
|
+
expect(Parser.new.parse('-199u')).to be_unspecified
|
56
|
+
expect(Parser.new.parse('-1999-uu-uu')).to be_unspecified
|
57
|
+
end
|
58
|
+
|
54
59
|
it 'parses open intervals' do
|
55
60
|
expect(Parser.new.parse('2004-01-01/open')).to be_open
|
56
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edtf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvester Keil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|