fat_core 4.12.0 → 4.13.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: 293a92293691aebd9771c017fa1dfeb9f9935bbb3832a19ec3494df49a75a176
4
- data.tar.gz: 273ca4995d0e8b5d95cb5103ce520643f5aca983a0d855b083deb7d052033b63
3
+ metadata.gz: 7d44c04c1eb71914c9c92ddedc40632d8b62c0adb20a49e74f1f04fd0bfb7a5c
4
+ data.tar.gz: 8e1437d71a5aaced95860f90c99acdff7ced1313210ea770bc895af4aeab7e7e
5
5
  SHA512:
6
- metadata.gz: b6f8fe6dc824a53d5087a2565a16bda84f7c311514346b3c0dcc58d9822b3dc84b3a93f9070dc1d27fce4aba90841556a3251a3e72d065f92b78f82402e9f73a
7
- data.tar.gz: 2aab09471276331aa009b76250e9dd163ca1512b135170495bd5d899cd46d575d3aa0c29d14a923781ee99606ebffb4a7d434a37c47d10be73c8dba363f254d0
6
+ metadata.gz: 25e90359637e217e73deccc7074dfdf42d88f57585a1ee0726375665fcd7e05afce333e14db47446b3e5a1b92bba8e41cb2d1d5b74813f96e6e356dfad2cea90
7
+ data.tar.gz: ddb016bf03fe574fab1cd1ce7447fd646af183f0014a927054c6b06368c47404320c7f83fcd8e5df757594597cc9086ec1c2c7f72fccc71bfb5fad0f689fae93
data/.rubocop.yml CHANGED
@@ -1,19 +1,25 @@
1
- inherit_gem:
2
- rubocop-shopify: rubocop.yml
1
+ inherit_from:
2
+ - ~/.rubocop.yml
3
3
 
4
- AllCops:
5
- TargetRubyVersion: 2.7
6
- Exclude:
7
- - 'test/tmp/**/*'
8
- - 'vendor/bundle/**/*'
4
+ # inherit_gem:
5
+ # rubocop-shopify: rubocop.yml
9
6
 
10
- Style/MethodCallWithArgsParentheses:
11
- Exclude:
12
- - '**/Gemfile'
7
+ # require:
8
+ # - rubocop-rspec
13
9
 
14
- Style/ClassAndModuleChildren:
15
- Exclude:
16
- - 'test/**/*'
10
+ # AllCops:
11
+ # TargetRubyVersion: 2.7
12
+ # Exclude:
13
+ # - 'test/tmp/**/*'
14
+ # - 'vendor/bundle/**/*'
17
15
 
18
- Style/StringLiterals:
19
- Enabled: false
16
+ # Style/MethodCallWithArgsParentheses:
17
+ # Exclude:
18
+ # - '**/Gemfile'
19
+
20
+ # Style/ClassAndModuleChildren:
21
+ # Exclude:
22
+ # - 'test/**/*'
23
+
24
+ # Style/StringLiterals:
25
+ # Enabled: false
data/fat_core.gemspec CHANGED
@@ -1,16 +1,20 @@
1
1
  # coding: utf-8
2
2
 
