date_ext 0.0.4 → 0.0.5

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{date_ext}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["hasclass"]
@@ -109,6 +109,8 @@ class Month
109
109
  date
110
110
  end
111
111
 
112
+ def weekdays; (first_weekday..last_weekday).to_a; end
113
+
112
114
  def first_weekday
113
115
  d = first_day
114
116
  Weekday.civil_or_newer(d.year, d.month, d.day)
@@ -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..last_date).to_a; end
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; last_weekday.last_weekday; end
46
+ def last_weekday; last_month.last_weekday; end
47
47
  end
@@ -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..last_date).to_a; end
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
@@ -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 "have correct flag" do
129
+ should "assign year, month" do
130
130
  assert_equal @m.year, 2009
131
131
  assert_equal @m.month, 2
132
- end
133
- end
134
-
135
- context "new" do
136
- setup { @m = Month.new("2009","02")}
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
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: date_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - hasclass