month 1.7.1 → 2.0.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 +12 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/lib/month.rb +37 -14
- data/month.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4eae90e4553fd130639c8f35f5feda52af6a7a4d56ec8631981fd0cadaa1895a
|
4
|
+
data.tar.gz: 76fb1049ecc66fdd30f145f7623ce978ea8606cd415dca8c20b63978af991b42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d6ee334ce0de8c6162fb51ea14950e1d18fe085ce3818f290ab2a578a383853193c2f1606c16886dd978ee1bed750308d90a7eced6a24d7b62c3a1ed69cc71d
|
7
|
+
data.tar.gz: 15a1e39f3722c920152f3ae36301a149ddf520f7dce91b6591ed6b4c25cdcf5a2f46f6e2221651d8ff82007d93d4f1b46036d4d5fbb527006d646250e9324a47
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# 2.0.0
|
2
|
+
|
3
|
+
* Changed required_ruby_version to >= 2.6.0
|
4
|
+
|
5
|
+
* Fixed Month#next_month and Month#prev_month methods
|
6
|
+
|
7
|
+
* Added functionality for parsing strings like '2014 JAN'
|
8
|
+
|
9
|
+
* Added functionality for parsing strings like 'January 2014'
|
10
|
+
|
11
|
+
* Removed Month.today method in favour of Month.now method
|
12
|
+
|
1
13
|
# 1.7.1
|
2
14
|
|
3
15
|
* 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,7 +32,7 @@ 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
|
@@ -77,18 +77,20 @@ class Month
|
|
77
77
|
|
78
78
|
alias_method :succ, :next
|
79
79
|
|
80
|
+
alias_method :next_month, :next
|
81
|
+
|
82
|
+
def prev_month
|
83
|
+
self - 1
|
84
|
+
end
|
85
|
+
|
80
86
|
def >>(n)
|
81
87
|
self + n
|
82
88
|
end
|
83
89
|
|
84
|
-
alias_method :next_month, :>>
|
85
|
-
|
86
90
|
def <<(n)
|
87
91
|
self - n
|
88
92
|
end
|
89
93
|
|
90
|
-
alias_method :prev_month, :<<
|
91
|
-
|
92
94
|
def step(limit, step = 1)
|
93
95
|
raise ArgumentError if step.zero?
|
94
96
|
|
@@ -135,8 +137,8 @@ class Month
|
|
135
137
|
end
|
136
138
|
end
|
137
139
|
|
138
|
-
def include?(
|
139
|
-
@year ==
|
140
|
+
def include?(time)
|
141
|
+
@year == time.year && @number == time.month
|
140
142
|
end
|
141
143
|
|
142
144
|
alias_method :===, :include?
|
@@ -159,13 +161,38 @@ class Month
|
|
159
161
|
end
|
160
162
|
|
161
163
|
class Month
|
162
|
-
|
164
|
+
ABBREVIATIONS = {
|
165
|
+
'JAN' => 1,
|
166
|
+
'FEB' => 2,
|
167
|
+
'MAR' => 3,
|
168
|
+
'APR' => 4,
|
169
|
+
'MAY' => 5,
|
170
|
+
'JUN' => 6,
|
171
|
+
'JUL' => 7,
|
172
|
+
'AUG' => 8,
|
173
|
+
'SEP' => 9,
|
174
|
+
'OCT' => 10,
|
175
|
+
'NOV' => 11,
|
176
|
+
'DEC' => 12,
|
177
|
+
}
|
178
|
+
|
179
|
+
REGEXP1 = /\A(\d{4})-(\d{2})\z/
|
180
|
+
REGEXP2 = /\A(\d{4}) (#{ABBREVIATIONS.keys.join('|')})\z/
|
181
|
+
REGEXP3 = /\A(#{Date::MONTHNAMES.compact.join('|')}) (\d{4})\z/
|
163
182
|
|
164
|
-
private_constant :
|
183
|
+
private_constant :ABBREVIATIONS
|
184
|
+
private_constant :REGEXP1
|
185
|
+
private_constant :REGEXP2
|
186
|
+
private_constant :REGEXP3
|
165
187
|
|
166
188
|
def self.parse(string)
|
167
|
-
|
189
|
+
case string
|
190
|
+
when REGEXP1
|
168
191
|
Month.new($1.to_i, $2.to_i)
|
192
|
+
when REGEXP2
|
193
|
+
Month.new($1.to_i, ABBREVIATIONS.fetch($2))
|
194
|
+
when REGEXP3
|
195
|
+
Month.new($2.to_i, Date::MONTHNAMES.index($1))
|
169
196
|
else
|
170
197
|
raise ArgumentError, 'invalid month'
|
171
198
|
end
|
@@ -183,10 +210,6 @@ def Month(object)
|
|
183
210
|
end
|
184
211
|
end
|
185
212
|
|
186
|
-
def Month.today
|
187
|
-
Month(Date.today)
|
188
|
-
end
|
189
|
-
|
190
213
|
def Month.now
|
191
214
|
Month(Time.now)
|
192
215
|
end
|
data/month.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'month'
|
3
|
-
s.version = '
|
3
|
+
s.version = '2.0.0'
|
4
4
|
s.license = 'MIT'
|
5
5
|
s.platform = Gem::Platform::RUBY
|
6
6
|
s.authors = ['Tim Craft']
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
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,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: month
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Craft
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ruby gem for working with months
|
14
14
|
email:
|
@@ -39,14 +39,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
39
39
|
requirements:
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
42
|
+
version: 2.6.0
|
43
43
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
requirements: []
|
49
|
-
rubygems_version: 3.
|
49
|
+
rubygems_version: 3.2.32
|
50
50
|
signing_key:
|
51
51
|
specification_version: 4
|
52
52
|
summary: See description
|