fat_core 1.2.8 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b584803e27f06145ac112e534d19283bb680c525
4
- data.tar.gz: 03f00dfaca603a3487db9b5f702aa188510151cb
3
+ metadata.gz: 49d7213a1c1d8f0372f9a5f0e057dec4a194e541
4
+ data.tar.gz: 6f8ee1ddc0bfb0e8b66247453e2f4c11fc51d0d1
5
5
  SHA512:
6
- metadata.gz: 71655e984f1019ce9a7c3ae3fc6f180b317061a892dc37315070aca2c5ffc0765ba35fc4e227924bebf9145fc13b3ebe6a70dfc080a364b6d3327b1071a253b0
7
- data.tar.gz: 7b7a975597653fa34761a7e075bb8f1f5bdd17d3018c29538bced08b47332972f208d4017d1a990a87e53f674606a61d558194a281e484e0e0838ca3ee5b2cc9
6
+ metadata.gz: 074407a3a3e4b7885d841b8fe351c18fd03d001620058e9364129fe82f995d3e25554c4b3c2bb364851e006faa95778929bc7342d7799ed8d8c10956421fb64f
7
+ data.tar.gz: 4d0d70cfc49d8f1152db707a8eb43672d5fcf1586f088e41646a3f33f2d49c2634c15d5944246624a80bc325e277559a960e5e9840077804d4296f2ba1b00d61
data/.gitignore CHANGED
@@ -19,3 +19,4 @@ tmp
19
19
  /GRTAGS
20
20
  /GTAGS
21
21
  /.rubocop_todo.yml
22
+ /gtags.files
@@ -65,8 +65,8 @@ class Date
65
65
  end
66
66
 
67
67
  today = Date.current
68
- case spec
69
- when /^(\d\d\d\d)-(\d\d?)-(\d\d?)*$/
68
+ case spec.clean
69
+ when /\A(\d\d\d\d)[-\/](\d\d?)[-\/](\d\d?)\z/
70
70
  # A specified date
71
71
  Date.new($1.to_i, $2.to_i, $3.to_i)
72
72
  when /\AW(\d\d?)\z/, /\A(\d\d?)W\z/
@@ -79,7 +79,7 @@ class Date
79
79
  else
80
80
  Date.commercial(today.year, week_num).end_of_week
81
81
  end
82
- when /\A(\d\d\d\d)-W(\d\d?)\z/, /\A(\d\d\d\d)-(\d\d?)W\z/
82
+ when /\A(\d\d\d\d)[-\/]W(\d\d?)\z/, /\A(\d\d\d\d)[-\/](\d\d?)W\z/
83
83
  year = $1.to_i
84
84
  week_num = $2.to_i
85
85
  if week_num < 1 || week_num > 53
@@ -90,7 +90,7 @@ class Date
90
90
  else
91
91
  Date.commercial(year, week_num).end_of_week
92
92
  end
93
- when /^(\d\d\d\d)-(\d)[Qq]$/, /^(\d\d\d\d)-[Qq](\d)$/
93
+ when /^(\d\d\d\d)[-\/](\d)[Qq]$/, /^(\d\d\d\d)[-\/][Qq](\d)$/
94
94
  # Year-Quarter
95
95
  year = $1.to_i
96
96
  quarter = $2.to_i
@@ -113,7 +113,7 @@ class Date
113
113
  else
114
114
  date.end_of_quarter
115
115
  end
116
- when /^(\d\d\d\d)-(\d)[Hh]$/, /^(\d\d\d\d)-[Hh](\d)$/
116
+ when /^(\d\d\d\d)[-\/](\d)[Hh]$/, /^(\d\d\d\d)[-\/][Hh](\d)$/
117
117
  # Year-Half
118
118
  year = $1.to_i
119
119
  half = $2.to_i
@@ -136,13 +136,20 @@ class Date
136
136
  else
137
137
  date.end_of_half
138
138
  end
139
- when /^(\d\d\d\d)-(\d\d?)*$/
139
+ when /^(\d\d\d\d)[-\/](\d\d?)*$/
140
140
  # Year-Month only
141
141
  if spec_type == :from
142
142
  Date.new($1.to_i, $2.to_i, 1)
143
143
  else
144
144
  Date.new($1.to_i, $2.to_i, 1).end_of_month
145
145
  end
146
+ when /^(\d\d?)[-\/](\d\d?)*$/
147
+ # Month-Day only
148
+ if spec_type == :from
149
+ Date.new(today.year, $1.to_i, $2.to_i)
150
+ else
151
+ Date.new(today.year, $1.to_i, $2.to_i).end_of_month
152
+ end
146
153
  when /\A(\d\d?)\z/
147
154
  # Month only
148
155
  if spec_type == :from
@@ -1,7 +1,7 @@
1
1
  module FatCore
2
2
  MAJOR = 1
3
- MINOR = 2
4
- PATCH = 8
3
+ MINOR = 3
4
+ PATCH = 0
5
5
 
6
6
  VERSION = [MAJOR, MINOR, PATCH].compact.join('.')
7
7
  end
@@ -211,7 +211,7 @@ describe Date do
211
211
 
