funtimes 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,10 +1,20 @@
1
1
  = funtimes
2
2
 
3
- Library for working with months, quarters and date ranges in Ruby.
3
+ Funtimes is a library for working with months, quarters and date ranges in Ruby.
4
4
 
5
- include DateRange in any class with a start_date and end_date and be able to iterate over months and days.
5
+ == Installation
6
6
 
7
- Look in the specs for the, uhm, specs.
7
+ $ gem install funtimes
8
+
9
+ == Usage
10
+
11
+ Include DateRange in any class that has a start_date and end_date and you'll now have access to months, quarters, days and the be able to find intersections of date ranges.
12
+
13
+ Date Range Specs: http://github.com/ignu/fun-times/blob/master/spec/date_range_spec.rb
14
+
15
+ Month Specs http://github.com/ignu/fun-times/blob/master/spec/month_spec.rb
16
+
17
+ Quarter Specs http://github.com/ignu/fun-times/blob/master/spec/quarter_spec.rb
8
18
 
9
19
  == Copyright
10
20
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/funtimes.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{funtimes}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
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 = %q{2010-07-02}
12
+ s.date = %q{2010-07-06}
13
13
  s.description = %q{Manage date ranges, months and quarters}
14
14
  s.email = %q{ignu.smith@gmail.com}
15
15
  s.extra_rdoc_files = [
data/lib/quarter.rb CHANGED
@@ -1,17 +1,18 @@
1
1
  class Quarter
2
2
  include DateRange
3
3
  attr_accessor :number, :year, :start_date, :end_date
4
+ @@months = [1, 4, 7, 10]
4
5
 
5
6
  def initialize(q,y)
6
- months = [1, 4, 7, 10]
7
7
  @number, @year = q, y
8
- @start_date = DateTime.new(y, months[q-1], 1)
9
- @end_date = DateTime.new(y, months[q], 1) - 1 unless q == 4
8
+ @start_date = DateTime.new(y, @@months[q-1], 1)
9
+ @end_date = DateTime.new(y, @@months[q], 1) - 1 unless q == 4
10
10
  @end_date = DateTime.new(y+1, 1, 1) - 1 if q == 4
11
11
  end
12
12
 
13
13
  def self.from(date)
14
- new(date.month/4+1, date.year)
14
+ number = @@months.index(@@months.reverse.detect{|i| i <= date.month}) + 1
15
+ new(number, date.year)
15
16
  end
16
17
 
17
18
  def succ
data/spec/quarter_spec.rb CHANGED
@@ -16,6 +16,10 @@ describe "Quarter" do
16
16
  it "can initialize from any date" do
17
17
  quarter = Quarter.from(DateTime.new(2009, 2, 1))
18
18
  quarter.year.should == 2009
19
+ quarter.number.should == 1
20
+ quarter = Quarter.from(DateTime.new(2009, 7, 15))
21
+ quarter.year.should == 2009
22
+ quarter.number.should == 3
19
23
  end
20
24
 
21
25
  it "sets the start date correctly" do
@@ -41,5 +45,10 @@ describe "Quarter" do
41
45
 
42
46
  it "is a daterange" do
43
47
  q1.months.to_a.length.should == 3
44
- end
48
+ end
49
+
50
+ it "can calculate the number of quarters in a daterange correctly" do
51
+ range = SimpleRange.new(DateTime.new(2009, 1, 1), DateTime.new(2009, 7, 15))
52
+ range.quarters.to_a.length.should == 3
53
+ end
45
54
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Len Smith
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-02 00:00:00 -04:00
17
+ date: 2010-07-06 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency