edtf 3.0.8 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,11 @@
1
1
  module EDTF
2
-
2
+
3
3
  describe Uncertainty do
4
4
 
5
5
  let(:uncertainty) { Uncertainty.new }
6
-
6
+
7
7
  describe '#uncertain?' do
8
-
8
+
9
9
  it { is_expected.to be_certain }
10
10
 
11
11
  it 'should be uncertain if at least one part is uncertain' do
@@ -30,7 +30,7 @@ module EDTF
30
30
  uncertainty.send("#{part}=", true)
31
31
  expect(uncertainty.uncertain?(part)).to be true
32
32
  end
33
-
33
+
34
34
  # ([:year, :month, :day, :hour, :minute, :second] - [part]).each do |other|
35
35
  ([:year, :month, :day] - [part]).each do |other|
36
36
  it "#{other} should not be uncertain if #{part} is uncertain" do
@@ -42,13 +42,13 @@ module EDTF
42
42
  end
43
43
 
44
44
  describe '#hash' do
45
-
45
+
46
46
  describe 'with the default hash base (1)' do
47
47
 
48
48
  it 'returns 0 by default' do
49
49
  expect(Uncertainty.new.hash).to eq(0)
50
50
  end
51
-
51
+
52
52
  it 'returns 1 for uncertain year' do
53
53
  expect(Uncertainty.new.hash).to eq(0)
54
54
  end
@@ -76,30 +76,30 @@ module EDTF
76
76
  it 'returns 6 for uncertain month, day' do
77
77
  expect(Uncertainty.new(nil, true, true).hash).to eq(6)
78
78
  end
79
-
79
+
80
80
  end
81
-
81
+
82
82
  end
83
-
83
+
84
84
  end
85
-
85
+
86
86
  describe '#uncertain!' do
87
87
  it 'should make all parts certain when no part given' do
88
88
  expect { uncertainty.uncertain! }.to change { uncertainty.certain? }
89
89
  end
90
90
  end
91
-
91
+
92
92
  end
93
-
93
+
94
94
  describe Unspecified do
95
95
  let(:u) { Unspecified.new }
96
-
97
-
96
+
97
+
98
98
  describe '#unspecified?' do
99
99
  it 'should return false by default' do
100
100
  expect(u).not_to be_unspecified
101
101
  end
102
-
102
+
103
103
  it 'should return true if the day is unspecified' do
104
104
  expect(u.unspecified!(:day)).to be_unspecified
105
105
  end
@@ -112,191 +112,185 @@ module EDTF
112
112
  expect(u.unspecified!(:year)).to be_unspecified
113
113
  end
114
114
  end
115
-
115
+
116
116
  describe '#year' do
117
117
  it 'returns the year values' do
118
118
  expect(u.year).to eq([nil,nil,nil,nil])
119
119
  end
120
-
120
+
121
121
  it 'allows you to set individual offsets' do
122
122
  u.year[1] = true
123
- expect(u.to_s).to eq('suss-ss-ss')
123
+ expect(u.to_s).to eq('sXss-ss-ss')
124
124
  end
125
125
  end
126
-
126
+
127
127
  describe '#to_s' do
128
128
  it 'should be return "ssss-ss-ss" by default' do
129
129
  expect(u.to_s).to eq('ssss-ss-ss')
130
130
  end
131
-
131
+
132
132
  it 'should return "ssss-ss-uu" if the day is unspecified' do
133
- expect(u.unspecified!(:day).to_s).to eq('ssss-ss-uu')
133
+ expect(u.unspecified!(:day).to_s).to eq('ssss-ss-XX')
134
134
  end
135
135
 
136
136
  it 'should return "ssss-uu-ss" if the month is unspecified' do
137
- expect(u.unspecified!(:month).to_s).to eq('ssss-uu-ss')
137
+ expect(u.unspecified!(:month).to_s).to eq('ssss-XX-ss')
138
138
  end
139
139
 
140
140
  it 'should return "ssss-uu-uu" if month and day are unspecified' do
141
- expect(u.unspecified!([:day, :month]).to_s).to eq('ssss-uu-uu')
141
+ expect(u.unspecified!([:day, :month]).to_s).to eq('ssss-XX-XX')
142
142
  end
143
143
 
144
144
  it 'should return "uuuu-ss-ss" if the year is unspecified' do
145
- expect(u.unspecified!(:year).to_s).to eq('uuuu-ss-ss')
145
+ expect(u.unspecified!(:year).to_s).to eq('XXXX-ss-ss')
146
146
  end
147
147
 
148
148
  it 'should return "uuuu-uu-uu" if the date is unspecified' do
149
- expect(u.unspecified!.to_s).to eq('uuuu-uu-uu')
149
+ expect(u.unspecified!.to_s).to eq('XXXX-XX-XX')
150
150
  end
151
-
151
+
152
152
  end
153
153
 
154
154
  describe '#mask' do
155
-
155
+
156
156
  context 'when passed an empty array' do
157
157
  it 'should return an empty array' do
158
158
  expect(u.mask([])).to eq([])
159
159
  end
160
160
  end
161
-
161
+
162
162
  context 'when passed an array with a year string' do
163
163
  let(:date) { ['1994'] }
164
-
164
+
165
165
  it 'should return the array with the year by default' do
166
166
  expect(u.mask(date)).to eq(['1994'])
167
167
  end
168
-
168
+
169
169
  context 'when the year is unspecified' do
170
170
  before(:each) { u.year[3] = true }
171
-
171
+
172
172
  it 'should return the array with the year and the fourth digit masked' do
173
- expect(u.mask(date)).to eq(['199u'])
173
+ expect(u.mask(date)).to eq(['199X'])
174
174
  end
175
-
175
+
176
176
  end
177
177
 
178
178
  context 'when the decade is unspecified' do
179
179
  before(:each) { u.year[2,2] = [true,true] }
180
-
180
+
181
181
  it 'should return the array with the year and the third and fourth digit masked' do
182
- expect(u.mask(date)).to eq(['19uu'])
182
+ expect(u.mask(date)).to eq(['19XX'])
183
183
  end
184
-
184
+
185
185
  end
186
-
186
+
187
187
  end
188
-
188
+
189
189
  context 'when passed an array with a negative year string' do
190
190
  let(:date) { ['-1994'] }
191
-
191
+
192
192
  it 'should return the array with the year by default' do
193
193
  expect(u.mask(date)).to eq(['-1994'])
194
194
  end
195
195
 
196
196
  context 'when the year is unspecified' do
197
197
  before(:each) { u.year[3] = true }
198
-
198
+
199
199
  it 'should return the array with the year and the fourth digit masked' do
200
- expect(u.mask(date)).to eq(['-199u'])
201
- end
200
+ expect(u.mask(date)).to eq(['-199X'])
201
+ end
202
202
  end
203
203
 
204
204
  context 'when the decade is unspecified' do
205
205
  before(:each) { u.year[2,2] = [true,true] }
206
-
206
+
207
207
  it 'should return the array with the year and the third and fourth digit masked' do
208
- expect(u.mask(date)).to eq(['-19uu'])
208
+ expect(u.mask(date)).to eq(['-19XX'])
209
209
  end
210
-
210
+
211
211
  end
212
212
  end
213
213
 
214
214
  context 'when passed an array with a year-month string' do
215
215
  let(:date) { ['1994', '01'] }
216
-
216
+
217
217
  it 'should return the array with the year by default' do
218
218
  expect(u.mask(date)).to eq(['1994', '01'])
219
219
  end
220
220
 
221
221
  context 'when the year is unspecified' do
222
222
  before(:each) { u.year[3] = true }
223
-
223
+
224
224
  it 'should return the array with the year and the fourth digit masked' do
225
- expect(u.mask(date)).to eq(['199u', '01'])
225
+ expect(u.mask(date)).to eq(['199X', '01'])
226
226
  end
227
-
227
+
228
228
  context 'when the month is unspecified' do
229
229
  before(:each) { u.unspecified! :month }
230
230
 
231
231
  it 'should return the array with the month masked' do
232
- expect(u.mask(date)).to eq(['199u', 'uu'])
233
- end
232
+ expect(u.mask(date)).to eq(['199X', 'XX'])
233
+ end
234
234
  end
235
235
  end
236
236
 
237
237
  context 'when the decade is unspecified' do
238
238
  before(:each) { u.year[2,2] = [true,true] }
239
-
239
+
240
240
  it 'should return the array with the year and the third and fourth digit masked' do
241
- expect(u.mask(date)).to eq(['19uu', '01'])
241
+ expect(u.mask(date)).to eq(['19XX', '01'])
242
242
  end
243
-
243
+
244
244
  context 'when the month is unspecified' do
245
245
  before(:each) { u.unspecified! :month }
246
246
 
247
247
  it 'should return the array with the month masked' do
248
- expect(u.mask(date)).to eq(['19uu', 'uu'])
249
- end
250
- end
248
+ expect(u.mask(date)).to eq(['19XX', 'XX'])
249
+ end
250
+ end
251
251
  end
252
252
 
253
253
  context 'when the month is unspecified' do
