fat_core 4.9.3 → 4.10.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 +4 -4
- data/.simplecov +18 -0
- data/fat_core.gemspec +1 -2
- data/lib/fat_core/date.rb +4 -1
- data/lib/fat_core/numeric.rb +1 -1
- data/lib/fat_core/range.rb +1 -1
- data/lib/fat_core/string.rb +3 -3
- data/lib/fat_core/version.rb +2 -2
- data/spec/lib/date_spec.rb +32 -5
- data/spec/lib/string_spec.rb +5 -5
- data/spec/spec_helper.rb +1 -2
- metadata +11 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3860db07c85484c1d82e2fafa18d730e7dedb991f33868b21c2c11d3e56c7fde
|
4
|
+
data.tar.gz: 524ca9b2ecdd017b5f14d8ff70e787d550bdf0a3eb4769be6442c3df914f965c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fda77f07f98048d111fdf752b115595f1b3b79e8f2c6b1d73482edfcb9e89ad45f6d46331fca04b3cabab3f1ab2f4da91675de5b8c4965943aa12d4902501839
|
7
|
+
data.tar.gz: 37a9824e50cdc58880d081007c70b9e5b4d6c338f381139ad178e936d68da24e19a6b188298072da9df7444b88eacfa9ed362bcb2767092abdb6f532e93e7089
|
data/.simplecov
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
|
3
|
+
SimpleCov.start do
|
4
|
+
# any custom configs like groups and filters can be here at a central place
|
5
|
+
add_filter '/spec/'
|
6
|
+
add_filter '/tmp/'
|
7
|
+
add_group "Models", "lib/fat_core"
|
8
|
+
# add_group "Core Extension", "lib/ext"
|
9
|
+
# After this many seconds between runs, old coverage stats are thrown out,
|
10
|
+
# so 3600 => 1 hour
|
11
|
+
merge_timeout 3600
|
12
|
+
# Make this true to merge rspec and cucumber coverage together
|
13
|
+
use_merging false
|
14
|
+
command_name 'Rspec'
|
15
|
+
nocov_token 'no_cover'
|
16
|
+
# Branch coverage
|
17
|
+
enable_coverage :branch
|
18
|
+
end
|
data/fat_core.gemspec
CHANGED
@@ -24,12 +24,11 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.add_development_dependency 'simplecov'
|
26
26
|
spec.add_development_dependency 'bundler'
|
27
|
+
spec.add_development_dependency 'debug', '>= 1.0.0'
|
27
28
|
spec.add_development_dependency 'rake'
|
28
29
|
spec.add_development_dependency 'rspec'
|
29
|
-
spec.add_development_dependency 'byebug'
|
30
30
|
spec.add_development_dependency 'pry'
|
31
31
|
spec.add_development_dependency 'pry-doc'
|
32
|
-
spec.add_development_dependency 'pry-byebug'
|
33
32
|
spec.add_development_dependency 'redcarpet'
|
34
33
|
spec.add_development_dependency 'solargraph'
|
35
34
|
|
data/lib/fat_core/date.rb
CHANGED
@@ -48,6 +48,9 @@ require 'fat_core/patches'
|
|
48
48
|
# the NYSE was closed for special reasons, such as the 9-11 attacks in 2001.
|
49
49
|
module FatCore
|
50
50
|
module Date
|
51
|
+
# Set the default beginning of week to Monday for commercial weeks.
|
52
|
+
::Date.beginning_of_week = :monday
|
53
|
+
|
51
54
|
# Constant for Beginning of Time (BOT) outside the range of what we would ever
|
52
55
|
# want to find in commercial situations.
|
53
56
|
BOT = ::Date.parse('1900-01-01')
|
@@ -70,7 +73,7 @@ module FatCore
|
|
70
73
|
# Format date to TeX documents as ISO strings but with en-dashes
|
71
74
|
# @return [String]
|
72
75
|
def tex_quote
|
73
|
-
strftime('%Y--%m--%d')
|
76
|
+
strftime('%Y--%m--%d').tex_quote
|
74
77
|
end
|
75
78
|
|
76
79
|
# :category: Formatting
|
data/lib/fat_core/numeric.rb
CHANGED
data/lib/fat_core/range.rb
CHANGED
data/lib/fat_core/string.rb
CHANGED
@@ -247,8 +247,8 @@ module FatCore
|
|
247
247
|
# characters) from both self and `matcher`,
|
248
248
|
# 2. Treat ':' in the matcher as the equivalent of '.*' in a regular
|
249
249
|
# expression, that is, match anything in self,
|
250
|
-
# 3.
|
251
|
-
# 4.
|
250
|
+
# 3. Require each component to match the beginning of a word boundary
|
251
|
+
# 4. Ignore case in the match
|
252
252
|
#
|
253
253
|
# @example
|
254
254
|
# "St. Luke's Hospital".fuzzy_match('st lukes') #=> 'St Lukes'
|
@@ -264,7 +264,7 @@ module FatCore
|
|
264
264
|
matcher = matcher.gsub(/[\*.,']/, '')
|
265
265
|
target = gsub(/[\*.,']/, '')
|
266
266
|
matchers = matcher.split(/[: ]+/)
|
267
|
-
regexp_string = matchers.map { |m| "
|
267
|
+
regexp_string = matchers.map { |m| ".*?\\b#{Regexp.escape(m)}.*?" }.join('[: ]')
|
268
268
|
regexp_string.sub!(/^\.\*\?/, '')
|
269
269
|
regexp_string.sub!(/\.\*\?$/, '')
|
270
270
|
regexp = /#{regexp_string}/i
|
data/lib/fat_core/version.rb
CHANGED
data/spec/lib/date_spec.rb
CHANGED
@@ -586,7 +586,7 @@ describe Date do
|
|
586
586
|
.to be_end_of_semimonth
|
587
587
|
end
|
588
588
|
|
589
|
-
it '
|
589
|
+
it 'knows about biweeks' do
|
590
590
|
expect(Date.parse('2013-11-07').beginning_of_biweek)
|
591
591
|
.to eq Date.parse('2013-11-04')
|
592
592
|
expect(Date.parse('2013-11-07').end_of_biweek)
|
@@ -599,16 +599,23 @@ describe Date do
|
|
599
599
|
.to eq Date.parse('2010-01-03')
|
600
600
|
end
|
601
601
|
|
602
|
-
it '
|
602
|
+
it 'knows that a Monday is the beginning of the week' do
|
603
|
+
# A Monday
|
603
604
|
expect(Date.parse('2013-11-04')).to be_beginning_of_week
|
604
|
-
expect(Date.parse('2013-11-10')).to be_end_of_week
|
605
605
|
expect(Date.parse('2013-12-02')).to be_beginning_of_week
|
606
|
-
|
606
|
+
# A Sunday
|
607
607
|
expect(Date.parse('2013-10-13')).to_not be_beginning_of_week
|
608
|
+
end
|
609
|
+
|
610
|
+
it 'knows that a Sunday is the end of the week' do
|
611
|
+
# A Sunday
|
612
|
+
expect(Date.parse('2013-11-10')).to be_end_of_week
|
613
|
+
expect(Date.parse('2013-12-08')).to be_end_of_week
|
614
|
+
# A Saturday
|
608
615
|
expect(Date.parse('2013-10-19')).to_not be_end_of_week
|
609
616
|
end
|
610
617
|
|
611
|
-
it 'should know the beginning of chunks' do
|
618
|
+
it 'should know the beginning of non-week chunks' do
|
612
619
|
expect(Date.parse('2013-11-04').beginning_of_chunk(:year))
|
613
620
|
.to eq Date.parse('2013-01-01')
|
614
621
|
expect(Date.parse('2013-11-04').beginning_of_chunk(:half))
|
@@ -623,10 +630,30 @@ describe Date do
|
|
623
630
|
.to eq Date.parse('2013-11-01')
|
624
631
|
expect(Date.parse('2013-11-24').beginning_of_chunk(:semimonth))
|
625
632
|
.to eq Date.parse('2013-11-16')
|
633
|
+
end
|
634
|
+
|
635
|
+
it 'knows the beginning and end of bi-week-based chunks' do
|
636
|
+
# First Friday to prior Monday
|
626
637
|
expect(Date.parse('2013-11-08').beginning_of_chunk(:biweek))
|
627
638
|
.to eq Date.parse('2013-11-04')
|
639
|
+
# Second Wednesday to 2 prior Monday
|
640
|
+
expect(Date.parse('2013-11-13').beginning_of_chunk(:biweek))
|
641
|
+
.to eq Date.parse('2013-11-04')
|
642
|
+
end
|
643
|
+
|
644
|
+
it 'knows the beginning and end of week-based chunks' do
|
645
|
+
# A Friday to prior Monday
|
628
646
|
expect(Date.parse('2013-11-08').beginning_of_chunk(:week))
|
629
647
|
.to eq Date.parse('2013-11-04')
|
648
|
+
# A Friday to following Sunday
|
649
|
+
expect(Date.parse('2013-11-08').end_of_chunk(:week))
|
650
|
+
.to eq Date.parse('2013-11-10')
|
651
|
+
# A Sunday to prior Monday
|
652
|
+
expect(Date.parse('2013-11-10').beginning_of_chunk(:week))
|
653
|
+
.to eq Date.parse('2013-11-04')
|
654
|
+
# A Sunday to itself
|
655
|
+
expect(Date.parse('2013-11-10').end_of_chunk(:week))
|
656
|
+
.to eq Date.parse('2013-11-10')
|
630
657
|
expect {
|
631
658
|
Date.parse('2013-11-04').beginning_of_chunk(:wek)
|
632
659
|
}.to raise_error(ArgumentError)
|
data/spec/lib/string_spec.rb
CHANGED
@@ -245,7 +245,7 @@ the people, for the people, shall not perish from the earth."
|
|
245
245
|
|
246
246
|
describe 'Matching' do
|
247
247
|
it 'should be able to fuzzy match with another string' do
|
248
|
-
expect('Hello, world'.fuzzy_match('
|
248
|
+
expect('Hello, world'.fuzzy_match('wor')).to be_truthy
|
249
249
|
expect('Hello, world'.fuzzy_match('ox')).to be_falsy
|
250
250
|
end
|
251
251
|
|
@@ -255,23 +255,23 @@ the people, for the people, shall not perish from the earth."
|
|
255
255
|
end
|
256
256
|
|
257
257
|
it 'should be able to fuzzy match space-separated parts' do
|
258
|
-
expect('Hello world'.fuzzy_match('hel
|
258
|
+
expect('Hello world'.fuzzy_match('hel wor')).to be_truthy
|
259
259
|
expect('Hello, world'.fuzzy_match('hel ox')).to be_falsy
|
260
260
|
end
|
261
261
|
|
262
262
|
it 'should be able to fuzzy match colon-separated parts' do
|
263
|
-
expect('Hello:world'.fuzzy_match('hel:
|
263
|
+
expect('Hello:world'.fuzzy_match('hel:wor')).to be_truthy
|
264
264
|
expect('Hello:world'.fuzzy_match('hel:ox')).to be_falsy
|
265
265
|
end
|
266
266
|
|
267
267
|
it 'should be able to fuzzy match colon-separated parts' do
|
268
|
-
expect('Hello:world'.fuzzy_match('hel:
|
268
|
+
expect('Hello:world'.fuzzy_match('hel:wor')).to be_truthy
|
269
269
|
expect('Hello:world'.fuzzy_match('hel:ox')).to be_falsy
|
270
270
|
end
|
271
271
|
|
272
272
|
it 'should return the matched text' do
|
273
273
|
expect('Hello:world'.fuzzy_match('hel')).to eq('Hel')
|
274
|
-
expect('Hello:world'.fuzzy_match('hel:
|
274
|
+
expect('Hello:world'.fuzzy_match('hel:wor')).to eq('Hello:wor')
|
275
275
|
expect('Hello:world'.matches_with('/^h.*r/')).to eq('Hello:wor')
|
276
276
|
end
|
277
277
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
require 'simplecov'
|
2
2
|
SimpleCov.command_name 'Rspec'
|
3
|
-
SimpleCov.start
|
4
3
|
|
5
4
|
require 'bundler/setup'
|
6
5
|
Bundler.setup
|
7
6
|
|
8
7
|
require 'pry'
|
9
|
-
require '
|
8
|
+
require 'debug'
|
10
9
|
|
11
10
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
12
11
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
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.
|
4
|
+
version: 4.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel E. Doherty
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simplecov
|
@@ -39,21 +39,21 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: debug
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 1.0.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 1.0.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -108,20 +108,6 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: pry-byebug
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
112
|
name: redcarpet
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -189,6 +175,7 @@ files:
|
|
189
175
|
- ".gitignore"
|
190
176
|
- ".rspec"
|
191
177
|
- ".rubocop.yml"
|
178
|
+
- ".simplecov"
|
192
179
|
- ".travis.yml"
|
193
180
|
- ".yardopts"
|
194
181
|
- Gemfile
|
@@ -232,7 +219,7 @@ licenses:
|
|
232
219
|
- MIT
|
233
220
|
metadata:
|
234
221
|
yard.run: yri
|
235
|
-
post_install_message:
|
222
|
+
post_install_message:
|
236
223
|
rdoc_options: []
|
237
224
|
require_paths:
|
238
225
|
- lib
|
@@ -248,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
248
235
|
version: '0'
|
249
236
|
requirements: []
|
250
237
|
rubygems_version: 3.3.3
|
251
|
-
signing_key:
|
238
|
+
signing_key:
|
252
239
|
specification_version: 4
|
253
240
|
summary: fat_core provides some useful core extensions
|
254
241
|
test_files:
|