edtf 0.0.5 → 0.0.6
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.
- data/README.md +24 -25
- data/features/parser/dates.feature +28 -5
- data/features/print/level_0_edtf.feature +73 -0
- data/features/print/level_1_edtf.feature +9 -62
- data/features/step_definitions/edtf_steps.rb +13 -0
- data/lib/edtf/date.rb +22 -17
- data/lib/edtf/parser.y +410 -229
- data/lib/edtf/version.rb +1 -1
- data/spec/edtf/parser_spec.rb +90 -0
- metadata +69 -108
- data/features/print/level_2_edtf.feature +0 -8
data/lib/edtf/version.rb
CHANGED
data/spec/edtf/parser_spec.rb
CHANGED
|
@@ -33,6 +33,11 @@ module EDTF
|
|
|
33
33
|
Parser.new.parse('1984').should be_certain
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
+
it 'parses uncertain dates (day precision)' do
|
|
37
|
+
Parser.new.parse('1984-11-23?').should be_uncertain
|
|
38
|
+
Parser.new.parse('1984-11-23').should be_certain
|
|
39
|
+
end
|
|
40
|
+
|
|
36
41
|
it 'parses approximate dates' do
|
|
37
42
|
Parser.new.parse('1984-01~').should be_approximate
|
|
38
43
|
Parser.new.parse('1984-01').should be_precise
|
|
@@ -171,6 +176,91 @@ module EDTF
|
|
|
171
176
|
Parser.new.parse('1999-uu-01').unspecified.to_s.should == 'ssss-uu-ss'
|
|
172
177
|
end
|
|
173
178
|
|
|
179
|
+
it 'parses "2004?-06-11": uncertain year; month, day known' do
|
|
180
|
+
d = Parser.new.parse('2004?-06-11')
|
|
181
|
+
d.uncertain?(:year).should be true
|
|
182
|
+
d.uncertain?([:month, :day]).should be false
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
it 'parses "2004-06~-11": year and month are approximate; day known' do
|
|
186
|
+
d = Parser.new.parse('2004-06~-11')
|
|
187
|
+
d.approximate?(:year).should be true
|
|
188
|
+
d.approximate?(:month).should be true
|
|
189
|
+
d.approximate?(:day).should be false
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
it 'parses "2004-(06)?-11": uncertain month, year and day known' do
|
|
193
|
+
d = Parser.new.parse('2004-(06)?-11')
|
|
194
|
+
|
|
195
|
+
d.uncertain?(:year).should be false
|
|
196
|
+
d.approximate?(:year).should be false
|
|
197
|
+
|
|
198
|
+
d.uncertain?(:month).should be true
|
|
199
|
+
d.approximate?(:month).should be false
|
|
200
|
+
|
|
201
|
+
d.uncertain?(:day).should be false
|
|
202
|
+
d.approximate?(:day).should be false
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
it 'parses "2004-06-(11)~": day is approximate; year, month known' do
|
|
206
|
+
d = Parser.new.parse('2004-06-(11)~')
|
|
207
|
+
d.approximate?(:year).should be false
|
|
208
|
+
d.approximate?(:month).should be false
|
|
209
|
+
d.approximate?(:day).should be true
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
it 'parses "2004-(06)?~": year known, month within year is approximate and uncertain' do
|
|
213
|
+
d = Parser.new.parse('2004-(06)?~')
|
|
214
|
+
|
|
215
|
+
d.approximate?(:year).should be false
|
|
216
|
+
d.uncertain?(:year).should be false
|
|
217
|
+
|
|
218
|
+
d.approximate?(:month).should be true
|
|
219
|
+
d.uncertain?(:month).should be true
|
|
220
|
+
|
|
221
|
+
d.approximate?(:day).should be false
|
|
222
|
+
d.uncertain?(:day).should be false
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
it 'parses "2004-(06-11)?": year known, month and day uncertain' do
|
|
226
|
+
d = Parser.new.parse('2004-(06-11)?')
|
|
227
|
+
|
|
228
|
+
d.approximate?(:year).should be false
|
|
229
|
+
d.uncertain?(:year).should be false
|
|
230
|
+
|
|
231
|
+
d.approximate?(:month).should be false
|
|
232
|
+
d.uncertain?(:month).should be true
|
|
233
|
+
|
|
234
|
+
d.approximate?(:day).should be false
|
|
235
|
+
d.uncertain?(:day).should be true
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
it 'parses "2004?-06-(11)~": year uncertain, month known, day approximate' do
|
|
239
|
+
d = Parser.new.parse('2004?-06-(11)~')
|
|
240
|
+
|
|
241
|
+
d.approximate?(:year).should be false
|
|
242
|
+
d.uncertain?(:year).should be true
|
|
243
|
+
|
|
244
|
+
d.approximate?(:month).should be false
|
|
245
|
+
d.uncertain?(:month).should be false
|
|
246
|
+
|
|
247
|
+
d.approximate?(:day).should be true
|
|
248
|
+
d.uncertain?(:day).should be false
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
it 'parses "(2004-(06)~)?": year uncertain and month is both uncertain and approximate' do
|
|
252
|
+
d = Parser.new.parse('(2004-(06)~)?')
|
|
253
|
+
|
|
254
|
+
d.approximate?(:year).should be false
|
|
255
|
+
d.uncertain?(:year).should be true
|
|
256
|
+
|
|
257
|
+
d.approximate?(:month).should be true
|
|
258
|
+
d.uncertain?(:month).should be true
|
|
259
|
+
|
|
260
|
+
d.approximate?(:day).should be false
|
|
261
|
+
d.uncertain?(:day).should be false
|
|
262
|
+
end
|
|
263
|
+
|
|
174
264
|
end
|
|
175
265
|
end
|
|
176
266
|
end
|
metadata
CHANGED
|
@@ -1,123 +1,91 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: edtf
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.6
|
|
5
5
|
prerelease:
|
|
6
|
-
segments:
|
|
7
|
-
- 0
|
|
8
|
-
- 0
|
|
9
|
-
- 5
|
|
10
|
-
version: 0.0.5
|
|
11
6
|
platform: ruby
|
|
12
|
-
authors:
|
|
7
|
+
authors:
|
|
13
8
|
- Sylvester Keil
|
|
14
9
|
autorequire:
|
|
15
10
|
bindir: bin
|
|
16
11
|
cert_chain: []
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
- !ruby/object:Gem::Dependency
|
|
12
|
+
date: 2011-08-26 00:00:00.000000000Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
21
15
|
name: activesupport
|
|
22
|
-
|
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
|
16
|
+
requirement: &2156218120 !ruby/object:Gem::Requirement
|
|
24
17
|
none: false
|
|
25
|
-
requirements:
|
|
18
|
+
requirements:
|
|
26
19
|
- - ~>
|
|
27
|
-
- !ruby/object:Gem::Version
|
|
28
|
-
|
|
29
|
-
segments:
|
|
30
|
-
- 3
|
|
31
|
-
- 0
|
|
32
|
-
version: "3.0"
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '3.0'
|
|
33
22
|
type: :runtime
|
|
34
|
-
version_requirements: *id001
|
|
35
|
-
- !ruby/object:Gem::Dependency
|
|
36
|
-
name: rake
|
|
37
23
|
prerelease: false
|
|
38
|
-
|
|
24
|
+
version_requirements: *2156218120
|
|
25
|
+
- !ruby/object:Gem::Dependency
|
|
26
|
+
name: rake
|
|
27
|
+
requirement: &2156217480 !ruby/object:Gem::Requirement
|
|
39
28
|
none: false
|
|
40
|
-
requirements:
|
|
29
|
+
requirements:
|
|
41
30
|
- - ~>
|
|
42
|
-
- !ruby/object:Gem::Version
|
|
43
|
-
|
|
44
|
-
segments:
|
|
45
|
-
- 0
|
|
46
|
-
- 9
|
|
47
|
-
version: "0.9"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0.9'
|
|
48
33
|
type: :development
|
|
49
|
-
version_requirements: *id002
|
|
50
|
-
- !ruby/object:Gem::Dependency
|
|
51
|
-
name: racc
|
|
52
34
|
prerelease: false
|
|
53
|
-
|
|
35
|
+
version_requirements: *2156217480
|
|
36
|
+
- !ruby/object:Gem::Dependency
|
|
37
|
+
name: racc
|
|
38
|
+
requirement: &2156216920 !ruby/object:Gem::Requirement
|
|
54
39
|
none: false
|
|
55
|
-
requirements:
|
|
40
|
+
requirements:
|
|
56
41
|
- - ~>
|
|
57
|
-
- !ruby/object:Gem::Version
|
|
58
|
-
|
|
59
|
-
segments:
|
|
60
|
-
- 1
|
|
61
|
-
- 4
|
|
62
|
-
version: "1.4"
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '1.4'
|
|
63
44
|
type: :development
|
|
64
|
-
version_requirements: *id003
|
|
65
|
-
- !ruby/object:Gem::Dependency
|
|
66
|
-
name: cucumber
|
|
67
45
|
prerelease: false
|
|
68
|
-
|
|
46
|
+
version_requirements: *2156216920
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: cucumber
|
|
49
|
+
requirement: &2156216360 !ruby/object:Gem::Requirement
|
|
69
50
|
none: false
|
|
70
|
-
requirements:
|
|
51
|
+
requirements:
|
|
71
52
|
- - ~>
|
|
72
|
-
- !ruby/object:Gem::Version
|
|
73
|
-
|
|
74
|
-
segments:
|
|
75
|
-
- 1
|
|
76
|
-
- 0
|
|
77
|
-
version: "1.0"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '1.0'
|
|
78
55
|
type: :development
|
|
79
|
-
version_requirements: *id004
|
|
80
|
-
- !ruby/object:Gem::Dependency
|
|
81
|
-
name: rspec
|
|
82
56
|
prerelease: false
|
|
83
|
-
|
|
57
|
+
version_requirements: *2156216360
|
|
58
|
+
- !ruby/object:Gem::Dependency
|
|
59
|
+
name: rspec
|
|
60
|
+
requirement: &2156215840 !ruby/object:Gem::Requirement
|
|
84
61
|
none: false
|
|
85
|
-
requirements:
|
|
62
|
+
requirements:
|
|
86
63
|
- - ~>
|
|
87
|
-
- !ruby/object:Gem::Version
|
|
88
|
-
|
|
89
|
-
segments:
|
|
90
|
-
- 2
|
|
91
|
-
- 6
|
|
92
|
-
version: "2.6"
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
65
|
+
version: '2.6'
|
|
93
66
|
type: :development
|
|
94
|
-
version_requirements: *id005
|
|
95
|
-
- !ruby/object:Gem::Dependency
|
|
96
|
-
name: ZenTest
|
|
97
67
|
prerelease: false
|
|
98
|
-
|
|
68
|
+
version_requirements: *2156215840
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: ZenTest
|
|
71
|
+
requirement: &2156215240 !ruby/object:Gem::Requirement
|
|
99
72
|
none: false
|
|
100
|
-
requirements:
|
|
73
|
+
requirements:
|
|
101
74
|
- - ~>
|
|
102
|
-
- !ruby/object:Gem::Version
|
|
103
|
-
|
|
104
|
-
segments:
|
|
105
|
-
- 4
|
|
106
|
-
- 6
|
|
107
|
-
version: "4.6"
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '4.6'
|
|
108
77
|
type: :development
|
|
109
|
-
|
|
78
|
+
prerelease: false
|
|
79
|
+
version_requirements: *2156215240
|
|
110
80
|
description: An Extended Date/Time Format (EDTF) Parser for Ruby.
|
|
111
|
-
email:
|
|
81
|
+
email:
|
|
112
82
|
- http://sylvester.keil.or.at
|
|
113
83
|
executables: []
|
|
114
|
-
|
|
115
84
|
extensions: []
|
|
116
|
-
|
|
117
|
-
extra_rdoc_files:
|
|
85
|
+
extra_rdoc_files:
|
|
118
86
|
- README.md
|
|
119
87
|
- LICENSE
|
|
120
|
-
files:
|
|
88
|
+
files:
|
|
121
89
|
- .autotest
|
|
122
90
|
- .gitignore
|
|
123
91
|
- .rspec
|
|
@@ -131,8 +99,8 @@ files:
|
|
|
131
99
|
- features/parser/intervals.feature
|
|
132
100
|
- features/parser/precision.feature
|
|
133
101
|
- features/parser/unspecified.feature
|
|
102
|
+
- features/print/level_0_edtf.feature
|
|
134
103
|
- features/print/level_1_edtf.feature
|
|
135
|
-
- features/print/level_2_edtf.feature
|
|
136
104
|
- features/step_definitions/edtf_steps.rb
|
|
137
105
|
- features/support/env.rb
|
|
138
106
|
- lib/edtf.rb
|
|
@@ -155,52 +123,45 @@ files:
|
|
|
155
123
|
- spec/spec_helper.rb
|
|
156
124
|
- lib/edtf/parser.rb
|
|
157
125
|
homepage: http://inukshuk.github.com/edtf-ruby
|
|
158
|
-
licenses:
|
|
126
|
+
licenses:
|
|
159
127
|
- FreeBSD
|
|
160
128
|
post_install_message:
|
|
161
|
-
rdoc_options:
|
|
129
|
+
rdoc_options:
|
|
162
130
|
- --line-numbers
|
|
163
131
|
- --inline-source
|
|
164
132
|
- --title
|
|
165
|
-
- "
|
|
133
|
+
- ! '"EDTF-Ruby"'
|
|
166
134
|
- --main
|
|
167
135
|
- README.md
|
|
168
136
|
- --webcvs=http://github.com/inukshuk/edtf-ruby/tree/master/
|
|
169
|
-
require_paths:
|
|
137
|
+
require_paths:
|
|
170
138
|
- lib
|
|
171
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
172
140
|
none: false
|
|
173
|
-
requirements:
|
|
174
|
-
- -
|
|
175
|
-
- !ruby/object:Gem::Version
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
- 0
|
|
179
|
-
version: "0"
|
|
180
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
|
+
requirements:
|
|
142
|
+
- - ! '>='
|
|
143
|
+
- !ruby/object:Gem::Version
|
|
144
|
+
version: '0'
|
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
146
|
none: false
|
|
182
|
-
requirements:
|
|
183
|
-
- -
|
|
184
|
-
- !ruby/object:Gem::Version
|
|
185
|
-
|
|
186
|
-
segments:
|
|
187
|
-
- 0
|
|
188
|
-
version: "0"
|
|
147
|
+
requirements:
|
|
148
|
+
- - ! '>='
|
|
149
|
+
- !ruby/object:Gem::Version
|
|
150
|
+
version: '0'
|
|
189
151
|
requirements: []
|
|
190
|
-
|
|
191
152
|
rubyforge_project:
|
|
192
|
-
rubygems_version: 1.8.
|
|
153
|
+
rubygems_version: 1.8.7
|
|
193
154
|
signing_key:
|
|
194
155
|
specification_version: 3
|
|
195
156
|
summary: Extended Date/Time Format for Ruby.
|
|
196
|
-
test_files:
|
|
157
|
+
test_files:
|
|
197
158
|
- features/parser/date_times.feature
|
|
198
159
|
- features/parser/dates.feature
|
|
199
160
|
- features/parser/intervals.feature
|
|
200
161
|
- features/parser/precision.feature
|
|
201
162
|
- features/parser/unspecified.feature
|
|
163
|
+
- features/print/level_0_edtf.feature
|
|
202
164
|
- features/print/level_1_edtf.feature
|
|
203
|
-
- features/print/level_2_edtf.feature
|
|
204
165
|
- features/step_definitions/edtf_steps.rb
|
|
205
166
|
- features/support/env.rb
|
|
206
167
|
- spec/edtf/date_spec.rb
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
Feature: Print Date/Time objects as Level 2 EDTF strings
|
|
2
|
-
As a Ruby programmer
|
|
3
|
-
I want to convert Date/Time objects to EDTF strings
|
|
4
|
-
|
|
5
|
-
Scenario: Uncertain or approximate dates
|
|
6
|
-
When I parse the string "2001?"
|
|
7
|
-
When I convert the date
|
|
8
|
-
Then the EDTF string should be "2001?"
|