fat_core 5.4.0 → 5.5.1

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
  SHA256:
3
- metadata.gz: 6915be154abea741bce220665d425858a13c22aacdcff27952fda89627d0349c
4
- data.tar.gz: 82fbae6f418d862154ba909c1f6097d2b82f020eddb740fa207285ee9bb8db3a
3
+ metadata.gz: e1d33a9870d8ccce5d113d794887245fbf460f7e0b7d3985232d15747c566f81
4
+ data.tar.gz: a3e9ee377b71fff964bf72d1a7f7cd732a48160aa2e999c72917854c4385b6d3
5
5
  SHA512:
6
- metadata.gz: 71698e9642833bd200638b30b879b86eaf21f44ee690048299597982ee0abfb4ddbd2302f3b87d649dcd4963f35de8e04f79cda705fda72cb0bcfb8efb3ae158
7
- data.tar.gz: 03407fbd6b3340c9742df04dff407ddd695ebd2ecb7f47ff7304e095be8b27aac933a48573d35279e20b6f3df922908f2d4d3f9043fcac29296dbc3d9ca84228
6
+ metadata.gz: 96f62693a783e002ebc46d390daae93fd3d5e234e2ddfcd94b116dd2a56c60c551413a30b6ee3a7d3ae5bb1bae58e4c4526bb0cdf4757737b3dbe077757928d9
7
+ data.tar.gz: 5975a2e7eaf800668e17104e3285cf28627d6c6f21ef205f8a092e001def9149b0847bd1e62b442fb49d493e1ae2ff2d736e4648859d1c26ef64e43b14b14772
data/bin/easter ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "debug"
5
+ require 'fat_core/date'
6
+
7
+ usage = <<~HELP
8
+ USAGE:
9
+ easter -- print the date of Easter for the current year
10
+ easter year -- print the date of Easter for the given year
11
+ easter year1 year2 -- print the dates of Easter from year1 to year2
12
+
13
+ Note: if the date of Easter is the earliest possible, it is marked with a '<';
14
+ if it is the latest date possible, it is marked with a '>'
15
+ HELP
16
+ first, last = *ARGV
17
+ first ||= Date.today.year
18
+ last ||= Date.today.year
19
+
20
+ if first.to_s.match?(/--help|-h/)
21
+ puts usage
22
+ exit(1)
23
+ end
24
+
25
+ begin
26
+ first = Integer(first)
27
+ last = Integer(last)
28
+ rescue ArgumentError
29
+ warn "!!Error: invalid year number given\n\n"
30
+ puts usage
31
+ exit(2)
32
+ end
33
+
34
+ (first..last).each do |yr|
35
+ easter = Date.easter(yr)
36
+ sig =
37
+ if easter.month == 4 && easter.day >= 25
38
+ ' >'
39
+ elsif easter.month == 3 && easter.day <= 22
40
+ ' <'
41
+ else
42
+ ''
43
+ end
44
+ puts "Easter #{yr}: #{easter.iso}#{sig}"
45
+ end
data/fat_core.gemspec CHANGED
@@ -27,4 +27,6 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_dependency 'activesupport'
29
29
  spec.add_dependency 'damerau-levenshtein'
30
+ spec.add_dependency 'ostruct'
31
+ spec.add_dependency 'stringio', '>=3.1.2'
30
32
  end
data/lib/fat_core/date.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'date'
4
- require 'active_support'
5
3
  require 'active_support/core_ext/date'
6
4
  require 'active_support/core_ext/time'
7
5
  require 'active_support/core_ext/numeric/time'
@@ -58,7 +56,7 @@ module FatCore
58
56
  EOT = ::Date.parse('3000-12-31')
59
57
 
60
58
  # Symbols for each of the days of the week, e.g., :sunday, :monday, etc.
61
- DAYSYMS = ::Date::DAYNAMES.map(&:downcase).map(&:to_sym)
59
+ DAYSYMS = ::Date::DAYNAMES.map { |name| name.downcase.to_sym }
62
60
 
63
61
  # :category: Formatting
64
62
  # @group Formatting
@@ -532,7 +530,7 @@ module FatCore
532
530
  else
533
531
  # One of the days before the start of the year's first week, so it
534
532
  # belongs to the last week of the prior year.
535
- Date.new(year - 1, 12, 31).week_number
533
+ ::Date.new(year - 1, 12, 31).week_number
536
534
  end
537
535
  end
538
536
 
@@ -944,7 +942,9 @@ module FatCore
944
942
  ::Date.parse('2018-12-24'),
945
943
  ::Date.parse('2019-12-24'),
946
944
  ::Date.parse('2020-12-24'),
947
- ].freeze
945
+ # Biden
946
+ ::Date.parse('2024-12-24'),
947
+ ]
948
948
 
949
949
  # Presidential funeral since JFK
