date_ext 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/date_ext.gemspec +1 -1
- data/lib/month.rb +2 -0
- data/lib/quarter.rb +2 -2
- data/lib/year.rb +1 -1
- data/test/month_test.rb +9 -13
- data/test/quarter_test.rb +6 -0
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/date_ext.gemspec
CHANGED
data/lib/month.rb
CHANGED
data/lib/quarter.rb
CHANGED
@@ -40,8 +40,8 @@ class Quarter
|
|
40
40
|
def first_date; first_month.first_day; end
|
41
41
|
def last_date; last_month.last_day; end
|
42
42
|
|
43
|
-
def weekdays; (first_weekday..
|
43
|
+
def weekdays; (first_weekday..last_weekday).to_a; end
|
44
44
|
|
45
45
|
def first_weekday; first_month.first_weekday; end
|
46
|
-
def last_weekday;
|
46
|
+
def last_weekday; last_month.last_weekday; end
|
47
47
|
end
|
data/lib/year.rb
CHANGED
@@ -35,7 +35,7 @@ class Year
|
|
35
35
|
def first_date; Date.new(year,1,1); end
|
36
36
|
def last_date; Date.new(year,12,31); end
|
37
37
|
|
38
|
-
def weekdays; (first_weekday..
|
38
|
+
def weekdays; (first_weekday..last_weekday).to_a; end
|
39
39
|
|
40
40
|
def first_weekday; first_month.first_weekday; end
|
41
41
|
def last_weekday; last_month.last_weekday; end
|
data/test/month_test.rb
CHANGED
@@ -110,7 +110,7 @@ class MonthTest < Test::Unit::TestCase
|
|
110
110
|
end
|
111
111
|
|
112
112
|
|
113
|
-
context "new" do
|
113
|
+
context "#new from date" do
|
114
114
|
setup do
|
115
115
|
@d = Date.new(2009,2,1)
|
116
116
|
@m = Month.new(@d)
|
@@ -123,23 +123,19 @@ class MonthTest < Test::Unit::TestCase
|
|
123
123
|
end
|
124
124
|
|
125
125
|
|
126
|
-
context "new" do
|
126
|
+
context "#new" do
|
127
127
|
setup { @m = Month.new(2009,2)}
|
128
128
|
|
129
|
-
should "
|
129
|
+
should "assign year, month" do
|
130
130
|
assert_equal @m.year, 2009
|
131
131
|
assert_equal @m.month, 2
|
132
|
-
end
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
132
|
+
end
|
133
|
+
|
134
|
+
should "#weekdays have first and last_weekdays" do
|
135
|
+
assert_equal @m.first_weekday, @m.weekdays.first
|
136
|
+
assert_equal @m.last_weekday, @m.weekdays.last
|
137
|
+
end
|
137
138
|
|
138
|
-
should "initialize" do
|
139
|
-
assert_equal @m.year, 2009
|
140
|
-
assert_equal @m.month, 2
|
141
|
-
end
|
142
139
|
end
|
143
140
|
|
144
|
-
|
145
141
|
end
|
data/test/quarter_test.rb
CHANGED
@@ -15,9 +15,15 @@ class QuarterTest < Test::Unit::TestCase
|
|
15
15
|
should "have 2009-01-01 as first_date" do
|
16
16
|
assert_equal Date.new(2009,1,1), @quarter.first_date
|
17
17
|
end
|
18
|
+
should "have 2009-01-01 as first_weekday" do
|
19
|
+
assert_equal Date.new(2009,1,1), @quarter.first_weekday
|
20
|
+
end
|
18
21
|
should "have 2009-12-31 as last_date" do
|
19
22
|
assert_equal Date.new(2009,3,31), @quarter.last_date
|
20
23
|
end
|
24
|
+
should "have 2009-12-31 as last_weekday" do
|
25
|
+
assert_equal Date.new(2009,3,31), @quarter.last_weekday
|
26
|
+
end
|
21
27
|
end
|
22
28
|
|
23
29
|
end
|