fat_core 2.0.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/bin/console +14 -0
- data/fat_core.gemspec +1 -0
- data/lib/fat_core/all.rb +14 -0
- data/lib/fat_core/array.rb +29 -22
- data/lib/fat_core/big_decimal.rb +12 -0
- data/lib/fat_core/date.rb +951 -938
- data/lib/fat_core/enumerable.rb +19 -3
- data/lib/fat_core/hash.rb +48 -43
- data/lib/fat_core/kernel.rb +4 -2
- data/lib/fat_core/nil.rb +13 -13
- data/lib/fat_core/numeric.rb +82 -86
- data/lib/fat_core/range.rb +164 -160
- data/lib/fat_core/string.rb +247 -242
- data/lib/fat_core/symbol.rb +17 -11
- data/lib/fat_core/version.rb +2 -2
- data/lib/fat_core.rb +0 -21
- data/spec/lib/array_spec.rb +2 -0
- data/spec/lib/big_decimal_spec.rb +7 -0
- data/spec/lib/date_spec.rb +7 -26
- data/spec/lib/enumerable_spec.rb +26 -1
- data/spec/lib/hash_spec.rb +2 -0
- data/spec/lib/kernel_spec.rb +2 -0
- data/spec/lib/nil_spec.rb +6 -0
- data/spec/lib/numeric_spec.rb +1 -5
- data/spec/lib/range_spec.rb +1 -1
- data/spec/lib/string_spec.rb +1 -6
- data/spec/lib/symbol_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -2
- metadata +9 -8
- data/lib/fat_core/boolean.rb +0 -25
- data/lib/fat_core/latex_eruby.rb +0 -11
- data/lib/fat_core/period.rb +0 -533
- data/spec/lib/period_spec.rb +0 -677
data/spec/lib/date_spec.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
require 'spec_helper'
|
2
|
+
#require 'spec_helper'
|
3
|
+
|
4
|
+
require 'fat_core/date'
|
3
5
|
|
4
6
|
describe Date do
|
5
7
|
before :each do
|
@@ -624,27 +626,6 @@ describe Date do
|
|
624
626
|
}.to raise_error(ArgumentError)
|
625
627
|
end
|
626
628
|
|
627
|
-
it 'should know how to expand to chunk periods' do
|
628
|
-
expect(Date.parse('2013-07-04').expand_to_period(:year))
|
629
|
-
.to eq Period.new('2013-01-01', '2013-12-31')
|
630
|
-
expect(Date.parse('2013-07-04').expand_to_period(:half))
|
631
|
-
.to eq Period.new('2013-07-01', '2013-12-31')
|
632
|
-
expect(Date.parse('2013-07-04').expand_to_period(:quarter))
|
633
|
-
.to eq Period.new('2013-07-01', '2013-09-30')
|
634
|
-
expect(Date.parse('2013-07-04').expand_to_period(:bimonth))
|
635
|
-
.to eq Period.new('2013-07-01', '2013-08-31')
|
636
|
-
expect(Date.parse('2013-07-04').expand_to_period(:month))
|
637
|
-
.to eq Period.new('2013-07-01', '2013-07-31')
|
638
|
-
expect(Date.parse('2013-07-04').expand_to_period(:semimonth))
|
639
|
-
.to eq Period.new('2013-07-01', '2013-07-15')
|
640
|
-
expect(Date.parse('2013-07-04').expand_to_period(:biweek))
|
641
|
-
.to eq Period.new('2013-07-01', '2013-07-14')
|
642
|
-
expect(Date.parse('2013-07-04').expand_to_period(:week))
|
643
|
-
.to eq Period.new('2013-07-01', '2013-07-07')
|
644
|
-
expect(Date.parse('2013-07-04').expand_to_period(:day))
|
645
|
-
.to eq Period.new('2013-07-04', '2013-07-04')
|
646
|
-
end
|
647
|
-
|
648
629
|
it "should know if it's within 6 months of another date" do
|
649
630
|
# This uses Section 16's logic that one date is "within a
|
650
631
|
# period of less than six months" of another date only if it
|
@@ -833,16 +814,16 @@ describe Date do
|
|
833
814
|
expect(Date.parse('2014-11-22')).to be_nyse_holiday
|
834
815
|
expect(Date.parse('2014-11-23')).to be_nyse_holiday
|
835
816
|
|
817
|
+
# 9-11 Attacks
|
818
|
+
expect(Date.parse('2001-09-11')).to be_nyse_holiday
|
819
|
+
expect(Date.parse('2001-09-14')).to be_nyse_holiday
|
820
|
+
|
836
821
|
# 1968 Paperwork Crisis (Closed every Wed unless other holiday in
|
837
822
|
# week) from June 12 to December 31, 1968
|
838
823
|
expect(Date.parse('1968-06-12')).to be_nyse_holiday
|
839
824
|
expect(Date.parse('1968-07-03')).not_to be_nyse_holiday
|
840
825
|
expect(Date.parse('1968-08-21')).to be_nyse_holiday
|
841
826
|
|
842
|
-
# 9-11 Attacks
|
843
|
-
expect(Date.parse('2001-09-11')).to be_nyse_holiday
|
844
|
-
expect(Date.parse('2001-09-14')).to be_nyse_holiday
|
845
|
-
|
846
827
|
# Hurricane Sandy
|
847
828
|
expect(Date.parse('2012-10-29')).to be_nyse_holiday
|
848
829
|
expect(Date.parse('2012-10-30')).to be_nyse_holiday
|
data/spec/lib/enumerable_spec.rb
CHANGED
@@ -1,10 +1,35 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
require 'fat_core/enumerable'
|
4
|
+
|
3
5
|
describe Enumerable do
|
4
6
|
it 'should be able to emit in groups of size k' do
|
5
7
|
letters = ('a'..'z').to_a
|
6
8
|
letters.groups_of(3).each do |k, grp|
|
7
|
-
expect(grp.
|
9
|
+
expect(grp.class).to eq Array
|
10
|
+
if grp.last == 'z'
|
11
|
+
expect(grp.size).to eq(2)
|
12
|
+
expect(grp).to eq(['y', 'z'])
|
13
|
+
else
|
14
|
+
expect(grp.size).to eq(3)
|
15
|
+
expect(grp.join).to match(/\A[a-z]{3}\z/)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should be able to yield each with flags' do
|
21
|
+
letters = ('a'..'z').to_a
|
22
|
+
letters.each_with_flags do |l, first, last|
|
23
|
+
if l == 'a'
|
24
|
+
expect(first).to eq true
|
25
|
+
expect(last).to eq false
|
26
|
+
elsif l == 'z'
|
27
|
+
expect(first).to eq false
|
28
|
+
expect(last).to eq true
|
29
|
+
else
|
30
|
+
expect(first).to eq false
|
31
|
+
expect(last).to eq false
|
32
|
+
end
|
8
33
|
end
|
9
34
|
end
|
10
35
|
end
|
data/spec/lib/hash_spec.rb
CHANGED
data/spec/lib/kernel_spec.rb
CHANGED
data/spec/lib/nil_spec.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
require 'fat_core/nil'
|
4
|
+
|
3
5
|
describe NilClass do
|
4
6
|
it 'should respond to entitle' do
|
5
7
|
expect(nil.entitle).to eq ''
|
@@ -8,4 +10,8 @@ describe NilClass do
|
|
8
10
|
it 'should respond to tex_quote' do
|
9
11
|
expect(nil.tex_quote).to eq ''
|
10
12
|
end
|
13
|
+
|
14
|
+
it 'should respond to commas' do
|
15
|
+
expect(nil.commas).to eq ''
|
16
|
+
end
|
11
17
|
end
|
data/spec/lib/numeric_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'fat_core/numeric'
|
2
2
|
|
3
3
|
describe Numeric do
|
4
4
|
it 'should implement signum function' do
|
@@ -17,10 +17,6 @@ describe Numeric do
|
|
17
17
|
expect(195.45.tex_quote).to eq '195.45'
|
18
18
|
end
|
19
19
|
|
20
|
-
it 'should provide a human-readable inspect for BigDecimal' do
|
21
|
-
expect(BigDecimal('33.45').inspect).to eq '33.45'
|
22
|
-
end
|
23
|
-
|
24
20
|
it 'should be able to report if its a whole number' do
|
25
21
|
expect(236.whole?).to be true
|
26
22
|
expect(236.5555.whole?).to be false
|
data/spec/lib/range_spec.rb
CHANGED
data/spec/lib/string_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'fat_core/string'
|
2
2
|
|
3
3
|
describe String do
|
4
4
|
before do
|
@@ -172,11 +172,6 @@ the people, for the people, shall not perish from the earth."
|
|
172
172
|
expect('Hello:world'.fuzzy_match('hel:ox')).to be_falsy
|
173
173
|
end
|
174
174
|
|
175
|
-
it 'should be able to fuzzy match colon-separated parts' do
|
176
|
-
expect('Hello:world'.fuzzy_match('hel:or')).to be_truthy
|
177
|
-
expect('Hello:world'.fuzzy_match('hel:ox')).to be_falsy
|
178
|
-
end
|
179
|
-
|
180
175
|
it 'should return the matched text' do
|
181
176
|
expect('Hello:world'.fuzzy_match('hel')).to eq('Hel')
|
182
177
|
expect('Hello:world'.fuzzy_match('hel:or')).to eq('Hello:wor')
|
data/spec/lib/symbol_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
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:
|
4
|
+
version: 3.0.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-
|
11
|
+
date: 2017-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simplecov
|
@@ -182,6 +182,7 @@ description: Write a longer description. Optional.
|
|
182
182
|
email:
|
183
183
|
- ded@ddoherty.net
|
184
184
|
executables:
|
185
|
+
- console
|
185
186
|
- easters
|
186
187
|
extensions: []
|
187
188
|
extra_rdoc_files: []
|
@@ -197,33 +198,33 @@ files:
|
|
197
198
|
- README.md
|
198
199
|
- Rakefile
|
199
200
|
- TODO.org
|
201
|
+
- bin/console
|
200
202
|
- bin/easters
|
201
203
|
- fat_core.gemspec
|
202
204
|
- lib/core_extensions/date/fat_core.rb
|
203
205
|
- lib/fat_core.rb
|
204
206
|
- lib/fat_core/ChangeLog
|
207
|
+
- lib/fat_core/all.rb
|
205
208
|
- lib/fat_core/array.rb
|
206
|
-
- lib/fat_core/
|
209
|
+
- lib/fat_core/big_decimal.rb
|
207
210
|
- lib/fat_core/date.rb
|
208
211
|
- lib/fat_core/enumerable.rb
|
209
212
|
- lib/fat_core/hash.rb
|
210
213
|
- lib/fat_core/kernel.rb
|
211
|
-
- lib/fat_core/latex_eruby.rb
|
212
214
|
- lib/fat_core/nil.rb
|
213
215
|
- lib/fat_core/numeric.rb
|
214
|
-
- lib/fat_core/period.rb
|
215
216
|
- lib/fat_core/range.rb
|
216
217
|
- lib/fat_core/string.rb
|
217
218
|
- lib/fat_core/symbol.rb
|
218
219
|
- lib/fat_core/version.rb
|
219
220
|
- spec/lib/array_spec.rb
|
221
|
+
- spec/lib/big_decimal_spec.rb
|
220
222
|
- spec/lib/date_spec.rb
|
221
223
|
- spec/lib/enumerable_spec.rb
|
222
224
|
- spec/lib/hash_spec.rb
|
223
225
|
- spec/lib/kernel_spec.rb
|
224
226
|
- spec/lib/nil_spec.rb
|
225
227
|
- spec/lib/numeric_spec.rb
|
226
|
-
- spec/lib/period_spec.rb
|
227
228
|
- spec/lib/range_spec.rb
|
228
229
|
- spec/lib/string_spec.rb
|
229
230
|
- spec/lib/symbol_spec.rb
|
@@ -240,7 +241,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
240
241
|
requirements:
|
241
242
|
- - ">="
|
242
243
|
- !ruby/object:Gem::Version
|
243
|
-
version:
|
244
|
+
version: 2.3.1
|
244
245
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
245
246
|
requirements:
|
246
247
|
- - ">="
|
@@ -254,13 +255,13 @@ specification_version: 4
|
|
254
255
|
summary: fat_core provides some useful core extensions
|
255
256
|
test_files:
|
256
257
|
- spec/lib/array_spec.rb
|
258
|
+
- spec/lib/big_decimal_spec.rb
|
257
259
|
- spec/lib/date_spec.rb
|
258
260
|
- spec/lib/enumerable_spec.rb
|
259
261
|
- spec/lib/hash_spec.rb
|
260
262
|
- spec/lib/kernel_spec.rb
|
261
263
|
- spec/lib/nil_spec.rb
|
262
264
|
- spec/lib/numeric_spec.rb
|
263
|
-
- spec/lib/period_spec.rb
|
264
265
|
- spec/lib/range_spec.rb
|
265
266
|
- spec/lib/string_spec.rb
|
266
267
|
- spec/lib/symbol_spec.rb
|
data/lib/fat_core/boolean.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
class TrueClass
|
2
|
-
def format_by(fmt = 'T')
|
3
|
-
case fmt
|
4
|
-
when /^[tf]/i
|
5
|
-
'T'
|
6
|
-
when /^[yn]/i
|
7
|
-
'Y'
|
8
|
-
else
|
9
|
-
'T'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class FalseClass
|
15
|
-
def format_by(fmt = 'T')
|
16
|
-
case fmt
|
17
|
-
when /^[tf]/i
|
18
|
-
'F'
|
19
|
-
when /^[yn]/i
|
20
|
-
'N'
|
21
|
-
else
|
22
|
-
'F'
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/fat_core/latex_eruby.rb
DELETED