coaster 1.4.5 → 1.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/coaster/core_ext/date.rb +50 -0
- data/lib/coaster/git/repository.rb +2 -2
- data/lib/coaster/version.rb +1 -1
- data/test/test_helper.rb +2 -0
- data/test/test_month.rb +39 -0
- data/test/test_string.rb +0 -6
- 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: bc563bd833f85761a0dd634b98527069c0c61331a354a9c62e48bbe9dbbf9173
|
4
|
+
data.tar.gz: 011c8922be26c2e8c5a6c192baf1d1e1d673ebae2e64c3518f1c5d1078d8b130
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e32aa85da5169a73b3bb85cfd7757aa14b3a03269700364e9747432b5e1e8b2338ab9607977c575a94bd6239919c158495fa42375df0447b2a8ba429db3b4499
|
7
|
+
data.tar.gz: d146502d6f5c06d33949822e348a596b77a1fe712e9ae0f5e24493bff450bdc513b478faebbdf06505b737b668d54693377576ab85f0b58cf55457b5ed1e2a04
|
@@ -2,4 +2,54 @@ class Date
|
|
2
2
|
def to_time_range
|
3
3
|
beginning_of_day...(self + 1.day).beginning_of_day
|
4
4
|
end
|
5
|
+
|
6
|
+
def prev_specific_date(day_num)
|
7
|
+
raise Date::Error, 'invalid date' if day_num < 1 || day_num > 31
|
8
|
+
|
9
|
+
m = Month.from(self)
|
10
|
+
if day_num < day
|
11
|
+
begin
|
12
|
+
m.date_for_day(day_num)
|
13
|
+
rescue Date::Error
|
14
|
+
m.last_date
|
15
|
+
end
|
16
|
+
else
|
17
|
+
begin
|
18
|
+
m.previous.date_for_day(day_num)
|
19
|
+
rescue Date::Error
|
20
|
+
m.previous.last_date
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def next_specific_date(day_num)
|
26
|
+
raise Date::Error, 'invalid date' if day_num < 1 || day_num > 31
|
27
|
+
|
28
|
+
m = Month.from(self)
|
29
|
+
if day < day_num
|
30
|
+
if m.last_date.day < day_num
|
31
|
+
if day < m.last_date.day
|
32
|
+
m.last_date
|
33
|
+
else
|
34
|
+
begin
|
35
|
+
m.later.date_for_day(day_num)
|
36
|
+
rescue Date::Error
|
37
|
+
m.later.last_date
|
38
|
+
end
|
39
|
+
end
|
40
|
+
else
|
41
|
+
begin
|
42
|
+
m.date_for_day(day_num)
|
43
|
+
rescue Date::Error
|
44
|
+
m.last_date
|
45
|
+
end
|
46
|
+
end
|
47
|
+
else
|
48
|
+
begin
|
49
|
+
m.later.date_for_day(day_num)
|
50
|
+
rescue Date::Error
|
51
|
+
m.later.last_date
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
5
55
|
end
|
@@ -117,10 +117,10 @@ module Coaster
|
|
117
117
|
puts "[DEEP_MERGE] #{path} #{pointer}"
|
118
118
|
submodules.values.each do |submodule|
|
119
119
|
sm_sha = submodule_sha(submodule.path, pointer: pointer)
|
120
|
-
submodule.merge(sm_sha)
|
120
|
+
submodule.merge(sm_sha) if sm_sha.present?
|
121
121
|
end
|
122
122
|
merge_without_submodules do
|
123
|
-
merge(pointer)
|
123
|
+
merge(pointer) if pointer.present?
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
data/lib/coaster/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
data/test/test_month.rb
CHANGED
@@ -10,5 +10,44 @@ module Coaster
|
|
10
10
|
assert_equal m.end_of_month, Date.parse('20200131').end_of_day
|
11
11
|
assert_equal m.to_time_range, Date.parse('20200101').beginning_of_day...Date.parse('20200201').beginning_of_day
|
12
12
|
end
|
13
|
+
|
14
|
+
def test_next_specific_date
|
15
|
+
d = Date.parse('20200101')
|
16
|
+
assert_equal d.next_specific_date(1), Date.parse('20200201')
|
17
|
+
assert_equal d.next_specific_date(2), Date.parse('20200102')
|
18
|
+
assert_equal d.next_specific_date(31), Date.parse('20200131')
|
19
|
+
d = Date.parse('20200131')
|
20
|
+
assert_equal d.next_specific_date(31), Date.parse('20200229')
|
21
|
+
d = Date.parse('20200130')
|
22
|
+
assert_equal d.next_specific_date(31), Date.parse('20200131')
|
23
|
+
d = Date.parse('20200129')
|
24
|
+
assert_equal d.next_specific_date(29), Date.parse('20200229')
|
25
|
+
d = Date.parse('20200210')
|
26
|
+
assert_equal d.next_specific_date(29), Date.parse('20200229')
|
27
|
+
assert_equal d.next_specific_date(31), Date.parse('20200229')
|
28
|
+
d = Date.parse('20210210')
|
29
|
+
assert_equal d.next_specific_date(9), Date.parse('20210309')
|
30
|
+
assert_equal d.next_specific_date(10), Date.parse('20210310')
|
31
|
+
assert_equal d.next_specific_date(29), Date.parse('20210228')
|
32
|
+
assert_equal d.next_specific_date(31), Date.parse('20210228')
|
33
|
+
d = Date.parse('20210228')
|
34
|
+
assert_equal d.next_specific_date(31), Date.parse('20210331')
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_prev_specific_date
|
38
|
+
d = Date.parse('20200101')
|
39
|
+
assert_equal d.prev_specific_date(1), Date.parse('20191201')
|
40
|
+
assert_equal d.prev_specific_date(2), Date.parse('20191202')
|
41
|
+
assert_equal d.prev_specific_date(31), Date.parse('20191231')
|
42
|
+
d = Date.parse('20200331')
|
43
|
+
assert_equal d.prev_specific_date(31), Date.parse('20200229')
|
44
|
+
assert_equal d.prev_specific_date(30), Date.parse('20200330')
|
45
|
+
d = Date.parse('20200330')
|
46
|
+
assert_equal d.prev_specific_date(30), Date.parse('20200229')
|
47
|
+
d = Date.parse('20200229')
|
48
|
+
assert_equal d.prev_specific_date(29), Date.parse('20200129')
|
49
|
+
assert_equal d.prev_specific_date(30), Date.parse('20200130')
|
50
|
+
assert_equal d.prev_specific_date(31), Date.parse('20200131')
|
51
|
+
end
|
13
52
|
end
|
14
53
|
end
|
data/test/test_string.rb
CHANGED
@@ -64,22 +64,16 @@ module Coaster
|
|
64
64
|
not_target_full_seq = ((33..255).map { |c| (c + 0xfee0).chr('UTF-8') }.join.chars - full_seq.chars).join + '일이삼いちにさんイチニサン一二三'
|
65
65
|
mixed_str = full_seq + not_target_full_seq
|
66
66
|
# full -> half 1:1 잘 변환되는가?
|
67
|
-
expect(full_seq.to_half_characters(symbol: true)).to eq half_seq
|
68
67
|
assert_equal full_seq.to_half_characters(symbol: true), half_seq
|
69
68
|
# full -> half -> full 변환 시, 원래 string 유지되는가?
|
70
|
-
expect(full_seq.to_half_characters(symbol: true).to_full_characters(symbol: true)).to eq full_seq
|
71
69
|
assert_equal full_seq.to_half_characters(symbol: true).to_full_characters(symbol: true), full_seq
|
72
70
|
# not_target string은 to half 변환 시도시 원본이 유지되는가?
|
73
|
-
expect(not_target_full_seq.to_half_characters(symbol: true)).to eq not_target_full_seq
|
74
71
|
assert_equal not_target_full_seq.to_half_characters(symbol: true), not_target_full_seq
|
75
72
|
# target / not_target이 섞여있는 문장에서, target'만' half로 변환되는가?
|
76
|
-
expect(mixed_str.to_half_characters(symbol: true)).to eq half_seq + not_target_full_seq
|
77
73
|
assert_equal mixed_str.to_half_characters(symbol: true), half_seq + not_target_full_seq
|
78
74
|
# target / not_target이 섞여있는 문장에서, full -> half -> full 변환시, 원래 string 유지되는가?
|
79
|
-
expect(mixed_str.to_half_characters(symbol: true).to_full_characters(symbol: true)).to eq mixed_str
|
80
75
|
assert_equal mixed_str.to_half_characters(symbol: true).to_full_characters(symbol: true), mixed_str
|
81
76
|
# 공백문자열에 다른게 추가되지는 않는가?
|
82
|
-
expect(''.to_half_characters(symbol: true)).to eq ''
|
83
77
|
assert_equal ''.to_half_characters(symbol: true), ''
|
84
78
|
end
|
85
79
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coaster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- buzz jung
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|