increments-schedule 0.16.1 → 0.17.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/.rubocop.yml +1 -2
- data/lib/increments/schedule.rb +73 -20
- data/lib/increments/schedule/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82bb6909cb6c21c1c942ca749dd55b059c196d579a47a9c5ebc364e18c60ce2f
|
4
|
+
data.tar.gz: 3178e7321f0293c611a987fd93377c774ab68af96071b4e2917669be74725665
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73875c7d926a760744b1ba833fa0dff3a73358dd7708d4eb1ad79d1529cd3986423d805637d396d1918c28b4c449a6fc90dad22deb18e68ddd7469f89916f090
|
7
|
+
data.tar.gz: f95a328aa00b00040a6567dd4826dc026eb426f1078bb3350eed1bb8fe643eccbf0ffbe5e057c1a01744da5141830b3f4a31e4310364c2b01a636c66f7255690
|
data/.rubocop.yml
CHANGED
data/lib/increments/schedule.rb
CHANGED
@@ -45,14 +45,7 @@ module Increments
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def winter_vacation_day?(date = Date.today)
|
48
|
-
|
49
|
-
when 1
|
50
|
-
first_three_days_or_adjoining_weekend?(date)
|
51
|
-
when 12
|
52
|
-
last_four_days_or_after_last_saturday?(date)
|
53
|
-
else
|
54
|
-
false
|
55
|
-
end
|
48
|
+
WinterVacationSchedule.new(date).winter_vacation?
|
56
49
|
end
|
57
50
|
|
58
51
|
alias winter_vacation? winter_vacation_day?
|
@@ -71,25 +64,85 @@ module Increments
|
|
71
64
|
end
|
72
65
|
end
|
73
66
|
|
74
|
-
|
67
|
+
WinterVacationSchedule = Struct.new(:date) do
|
68
|
+
def winter_vacation?
|
69
|
+
year_end_vacation.days.include?(date) || new_year_vacation.days.include?(date)
|
70
|
+
end
|
75
71
|
|
76
|
-
|
77
|
-
jan_3 = ExtendedDate.new(date.year, 1, 3)
|
78
|
-
return true if date <= jan_3
|
72
|
+
private
|
79
73
|
|
80
|
-
|
81
|
-
|
74
|
+
def year_end_vacation
|
75
|
+
@year_end_vacation ||= YearEndVacation.new(date.year)
|
76
|
+
end
|
82
77
|
|
83
|
-
|
84
|
-
|
78
|
+
def new_year_vacation
|
79
|
+
@new_year_vacation ||= NewYearVacation.new(date.year)
|
80
|
+
end
|
81
|
+
|
82
|
+
YearEndVacation = Struct.new(:year) do
|
83
|
+
def days
|
84
|
+
beginning_day..dec_31
|
85
|
+
end
|
86
|
+
|
87
|
+
def beginning_day
|
88
|
+
if coupled_new_year_vacation.days.count >= 5
|
89
|
+
last_saturday
|
90
|
+
else
|
91
|
+
[dec_28, last_saturday].min
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def dec_28
|
96
|
+
@dec_28 ||= Date.new(year, 12, 28)
|
97
|
+
end
|
98
|
+
|
99
|
+
def dec_31
|
100
|
+
@dec_31 ||= Date.new(year, 12, 31)
|
101
|
+
end
|
102
|
+
|
103
|
+
def last_saturday
|
104
|
+
@last_saturday ||= dec_31.find_previous(&:saturday?)
|
105
|
+
end
|
85
106
|
|
86
|
-
|
87
|
-
|
107
|
+
def coupled_new_year_vacation
|
108
|
+
@coupled_new_year_vacation ||= NewYearVacation.new(year + 1)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
NewYearVacation = Struct.new(:year) do
|
113
|
+
def days
|
114
|
+
jan_1..end_day
|
115
|
+
end
|
88
116
|
|
89
|
-
|
117
|
+
def end_day
|
118
|
+
return jan_3 if first_sunday <= jan_3
|
119
|
+
|
120
|
+
if first_weekend_almost_adjoins_jan_3?
|
121
|
+
first_sunday
|
122
|
+
else
|
123
|
+
jan_3
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def first_weekend_almost_adjoins_jan_3?
|
128
|
+
jan_3.next_day.upto(first_sunday).all? { |d| d.friday? || d.saturday? || d.sunday? }
|
129
|
+
end
|
130
|
+
|
131
|
+
def first_sunday
|
132
|
+
@first_sunday ||= jan_1.find_next(&:sunday?)
|
133
|
+
end
|
134
|
+
|
135
|
+
def jan_1
|
136
|
+
@jan_1 ||= Date.new(year, 1, 1)
|
137
|
+
end
|
138
|
+
|
139
|
+
def jan_3
|
140
|
+
@jan_3 ||= Date.new(year, 1, 3)
|
141
|
+
end
|
142
|
+
end
|
90
143
|
end
|
91
144
|
|
92
|
-
class
|
145
|
+
class Date < Date
|
93
146
|
INFINITY_FUTURE = Date.new(10_000, 1, 1)
|
94
147
|
INFINITY_PAST = Date.new(0, 1, 1)
|
95
148
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: increments-schedule
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuji Nakayama
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: holiday_japan
|