month 1.7.1 → 2.1.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/CHANGES.md +16 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/lib/month.rb +41 -14
- data/month.gemspec +3 -3
- metadata +5 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e3aca66897fb2dc1cb5c5c6f2b34d7f5611f0727bed247a0676aeb9cd09dba8
|
4
|
+
data.tar.gz: ae9b57770644dd9f62945db5712372743d198e034f8c6dae3b447c0cf78d8eda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b17a3f52d33950f8dc85449dc934b43470aa6be0c55d33a919b3247a56d1645fe9da491447ce133840ee1859e453255d8ba9bc3da664b2a389cbc52b7486ed7a
|
7
|
+
data.tar.gz: 389db54dbe6083a165d169ed4272943fef8ee3d77a6f74f8b8ba575bf152dff3fc91566d7c1cf9666e9a75ef285bdf6509bdbb0e8914ec6362f65e7a0ab94b8d
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
# 2.1.0
|
2
|
+
|
3
|
+
* Added Month#inspect method
|
4
|
+
|
5
|
+
# 2.0.0
|
6
|
+
|
7
|
+
* Changed required_ruby_version to >= 2.6.0
|
8
|
+
|
9
|
+
* Fixed Month#next_month and Month#prev_month methods
|
10
|
+
|
11
|
+
* Added functionality for parsing strings like '2014 JAN'
|
12
|
+
|
13
|
+
* Added functionality for parsing strings like 'January 2014'
|
14
|
+
|
15
|
+
* Removed Month.today method in favour of Month.now method
|
16
|
+
|
1
17
|
# 1.7.1
|
2
18
|
|
3
19
|
* Added CHANGES.md to gem files
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# month
|
2
2
|
|
3
3
|

|
4
|
-