950
950
  PRESIDENTIAL_FUNERALS = [
@@ -964,7 +964,9 @@ module FatCore
964
964
  ::Date.parse('2007-01-02'),
965
965
  # GHWBFuneral
966
966
  ::Date.parse('2018-12-05'),
967
- ].freeze
967
+ # JEC Funeral
968
+ ::Date.parse('2018-12-05'),
969
+ ]
968
970
 
969
971
  # Return whether this date is a United States federal holiday.
970
972
  #
@@ -1834,6 +1836,7 @@ module FatCore
1834
1836
  # @param year [Integer] the year of interest
1835
1837
  # @return [::Date] the date of Easter for year
1836
1838
  def easter(year)
1839
+ year = year.to_i
1837
1840
  y = year
1838
1841
  a = y % 19
1839
1842
  b, c = y.divmod(100)
@@ -2,8 +2,8 @@
2
2
 
3
3
  module FatCore
4
4
  MAJOR = 5
5
- MINOR = 4
6
- PATCH = 0
5
+ MINOR = 5
6
+ PATCH = 1
7
7
 
8
8
  # FatCore version number
9
9
  VERSION = [MAJOR, MINOR, PATCH].compact.join('.')
data/lib/fat_core.rb CHANGED
@@ -1,5 +1,7 @@
1
- require 'fat_core/version'
2
- require 'fat_core/patches'
1
+ require 'date'
3
2
  require 'active_support'
4
3
  require 'active_support/core_ext/object/blank'
5
4
  require 'active_support/core_ext/object/deep_dup'
5
+
6
+ require 'fat_core/version'
7
+ require 'fat_core/patches'
@@ -1069,6 +1069,7 @@ describe Date do
1069
1069
  describe 'holidays' do
1070
1070
  it 'knows Easter in its year' do
1071
1071
  expect(described_class.today.easter_this_year).to eq(described_class.parse('2012-04-08'))
1072
+ expect(Date.easter(2012)).to eq(Date.parse('2012-04-08'))
1072
1073
  expect(described_class.parse('2014-04-20').easter?).to be true
1073
1074
  expect(described_class.parse('2014-03-20').easter?).to be false
1074
1075
  end
@@ -139,7 +139,7 @@ the people, for the people, shall not perish from the earth."
139
139
  expect('-8.008'.number?).to be true
140
140
  expect('8.008e33'.number?).to be true
141
141
  expect('-8.008e33'.number?).to be true
142
- expect('0x8.008'.number?).to be false
142
+ expect('0x8.008'.number?).to be_truthy
143
143
  expect('hello world'.number?).to be false
144
144
  end
145
145
  end
data/spec/spec_helper.rb CHANGED
@@ -8,6 +8,7 @@ require 'pry'
8
8
  require 'debug'
9
9
 
10
10
  require 'active_support/testing/time_helpers'
11
+ require 'fat_core'
11
12
 
12
13
  # This file was generated by the `rspec --init` command. Conventionally, all
13
14
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fat_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.0
4
+ version: 5.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-11 00:00:00.000000000 Z
10
+ date: 2025-02-23 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -38,6 +37,34 @@ dependencies:
38
37
  - - ">="
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: ostruct
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: stringio
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 3.1.2
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 3.1.2
41
68
  description: |
42
69
  Useful extensions to Date, String, Range and other classes
43
70
  including useful Date extensions for dealing with US Federal
@@ -47,7 +74,7 @@ description: |
47
74
  email:
48
75
  - ded@ddoherty.net
49
76
  executables:
50
- - easters
77
+ - easter
51
78
  extensions: []
52
79
  extra_rdoc_files: []
53
80
  files:
@@ -64,7 +91,7 @@ files:
64
91
  - Rakefile
65
92
  - TODO.org
66
93
  - bin/console
67
- - bin/easters
94
+ - bin/easter
68
95
  - fat_core.gemspec
69
96
  - lib/fat_core.rb
70
97
  - lib/fat_core/ChangeLog
@@ -99,7 +126,6 @@ licenses:
99
126
  - MIT
100
127
  metadata:
101
128
  yard.run: yri
102
- post_install_message:
103
129
  rdoc_options: []
104
130
  require_paths:
105
131
  - lib
@@ -114,8 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
140
  - !ruby/object:Gem::Version
115
141
  version: '0'
116
142
  requirements: []
117
- rubygems_version: 3.5.22
118
- signing_key:
143
+ rubygems_version: 3.6.3
119
144
  specification_version: 4
120
145
  summary: some useful core extensions
121
146
  test_files: []
data/bin/easters DELETED
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- #
5
- # This file was generated by Bundler.
6
- #
7
- # The application 'easters' is installed as part of a gem, and
8
- # this file is here to facilitate running it.
9
- #
10
-
11
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
-
13
- bundle_binstub = File.expand_path("bundle", __dir__)
14
-
15
- if File.file?(bundle_binstub)
16
- if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
17
- load(bundle_binstub)
18
- else
19
- abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20
- Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21
- end
22
- end
23
-
24
- require "rubygems"
25
- require "bundler/setup"
26
-
27
- load Gem.bin_path("fat_core", "easters")