fat_core 5.4.0 → 5.5.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: 6915be154abea741bce220665d425858a13c22aacdcff27952fda89627d0349c
4
- data.tar.gz: 82fbae6f418d862154ba909c1f6097d2b82f020eddb740fa207285ee9bb8db3a
3
+ metadata.gz: 76bee6cef8acc3f947d63674a3010b4dd98ec22e84761fd4413380ac7223957a
4
+ data.tar.gz: a3c464aee07bfbeadde7ed71080f6e050821d7f1cf643918d500625f41d629c0
5
5
  SHA512:
6
- metadata.gz: 71698e9642833bd200638b30b879b86eaf21f44ee690048299597982ee0abfb4ddbd2302f3b87d649dcd4963f35de8e04f79cda705fda72cb0bcfb8efb3ae158
7
- data.tar.gz: 03407fbd6b3340c9742df04dff407ddd695ebd2ecb7f47ff7304e095be8b27aac933a48573d35279e20b6f3df922908f2d4d3f9043fcac29296dbc3d9ca84228
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
@@ -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
 
@@ -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)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module FatCore
4
4
  MAJOR = 5
5
- MINOR = 4
5
+ MINOR = 5
6
6
  PATCH = 0
7
7
 
8
8
  # FatCore version number
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
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.0
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 00:00:00.000000000 Z
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
- - easters
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/easters
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")