|
5
5
|
|
6
6
|
|
7
7
|
Ruby gem for working with months.
|
data/lib/month.rb
CHANGED
@@ -32,11 +32,15 @@ class Month
|
|
32
32
|
alias_method :month, :number
|
33
33
|
|
34
34
|
def to_s
|
35
|
-
"
|
35
|
+
"#{@year}-#{@number.to_s.rjust(2, '0')}"
|
36
36
|
end
|
37
37
|
|
38
38
|
alias_method :iso8601, :to_s
|
39
39
|
|
40
|
+
def inspect
|
41
|
+
"<Month: #{to_s}>"
|
42
|
+
end
|
43
|
+
|
40
44
|
def name
|
41
45
|
NAMES.fetch(@number)
|
42
46
|
end
|
@@ -77,18 +81,20 @@ class Month
|
|
77
81
|
|
78
82
|
alias_method :succ, :next
|
79
83
|
|
84
|
+
alias_method :next_month, :next
|
85
|
+
|
86
|
+
def prev_month
|
87
|
+
self - 1
|
88
|
+
end
|
89
|
+
|
80
90
|
def >>(n)
|
81
91
|
self + n
|
82
92
|
end
|
83
93
|
|
84
|
-
alias_method :next_month, :>>
|
85
|
-
|
86
94
|
def <<(n)
|
87
95
|
self - n
|
88
96
|
end
|
89
97
|
|
90
|
-
alias_method :prev_month, :<<
|
91
|
-
|
92
98
|
def step(limit, step = 1)
|
93
99
|
raise ArgumentError if step.zero?
|
94
100
|
|
@@ -135,8 +141,8 @@ class Month
|
|
135
141
|
end
|
136
142
|
end
|
137
143
|
|
138
|
-
def include?(
|
139
|
-
@year ==
|
144
|
+
def include?(time)
|
145
|
+
@year == time.year && @number == time.month
|
140
146
|
end
|
141
147
|
|
142
148
|
alias_method :===, :include?
|
@@ -159,13 +165,38 @@ class Month
|
|
159
165
|
end
|
160
166
|
|
161
167
|
class Month
|
162
|
-
|
168
|
+
ABBREVIATIONS = {
|
169
|
+
'JAN' => 1,
|
170
|
+
'FEB' => 2,
|
171
|
+
'MAR' => 3,
|
172
|
+
'APR' => 4,
|
173
|
+
'MAY' => 5,
|
174
|
+
'JUN' => 6,
|
175
|
+
'JUL' => 7,
|
176
|
+
'AUG' => 8,
|
177
|
+
'SEP' => 9,
|
178
|
+
'OCT' => 10,
|
179
|
+
'NOV' => 11,
|
180
|
+
'DEC' => 12,
|
181
|
+
}
|
182
|
+
|
183
|
+
REGEXP1 = /\A(\d{4})-(\d{2})\z/
|
184
|
+
REGEXP2 = /\A(\d{4}) (#{ABBREVIATIONS.keys.join('|')})\z/
|
185
|
+
REGEXP3 = /\A(#{Date::MONTHNAMES.compact.join('|')}) (\d{4})\z/
|
163
186
|
|
164
|
-
private_constant :
|
187
|
+
private_constant :ABBREVIATIONS
|
188
|
+
private_constant :REGEXP1
|
189
|
+
private_constant :REGEXP2
|
190
|
+
private_constant :REGEXP3
|
165
191
|
|
166
192
|
def self.parse(string)
|
167
|
-
|
193
|
+
case string
|
194
|
+
when REGEXP1
|
168
195
|
Month.new($1.to_i, $2.to_i)
|
196
|
+
when REGEXP2
|
197
|
+
Month.new($1.to_i, ABBREVIATIONS.fetch($2))
|
198
|
+
when REGEXP3
|
199
|
+
Month.new($2.to_i, Date::MONTHNAMES.index($1))
|
169
200
|
else
|
170
201
|
raise ArgumentError, 'invalid month'
|
171
202
|
end
|
@@ -183,10 +214,6 @@ def Month(object)
|
|
183
214
|
end
|
184
215
|
end
|
185
216
|
|
186
|
-
def Month.today
|
187
|
-
Month(Date.today)
|
188
|
-
end
|
189
|
-
|
190
217
|
def Month.now
|
191
218
|
Month(Time.now)
|
192
219
|
end
|
data/month.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'month'
|
3
|
-
s.version = '1.
|
3
|
+
s.version = '2.1.0'
|
4
4
|
s.license = 'MIT'
|
5
5
|
s.platform = Gem::Platform::RUBY
|
6
6
|
s.authors = ['Tim Craft']
|
7
|
-
s.email = ['
|
7
|
+
s.email = ['email@timcraft.com']
|
8
8
|
s.homepage = 'https://github.com/readysteady/month'
|
9
9
|
s.description = 'Ruby gem for working with months'
|
10
10
|
s.summary = 'See description'
|
11
11
|
s.files = Dir.glob('lib/**/*.rb') + %w[CHANGES.md LICENSE.txt README.md month.gemspec]
|
12
|
-
s.required_ruby_version = '>=
|
12
|
+
s.required_ruby_version = '>= 2.6.0'
|
13
13
|
s.require_path = 'lib'
|
14
14
|
s.metadata = {
|
15
15
|
'homepage' => 'https://github.com/readysteady/month',
|
metadata
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: month
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Craft
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
12
|
description: Ruby gem for working with months
|
14
13
|
email:
|
15
|
-
-
|
14
|
+
- email@timcraft.com
|
16
15
|
executables: []
|
17
16
|
extensions: []
|
18
17
|
extra_rdoc_files: []
|
@@ -31,7 +30,6 @@ metadata:
|
|
31
30
|
source_code_uri: https://github.com/readysteady/month
|
32
31
|
bug_tracker_uri: https://github.com/readysteady/month/issues
|
33
32
|
changelog_uri: https://github.com/readysteady/month/blob/main/CHANGES.md
|
34
|
-
post_install_message:
|
35
33
|
rdoc_options: []
|
36
34
|
require_paths:
|
37
35
|
- lib
|
@@ -39,15 +37,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
39
37
|
requirements:
|
40
38
|
- - ">="
|
41
39
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
40
|
+
version: 2.6.0
|
43
41
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
42
|
requirements:
|
45
43
|
- - ">="
|
46
44
|
- !ruby/object:Gem::Version
|
47
45
|
version: '0'
|
48
46
|
requirements: []
|
49
|
-
rubygems_version: 3.
|
50
|
-
signing_key:
|
47
|
+
rubygems_version: 3.6.2
|
51
48
|
specification_version: 4
|
52
49
|
summary: See description
|
53
50
|
test_files: []
|