3
- lib = File.expand_path('../lib', __FILE__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'fat_core/version'
3
+ require_relative 'lib/fat_core/version'
6
4
 
7
5
  Gem::Specification.new do |spec|
8
6
  spec.name = 'fat_core'
9
7
  spec.version = FatCore::VERSION
10
8
  spec.authors = ['Daniel E. Doherty']
11
9
  spec.email = ['ded@ddoherty.net']
12
- spec.summary = 'fat_core provides some useful core extensions'
13
- spec.description = 'Useful extensions to Date, String, Range and other classes'
10
+ spec.summary = 'some useful core extensions'
11
+ spec.description = <<~DESC
12
+ Useful extensions to Date, String, Range and other classes
13
+ including useful Date extensions for dealing with US Federal
14
+ and New York Stock Exchange holidays and working days, a useful
15
+ Enumerable#each_with_flags for flagging first and last items in the
16
+ iteration, (also for Hash), set operations on Ranges
17
+ DESC
14
18
  spec.homepage = 'https://github.com/ddoherty03/fat_core.git'
15
19
  spec.license = 'MIT'
16
20
  spec.required_ruby_version = '>= 2.2.2'
@@ -4,6 +4,7 @@ require 'bigdecimal'
4
4
  require 'fat_core/patches'
5
5
  require 'damerau-levenshtein'
6
6
  require 'active_support/core_ext/regexp'
7
+ require_relative 'numeric'
7
8
 
8
9
  module FatCore
9
10
  module String
@@ -245,8 +246,9 @@ module FatCore
245
246
  #
246
247
  # 1. Remove all periods, commas, apostrophes, and asterisks (the punctuation
247
248
  # characters) from both self and `matcher`,
248
- # 2. Treat internal ':' in the matcher as the equivalent of '.*' in a
249
- # regular expression, that is, match anything in self,
249
+ # 2. Treat internal ':stuff' in the matcher as the equivalent of
250
+ # '\bstuff.*?\b' in a regular expression, that is, match any word
251
+ # starting with stuff in self,
250
252
  # 3. Treat leading ':' in the matcher as anchoring the match to the
251
253
  # beginning of the target string,
252
254
  # 4. Treat ending ':' in the matcher as anchoring the match to the
@@ -278,7 +280,7 @@ module FatCore
278
280
  end
279
281
  target = gsub(/[\*.,']/, '')
280
282
  matchers = matcher.split(/[: ]+/)
281
- regexp_string = matchers.map { |m| ".*?\\b#{Regexp.escape(m)}.*?" }.join('[: ]')
283
+ regexp_string = matchers.map { |m| ".*?\\b#{Regexp.escape(m)}.*?" }.join('\\b')
282
284
  regexp_string.sub!(/^\.\*\?/, '')
283
285
  regexp_string.sub!(/\.\*\?$/, '')
284
286
  regexp_string.sub!(/\A/, '\\A') if begin_anchor
@@ -364,70 +366,7 @@ module FatCore
364
366
  numeric_re = /\A([-+])?([\d_]*)((\.)?([\d_]*))?([eE][+-]?[\d_]+)?\z/
365
367
  return self unless clean =~ numeric_re
366
368
 
367
- sig = $1 || ''
368
- whole = $2 ? $2.delete('_') : ''
369
- frac = $5 || ''
370
- exp = $6 || ''
371
-
372
- # Round frac or whole if places given. For positve places, round fraction
373
- # to that many places; for negative, round the whole-number part to the
374
- # absolute value of places left of the decimal.
375
- if places
376
- new_frac = frac.dup
377
- new_whole = whole.dup
378
- if places.zero?
379
- new_frac = ''
380
- elsif places.positive? && places < frac.length
381
- new_frac = frac[0...places - 1]
382
- new_frac[places - 1] =
383
- if frac[places].to_i >= 5
384
- (frac[places - 1].to_i + 1).to_s
385
- else
386
- frac[places - 1]
387
- end
388
- elsif places >= frac.length
389
- new_frac = frac + '0' * (places - frac.length)
390
- else
391
- # Negative places, round whole to places.abs from decimal
392
- places = places.abs
393
- if places > whole.length
394
- lead = whole[0].to_i >= 5 ? '1' : '0'
395
- new_whole[0] = places == whole.length + 1 ? lead : '0'
396
- new_whole[1..-1] = '0' * (places - 1)
397
- new_frac = ''
398
- elsif places > 1
399
- target = whole.length - places
400
- new_whole[target] =
401
- if whole[target + 1].to_i >= 5
402
- (whole[target].to_i + 1).to_s
403
- else
404
- whole[target]
405
- end
406
- new_whole[target + 1..whole.length - 1] =
407
- '0' * (whole.length - target - 1)
408
- new_frac = ''
409
- else
410
- # Rounding to 1 place, therefore, no rounding
411
- new_frac = ''
412
- new_whole = whole
413
- end
414
- end
415
- frac = new_frac
416
- whole = new_whole
417
- end
418
-
419
- # Place the commas in the whole part only
420
- whole = whole.reverse
421
- whole.gsub!(/([0-9]{3})/, '\\1,')
422
- whole.gsub!(/,$/, '')
423
- whole.reverse!
424
-
425
- # Reassemble
426
- if frac.blank?
427
- sig + whole + exp
428
- else
429
- sig + whole + '.' + frac + exp
430
- end
369
+ to_f.commas(places)
431
370
  end
432
371
 
433
372
  module ClassMethods
@@ -2,7 +2,7 @@
2
2
 
3
3
  module FatCore
4
4
  MAJOR = 4
5
- MINOR = 12
5
+ MINOR = 13
6
6
  PATCH = 0
7
7
 
8
8
  # FatCore version number
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  require 'fat_core/array'
4
4
 
5
5
  describe Array do
6
- it 'should be able to report its last index' do
6
+ it 'reports its last index' do
7
7
  letters = ('a'..'z').to_a
8
8
  expect(letters.last_i).to eq(25)
9
9
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'fat_core/bigdecimal'
3
3
 
4
4
  describe BigDecimal do
5
- it 'should provide a human-readable inspect for BigDecimal' do
5
+ it 'provides a human-readable inspect for BigDecimal' do
6
6
  expect(BigDecimal('33.45').inspect).to eq '33.45'
7
7
  end
8
8
  end