edtf 3.2.0 → 4.0.0
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/LICENSE +1 -1
- data/README.md +145 -118
- data/lib/edtf/date.rb +39 -2
- data/lib/edtf/epoch.rb +3 -1
- data/lib/edtf/interval.rb +56 -28
- data/lib/edtf/parser.rb +797 -686
- data/lib/edtf/parser.y +67 -35
- data/lib/edtf/season.rb +10 -2
- data/lib/edtf/set.rb +15 -1
- data/lib/edtf/uncertainty.rb +7 -8
- data/lib/edtf/version.rb +1 -1
- metadata +28 -64
- data/.autotest +0 -8
- data/.github/workflows/ci.yml +0 -41
- data/.gitignore +0 -8
- data/.rspec +0 -3
- data/.simplecov +0 -19
- data/Gemfile +0 -22
- data/Rakefile +0 -68
- data/cucumber.yml +0 -1
- data/edtf.gemspec +0 -29
- data/features/parser/date_times.feature +0 -41
- data/features/parser/dates.feature +0 -89
- data/features/parser/intervals.feature +0 -18
- data/features/parser/precision.feature +0 -14
- data/features/parser/uncertain_or_approximate.feature +0 -129
- data/features/parser/unspecified.feature +0 -34
- data/features/print/level_0_edtf.feature +0 -79
- data/features/print/level_1_edtf.feature +0 -137
- data/features/print/level_2_edtf.feature +0 -39
- data/features/print/uncertain_or_approximate.feature +0 -131
- data/features/step_definitions/edtf_steps.rb +0 -148
- data/features/support/env.rb +0 -13
- data/spec/edtf/date_spec.rb +0 -245
- data/spec/edtf/epoch_spec.rb +0 -88
- data/spec/edtf/interval_spec.rb +0 -161
- data/spec/edtf/parser_spec.rb +0 -427
- data/spec/edtf/season_spec.rb +0 -111
- data/spec/edtf/set_spec.rb +0 -82
- data/spec/edtf/uncertainty_spec.rb +0 -296
- data/spec/spec_helper.rb +0 -15
data/spec/edtf/interval_spec.rb
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
module EDTF
|
|
2
|
-
describe 'Interval' do
|
|
3
|
-
|
|
4
|
-
describe 'the interval 2008/2011' do
|
|
5
|
-
let(:interval) { Date.edtf('2008/2011') }
|
|
6
|
-
|
|
7
|
-
it { expect(interval).not_to be_open }
|
|
8
|
-
it { expect(interval).not_to be_open_end }
|
|
9
|
-
it { expect(interval).not_to be_unknown_start }
|
|
10
|
-
it { expect(interval).not_to be_unknown_end }
|
|
11
|
-
|
|
12
|
-
it 'has a length of 4' do
|
|
13
|
-
expect(interval.to_a.length).to eq(4)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it '#step(2) yields the years 2008 and 2010' do
|
|
17
|
-
expect(interval.step(2).map(&:year)).to eq([2008,2010])
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'the max date is 2011-12-31' do
|
|
21
|
-
expect(interval.max.to_s).to eq('2011-12-31')
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it 'the max date has year precision' do
|
|
25
|
-
expect(interval.max).to be_year_precision
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it 'the min date is 2008-01-01' do
|
|
29
|
-
expect(interval.min.to_s).to eq('2008-01-01')
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it 'the min date has year precision' do
|
|
33
|
-
expect(interval.min).to be_year_precision
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
it 'includes the years 2008, 2009, 2010 and 2011' do
|
|
38
|
-
expect(interval.to_a.map(&:year)).to eq([2008, 2009, 2010, 2011])
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it 'does not include christmas day 2009' do
|
|
42
|
-
expect(interval).not_to be_include(Date.new(2009,12,24))
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it 'christmas day 2009 is less than max' do
|
|
46
|
-
expect(Date.new(2009,12,24)).to be < interval.max
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it 'christmas day 2009 is greater than min' do
|
|
50
|
-
expect(Date.new(2009,12,24)).to be > interval.min
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it 'covers christmas day 2009' do
|
|
54
|
-
expect(interval).to be_cover(Date.new(2009,12,24))
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it 'covers 2011-12-31' do
|
|
58
|
-
expect(interval).to be_cover(Date.new(2011,12,31))
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
describe 'the interval 2008-08-23/2011-07-01' do
|
|
63
|
-
let(:interval) { Date.edtf('2008-08-23/2011-07-01') }
|
|
64
|
-
|
|
65
|
-
it 'includes christmas day 2009' do
|
|
66
|
-
expect(interval).to be_include(Date.new(2009,12,24))
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it 'covers christmas day 2009' do
|
|
70
|
-
expect(interval).to be_cover(Date.new(2009,12,24))
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it 'does not cover 2011-07-02' do
|
|
74
|
-
expect(interval).not_to be_cover(Date.new(2011,07,02))
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
describe 'the interval 2008-08-23/open' do
|
|
79
|
-
let(:interval) { Date.edtf('2008-08-23/open') }
|
|
80
|
-
|
|
81
|
-
it { expect(interval).to be_open }
|
|
82
|
-
it { expect(interval).to be_open_end }
|
|
83
|
-
it { expect(interval).not_to be_unknown }
|
|
84
|
-
it { expect(interval).not_to be_unknown_start }
|
|
85
|
-
it { expect(interval).not_to be_unknown_end }
|
|
86
|
-
|
|
87
|
-
it 'the min date is 2008-08-23' do
|
|
88
|
-
expect(interval.min).to eq(Date.new(2008,8,23))
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it 'the max date is nil' do
|
|
92
|
-
expect(interval.max).to be nil
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it 'includes christmas day 2009' do
|
|
96
|
-
expect(interval).to be_include(Date.new(2009,12,24))
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
it 'covers christmas day 2009' do
|
|
100
|
-
expect(interval).to be_cover(Date.new(2009,12,24))
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
it 'covers 2023-07-02' do
|
|
104
|
-
expect(interval).to be_cover(Date.new(2023,07,02))
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
describe 'the interval 2008/unknown' do
|
|
110
|
-
let(:interval) { Date.edtf('2008/unknown') }
|
|
111
|
-
|
|
112
|
-
it { expect(interval).to be_unknown }
|
|
113
|
-
it { expect(interval).to be_unknown_end }
|
|
114
|
-
it { expect(interval).not_to be_unknown_start }
|
|
115
|
-
|
|
116
|
-
it 'the min date is 2008-01-01' do
|
|
117
|
-
expect(interval.min.to_s).to eq('2008-01-01')
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
it 'the min date has year precision' do
|
|
121
|
-
expect(interval.min).to be_year_precision
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
it 'the max date is nil' do
|
|
125
|
-
expect(interval.max).to be nil
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
describe 'comparisions' do
|
|
130
|
-
it '2007/2009 should be greater than 2001/2002' do
|
|
131
|
-
expect(Date.edtf('2007/2009')).to be > Date.edtf('2001/2002')
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
it '2007/2009 should be less than 2011/2012' do
|
|
135
|
-
expect(Date.edtf('2007/2009')).to be < Date.edtf('2011/2012')
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
it '2007/2009 should be less than 2008/2009' do
|
|
139
|
-
expect(Date.edtf('2007/2009')).to be < Date.edtf('2008/2009')
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
it '2007/2009 should be greater than 2007/2008' do
|
|
143
|
-
expect(Date.edtf('2007/2009')).to be > Date.edtf('2007/2008')
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
it '2007/2009 should be greater than 2006/2007' do
|
|
147
|
-
expect(Date.edtf('2007/2009')).to be > Date.edtf('2006/2007')
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
it '2007/2009 should be equal to 2007/2009' do
|
|
151
|
-
expect(Date.edtf('2007/2009')).to eq(Date.edtf('2007/2009'))
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
it 'may not have an open start' do
|
|
156
|
-
expect {
|
|
157
|
-
Interval.new(:open, Date.today)
|
|
158
|
-
}.to raise_error(ArgumentError)
|
|
159
|
-
end
|
|
160
|
-
end
|
|
161
|
-
end
|
data/spec/edtf/parser_spec.rb
DELETED
|
@@ -1,427 +0,0 @@
|
|
|
1
|
-
module EDTF
|
|
2
|
-
describe Parser do
|
|
3
|
-
describe '#parse' do
|
|
4
|
-
|
|
5
|
-
it 'parses simple dates "2001-02-03"' do
|
|
6
|
-
expect(Parser.new.parse('2001-02-03').to_s).to eq('2001-02-03')
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
it 'parses negative years' do
|
|
10
|
-
expect(Parser.new.parse('-2323').to_s).to eq('-2323-01-01')
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it 'parses the negative year -2101 and sets the precision to :year' do
|
|
14
|
-
expect(Parser.new.parse('-2101')).to be_year_precision
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it 'parses year zero' do
|
|
18
|
-
expect(Parser.new.parse('0000').to_s).to eq('0000-01-01')
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it 'parses date/time with time zones' do
|
|
22
|
-
expect(Parser.new.parse('2011-08-15T11:19:00+01:00').to_s).to eq('2011-08-15T11:19:00+01:00')
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'parses simple intervals like "2007/2008"' do
|
|
26
|
-
expect(Parser.new.parse('2007/2008')).to be_a(Interval)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it 'parses uncertain dates' do
|
|
30
|
-
expect(Parser.new.parse('1984?')).to be_uncertain
|
|
31
|
-
expect(Parser.new.parse('1984')).to be_certain
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it 'parses uncertain dates (day precision)' do
|
|
35
|
-
expect(Parser.new.parse('1984-11-23?')).to be_uncertain
|
|
36
|
-
expect(Parser.new.parse('1984-11-23')).to be_certain
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it 'parses approximate dates' do
|
|
40
|
-
expect(Parser.new.parse('1984-01~')).to be_approximate
|
|
41
|
-
expect(Parser.new.parse('1984-01')).to be_precise
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it 'parses draft spec uncertain approximate dates' do
|
|
45
|
-
expect(Parser.new.parse('1984?~')).to be_uncertain
|
|
46
|
-
expect(Parser.new.parse('1984?~')).to be_approximate
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it 'parses final spec uncertain approximate dates' do
|
|
50
|
-
expect(Parser.new.parse('1984%')).to be_uncertain
|
|
51
|
-
expect(Parser.new.parse('1984%')).to be_approximate
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it 'parses draft spec unspecified dates' do
|
|
55
|
-
expect(Parser.new.parse('199u')).to be_unspecified
|
|
56
|
-
expect(Parser.new.parse('1999-uu-uu')).to be_unspecified
|
|
57
|
-
expect(Parser.new.parse('199u-01')).to be_unspecified
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
it 'parses final spec unspecified dates' do
|
|
61
|
-
expect(Parser.new.parse('199X')).to be_unspecified
|
|
62
|
-
expect(Parser.new.parse('1999-XX-XX')).to be_unspecified
|
|
63
|
-
expect(Parser.new.parse('199X-01')).to be_unspecified
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
it 'parses draft spec negative unspecified dates' do
|
|
67
|
-
expect(Parser.new.parse('-199u')).to be_unspecified
|
|
68
|
-
expect(Parser.new.parse('-1999-uu-uu')).to be_unspecified
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it 'parses final spec negative unspecified dates' do
|
|
72
|
-
expect(Parser.new.parse('-199X')).to be_unspecified
|
|
73
|
-
expect(Parser.new.parse('-1999-XX-XX')).to be_unspecified
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
it 'parses open intervals' do
|
|
77
|
-
expect(Parser.new.parse('2004-01-01/open')).to be_open
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
it 'parses unknown intervals' do
|
|
81
|
-
expect(Parser.new.parse('2004-01-01/unknown')).to be_unknown_end
|
|
82
|
-
expect(Parser.new.parse('unknown/2004-01-01')).to be_unknown_start
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
it 'parses intervals with uncertain or approximate dates' do
|
|
86
|
-
expect(Parser.new.parse('1984-06-02?/2004-08-08~').from).to be_uncertain
|
|
87
|
-
expect(Parser.new.parse('1984-06-02?/2004-08-08~').to).to be_approximate
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
it 'parses positive long years' do
|
|
91
|
-
expect(Parser.new.parse('y170000002').year).to eq(170000002)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
it 'parses negative long years' do
|
|
95
|
-
expect(Parser.new.parse('y-170000002').year).to eq(-170000002)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
it 'parses season codes' do
|
|
99
|
-
expect(Parser.new.parse('2003-23')).to be_autumn
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
it 'parses calendar names' do
|
|
103
|
-
expect(Parser.new.parse('2001-02-03^xyz').calendar).to eq('xyz')
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
it 'parses season qualifiers' do
|
|
107
|
-
d = Parser.new.parse('2003-23^european')
|
|
108
|
-
expect(d).to be_autumn
|
|
109
|
-
expect(d).to be_qualified
|
|
110
|
-
expect(d.qualifier).to eq('european')
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
it 'parses uncertain seasons' do
|
|
114
|
-
expect(Parser.new.parse!('2003-23?')).to be_uncertain
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
it 'parses approximate seasons' do
|
|
118
|
-
expect(Parser.new.parse!('2003-23~')).to be_approximate
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
it 'parses draft spec uncertain and approximate seasons' do
|
|
122
|
-
expect(Parser.new.parse!('2003-23?~')).to be_uncertain
|
|
123
|
-
expect(Parser.new.parse!('2003-23?~')).to be_approximate
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
it 'parses final spec uncertain and approximate seasons' do
|
|
127
|
-
expect(Parser.new.parse!('2003-23%')).to be_uncertain
|
|
128
|
-
expect(Parser.new.parse!('2003-23%')).to be_approximate
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
it 'parses positive scientific long years' do
|
|
132
|
-
expect(Parser.new.parse('y17e7').year).to eq(170000000)
|
|
133
|
-
expect(Parser.new.parse('Y17E7').year).to eq(170000000)
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
it 'parses negative scientific long years' do
|
|
137
|
-
expect(Parser.new.parse('y-17e7').year).to eq(-170000000)
|
|
138
|
-
expect(Parser.new.parse('Y-17E7').year).to eq(-170000000)
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
it 'parses masked precision date strings (decades)' do
|
|
142
|
-
d = Parser.new.parse!('198x')
|
|
143
|
-
expect(d).to be_cover(Date.new(1983,3,12))
|
|
144
|
-
expect(d).not_to be_cover(Date.new(1990,1,1))
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
it 'parses masked precision date strings (centuries)' do
|
|
148
|
-
d = Parser.new.parse!('18xx')
|
|
149
|
-
expect(d).to be_cover(Date.new(1848,1,14))
|
|
150
|
-
expect(d).not_to be_cover(Date.new(1799,12,31))
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
it 'parses multiple dates (years)' do
|
|
154
|
-
d = Parser.new.parse!('{1667,1668, 1670..1672}')
|
|
155
|
-
expect(d.map(&:year)).to eq([1667,1668,1670,1671,1672])
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
it 'parses multiple dates (mixed years and months)' do
|
|
159
|
-
d = Parser.new.parse!('{1960, 1961-12}')
|
|
160
|
-
expect(d.map { |x| [x.year,x.month] }).to eq([[1960,1],[1961,12]])
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
it 'parses choice lists (One of the years 1667, 1668, 1670, 1671, 1672)' do
|
|
164
|
-
d = Parser.new.parse!('[1667,1668, 1670..1672]')
|
|
165
|
-
expect(d.map(&:year)).to eq([1667,1668,1670,1671,1672])
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
it 'parses choice lists (December 3, 1760 or some earlier date)' do
|
|
169
|
-
d = Parser.new.parse!('[..1760-12-03]')
|
|
170
|
-
expect(d.map(&:to_s)).to eq(['1760-12-03'])
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
it 'parses choice lists (December 1760 or some later month)' do
|
|
174
|
-
d = Parser.new.parse!('[1760-12..]')
|
|
175
|
-
expect(d.map { |x| [x.year,x.month] }).to eq([[1760,12]])
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
it 'parses choice lists (January or February of 1760 or December 1760 or some later month)' do
|
|
179
|
-
d = Parser.new.parse!('[1760-01, 1760-02, 1760-12..]')
|
|
180
|
-
expect(d.length).to eq(3)
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
it 'parses intern unspecified "199u-01-01"' do
|
|
184
|
-
expect(Parser.new.parse!('199u-01-01').unspecified.to_s).to eq('sssX-ss-ss')
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
it 'parses intern unspecified "19uu-01-01"' do
|
|
188
|
-
expect(Parser.new.parse!('19uu-01-01').unspecified.to_s).to eq('ssXX-ss-ss')
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
it 'parses intern unspecified "199u-uu-01"' do
|
|
192
|
-
expect(Parser.new.parse!('199u-uu-01').unspecified.to_s).to eq('sssX-XX-ss')
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
it 'parses intern unspecified "19uu-uu-01"' do
|
|
196
|
-
expect(Parser.new.parse!('19uu-uu-01').unspecified.to_s).to eq('ssXX-XX-ss')
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
it 'parses intern unspecified "199u-uu-uu"' do
|
|
200
|
-
expect(Parser.new.parse!('199u-uu-uu').unspecified.to_s).to eq('sssX-XX-XX')
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
it 'parses intern unspecified "19uu-uu-uu"' do
|
|
204
|
-
expect(Parser.new.parse!('19uu-uu-uu').unspecified.to_s).to eq('ssXX-XX-XX')
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
it 'parses intern unspecified "199u-01-uu"' do
|
|
208
|
-
expect(Parser.new.parse!('199u-01-uu').unspecified.to_s).to eq('sssX-ss-XX')
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
it 'parses intern unspecified "19uu-01-uu"' do
|
|
212
|
-
expect(Parser.new.parse!('19uu-01-uu').unspecified.to_s).to eq('ssXX-ss-XX')
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
it 'parses intern unspecified "1999-uu-01"' do
|
|
216
|
-
expect(Parser.new.parse!('1999-uu-01').unspecified.to_s).to eq('ssss-XX-ss')
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
it 'parses intern unspecified "2004-06-uu"' do
|
|
220
|
-
expect(Parser.new.parse!('2004-06-uu').unspecified.to_s).to eq('ssss-ss-XX')
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
it 'parses internal unspecified interval "2004-06-uu/2004-07-03"' do
|
|
224
|
-
expect(Parser.new.parse!('2004-06-uu/2004-07-03').from).to eq(Date.new(2004,6,1))
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
it 'parses intern unspecified "199X-01-01"' do
|
|
228
|
-
expect(Parser.new.parse!('199X-01-01').unspecified.to_s).to eq('sssX-ss-ss')
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
it 'parses intern unspecified "19XX-01-01"' do
|
|
232
|
-
expect(Parser.new.parse!('19XX-01-01').unspecified.to_s).to eq('ssXX-ss-ss')
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
it 'parses intern unspecified "199X-XX-01"' do
|
|
236
|
-
expect(Parser.new.parse!('199X-XX-01').unspecified.to_s).to eq('sssX-XX-ss')
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
it 'parses intern unspecified "19XX-XX-01"' do
|
|
240
|
-
expect(Parser.new.parse!('19XX-XX-01').unspecified.to_s).to eq('ssXX-XX-ss')
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
it 'parses intern unspecified "199X-XX-XX"' do
|
|
244
|
-
expect(Parser.new.parse!('199X-XX-XX').unspecified.to_s).to eq('sssX-XX-XX')
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
it 'parses intern unspecified "19XX-XX-XX"' do
|
|
248
|
-
expect(Parser.new.parse!('19XX-XX-XX').unspecified.to_s).to eq('ssXX-XX-XX')
|
|
249
|
-
end
|
|
250
|
-
|
|
251
|
-
it 'parses intern unspecified "199X-01-XX"' do
|
|
252
|
-
expect(Parser.new.parse!('199X-01-XX').unspecified.to_s).to eq('sssX-ss-XX')
|
|
253
|
-
end
|
|
254
|
-
|
|
255
|
-
it 'parses intern unspecified "19XX-01-XX"' do
|
|
256
|
-
expect(Parser.new.parse!('19XX-01-XX').unspecified.to_s).to eq('ssXX-ss-XX')
|
|
257
|
-
end
|
|
258
|
-
|
|
259
|
-
it 'parses intern unspecified "1999-XX-01"' do
|
|
260
|
-
expect(Parser.new.parse!('1999-XX-01').unspecified.to_s).to eq('ssss-XX-ss')
|
|
261
|
-
end
|
|
262
|
-
|
|
263
|
-
it 'parses intern unspecified "2004-06-XX"' do
|
|
264
|
-
expect(Parser.new.parse!('2004-06-XX').unspecified.to_s).to eq('ssss-ss-XX')
|
|
265
|
-
end
|
|
266
|
-
|
|
267
|
-
it 'parses internal unspecified interval "2004-06-XX/2004-07-03"' do
|
|
268
|
-
expect(Parser.new.parse!('2004-06-XX/2004-07-03').from).to eq(Date.new(2004,6,1))
|
|
269
|
-
end
|
|
270
|
-
|
|
271
|
-
it 'parses "2004?-06-11": uncertain year; month, day known' do
|
|
272
|
-
d = Parser.new.parse!('2004?-06-11')
|
|
273
|
-
expect(d.uncertain?(:year)).to be true
|
|
274
|
-
expect(d.uncertain?([:month, :day])).to be false
|
|
275
|
-
end
|
|
276
|
-
|
|
277
|
-
it 'parses "2004-06~-11": year and month are approximate; day known' do
|
|
278
|
-
d = Parser.new.parse!('2004-06~-11')
|
|
279
|
-
expect(d.approximate?(:year)).to be true
|
|
280
|
-
expect(d.approximate?(:month)).to be true
|
|
281
|
-
expect(d.approximate?(:day)).to be false
|
|
282
|
-
end
|
|
283
|
-
|
|
284
|
-
it 'parses "2004-(06)?-11": uncertain month, year and day known' do
|
|
285
|
-
d = Parser.new.parse!('2004-(06)?-11')
|
|
286
|
-
|
|
287
|
-
expect(d.uncertain?(:year)).to be false
|
|
288
|
-
expect(d.approximate?(:year)).to be false
|
|
289
|
-
|
|
290
|
-
expect(d.uncertain?(:month)).to be true
|
|
291
|
-
expect(d.approximate?(:month)).to be false
|
|
292
|
-
|
|
293
|
-
expect(d.uncertain?(:day)).to be false
|
|
294
|
-
expect(d.approximate?(:day)).to be false
|
|
295
|
-
end
|
|
296
|
-
|
|
297
|
-
it 'parses "2004-06-(11)~": day is approximate; year, month known' do
|
|
298
|
-
d = Parser.new.parse!('2004-06-(11)~')
|
|
299
|
-
expect(d.approximate?(:year)).to be false
|
|
300
|
-
expect(d.approximate?(:month)).to be false
|
|
301
|
-
expect(d.approximate?(:day)).to be true
|
|
302
|
-
end
|
|
303
|
-
|
|
304
|
-
it 'parses "2004-(06)?~": year known, month within year is approximate and uncertain' do
|
|
305
|
-
d = Parser.new.parse!('2004-(06)?~')
|
|
306
|
-
|
|
307
|
-
expect(d.approximate?(:year)).to be false
|
|
308
|
-
expect(d.uncertain?(:year)).to be false
|
|
309
|
-
|
|
310
|
-
expect(d.approximate?(:month)).to be true
|
|
311
|
-
expect(d.uncertain?(:month)).to be true
|
|
312
|
-
|
|
313
|
-
expect(d.approximate?(:day)).to be false
|
|
314
|
-
expect(d.uncertain?(:day)).to be false
|
|
315
|
-
end
|
|
316
|
-
|
|
317
|
-
it 'parses "2004-(06-11)?": year known, month and day uncertain' do
|
|
318
|
-
d = Parser.new.parse!('2004-(06-11)?')
|
|
319
|
-
|
|
320
|
-
expect(d.approximate?(:year)).to be false
|
|
321
|
-
expect(d.uncertain?(:year)).to be false
|
|
322
|
-
|
|
323
|
-
expect(d.approximate?(:month)).to be false
|
|
324
|
-
expect(d.uncertain?(:month)).to be true
|
|
325
|
-
|
|
326
|
-
expect(d.approximate?(:day)).to be false
|
|
327
|
-
expect(d.uncertain?(:day)).to be true
|
|
328
|
-
end
|
|
329
|
-
|
|
330
|
-
it 'parses "2004?-06-(11)~": year uncertain, month known, day approximate' do
|
|
331
|
-
d = Parser.new.parse('2004?-06-(11)~')
|
|
332
|
-
|
|
333
|
-
expect(d.approximate?(:year)).to be false
|
|
334
|
-
expect(d.uncertain?(:year)).to be true
|
|
335
|
-
|
|
336
|
-
expect(d.approximate?(:month)).to be false
|
|
337
|
-
expect(d.uncertain?(:month)).to be false
|
|
338
|
-
|
|
339
|
-
expect(d.approximate?(:day)).to be true
|
|
340
|
-
expect(d.uncertain?(:day)).to be false
|
|
341
|
-
end
|
|
342
|
-
|
|
343
|
-
it 'parses "(2004-(06)~)?": year uncertain and month is both uncertain and approximate' do
|
|
344
|
-
d = Parser.new.parse!('(2004-(06)~)?')
|
|
345
|
-
|
|
346
|
-
expect(d.approximate?(:year)).to be false
|
|
347
|
-
expect(d.uncertain?(:year)).to be true
|
|
348
|
-
|
|
349
|
-
expect(d.approximate?(:month)).to be true
|
|
350
|
-
expect(d.uncertain?(:month)).to be true
|
|
351
|
-
|
|
352
|
-
expect(d.approximate?(:day)).to be false
|
|
353
|
-
expect(d.uncertain?(:day)).to be false
|
|
354
|
-
end
|
|
355
|
-
|
|
356
|
-
it 'parses "2004~-(06)?-01~": year and day approximate, month uncertain' do
|
|
357
|
-
d = Parser.new.parse!("2004~-(06)?-01~")
|
|
358
|
-
|
|
359
|
-
expect(d.approximate?(:year)).to be true
|
|
360
|
-
expect(d.uncertain?(:year)).to be false
|
|
361
|
-
|
|
362
|
-
expect(d.approximate?(:month)).to be false
|
|
363
|
-
expect(d.uncertain?(:month)).to be true
|
|
364
|
-
|
|
365
|
-
expect(d.approximate?(:day)).to be true
|
|
366
|
-
expect(d.uncertain?(:day)).to be false
|
|
367
|
-
end
|
|
368
|
-
|
|
369
|
-
it 'parses "2004~-(06-(01)~)?": year and day approximate, month and day uncertain' do
|
|
370
|
-
d = Parser.new.parse!("2004~-(06-(01)~)?")
|
|
371
|
-
|
|
372
|
-
expect(d.approximate?(:year)).to be true
|
|
373
|
-
expect(d.uncertain?(:year)).to be false
|
|
374
|
-
|
|
375
|
-
expect(d.approximate?(:month)).to be false
|
|
376
|
-
expect(d.uncertain?(:month)).to be true
|
|
377
|
-
|
|
378
|
-
expect(d.approximate?(:day)).to be true
|
|
379
|
-
expect(d.uncertain?(:day)).to be true
|
|
380
|
-
end
|
|
381
|
-
|
|
382
|
-
it 'parses "2004~-(06)?-01?~": year and day approximate, month and day uncertain' do
|
|
383
|
-
d = Parser.new.parse!("2004~-(06)?-01?~")
|
|
384
|
-
|
|
385
|
-
expect(d.approximate?(:year)).to be true
|
|
386
|
-
expect(d.uncertain?(:year)).to be false
|
|
387
|
-
|
|
388
|
-
expect(d.approximate?(:month)).to be false
|
|
389
|
-
expect(d.uncertain?(:month)).to be true
|
|
390
|
-
|
|
391
|
-
expect(d.approximate?(:day)).to be true
|
|
392
|
-
expect(d.uncertain?(:day)).to be true
|
|
393
|
-
end
|
|
394
|
-
|
|
395
|
-
it 'parses "2004~-(06)?": year approximate, month uncertain' do
|
|
396
|
-
d = Parser.new.parse!("2004~-(06)?")
|
|
397
|
-
|
|
398
|
-
expect(d.approximate?(:year)).to be true
|
|
399
|
-
expect(d.uncertain?(:year)).to be false
|
|
400
|
-
|
|
401
|
-
expect(d.approximate?(:month)).to be false
|
|
402
|
-
expect(d.uncertain?(:month)).to be true
|
|
403
|
-
|
|
404
|
-
expect(d.approximate?(:day)).to be false
|
|
405
|
-
expect(d.uncertain?(:day)).to be false
|
|
406
|
-
end
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
it 'parses "2004~-06?": year approximate, year and month uncertain' do
|
|
410
|
-
d = Parser.new.parse!("2004~-06?")
|
|
411
|
-
|
|
412
|
-
expect(d.approximate?(:year)).to be true
|
|
413
|
-
expect(d.uncertain?(:year)).to be true
|
|
414
|
-
|
|
415
|
-
expect(d.approximate?(:month)).to be false
|
|
416
|
-
expect(d.uncertain?(:month)).to be true
|
|
417
|
-
|
|
418
|
-
expect(d.approximate?(:day)).to be false
|
|
419
|
-
expect(d.uncertain?(:day)).to be false
|
|
420
|
-
|
|
421
|
-
end
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
end
|
|
426
|
-
end
|
|
427
|
-
end
|
data/spec/edtf/season_spec.rb
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
module EDTF
|
|
2
|
-
describe 'Seasons' do
|
|
3
|
-
let(:subject) { Season.new }
|
|
4
|
-
let(:summer) { Season.new(:summer) }
|
|
5
|
-
let(:winter) { Season.new(:winter) }
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
describe 'uncertain/approximate' do
|
|
9
|
-
|
|
10
|
-
it 'is certain by default' do
|
|
11
|
-
expect(subject).to be_certain
|
|
12
|
-
expect(subject).not_to be_uncertain
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it 'is precise by default' do
|
|
16
|
-
expect(subject).to be_precise
|
|
17
|
-
expect(subject).not_to be_approximate
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
describe '#approximate!' do
|
|
21
|
-
it 'makes the season approximate' do
|
|
22
|
-
expect(subject.approximate!).to be_approximate
|
|
23
|
-
expect(subject.approximate!).not_to be_precise
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
describe '#uncertain!' do
|
|
28
|
-
it 'makes the season uncertain' do
|
|
29
|
-
expect(subject.uncertain!).to be_uncertain
|
|
30
|
-
expect(subject.uncertain!).not_to be_certain
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
describe '#succ' do
|
|
37
|
-
|
|
38
|
-
it 'returns a season' do
|
|
39
|
-
expect(summer.succ).to be_instance_of(Season)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it 'it returns a season that is greater than the original one' do
|
|
43
|
-
expect(summer.succ).to be > summer
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it 'the successor of the winter season is spring of the following year' do
|
|
47
|
-
spring = winter.succ
|
|
48
|
-
expect(spring).to be_spring
|
|
49
|
-
expect(spring.year).to eq(winter.year + 1)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
describe '#season?' do
|
|
55
|
-
it 'returns true by default' do
|
|
56
|
-
expect(subject).to be_season
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
describe '#season' do
|
|
61
|
-
before(:each) { subject.season = :summer }
|
|
62
|
-
|
|
63
|
-
it 'returns the season code' do
|
|
64
|
-
expect(subject.season).to eq(:summer)
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
describe '#season=' do
|
|
69
|
-
it 'sets the season code when called with a valid season code' do
|
|
70
|
-
expect {
|
|
71
|
-
(21..22).each do |i|
|
|
72
|
-
subject.season = i
|
|
73
|
-
end
|
|
74
|
-
}.not_to raise_error
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it 'throws an exception if given invalid season code' do
|
|
78
|
-
expect { subject.season = 13 }.to raise_error(NoMethodError)
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
describe '#summer!' do
|
|
83
|
-
it 'sets the season to :summer' do
|
|
84
|
-
subject.season = :spring
|
|
85
|
-
expect { subject.summer! }.to change { subject.season }.to(:summer)
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
describe '#winter?' do
|
|
90
|
-
it 'returns true if the season is set to :winter' do
|
|
91
|
-
subject.season = :winter
|
|
92
|
-
expect(subject).to be_winter
|
|
93
|
-
end
|
|
94
|
-
it 'returns false if the season is not set to :winter' do
|
|
95
|
-
subject.season = :summer
|
|
96
|
-
expect(subject).not_to be_winter
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
describe '#include?' do
|
|
101
|
-
|
|
102
|
-
context 'for summer' do
|
|
103
|
-
it 'returns true for August 24' do
|
|
104
|
-
expect(Season.new(1980, :summer)).to include(Date.new(1980,8,24))
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
end
|
|
111
|
-
end
|