monthify 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/monthify/month.rb +11 -0
- data/lib/monthify/version.rb +1 -1
- data/monthify.gemspec +1 -1
- data/spec/lib/monthify/month_spec.rb +21 -0
- metadata +4 -4
data/lib/monthify/month.rb
CHANGED
@@ -12,6 +12,16 @@ module Monthify
|
|
12
12
|
new(today.year, today.month)
|
13
13
|
end
|
14
14
|
|
15
|
+
#@return [Month] the month after the current month
|
16
|
+
def self.next
|
17
|
+
current.next
|
18
|
+
end
|
19
|
+
|
20
|
+
#@return [Month] the month before the current month
|
21
|
+
def self.previous
|
22
|
+
current.previous
|
23
|
+
end
|
24
|
+
|
15
25
|
#@param [Date, Time, #to_date] datish
|
16
26
|
#@return [Month] the month containing the given date
|
17
27
|
def self.containing(datish)
|
@@ -69,6 +79,7 @@ module Monthify
|
|
69
79
|
def next
|
70
80
|
self + 1.month
|
71
81
|
end
|
82
|
+
alias :succ :next
|
72
83
|
|
73
84
|
#@return [Range<Date, Date>] the range of dates in this month
|
74
85
|
def date_range
|
data/lib/monthify/version.rb
CHANGED
data/monthify.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = Monthify::VERSION
|
9
9
|
gem.authors = ["Matt Royal"]
|
10
10
|
gem.email = ["mroyal@gmail.com"]
|
11
|
-
gem.description = %q{The missing Month class
|
11
|
+
gem.description = %q{The missing Month class}
|
12
12
|
gem.summary = %q{}
|
13
13
|
gem.homepage = "https://github.com/matt-royal/monthify"
|
14
14
|
|
@@ -9,6 +9,18 @@ describe Month do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
describe '.next' do
|
13
|
+
it 'is the month after the current month' do
|
14
|
+
Month.next.should == Month.current.next
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.previous' do
|
19
|
+
it 'is the month before the current month' do
|
20
|
+
Month.previous.should == Month.current.previous
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
12
24
|
describe '.containing' do
|
13
25
|
it 'returns the month containing the date' do
|
14
26
|
Month.containing(Date.new(2011, 1, 15)).should == Month.new(2011, 1)
|
@@ -176,6 +188,15 @@ describe Month do
|
|
176
188
|
end
|
177
189
|
end
|
178
190
|
|
191
|
+
it 'can be used in a Range' do
|
192
|
+
range = Month.new(1980, 5)..Month.new(1980, 7)
|
193
|
+
range.to_a.should == [
|
194
|
+
Month.new(1980, 5),
|
195
|
+
Month.new(1980, 6),
|
196
|
+
Month.new(1980, 7)
|
197
|
+
]
|
198
|
+
end
|
199
|
+
|
179
200
|
describe "+" do
|
180
201
|
let(:month) { Month.new(2012, 8) }
|
181
202
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monthify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -27,7 +27,7 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
-
description: The missing Month class
|
30
|
+
description: The missing Month class
|
31
31
|
email:
|
32
32
|
- mroyal@gmail.com
|
33
33
|
executables: []
|
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
72
|
rubyforge_project:
|
73
|
-
rubygems_version: 1.8.
|
73
|
+
rubygems_version: 1.8.19
|
74
74
|
signing_key:
|
75
75
|
specification_version: 3
|
76
76
|
summary: ''
|