ae_bank_days 1.2.0 → 2.1.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: 06f9983d00ce48e33b4a934f726e456d1eb37daec1355aad31cf605f9c5ef0bd
4
- data.tar.gz: e3b17132d6696f57e38e2a1addac13d1ae4daa49fcb788dae5e553b66cec463f
3
+ metadata.gz: afad1460d6fb8acce458d2ad2dfabb29843d1a630162bd5043c5eb897b841d86
4
+ data.tar.gz: 54bdb02650c7a97a1161a357435c3d33fceb6f4286edb2b4a804a4267b3c97ef
5
5
  SHA512:
6
- metadata.gz: f43ac398011e018ece5207f6db467339a3b9255451627cad5cd5e970b3d08512d38c3ae9d09604ddf09d177a30febdbf98d7e5e5ba6ef8329c9122aea7424e8b
7
- data.tar.gz: b0e66f75d0ea3c5ac6d39a7240e3a284af57968292e69a5b14dbfb1753273bc21a425ab9b67e0b8f5bcedffd8bc87a7d77cca0959b6944d0a3d75105087a4c00
6
+ metadata.gz: b4acb7565fd8647e9f9a705b29fe7ccd4a76ae943f54945a04c3a02028a5fe93e4ac559b0ab895208c6104f0641d45869ca8e7d87a684b0ac04de89be93b2414
7
+ data.tar.gz: cf0fd6a295074b5b53f3b25590d614cc0e9f2d97a7e5612b2857667e48215a6da755b29066a3a7e6ce834619591ecda515f735910d0c60b4c3d5878fdbeee005
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2019-2020 AppFolio inc
1
+ Copyright (c) 2019-2022 AppFolio, Inc
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/ae_bank_days.gemspec CHANGED
@@ -1,31 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'ae_bank_days/version'
3
+ require_relative 'lib/ae_bank_days/version'
6
4
 
7
5
  Gem::Specification.new do |spec|
8
6
  spec.name = 'ae_bank_days'
9
7
  spec.version = AeBankDays::VERSION
10
8
  spec.platform = Gem::Platform::RUBY
11
- spec.authors = ['AppFolio']
12
- spec.email = ['dev@appfolio.com']
13
- spec.summary = 'Gem for finding the next banking date'
14
- spec.description = spec.summary
15
- spec.homepage = 'http://github.com/appfolio/ae_bank_days'
16
- spec.required_ruby_version = ['>= 2.3.3', '< 2.7']
17
- spec.licenses = ['MIT']
18
- spec.files = Dir['**/*'].reject { |f| f[%r{^log/}] || f[%r{^pkg/}] }
19
- spec.test_files = spec.files.grep(%r{^(test)/})
9
+ spec.author = 'AppFolio'
10
+ spec.email = 'opensource@appfolio.com'
11
+ spec.description = 'Gem for finding the next banking date.'
12
+ spec.summary = spec.description
13
+ spec.homepage = 'https://github.com/appfolio/ae_bank_days'
14
+ spec.license = 'MIT'
15
+ spec.files = Dir['**/*'].select { |f| f[%r{^(lib/|LICENSE.txt|.*gemspec)}] }
20
16
  spec.require_paths = ['lib']
17
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.6.3')
21
18
 
22
19
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
23
20
 
24
- spec.add_dependency('holidays', '~> 8.3')
25
-
26
- spec.add_development_dependency('bundler', ['>= 1.10.4', '< 3'])
27
- spec.add_development_dependency('minitest', '>= 5.8')
28
- spec.add_development_dependency('minitest-reporters', '>= 1.3')
29
- spec.add_development_dependency('mocha', '>= 1.1')
30
- spec.add_development_dependency('rake', '>= 12.0')
21
+ spec.add_dependency('holidays', ['>= 8.3', '< 9'])
31
22
  end
@@ -11,23 +11,37 @@ module AeBankDays
11
11
  end
12
12
 
13
13
  def next_banking_day(date, number_of_days: 0)
14
- banking_day = date
14
+ banking_day = date.to_date
15
+ banking_day += 1
15
16
  number_of_days.times do
16
- banking_day += 1 until bank_day?(banking_day)
17
+ banking_day = current_or_next_banking_day(banking_day)
17
18
  banking_day += 1
18
19
  end
19
- banking_day += 1 until bank_day?(banking_day)
20
- banking_day
20
+
21
+ current_or_next_banking_day(banking_day)
21
22
  end
22
23
 
23
24
  def previous_banking_day(date, number_of_days: 0)