212
212
  it 'should parse plain iso dates correctly' do
213
213
  expect(Date.parse_spec('2011-07-15')).to eq Date.parse('2011-07-15')
214
- expect(Date.parse_spec('2011-08-05')).to eq Date.parse('2011-08-05')
214
+ expect(Date.parse_spec('2011/08/05')).to eq Date.parse('2011-08-05')
215
215
  end
216
216
 
217
217
  it "should parse week numbers such as 'W23' or '23W' correctly" do
@@ -231,7 +231,7 @@ describe Date do
231
231
  expect(Date.parse_spec('2003-W23')).to eq Date.parse('2003-06-02')
232
232
  expect(Date.parse_spec('2003-W23', :to)).to eq Date.parse('2003-06-08')
233
233
  expect(Date.parse_spec('2003-23W')).to eq Date.parse('2003-06-02')
234
- expect(Date.parse_spec('2003-23W', :to)).to eq Date.parse('2003-06-08')
234
+ expect(Date.parse_spec('2003/23W', :to)).to eq Date.parse('2003-06-08')
235
235
  expect {
236
236
  Date.parse_spec('2003-W83', :to)
237
237
  }.to raise_error(ArgumentError)
@@ -241,7 +241,7 @@ describe Date do
241
241
  expect(Date.parse_spec('2011-2H', :from)).to eq Date.parse('2011-07-01')
242
242
  expect(Date.parse_spec('2011-2H', :to)).to eq Date.parse('2011-12-31')
243
243
  expect(Date.parse_spec('2011-H1', :from)).to eq Date.parse('2011-01-01')
244
- expect(Date.parse_spec('2011-H1', :to)).to eq Date.parse('2011-06-30')
244
+ expect(Date.parse_spec('2011/H1', :to)).to eq Date.parse('2011-06-30')
245
245
  expect { Date.parse_spec('2011-3H') }.to raise_error(ArgumentError)
246
246
  end
247
247
 
@@ -257,7 +257,7 @@ describe Date do
257
257
  expect(Date.parse_spec('2011-4Q', :from)).to eq Date.parse('2011-10-01')
258
258
  expect(Date.parse_spec('2011-4Q', :to)).to eq Date.parse('2011-12-31')
259
259
  expect(Date.parse_spec('2011-Q4', :from)).to eq Date.parse('2011-10-01')
260
- expect(Date.parse_spec('2011-Q4', :to)).to eq Date.parse('2011-12-31')
260
+ expect(Date.parse_spec('2011/Q4', :to)).to eq Date.parse('2011-12-31')
261
261
  expect { Date.parse_spec('2011-5Q') }.to raise_error(ArgumentError)
262
262
  end
263
263
 
@@ -271,7 +271,7 @@ describe Date do
271
271
 
272
272
  it 'should parse year-month specs such as YYYY-MM' do
273
273
  expect(Date.parse_spec('2010-5', :from)).to eq Date.parse('2010-05-01')
274
- expect(Date.parse_spec('2010-5', :to)).to eq Date.parse('2010-05-31')
274
+ expect(Date.parse_spec('2010/5', :to)).to eq Date.parse('2010-05-31')
275
275
  expect { Date.parse_spec('2010-13') }.to raise_error(ArgumentError)
276
276
  end
277
277
 
@@ -282,6 +282,21 @@ describe Date do
282
282
  expect { Date.parse_spec('011') }.to raise_error(ArgumentError)
283
283
  end
284
284
 
285
+ it 'should parse month-day specs such as MM-DD' do
286
+ expect(Date.parse_spec('10-12', :from)).to eq Date.parse('2012-10-12')
287
+ expect(Date.parse_spec('10-2', :from)).to eq Date.parse('2012-10-02')
288
+ expect(Date.parse_spec('5-12', :from)).to eq Date.parse('2012-05-12')
289
+ expect(Date.parse_spec('5-2', :from)).to eq Date.parse('2012-05-02')
290
+ expect(Date.parse_spec('10/12', :from)).to eq Date.parse('2012-10-12')
291
+ expect(Date.parse_spec('10/2', :from)).to eq Date.parse('2012-10-02')
292
+ expect(Date.parse_spec('5/12', :from)).to eq Date.parse('2012-05-12')
293
+ expect(Date.parse_spec('5/2', :from)).to eq Date.parse('2012-05-02')
294
+ expect { Date.parse_spec('99-3') }.to raise_error(ArgumentError)
295
+ expect { Date.parse_spec('3-33') }.to raise_error(ArgumentError)
296
+ expect { Date.parse_spec('99/3') }.to raise_error(ArgumentError)
297
+ expect { Date.parse_spec('3/33') }.to raise_error(ArgumentError)
298
+ end
299
+
285
300
  it 'should parse year-only specs such as YYYY' do
286
301
  expect(Date.parse_spec('2010', :from)).to eq Date.parse('2010-01-01')
287
302
  expect(Date.parse_spec('2010', :to)).to eq Date.parse('2010-12-31')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fat_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.8
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-28 00:00:00.000000000 Z
11
+ date: 2017-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simplecov