254
254
  before(:each) { u.unspecified! :month }
255
-
255
+
256
256
  it 'should return the array with the month masked' do
257
- expect(u.mask(date)).to eq(['1994', 'uu'])
258
- end
259
- end
257
+ expect(u.mask(date)).to eq(['1994', 'XX'])
258
+ end
259
+ end
260
260
 
261
261
  end
262
-
262
+
263
263
  context 'when passed an array with a year-month-day string' do
264
264
  let(:date) { ['1994', '01', '27'] }
265
-
265
+
266
266
  it 'should return the array with the date by default' do
267
267
  expect(u.mask(date)).to eq(['1994', '01', '27'])
268
268
  end
269
-
269
+
270
270
  context 'when the year is unspecified' do
271
271
  before(:each) { u.year[3] = true }
272
-
272
+
273
273
  it 'should return the array with the year and the fourth digit masked' do
274
- expect(u.mask(date)).to eq(['199u', '01', '27'])
274
+ expect(u.mask(date)).to eq(['199X', '01', '27'])
275
275
  end
276
-
276
+
277
277
  context 'when the month is unspecified' do
278
278
  before(:each) { u.unspecified! :month }
279
279
 
280
280
  it 'should return the array with the month masked' do
281
- expect(u.mask(date)).to eq(['199u', 'uu', '27'])
282
- end
283
-
281
+ expect(u.mask(date)).to eq(['199X', 'XX', '27'])
282
+ end
283
+
284
284
  context 'when the day is unspecified' do
285
285
  before(:each) { u.unspecified! :day }
286
286
 
287
287
  it 'should return the array with the month masked' do
288
- expect(u.mask(date)).to eq(['199u', 'uu', 'uu'])
289
- end
288
+ expect(u.mask(date)).to eq(['199X', 'XX', 'XX'])
289
+ end
290
290
  end
291
291
  end
292
292
  end
293
-
294
-
295
293
  end
296
-
297
-
298
294
  end
299
-
300
295
  end
301
-
302
- end
296
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,20 +1,11 @@
1
1
  begin
2
2
  require 'simplecov'
3
- require 'coveralls' if ENV['CI']
4
3
  rescue LoadError
5
4
  # ignore
6
5
  end
7
6
 
8
7
  begin
9
- case
10
- when RUBY_PLATFORM < 'java'
11
- require 'debug'
12
- Debugger.start
13
- when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
14
- require 'rubinius/debugger'
15
- else
16
- require 'byebug'
17
- end
8
+ require 'debug' unless RUBY_PLATFORM == 'java'
18
9
  rescue LoadError
19
10
  # ignore
20
11
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edtf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.8
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil
8
+ - Ilja Srna
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2022-01-11 00:00:00.000000000 Z
12
+ date: 2023-01-31 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: activesupport
@@ -32,7 +33,6 @@ dependencies:
32
33
  version: '8.0'
33
34
  description: A Ruby implementation of the Extended Date/Time Format (EDTF).
34
35
  email:
35
- - http://sylvester.keil.or.at
36
36
  executables: []
37
37
  extensions: []
38
38
  extra_rdoc_files:
@@ -40,11 +40,10 @@ extra_rdoc_files:
40
40
  - LICENSE
41
41
  files:
42
42
  - ".autotest"
43
- - ".coveralls.yml"
43
+ - ".github/workflows/ci.yml"
44
44
  - ".gitignore"
45
45
  - ".rspec"
46
46
  - ".simplecov"
47
- - ".travis.yml"
48
47
  - Gemfile
49
48
  - LICENSE
50
49
  - README.md
@@ -111,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
110
  - !ruby/object:Gem::Version
112
111
  version: '0'
113
112
  requirements: []
114
- rubygems_version: 3.2.15
113
+ rubygems_version: 3.4.2
115
114
  signing_key:
116
115
  specification_version: 4
117
116
  summary: Extended Date/Time Format for Ruby.
data/.coveralls.yml DELETED
@@ -1 +0,0 @@
1
- service_name: travis-ci
data/.travis.yml DELETED
@@ -1,17 +0,0 @@
1
- language: ruby
2
- bundler_args: --without debug extra
3
- sudo: false
4
- cache: bundler
5
- script: bundle exec rake test_with_coveralls
6
- rvm:
7
- - 2.5.0
8
- - 2.4.3
9
- - 2.3.6
10
- - 2.2.9
11
- - jruby-9.1.16.0
12
- notifications:
13
- email:
14
- - sk@semicolon.at
15
- - namyra@gmail.com
16
- on_success: change
17
- on_failure: change