24
- banking_day = date
25
+ banking_day = date.to_date
26
+ banking_day -= 1
25
27
  number_of_days.times do
26
- banking_day -= 1 until bank_day?(banking_day)
28
+ banking_day = current_or_previous_banking_day(banking_day)
27
29
  banking_day -= 1
28
30
  end
29
- banking_day -= 1 until bank_day?(banking_day)
30
- banking_day
31
+
32
+ current_or_previous_banking_day(banking_day)
33
+ end
34
+
35
+ def current_or_previous_banking_day(day)
36
+ date = day.to_date
37
+ date -= 1 until bank_day?(date)
38
+ date
39
+ end
40
+
41
+ def current_or_next_banking_day(day)
42
+ date = day.to_date
43
+ date += 1 until bank_day?(date)
44
+ date
31
45
  end
32
46
 
33
47
  private
@@ -1,15 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AeBankDays
2
4
  module DateExtensions
3
5
  def bank_day?
4
6
  BankDayHelper.bank_day?(self)
5
7
  end
6
8
 
7
- def next_banking_day(n = 0)
8
- BankDayHelper.next_banking_day(self, number_of_days: n)
9
+ def next_banking_day(number_of_days = 0)
10
+ BankDayHelper.next_banking_day(self, number_of_days: number_of_days)
9
11
  end
10
12
 
11
- def previous_banking_day(n = 0)
12
- BankDayHelper.previous_banking_day(self, number_of_days: n)
13
+ def previous_banking_day(number_of_days = 0)
14
+ BankDayHelper.previous_banking_day(self, number_of_days: number_of_days)
13
15
  end
14
16
  end
15
17
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AeBankDays
4
- VERSION = '1.2.0'
4
+ VERSION = '2.1.0'
5
5
  end
data/lib/ae_bank_days.rb CHANGED
@@ -8,4 +8,4 @@ module AeBankDays
8
8
  autoload :DateExtensions, 'ae_bank_days/date_extensions'
9
9
  end
10
10
 
11
- Date.send :include, AeBankDays::DateExtensions
11
+ Date.prepend(AeBankDays::DateExtensions)
metadata CHANGED
@@ -1,127 +1,48 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ae_bank_days
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AppFolio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-14 00:00:00.000000000 Z
11
+ date: 2022-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: holidays
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '8.3'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '8.3'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - ">="
32
18
  - !ruby/object:Gem::Version
33
- version: 1.10.4
19
+ version: '8.3'
34
20
  - - "<"
35
21
  - !ruby/object:Gem::Version
36
- version: '3'
37
- type: :development
22
+ version: '9'
23
+ type: :runtime
38
24
  prerelease: false
39
25
  version_requirements: !ruby/object:Gem::Requirement
40
26
  requirements:
41
27
  - - ">="
42
28
  - !ruby/object:Gem::Version
43
- version: 1.10.4
29
+ version: '8.3'
44
30
  - - "<"
45
31
  - !ruby/object:Gem::Version
46
- version: '3'
47
- - !ruby/object:Gem::Dependency
48
- name: minitest
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '5.8'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '5.8'
61
- - !ruby/object:Gem::Dependency
62
- name: minitest-reporters
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: '1.3'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '1.3'
75
- - !ruby/object:Gem::Dependency
76
- name: mocha
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: '1.1'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: '1.1'
89
- - !ruby/object:Gem::Dependency
90
- name: rake
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: '12.0'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: '12.0'
103
- description: Gem for finding the next banking date
104
- email:
105
- - dev@appfolio.com
32
+ version: '9'
33
+ description: Gem for finding the next banking date.
34
+ email: opensource@appfolio.com
106
35
  executables: []
107
36
  extensions: []
108
37
  extra_rdoc_files: []
109
38
  files:
110
- - Gemfile
111
- - Gemfile.lock
112
39
  - LICENSE.txt
113
- - README.rdoc
114
- - Rakefile
115
40
  - ae_bank_days.gemspec
116
41
  - lib/ae_bank_days.rb
117
42
  - lib/ae_bank_days/bank_day_helper.rb
118
43
  - lib/ae_bank_days/date_extensions.rb
119
44
  - lib/ae_bank_days/version.rb
120
- - test/ae_bank_days/bank_day_helper_test.rb
121
- - test/ae_bank_days/date_extensions_test.rb
122
- - test/ae_bank_days_test.rb
123
- - test/test_helper.rb
124
- homepage: http://github.com/appfolio/ae_bank_days
45
+ homepage: https://github.com/appfolio/ae_bank_days
125
46
  licenses:
