fat_core 5.4.0 → 5.5.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/bin/easter +45 -0
- data/fat_core.gemspec +2 -0
- data/lib/fat_core/date.rb +3 -4
- data/lib/fat_core/version.rb +1 -1
- data/lib/fat_core.rb +4 -2
- data/spec/lib/date_spec.rb +1 -0
- data/spec/spec_helper.rb +1 -0
- metadata +32 -4
- data/bin/easters +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76bee6cef8acc3f947d63674a3010b4dd98ec22e84761fd4413380ac7223957a
|
4
|
+
data.tar.gz: a3c464aee07bfbeadde7ed71080f6e050821d7f1cf643918d500625f41d629c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce57c6eb8ddc922e9508d82e92b6dc3b3123d1221cac98dae6f031c5835927c8f77154c6cd90e0e3e65c76c78b4ca215da43a45cccaced0c690b799b6886db21
|
7
|
+
data.tar.gz: 7c318d70e0891931511946e5752998de1363f15ef6a3277837aa913e6e4d003c8ec0fbfa0ff0896ec1e7a99f92e6b023335b195b6b91f2128a6bbb98fc4eb664
|
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
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
|
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
|
|
@@ -1834,6 +1832,7 @@ module FatCore
|
|
1834
1832
|
# @param year [Integer] the year of interest
|
1835
1833
|
# @return [::Date] the date of Easter for year
|
1836
1834
|
def easter(year)
|
1835
|
+
year = year.to_i
|
1837
1836
|
y = year
|
1838
1837
|
a = y % 19
|
1839
1838
|
b, c = y.divmod(100)
|
data/lib/fat_core/version.rb
CHANGED
data/lib/fat_core.rb
CHANGED
data/spec/lib/date_spec.rb
CHANGED
@@ -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
|
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,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fat_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.5.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: 2024-11-
|
11
|
+
date: 2024-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ostruct
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: stringio
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.1.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.1.2
|
41
69
|
description: |
|
42
70
|
Useful extensions to Date, String, Range and other classes
|
43
71
|
including useful Date extensions for dealing with US Federal
|
@@ -47,7 +75,7 @@ description: |
|
|
47
75
|
email:
|
48
76
|
- ded@ddoherty.net
|
49
77
|
executables:
|
50
|
-
-
|
78
|
+
- easter
|
51
79
|
extensions: []
|
52
80
|
extra_rdoc_files: []
|
53
81
|
files:
|
@@ -64,7 +92,7 @@ files:
|
|
64
92
|
- Rakefile
|
65
93
|
- TODO.org
|
66
94
|
- bin/console
|
67
|
-
- bin/
|
95
|
+
- bin/easter
|
68
96
|
- fat_core.gemspec
|
69
97
|
- lib/fat_core.rb
|
70
98
|
- lib/fat_core/ChangeLog
|
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")
|