edtf 3.0.0 → 3.0.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/lib/edtf/uncertainty.rb +7 -1
- data/lib/edtf/version.rb +1 -1
- data/spec/edtf/uncertainty_spec.rb +25 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67f953e3e0324036a11b5bbb58eb57aa87300308
|
4
|
+
data.tar.gz: 677f9a5d4ab49df4907f6cbcd11e0e44c994b023
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfe644b043661eb418187322e6133477087ac4600dcb907432cc9fb7a0de407ca33bfa9951dc0898efb733d76f1ba2cfa265b079dff7444fca87932b4c9da883
|
7
|
+
data.tar.gz: 7ef375fb47a1a5199bbc8e7af2abd24459113f987b7c56ce7173a00421b4de0235f67de0e46f1b5140b49e8403dcc15eb96330494979f0eabe7f3b928d8918c6
|
data/lib/edtf/uncertainty.rb
CHANGED
@@ -86,9 +86,15 @@ module EDTF
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def mask(values)
|
89
|
-
values
|
89
|
+
if values[0] && values[0][0] == "-"
|
90
|
+
values[0].delete!("-")
|
91
|
+
negative_year = true
|
92
|
+
end
|
93
|
+
results = values.zip(members.take(values.length)).map do |value, mask|
|
90
94
|
value.split(//).zip(send(mask)).map { |v,m| m ? U : v }.join
|
91
95
|
end
|
96
|
+
results[0] = "-#{results[0]}" if negative_year
|
97
|
+
results
|
92
98
|
end
|
93
99
|
end
|
94
100
|
|
data/lib/edtf/version.rb
CHANGED
@@ -186,6 +186,31 @@ module EDTF
|
|
186
186
|
|
187
187
|
end
|
188
188
|
|
189
|
+
context 'when passed an array with a negative year string' do
|
190
|
+
let(:date) { ['-1994'] }
|
191
|
+
|
192
|
+
it 'should return the array with the year by default' do
|
193
|
+
expect(u.mask(date)).to eq(['-1994'])
|
194
|
+
end
|
195
|
+
|
196
|
+
context 'when the year is unspecified' do
|
197
|
+
before(:each) { u.year[3] = true }
|
198
|
+
|
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
|
202
|
+
end
|
203
|
+
|
204
|
+
context 'when the decade is unspecified' do
|
205
|
+
before(:each) { u.year[2,2] = [true,true] }
|
206
|
+
|
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'])
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
189
214
|
context 'when passed an array with a year-month string' do
|
190
215
|
let(:date) { ['1994', '01'] }
|
191
216
|
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvester Keil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.6.
|
115
|
+
rubygems_version: 2.6.8
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: Extended Date/Time Format for Ruby.
|
@@ -137,4 +137,3 @@ test_files:
|
|
137
137
|
- spec/edtf/set_spec.rb
|
138
138
|
- spec/edtf/uncertainty_spec.rb
|
139
139
|
- spec/spec_helper.rb
|
140
|
-
has_rdoc:
|