fat_core 4.9.0 → 4.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4ec4463c5e5a2ba5718fea513be1cf2f01aba020205b05688a24b5e8d08c3a4
4
- data.tar.gz: 4133d30f997f69bacacc5975c85deb7614b7c95571aea1166a02fd204c984169
3
+ metadata.gz: 3860db07c85484c1d82e2fafa18d730e7dedb991f33868b21c2c11d3e56c7fde
4
+ data.tar.gz: 524ca9b2ecdd017b5f14d8ff70e787d550bdf0a3eb4769be6442c3df914f965c
5
5
  SHA512:
6
- metadata.gz: fb8fc88f40ca65406599bce7d26e4ef1d3b804369813ec708664c7ef3265fe03fc548066ed1bcae0639a2ea007e46bba352c838350ad5c8d16eabaeede02f092
7
- data.tar.gz: e53428dd7cd1cf4ae7c532f455a5c9fc6ec8d106e5f60f7c0f46e621ee97126ae48954862485727a3c0abdc42f70bdeb5bb32587e5c29eca893edad268333546
6
+ metadata.gz: fda77f07f98048d111fdf752b115595f1b3b79e8f2c6b1d73482edfcb9e89ad45f6d46331fca04b3cabab3f1ab2f4da91675de5b8c4965943aa12d4902501839
7
+ data.tar.gz: 37a9824e50cdc58880d081007c70b9e5b4d6c338f381139ad178e936d68da24e19a6b188298072da9df7444b88eacfa9ed362bcb2767092abdb6f532e93e7089
data/.rubocop.yml CHANGED
@@ -14,3 +14,6 @@ Style/MethodCallWithArgsParentheses:
14
14
  Style/ClassAndModuleChildren:
15
15
  Exclude:
16
16
  - 'test/**/*'
17
+
18
+ Style/StringLiterals:
19
+ Enabled: false
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,14 +24,14 @@ 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'
33
+ spec.add_development_dependency 'solargraph'
34
34
 
35
- spec.add_runtime_dependency 'activesupport'
35
+ spec.add_runtime_dependency 'activesupport', '~>6.0'
36
36
  spec.add_runtime_dependency 'damerau-levenshtein'
37
37
  end
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
@@ -860,6 +863,7 @@ module FatCore
860
863
  # And Trump
861
864
  ::Date.parse('2018-12-24'),
862
865
  ::Date.parse('2019-12-24'),
866
+ ::Date.parse('2020-12-24'),
863
867
  ].freeze
864
868
 
865
869
  # Presidential funeral since JFK
@@ -148,7 +148,7 @@ module FatCore
148
148
  # Quote self for use in TeX documents. Since number components are not
149
149
  # special to TeX, this just applies `#to_s`
150
150
  def tex_quote
151
- to_s
151
+ to_s.tex_quote
152
152
  end
153
153
  end
154
154
  end
@@ -193,7 +193,7 @@ module FatCore
193
193
  #
194
194
  # @return [String]
195
195
  def tex_quote
196
- to_s
196
+ to_s.tex_quote
197
197
  end
198
198
 
199
199
  # @group Queries
@@ -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. Ignore case in the match
251
- # 4. Match if any part of self matches `matcher`
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| ".*?#{Regexp.escape(m)}.*?" }.join('[: ]')
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  module FatCore
4
4
  MAJOR = 4
5
- MINOR = 9
5
+ MINOR = 10
6
6
  PATCH = 0
7
7
 
8
8
  # FatCore version number
data/lib/fat_core.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'fat_core/version'
2
2
  require 'fat_core/patches'
3
+ require 'active_support'
3
4
  require 'active_support/core_ext/object/blank'
4
5
  require 'active_support/core_ext/object/deep_dup'
@@ -586,7 +586,7 @@ describe Date do
586
586
  .to be_end_of_semimonth
587
587
  end
588
588
 
589
- it 'should know about biweeks' do
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 'should know about weeks' do
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
- expect(Date.parse('2013-12-08')).to be_end_of_week
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)
@@ -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('or')).to be_truthy
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 or')).to be_truthy
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:or')).to be_truthy
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:or')).to be_truthy
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:or')).to eq('Hello:wor')
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 'pry-byebug'
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.9.0
4
+ version: 4.10.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: 2021-02-15 00:00:00.000000000 Z
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: rake
42
+ name: debug
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
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: '0'
54
+ version: 1.0.0
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
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: byebug
70
+ name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: pry-byebug
112
+ name: redcarpet
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: redcarpet
126
+ name: solargraph
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -140,16 +140,16 @@ dependencies:
140
140
  name: activesupport
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ">="
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '0'
145
+ version: '6.0'
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ">="
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '0'
152
+ version: '6.0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: damerau-levenshtein
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -175,6 +175,7 @@ files:
175
175
  - ".gitignore"
176
176
  - ".rspec"
177
177
  - ".rubocop.yml"
178
+ - ".simplecov"
178
179
  - ".travis.yml"
179
180
  - ".yardopts"
180
181
  - Gemfile
@@ -233,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
234
  - !ruby/object:Gem::Version
234
235
  version: '0'
235
236
  requirements: []
236
- rubygems_version: 3.2.3
237
+ rubygems_version: 3.3.3
237
238
  signing_key:
238
239
  specification_version: 4
239
240
  summary: fat_core provides some useful core extensions