month 1.4.0 → 1.5.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/LICENSE.txt +1 -1
- data/lib/month.rb +21 -1
- data/month.gemspec +3 -3
- data/spec/month_spec.rb +34 -0
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4009cafb1322ac57f543f1890b413d8082e504720535272ea0de0fb73d82c184
|
4
|
+
data.tar.gz: fdc90cf876afdc7113d69c80fa1dad52a8d54a97d391ce75b3a500fc82e185a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c1b9f286ac469bfe6b2d1281a07085ca79e5305ed3ca22c39f7545c10ca0caae84b888a31be84dc75e9e823290ef847635d1c0ef1ef2b5c28055b8b68a4206e
|
7
|
+
data.tar.gz: b90587bf792e723dc9b59ef8814ffc6165e251c2da8afe596075f0667208781042c140f230707470df6fbdc2cdb3938ae7e426e7a869d206fcb43cd0f846bd1a
|
data/LICENSE.txt
CHANGED
data/lib/month.rb
CHANGED
@@ -72,6 +72,18 @@ class Month
|
|
72
72
|
|
73
73
|
alias_method :succ, :next
|
74
74
|
|
75
|
+
def >>(n)
|
76
|
+
self + n
|
77
|
+
end
|
78
|
+
|
79
|
+
alias_method :next_month, :>>
|
80
|
+
|
81
|
+
def <<(n)
|
82
|
+
self - n
|
83
|
+
end
|
84
|
+
|
85
|
+
alias_method :prev_month, :<<
|
86
|
+
|
75
87
|
def step(limit, step = 1)
|
76
88
|
raise ArgumentError if step.zero?
|
77
89
|
|
@@ -114,7 +126,7 @@ class Month
|
|
114
126
|
if object.is_a?(Integer)
|
115
127
|
self + (-object)
|
116
128
|
else
|
117
|
-
|
129
|
+
12 * (year - object.year) + (@number - object.number)
|
118
130
|
end
|
119
131
|
end
|
120
132
|
|
@@ -160,6 +172,14 @@ def Month(object)
|
|
160
172
|
end
|
161
173
|
end
|
162
174
|
|
175
|
+
def Month.today
|
176
|
+
Month(Date.today)
|
177
|
+
end
|
178
|
+
|
179
|
+
def Month.now
|
180
|
+
Month(Time.now)
|
181
|
+
end
|
182
|
+
|
163
183
|
class Month
|
164
184
|
module Methods
|
165
185
|
NAMES.each do |number, name|
|
data/month.gemspec
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'month'
|
3
|
-
s.version = '1.
|
3
|
+
s.version = '1.5.0'
|
4
4
|
s.license = 'MIT'
|
5
5
|
s.platform = Gem::Platform::RUBY
|
6
6
|
s.authors = ['Tim Craft']
|
7
7
|
s.email = ['mail@timcraft.com']
|
8
|
-
s.homepage = '
|
8
|
+
s.homepage = 'https://github.com/timcraft/month'
|
9
9
|
s.description = 'A little Ruby library for working with months'
|
10
10
|
s.summary = 'See description'
|
11
11
|
s.files = Dir.glob('{lib,spec}/**/*') + %w(LICENSE.txt README.md month.gemspec)
|
12
12
|
s.required_ruby_version = '>= 1.9.3'
|
13
|
-
s.add_development_dependency('rake', '
|
13
|
+
s.add_development_dependency('rake', '~> 12')
|
14
14
|
s.add_development_dependency('minitest', '~> 5')
|
15
15
|
s.require_path = 'lib'
|
16
16
|
end
|
data/spec/month_spec.rb
CHANGED
@@ -102,6 +102,22 @@ describe 'Month' do
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
+
describe '>> method' do
|
106
|
+
it 'returns a month object denoting n months after' do
|
107
|
+
(Month.new(2014, 1) >> 5).must_equal(Month.new(2014, 6))
|
108
|
+
(Month.new(2014, 12) >> 5).must_equal(Month.new(2015, 5))
|
109
|
+
(Month.new(2014, 12) >> -5).must_equal(Month.new(2014, 7))
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe '<< method' do
|
114
|
+
it 'returns a month object denoting n months before' do
|
115
|
+
(Month.new(2014, 1) << 5).must_equal(Month.new(2013, 8))
|
116
|
+
(Month.new(2014, 12) << 5).must_equal(Month.new(2014, 7))
|
117
|
+
(Month.new(2014, 12) << -5).must_equal(Month.new(2015, 5))
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
105
121
|
describe 'step method' do
|
106
122
|
it 'calls the block for every month until the given limit' do
|
107
123
|
months = []
|
@@ -294,6 +310,24 @@ describe 'Month method' do
|
|
294
310
|
end
|
295
311
|
end
|
296
312
|
|
313
|
+
describe 'Month today method' do
|
314
|
+
let(:current_date) { Date.today }
|
315
|
+
let(:current_month) { Month.new(current_date.year, current_date.month) }
|
316
|
+
|
317
|
+
it 'returns the current month' do
|
318
|
+
Month.today.must_equal(current_month)
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
describe 'Month now method' do
|
323
|
+
let(:current_time) { Time.now }
|
324
|
+
let(:current_month) { Month.new(current_time.year, current_time.month) }
|
325
|
+
|
326
|
+
it 'returns the current month' do
|
327
|
+
Month.now.must_equal(current_month)
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
297
331
|
describe 'A method defined in Month::Methods' do
|
298
332
|
include Month::Methods
|
299
333
|
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: month
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.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: 2019-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '12'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '12'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -50,7 +50,7 @@ files:
|
|
50
50
|
- lib/month.rb
|
51
51
|
- month.gemspec
|
52
52
|
- spec/month_spec.rb
|
53
|
-
homepage:
|
53
|
+
homepage: https://github.com/timcraft/month
|
54
54
|
licenses:
|
55
55
|
- MIT
|
56
56
|
metadata: {}
|
@@ -69,8 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
|
-
|
73
|
-
rubygems_version: 2.7.6
|
72
|
+
rubygems_version: 3.0.1
|
74
73
|
signing_key:
|
75
74
|
specification_version: 4
|
76
75
|
summary: See description
|