coaster 1.4.7 → 1.4.9
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/month.rb +16 -4
- data/lib/coaster/core_ext/require_more.rb +1 -1
- data/lib/coaster/version.rb +1 -1
- data/test/test_month.rb +15 -0
- 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: cd02d4d524a7b1c3fad6328bd31adf80c7d3540341336313dfcc52ffd1232ed7
|
4
|
+
data.tar.gz: fb3111b56584d927770b05975e1e14993cb030574e35292b41681ff53f28601e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11e0b6c6e5f82dff03a1b2d197593ac04461543fa622957c45b84daecfff09f6c1f422b3675d541144af2fbc6a935babed9893fce2ba2dcf7bb548f0aa3af7ae
|
7
|
+
data.tar.gz: 2d5f399653022620e521464414d3231795b946180ad62a43d56d18bf680dacd633137e8fdf9b3141f822a73c1365d3f8f8e5dc19efb0a5e8967cc013d7e6bd5a
|
@@ -113,20 +113,24 @@ class Month
|
|
113
113
|
|
114
114
|
def -(time)
|
115
115
|
case time
|
116
|
-
when ActiveSupport::Duration then first_date.in_time_zone(timezone) - time
|
116
|
+
when ActiveSupport::Duration then Month.from(first_date.in_time_zone(timezone) - time)
|
117
117
|
else
|
118
|
-
first_date - time
|
118
|
+
Month.from(first_date - time)
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
122
|
def +(time)
|
123
123
|
case time
|
124
|
-
when ActiveSupport::Duration then first_date.in_time_zone(timezone) + time
|
124
|
+
when ActiveSupport::Duration then Month.from(first_date.in_time_zone(timezone) + time)
|
125
125
|
else
|
126
|
-
first_date + time
|
126
|
+
Month.from(first_date + time)
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
+
def cover?(t)
|
131
|
+
to_time_range.cover?(t)
|
132
|
+
end
|
133
|
+
|
130
134
|
include Comparable
|
131
135
|
def <=>(other)
|
132
136
|
first_date <=> Month.from(other).first_date
|
@@ -136,4 +140,12 @@ class Month
|
|
136
140
|
def succ
|
137
141
|
later
|
138
142
|
end
|
143
|
+
|
144
|
+
def hash
|
145
|
+
first_date.hash
|
146
|
+
end
|
147
|
+
|
148
|
+
def eql?(other)
|
149
|
+
other.is_a?(Month) && first_date == other.first_date
|
150
|
+
end
|
139
151
|
end
|
data/lib/coaster/version.rb
CHANGED
data/test/test_month.rb
CHANGED
@@ -3,6 +3,10 @@ require 'minitest/autorun'
|
|
3
3
|
|
4
4
|
module Coaster
|
5
5
|
class TestMonth < Minitest::Test
|
6
|
+
def setup
|
7
|
+
Time.zone = 'Asia/Seoul'
|
8
|
+
end
|
9
|
+
|
6
10
|
def test_month
|
7
11
|
m = Month.parse('202001')
|
8
12
|
assert_equal m.year, 2020
|
@@ -58,5 +62,16 @@ module Coaster
|
|
58
62
|
assert_equal d.prev_specific_date(30), Date.parse('20200130')
|
59
63
|
assert_equal d.prev_specific_date(31), Date.parse('20200131')
|
60
64
|
end
|
65
|
+
|
66
|
+
def test_range
|
67
|
+
mn = Month.now
|
68
|
+
range = (mn..mn)
|
69
|
+
assert range.cover?(Month.from(Date.today))
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_hash
|
73
|
+
h = {Month.now => 1}
|
74
|
+
assert_equal h[Month.now], 1
|
75
|
+
end
|
61
76
|
end
|
62
77
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- buzz jung
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|