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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e8ae6d7e690ce70628c0687e935bd182eb3257e1b6253790a00cbd3c9ed6fc9
4
- data.tar.gz: a9d9708ee72f4872184c9c2969b2b414015d48eedd99ee5bfe5881630f93bf25
3
+ metadata.gz: cd02d4d524a7b1c3fad6328bd31adf80c7d3540341336313dfcc52ffd1232ed7
4
+ data.tar.gz: fb3111b56584d927770b05975e1e14993cb030574e35292b41681ff53f28601e
5
5
  SHA512:
6
- metadata.gz: c17c5fe51f8dc29c2961d74918b949a7f0907df3e0fbbc273f75cb60aaf15fc561f51dbc8b17cf53bdc113df173acf7439b47a58a1d2d33ae8310783422328c6
7
- data.tar.gz: cb22eedcdb827462e4b66beec6426a6b71561230e1fae62d873bd4244910ff1c1baeb176753e11734a7ec8db202d0e38472c1deef075a25fdabec2ea529a1fc0
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
@@ -13,7 +13,7 @@ def require_more
13
13
  more_load_paths = $LOAD_PATH.drop(load_path_index + 1)
14
14
  more_load_paths.each do |load_path|
15
15
  path = File.join(load_path, load_name)
16
- if File.exists?(path)
16
+ if File.exist?(path)
17
17
  return require_dependency path
18
18
  end
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module Coaster
2
- VERSION = '1.4.7'
2
+ VERSION = '1.4.9'
3
3
  end
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.7
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-01-10 00:00:00.000000000 Z
11
+ date: 2024-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj