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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa655e4e89a8cb161181b107461ecfc658d4c9e9
4
- data.tar.gz: d463ec75229bb90823ff4972dea2a7cf6fe6e2d4
3
+ metadata.gz: 67f953e3e0324036a11b5bbb58eb57aa87300308
4
+ data.tar.gz: 677f9a5d4ab49df4907f6cbcd11e0e44c994b023
5
5
  SHA512:
6
- metadata.gz: 673e1462165a23d661c145305041799a1cc1c9dd8ea2129c19a549b5e17eade2271e48fbdc9b6038fbde747d90149e2b5b6f78f01d63c6606efb6b49b44ade61
7
- data.tar.gz: e36ba83aacd9675b9cc3a59360ddb4428b55629ec28cbaaac48be4f413aa685d9ca984bb878af3d3c365159e9249788660e1c2442571d2bc8448e9d91c5ed3a4
6
+ metadata.gz: bfe644b043661eb418187322e6133477087ac4600dcb907432cc9fb7a0de407ca33bfa9951dc0898efb733d76f1ba2cfa265b079dff7444fca87932b4c9da883
7
+ data.tar.gz: 7ef375fb47a1a5199bbc8e7af2abd24459113f987b7c56ce7173a00421b4de0235f67de0e46f1b5140b49e8403dcc15eb96330494979f0eabe7f3b928d8918c6
@@ -86,9 +86,15 @@ module EDTF
86
86
  end
87
87
 
88
88
  def mask(values)
89
- values.zip(members.take(values.length)).map do |value, mask|
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
 
@@ -1,3 +1,3 @@
1
1
  module EDTF
2
- VERSION = '3.0.0'.freeze
2
+ VERSION = '3.0.1'.freeze
3
3
  end
@@ -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.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: 2016-07-17 00:00:00.000000000 Z
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.3
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: