increments-schedule 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -6
- data/lib/increments/schedule/version.rb +1 -1
- data/lib/increments/schedule.rb +15 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc11817841783d4d1d0b8b81c527bf51c053012e
|
4
|
+
data.tar.gz: cb0a7a4e0db7e96e9a960c1f4c13cf8f6074e74e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42d456886744ef07db78fb0029233b1b3eb665653a058fc81256159170107c6f3f2b0b3ae24bf4e8e1a15caeb296b373757b9dedba3d58434f297aa72ab3992c
|
7
|
+
data.tar.gz: 4e249baa1368e8d00a3d829ebbe0c9e1b73a26d24e1df2cd0ce8155a48eebf35f1865efc72d8b524e9b3dfbcbad1e3f44e3e98f03512dde7a94efde87e160d32
|
data/README.md
CHANGED
@@ -34,13 +34,11 @@ $ gem install increments-schedule
|
|
34
34
|
* `Increments::Schedule.super_hanakin?(date = Date.today)`
|
35
35
|
* `Increments::Schedule.pay_day?(date = Date.today)`
|
36
36
|
* `Increments::Schedule.work_day?(date = Date.today)`
|
37
|
-
* `Increments::Schedule.office_work_day?(date = Date.today)`
|
38
37
|
* `Increments::Schedule.remote_work_day?(date = Date.today)`
|
39
|
-
* `Increments::Schedule.normal_remote_work_day?(date = Date.today)`
|
40
|
-
* `Increments::Schedule.special_remote_work_day?(date = Date.today)`
|
41
38
|
* `Increments::Schedule.rest_day?(date = Date.today)`
|
42
39
|
* `Increments::Schedule.weekend?(date = Date.today)`
|
43
40
|
* `Increments::Schedule.holiday?(date = Date.today)`
|
41
|
+
* `Increments::Schedule.summer_vacation?(date = Date.today)`
|
44
42
|
* `Increments::Schedule.winter_vacation?(date = Date.today)`
|
45
43
|
|
46
44
|
### Enumeration Methods
|
@@ -49,13 +47,11 @@ $ gem install increments-schedule
|
|
49
47
|
* `Increments::Schedule.each_super_hanakin(max_date = Date.today + 365)`
|
50
48
|
* `Increments::Schedule.each_pay_day(max_date = Date.today + 365)`
|
51
49
|
* `Increments::Schedule.each_work_day(max_date = Date.today + 365)`
|
52
|
-
* `Increments::Schedule.each_office_work_day(max_date = Date.today + 365)`
|
53
50
|
* `Increments::Schedule.each_remote_work_day(max_date = Date.today + 365)`
|
54
|
-
* `Increments::Schedule.each_normal_remote_work_day(max_date = Date.today + 365)`
|
55
|
-
* `Increments::Schedule.each_special_remote_work_day(max_date = Date.today + 365)`
|
56
51
|
* `Increments::Schedule.each_rest_day(max_date = Date.today + 365)`
|
57
52
|
* `Increments::Schedule.each_weekend(max_date = Date.today + 365)`
|
58
53
|
* `Increments::Schedule.each_holiday(max_date = Date.today + 365)`
|
54
|
+
* `Increments::Schedule.each_summer_vacation(max_date = Date.today + 365)`
|
59
55
|
* `Increments::Schedule.each_winter_vacation(max_date = Date.today + 365)`
|
60
56
|
|
61
57
|
## Development
|
data/lib/increments/schedule.rb
CHANGED
@@ -29,10 +29,10 @@ module Increments
|
|
29
29
|
!rest_day?(date)
|
30
30
|
end
|
31
31
|
|
32
|
-
|
32
|
+
alias remote_work_day? work_day?
|
33
33
|
|
34
34
|
def rest_day?(date = Date.today)
|
35
|
-
weekend?(date) || holiday?(date) || winter_vacation?(date)
|
35
|
+
weekend?(date) || holiday?(date) || summer_vacation?(date) || winter_vacation?(date)
|
36
36
|
end
|
37
37
|
|
38
38
|
def weekend?(date = Date.today)
|
@@ -43,6 +43,13 @@ module Increments
|
|
43
43
|
HolidayJapan.check(date)
|
44
44
|
end
|
45
45
|
|
46
|
+
def summer_vacation?(date = Date.today)
|
47
|
+
return false unless date.month == 8
|
48
|
+
return true if date.day.between?(13, 16)
|
49
|
+
return false if !weekend?(date) && !holiday?(date)
|
50
|
+
any_adjacent_date?(date) { |adjacent_date| summer_vacation?(adjacent_date) }
|
51
|
+
end
|
52
|
+
|
46
53
|
def winter_vacation?(date = Date.today)
|
47
54
|
case date.month
|
48
55
|
when 1
|
@@ -72,6 +79,12 @@ module Increments
|
|
72
79
|
|
73
80
|
private
|
74
81
|
|
82
|
+
def any_adjacent_date?(date, &_block)
|
83
|
+
[(date - 1), (date + 1)].any? do |adjacent_date|
|
84
|
+
yield adjacent_date
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
75
88
|
def find_date(date, direction)
|
76
89
|
raise ArgumentError unless [:upto, :downto].include?(direction)
|
77
90
|
limit_date = direction == :upto ? INFINITY_FUTURE : INFINITY_PAST
|
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.12.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: 2016-
|
11
|
+
date: 2016-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: holiday_japan
|