funtimes 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.4.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "funtimes"
8
- s.version = "0.3.1"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Len Smith"]
12
- s.date = "2011-10-05"
12
+ s.date = "2011-10-13"
13
13
  s.description = "Manage date ranges, months and quarters"
14
14
  s.email = "ignu.smith@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -1,5 +1,4 @@
1
1
  module DateRange
2
-
3
2
  def days
4
3
  (_start)..(_end)
5
4
  end
@@ -14,6 +13,10 @@ module DateRange
14
13
  (Quarter.from(_start)..Quarter.from(_end))
15
14
  end
16
15
 
16
+ def weeks
17
+ (Week.new(_start)..Week.new(_end))
18
+ end
19
+
17
20
  def encompasses(other)
18
21
  _start <= other.start_date && _end >= other.end_date
19
22
  end
@@ -5,6 +5,7 @@ class Week
5
5
  attr_accessor :start_date, :end_date
6
6
  START_DAY = 0
7
7
 
8
+ include Comparable
8
9
  include DateRange
9
10
 
10
11
  def initialize(date)
@@ -16,14 +17,18 @@ class Week
16
17
  Week.new start_date
17
18
  end
18
19
 
19
- def previous
20
- Week.new(@start_date - 7)
20
+ def <=> (other)
21
+ @start_date <=> other.start_date
21
22
  end
22
23
 
23
- def next
24
+ def succ
24
25
  Week.new(@start_date + 7)
25
26
  end
26
27
 
28
+ def prev
29
+ Week.new(@start_date - 7)
30
+ end
31
+
27
32
  private
28
33
 
29
34
  def get_start_date(date)
@@ -1,7 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "DateRange" do
4
-
5
4
  let(:firstOfYear) { DateTime.new(2001,1,1) }
6
5
  let(:endOfYear) { DateTime.new(2001,12,31) }
7
6
  let(:firstOfMarch) { DateTime.new(2001,3,1) }
@@ -88,5 +87,11 @@ describe "DateRange" do
88
87
  r = SimpleRange.new(DateTime.new, nil)
89
88
  r.months.length.should == 0
90
89
  end
90
+
91
+ it "can return the weeks" do
92
+ range = SimpleRange.new(Date.new(2011, 10, 1), DateTime.new(2011, 10, 29))
93
+ range.weeks.to_a.length.should == 5
94
+ range.weeks.first.should == Week.new(Date.new(2011, 10, 1))
95
+ end
91
96
  end
92
97
  end
@@ -19,15 +19,15 @@ describe Week do
19
19
  first_week.days.first.should == Date.new(2011, 10, 2)
20
20
  end
21
21
 
22
- describe "#next" do
22
+ describe "#succ" do
23
23
  it "returns the next week" do
24
- first_week.next.days.first.should == Date.new(2011, 10, 9)
24
+ first_week.succ.days.first.should == Date.new(2011, 10, 9)
25
25
  end
26
26
  end
27
27
 
28
- describe "#previous" do
28
+ describe "#prev" do
29
29
  it "returns the previous week" do
30
- first_week.previous.days.first.should == Date.new(2011, 9, 25)
30
+ first_week.prev.days.first.should == Date.new(2011, 9, 25)
31
31
  end
32
32
  end
33
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: funtimes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-05 00:00:00.000000000Z
12
+ date: 2011-10-13 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70093346613780 !ruby/object:Gem::Requirement
16
+ requirement: &70218711014920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 2.5.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70093346613780
24
+ version_requirements: *70218711014920
25
25
  description: Manage date ranges, months and quarters
26
26
  email: ignu.smith@gmail.com
27
27
  executables: []