126
47
  - MIT
127
48
  metadata:
@@ -134,22 +55,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
55
  requirements:
135
56
  - - ">="
136
57
  - !ruby/object:Gem::Version
137
- version: 2.3.3
138
- - - "<"
139
- - !ruby/object:Gem::Version
140
- version: '2.7'
58
+ version: 2.6.3
141
59
  required_rubygems_version: !ruby/object:Gem::Requirement
142
60
  requirements:
143
61
  - - ">="
144
62
  - !ruby/object:Gem::Version
145
63
  version: '0'
146
64
  requirements: []
147
- rubygems_version: 3.0.3
65
+ rubygems_version: 3.3.3
148
66
  signing_key:
149
67
  specification_version: 4
150
- summary: Gem for finding the next banking date
151
- test_files:
152
- - test/ae_bank_days/bank_day_helper_test.rb
153
- - test/ae_bank_days/date_extensions_test.rb
154
- - test/ae_bank_days_test.rb
155
- - test/test_helper.rb
68
+ summary: Gem for finding the next banking date.
69
+ test_files: []
data/Gemfile DELETED
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- gemspec
data/Gemfile.lock DELETED
@@ -1,35 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- ae_bank_days (1.2.0)
5
- holidays (~> 8.3)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- ansi (1.5.0)
11
- builder (3.2.4)
12
- holidays (8.3.0)
13
- minitest (5.11.3)
14
- minitest-reporters (1.3.0)
15
- ansi
16
- builder
17
- minitest (>= 5.0)
18
- ruby-progressbar
19
- mocha (1.11.2)
20
- rake (12.3.3)
21
- ruby-progressbar (1.10.1)
22
-
23
- PLATFORMS
24
- ruby
25
-
26
- DEPENDENCIES
27
- ae_bank_days!
28
- bundler (>= 1.10.4, < 3)
29
- minitest (>= 5.8)
30
- minitest-reporters (>= 1.3)
31
- mocha (>= 1.1)
32
- rake (>= 12.0)
33
-
34
- BUNDLED WITH
35
- 2.1.4
data/README.rdoc DELETED
@@ -1,17 +0,0 @@
1
- = ae_bank_days
2
-
3
- Simple utility to find the next banking day
4
-
5
- == Contributing to ae_bank_days
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
- * Fork the project.
10
- * Start a feature/bugfix branch.
11
- * Commit and push until you are happy with your contribution.
12
- * Make sure to add tests for it. This is important so it doesn't break in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so it can be cherry-picked around.
14
-
15
- == Copyright
16
-
17
- Copyright © 2019-2020 AppFolio.
data/Rakefile DELETED
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rubygems'
4
- require 'bundler'
5
-
6
- begin
7
- Bundler.setup(:default, :development)
8
- rescue Bundler::BundlerError => e
9
- warn e.message
10
- warn 'Run `bundle install` to install missing gems'
11
- exit e.status_code
12
- end
13
-
14
- require 'rake/testtask'
15
-
16
- Rake::TestTask.new(:test) do |test|
17
- test.libs << 'test'
18
- test.pattern = 'test/**/*_test.rb'
19
- test.verbose = true
20
- end
21
-
22
- task default: :test
@@ -1,75 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- module AeBankDays
6
- class BankDayHelperTest < Minitest::Test
7
- def test_bank_day__weekday
8
- assert BankDayHelper.bank_day?(Date.civil(2017, 10, 3))
9
- end
10
-
11
- def test_bank_day__weekend
12
- refute BankDayHelper.bank_day?(Date.civil(2017, 10, 14))
13
- end
14
-
15
- def test_bank_day__holiday
16
- refute BankDayHelper.bank_day?(Date.civil(2017, 10, 9))
17
- end
18
-
19
- def test_bank_day__saturday_holiday_is_not_observed_on_friday
20
- # The federal bank does not observe holidays that fall on Saturday on the preceding Friday as is common.
21
- # This test makes sure that these dates are not accidentally marked as holidays.
22
- # July 4, 2020 fell on a Saturday. The day before was a generally observed federal holiday, but it was still
23
- # a banking day due to the federal banks holiday rules.
24
- assert BankDayHelper.bank_day?(Date.civil(2020, 6, 3))
25
- end
26
-
27
- def test_next_banking_day__weekday
28
- assert_equal Date.civil(2017, 10, 3), BankDayHelper.next_banking_day(Date.civil(2017, 10, 3))
29
- end
30
-
31
- def test_next_banking_day__weekday__extra_days
32
- assert_equal Date.civil(2017, 10, 6), BankDayHelper.next_banking_day(Date.civil(2017, 10, 3), number_of_days: 3)
33
- end
34
-
35
- def test_next_banking_day__weekend
36
- assert_equal Date.civil(2017, 10, 16), BankDayHelper.next_banking_day(Date.civil(2017, 10, 14))
37
- end
38
-
39
- def test_next_banking_day__weekend__extra_days
40
- assert_equal Date.civil(2017, 10, 19), BankDayHelper.next_banking_day(Date.civil(2017, 10, 14), number_of_days: 3)
41
- end
42
-
43
- def test_next_banking_day__holiday
44
- assert_equal Date.civil(2017, 10, 10), BankDayHelper.next_banking_day(Date.civil(2017, 10, 9))
45
- end
46
-
47
- def test_next_banking_day__holiday__extra_days
48
- assert_equal Date.civil(2017, 10, 13), BankDayHelper.next_banking_day(Date.civil(2017, 10, 9), number_of_days: 3)
49
- end
50
-
51
- def test_previous_banking_day__weekday
52
- assert_equal Date.civil(2017, 10, 3), BankDayHelper.previous_banking_day(Date.civil(2017, 10, 3))
53
- end
54
-
55
- def test_previous_banking_day__weekday__extra_days
56
- assert_equal Date.civil(2017, 10, 3), BankDayHelper.previous_banking_day(Date.civil(2017, 10, 6), number_of_days: 3)
57
- end
58
-
59
- def test_previous_banking_day__weekend
60
- assert_equal Date.civil(2017, 10, 13), BankDayHelper.previous_banking_day(Date.civil(2017, 10, 14))
61
- end
62
-
63
- def test_previous_banking_day__weekend__extra_days
64
- assert_equal Date.civil(2017, 10, 10), BankDayHelper.previous_banking_day(Date.civil(2017, 10, 14), number_of_days: 3)
65
- end
66
-
67
- def test_previous_banking_day__holiday
68
- assert_equal Date.civil(2017, 10, 6), BankDayHelper.previous_banking_day(Date.civil(2017, 10, 9))
69
- end
70
-
71
- def test_previous_banking_day__holiday__extra_days
72
- assert_equal Date.civil(2017, 10, 3), BankDayHelper.previous_banking_day(Date.civil(2017, 10, 9), number_of_days: 3)
73
- end
74
- end
75
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- module AeBankDays
6
- class DateExtensionsTest < Minitest::Test
7
- def test_bank_day
8
- date = Date.today
9
- BankDayHelper.expects(:bank_day?).with(date).returns(true)
10
-
11
- assert date.bank_day?
12
- end
13
-
14
- def test_next_banking_day
15
- date = Date.today
16
- new_date = date + 2
17
- BankDayHelper.expects(:next_banking_day).with(date, number_of_days: 2).returns(new_date)
18
-
19
- assert_equal new_date, date.next_banking_day(2)
20
- end
21
-
22
- def test_next_banking_day__default
23
- date = Date.today
24
- new_date = date + 2
25
- BankDayHelper.expects(:next_banking_day).with(date, number_of_days: 0).returns(new_date)
26
-
27
- assert_equal new_date, date.next_banking_day
28
- end
29
-
30
- def test_previous_banking_day
31
- date = Date.today
32
- new_date = date + 2
33
- BankDayHelper.expects(:previous_banking_day).with(date, number_of_days: 2).returns(new_date)
34
-
35
- assert_equal new_date, date.previous_banking_day(2)
36
- end
37
-
38
- def test_previous_banking_day__default
39
- date = Date.today
40
- new_date = date + 2
41
- BankDayHelper.expects(:previous_banking_day).with(date, number_of_days: 0).returns(new_date)
42
-
43
- assert_equal new_date, date.previous_banking_day
44
- end
45
- end
46
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class AeBankDaysTest < Minitest::Test
6
- def test_that_it_has_a_version_number
7
- refute_nil ::AeBankDays::VERSION
8
- end
9
- end
data/test/test_helper.rb DELETED
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rubygems'
4
- require 'bundler'
5
-
6
- begin
7
- Bundler.setup(:default, :development)
8
- rescue Bundler::BundlerError => e
9
- warn e.message
10
- warn 'Run `bundle install` to install missing gems'
11
- exit e.status_code
12
- end
13
-
14
- require 'ae_bank_days'
15
- require 'minitest/autorun'
16
- require 'minitest/reporters'
17
- require 'mocha/setup'
18
- require 'time'
19
-
20
- MiniTest::Reporters.use!