calorie 0.0.1 → 0.0.2

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/README.md CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  A calendar is a calendar is a calendar.
4
4
 
5
- Motivated by the frustration of solving the same problem in a dozen different ugly ways in a dozen different applications.
6
-
7
5
  ## Requirements
8
6
 
9
7
  This uses the ruby core `Date` library.
@@ -13,7 +11,7 @@ In other words, rails is *not* required.
13
11
  ## Usage
14
12
 
15
13
  Create a hash that uses the day of the month as the key.
16
- The data can be anything, and only your code will be interacting with it.
14
+ The data can be anything; only your code will be interacting with it.
17
15
 
18
16
  data = {
19
17
  1 => thing,
@@ -25,21 +23,30 @@ The data can be anything, and only your code will be interacting with it.
25
23
  # ... etc
26
24
  }
27
25
 
26
+ Obviously, you don't need to pass in any data -- if it's easy enough to just loop through and check what day it is and do whatever you need to do in your view, that's up to you.
27
+
28
28
  Create a presenter for a month by sending in `year`, `month`, and the data:
29
29
 
30
30
  cal = Calorie.new(2010, 6, data)
31
31
 
32
- In your view, you can style it however you wish, e.g.:
32
+ In your view, you can style it however you wish.
33
33
 
34
- cal.days_of_the_week do |label|
35
- if day.weekend?
36
- # label styled as a weekend
37
- else
38
- # label styled as a weekday
39
- end
34
+ # previous month, e.g. December 2009
35
+ cal.previous
36
+
37
+ # current month, e.g. January 2010
38
+ cal.current
39
+
40
+ # next month, e.g. February 2010
41
+ cal.next
42
+
43
+ cal.days_of_the_week do |day|
44
+ # day.label
45
+ # day.weekend?
40
46
  end
41
47
 
42
48
  cal.each_week do |week|
49
+ # week.number
43
50
  week.each_day do |day|
44
51
  unless day.blank?
45
52
  # the day of the month is day.number
@@ -51,8 +58,10 @@ In your view, you can style it however you wish, e.g.:
51
58
  end
52
59
  end
53
60
 
61
+ Note: Weeks are numbered per ISO-8601. This gets a bit weird if you've configured your week to start on Sunday, as the ISO-8601 specifies that the week starts on Monday.
62
+ On the other hand, the definition for *week 1* is the week that has the year's first Thursday in it, so that can be defined unambiguously even if you start your week on a Sunday.
54
63
 
55
- If you don't need to lay it out by week, you can also iterate straight through the days:
64
+ If you don't need to lay it out by week, you can also iterate straight through the days (though I'm not sure why you'd use Calorie for this):
56
65
 
57
66
  cal.each_day do |day|
58
67
  # the day of the month is day.number
@@ -62,8 +71,29 @@ If you don't need to lay it out by week, you can also iterate straight through t
62
71
  end
63
72
  end
64
73
 
65
- ## TODO
74
+ ## Configuration
75
+
76
+ By default the first day of the week is Sunday, however this can be changed to Monday like so:
77
+
78
+ Calorie.configuration do |config|
79
+ config.week_starts_on :monday
80
+ end
81
+
82
+
83
+ You will need to add translations for your locale(s).
84
+ The translations for the week begin with Sunday, regardless of how you configure your week.
85
+
86
+
87
+ # en.yml
88
+ ---
89
+ calorie:
90
+ days_of_the_week: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]
91
+ months: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
92
+
93
+
66
94
 
67
- * configurable week start
68
- * i18n for days of the week
69
- * add labels for current, previous, and next month (with i18n support)
95
+ # fr.yml
96
+ ---
97
+ calorie:
98
+ days_of_the_week: ["di", "lu", "ma", "me", "je", "ve", "sa"]
99
+ months: ["janv.", "fevr.", "mars", "avr.", "mai", "juin", "juil.", "aout", "sept.", "oct.", "nov.", "dec."]
@@ -20,5 +20,5 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.add_development_dependency "rspec"
22
22
  s.add_development_dependency "timecop"
23
- # s.add_runtime_dependency "rest-client"
23
+ s.add_runtime_dependency "i18n"
24
24
  end
@@ -1,15 +1,49 @@
1
1
  require "calorie/version"
2
2
 
3
3
  require 'date'
4
+ require 'i18n'
4
5
 
5
6
  require 'calorie/weeks_in_month'
7
+ require 'calorie/day_of_the_week'
6
8
  require 'calorie/calendar'
7
9
  require 'calorie/week'
8
10
  require 'calorie/day'
9
11
 
10
12
  module Calorie
11
13
 
12
- def self.new(year, month, data)
13
- Calendar.new(year, month, data)
14
+ class Config
15
+
16
+ def initialize
17
+ week_starts_on :sunday
18
+ end
19
+
20
+ def week_starts_on(day = nil)
21
+ @week_starts_on = day if day
22
+ @week_starts_on
23
+ end
24
+
25
+ def week_starts_on?(day)
26
+ day == @week_starts_on
27
+ end
28
+
14
29
  end
30
+
31
+ class << self
32
+ def configuration
33
+ @config ||= Config.new
34
+
35
+ yield @config if block_given?
36
+
37
+ @config
38
+ end
39
+
40
+ def config=(configuration)
41
+ @config = configuration
42
+ end
43
+
44
+ def new(year, month, data = {})
45
+ Calendar.new(year, month, data)
46
+ end
47
+ end
48
+
15
49
  end
@@ -4,7 +4,7 @@ module Calorie
4
4
  include WeeksInMonth
5
5
 
6
6
  attr_reader :days, :weeks, :year, :month, :data
7
- def initialize(year, month, data)
7
+ def initialize(year, month, data = {})
8
8
  @data = data
9
9
  @year = year
10
10
  @month = month
@@ -27,7 +27,11 @@ module Calorie
27
27
  end
28
28
 
29
29
  def first_day_falls_on
30
- first_day.wday
30
+ if Calorie.configuration.week_starts_on?(:monday)
31
+ (first_day.wday - 1) % 7
32
+ else
33
+ first_day.wday
34
+ end
31
35
  end
32
36
 
33
37
  def initialize_days
@@ -49,18 +53,22 @@ module Calorie
49
53
  def days_for_slicing
50
54
  slices = days.clone
51
55
 
52
- blank_days_at_start.times { slices.unshift(Calorie::Day.new) }
53
- blank_days_at_end.times { slices.push(Calorie::Day.new) }
56
+ (1..blank_days_at_start).each do |i|
57
+ slices.unshift(Calorie::NullDay.new(first_day - i))
58
+ end
59
+ (1..blank_days_at_end).each do |i|
60
+ slices.push(Calorie::NullDay.new(last_day + i))
61
+ end
54
62
 
55
63
  slices
56
64
  end
57
65
 
58
66
  def blank_days_at_start
59
- first_day.wday
67
+ first_day_falls_on
60
68
  end
61
69
 
62
70
  def blank_days_at_end
63
- (blank_days_at_start + days_in_month) % 7
71
+ 7 - ((blank_days_at_start + days_in_month) % 7)
64
72
  end
65
73
 
66
74
  def days_in_month
@@ -72,7 +80,33 @@ module Calorie
72
80
  end
73
81
 
74
82
  def days_of_the_week
75
- %w(Su Mo Tu We Th Fr Sa)
83
+ unless @days_of_the_week
84
+ @days_of_the_week ||= (0..6).map do |i|
85
+ DayOfTheWeek.new(i)
86
+ end
87
+ if Calorie.configuration.week_starts_on? :monday
88
+ @days_of_the_week.push(@days_of_the_week.shift)
89
+ end
90
+ end
91
+ @days_of_the_week
92
+ end
93
+
94
+ def previous
95
+ date = first_day.prev_month
96
+ the_month = I18n.translate('calorie.months')[date.month-1]
97
+ "#{the_month} #{date.year}"
98
+ end
99
+
100
+ def current
101
+ date = first_day
102
+ the_month = I18n.translate('calorie.months')[date.month-1]
103
+ "#{the_month} #{date.year}"
104
+ end
105
+
106
+ def next
107
+ date = first_day.next_month
108
+ the_month = I18n.translate('calorie.months')[date.month-1]
109
+ "#{the_month} #{date.year}"
76
110
  end
77
111
  end
78
112
  end
@@ -1,12 +1,9 @@
1
1
  module Calorie
2
2
  class Day
3
3
 
4
+ attr_reader :date
4
5
  def initialize(date = nil, data = nil)
5
- if date
6
- @date = date
7
- else
8
- @date = NullDate.new
9
- end
6
+ @date = date
10
7
  @data = data
11
8
  end
12
9
 
@@ -23,7 +20,7 @@ module Calorie
23
20
  end
24
21
 
25
22
  def blank?
26
- @date.is_a?(NullDate)
23
+ false
27
24
  end
28
25
 
29
26
  def today?
@@ -31,7 +28,16 @@ module Calorie
31
28
  end
32
29
  end
33
30
 
34
- class NullDate
31
+ class NullDay
32
+ attr_reader :date
33
+ def initialize(date = nil)
34
+ @date = date
35
+ end
36
+
37
+ def blank?
38
+ true
39
+ end
40
+
35
41
  def sunday?
36
42
  false
37
43
  end
@@ -42,5 +48,8 @@ module Calorie
42
48
 
43
49
  def mday
44
50
  end
51
+
52
+ def number
53
+ end
45
54
  end
46
55
  end
@@ -0,0 +1,21 @@
1
+ module Calorie
2
+ class DayOfTheWeek
3
+ class << self
4
+ def day_names
5
+ I18n.translate('calorie.days_of_the_week')
6
+ end
7
+ end
8
+
9
+ def initialize(day_of_the_week)
10
+ @day_of_the_week = day_of_the_week
11
+ end
12
+
13
+ def label
14
+ DayOfTheWeek.day_names[@day_of_the_week]
15
+ end
16
+
17
+ def weekend?
18
+ [0, 6].include?(@day_of_the_week)
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module Calorie
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,12 +1,23 @@
1
1
  module Calorie
2
2
  class Week
3
3
 
4
+ attr_reader :days
4
5
  def initialize(days)
5
6
  @days = days
6
7
  end
7
8
 
8
9
  def each_day(&block)
9
- @days.each {|day| block.call(day) }
10
+ days.each {|day| block.call(day) }
11
+ end
12
+
13
+ def number
14
+ (thursday.date.yday / 7.0).ceil
15
+ end
16
+
17
+ def thursday
18
+ days.each do |day|
19
+ return day if day.date.thursday?
20
+ end
10
21
  end
11
22
  end
12
23
  end
@@ -1,7 +1,48 @@
1
1
  require 'calorie'
2
2
 
3
3
  describe Calorie::Calendar do
4
- subject { Calorie::Calendar.new(2010, 12, {25 => 'Christmas'}) }
4
+ subject { Calorie::Calendar.new(2007, 12, {25 => 'Christmas'}) }
5
+
6
+ context "with default configuration" do
7
+ before(:each) { Calorie.config = nil }
8
+
9
+ context "in the first week" do
10
+ it "numbers the days correctly" do
11
+ numbers = []
12
+ subject.weeks.first.each_day do |day|
13
+ numbers << day.number
14
+ end
15
+ numbers.should eq([nil, nil, nil, nil, nil, nil, 1])
16
+ end
17
+
18
+ it "dates the days correctly" do
19
+ dates = []
20
+ subject.weeks.first.each_day do |day|
21
+ dates << day.date.to_s
22
+ end
23
+ dates.should eq(["2007-11-25", "2007-11-26", "2007-11-27", "2007-11-28", "2007-11-29", "2007-11-30", "2007-12-01"])
24
+ end
25
+ end
26
+
27
+ context "in the last week" do
28
+ it "numbers the days correctly" do
29
+ numbers = []
30
+ subject.weeks.last.each_day do |day|
31
+ numbers << day.number
32
+ end
33
+ numbers.should eq([30, 31, nil, nil, nil, nil, nil])
34
+ end
35
+
36
+ it "dates the days correctly" do
37
+ dates = []
38
+ subject.weeks.last.each_day do |day|
39
+ dates << day.date.to_s
40
+ end
41
+ dates.should eq(["2007-12-30", "2007-12-31", "2008-01-01", "2008-01-02", "2008-01-03", "2008-01-04", "2008-01-05"])
42
+ end
43
+ end
44
+
45
+ end
5
46
 
6
47
  it "creates all the days" do
7
48
  numbers = []
@@ -20,23 +61,102 @@ describe Calorie::Calendar do
20
61
  end
21
62
  end
22
63
 
23
- it "gets the first week right" do
24
- numbers = []
25
- subject.weeks.first.each_day do |day|
26
- numbers << day.number
64
+ context "when week starts on sunday" do
65
+ before(:each) { Calorie.config = nil }
66
+
67
+ describe "first day falls on" do
68
+ {
69
+ 2003 => 2,
70
+ 2004 => 4,
71
+ 2005 => 5,
72
+ 2006 => 6,
73
+ 2007 => 0,
74
+ 2008 => 2
75
+ }.each do |year, offset|
76
+ it "#{offset} in #{year}" do
77
+ cal = Calorie::Calendar.new(year, 4, {})
78
+ cal.first_day_falls_on.should eq(offset)
79
+ end
80
+ end
27
81
  end
28
- numbers.should eq([nil, nil, nil] + (1..4).to_a)
29
82
  end
30
83
 
31
- it "gets the last week right" do
32
- numbers = []
33
- subject.weeks.last.each_day do |day|
34
- numbers << day.number
84
+ context "when week starts on monday" do
85
+ before :each do
86
+ Calorie.configuration do |config|
87
+ config.week_starts_on :monday
88
+ end
89
+ end
90
+
91
+ describe "first day falls on" do
92
+ {
93
+ 2003 => 3,
94
+ 2004 => 5,
95
+ 2005 => 6,
96
+ 2006 => 0,
97
+ 2007 => 1,
98
+ 2008 => 3
99
+ }.each do |year, offset|
100
+ it "#{offset} in #{year}" do
101
+ cal = Calorie::Calendar.new(year, 5, {})
102
+ cal.first_day_falls_on.should eq(offset)
103
+ end
104
+ end
35
105
  end
36
- numbers.should eq((26..31).to_a + [nil])
37
106
  end
38
107
 
39
- it "has labels for the days of the week" do
40
- subject.days_of_the_week.should eq(%w(Su Mo Tu We Th Fr Sa))
108
+ describe "translation" do
109
+ around :each do |example|
110
+ I18n.with_locale(:xx) do
111
+ example.run
112
+ end
113
+ end
114
+
115
+ before :each do
116
+ xx = {
117
+ :calorie => {
118
+ :days_of_the_week => ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'],
119
+ :months => ['jan', 'fev', 'mar', 'avr', 'mai', 'jui', 'jui', 'aou', 'sep', 'oct', 'nov', 'dec']
120
+ }
121
+ }
122
+ I18n.backend.store_translations(:xx, xx)
123
+ end
124
+
125
+ describe "monthly labels" do
126
+ context "in january 2010" do
127
+ subject { Calorie::Calendar.new(2010, 1, {}) }
128
+
129
+ specify { subject.previous.should eq('dec 2009') }
130
+ specify { subject.current.should eq('jan 2010') }
131
+ end
132
+
133
+ context "in december" do
134
+ subject { Calorie::Calendar.new(2010, 12, {}) }
135
+
136
+ specify { subject.next.should eq('jan 2011') }
137
+ end
138
+ end
139
+
140
+
141
+ describe "weekdays" do
142
+ subject { Calorie::Calendar.new(2010, 4, {}) }
143
+
144
+ context "with default configuration" do
145
+ before(:each) { Calorie.config = nil }
146
+
147
+ specify { subject.days_of_the_week.map(&:label).should eq(%w(dimanche lundi mardi mercredi jeudi vendredi samedi)) }
148
+ end
149
+
150
+ context "with week starting on monday" do
151
+ before :each do
152
+ Calorie.configuration do |config|
153
+ config.week_starts_on :monday
154
+ end
155
+ end
156
+
157
+ specify { subject.days_of_the_week.map(&:label).should eq(%w(lundi mardi mercredi jeudi vendredi samedi dimanche)) }
158
+ end
159
+ end
41
160
  end
161
+
42
162
  end
@@ -10,4 +10,40 @@ describe Calorie do
10
10
  end
11
11
  end
12
12
  end
13
+
14
+ describe "configuration" do
15
+ it "has a global config" do
16
+ Calorie.configuration.should eq(Calorie.configuration)
17
+ end
18
+
19
+ context "when unconfigured" do
20
+ before :each do
21
+ Calorie.config = nil
22
+ end
23
+
24
+ it "starts week on Sunday by default" do
25
+ Calorie.configuration.week_starts_on.should eq(:sunday)
26
+ end
27
+
28
+ it "knows when the week starts" do
29
+ Calorie.configuration.week_starts_on?(:sunday).should be_true
30
+ end
31
+ end
32
+
33
+ context "when overriding defaults" do
34
+ before :each do
35
+ Calorie.configuration do |config|
36
+ config.week_starts_on :monday
37
+ end
38
+ end
39
+
40
+ it "has the correct start of the week" do
41
+ Calorie.configuration.week_starts_on.should eq(:monday)
42
+ end
43
+
44
+ it "knows when the week starts" do
45
+ Calorie.configuration.week_starts_on?(:monday).should be_true
46
+ end
47
+ end
48
+ end
13
49
  end
@@ -0,0 +1,27 @@
1
+ require 'calorie'
2
+
3
+ describe Calorie::DayOfTheWeek do
4
+ around :each do |example|
5
+ I18n.with_locale(:xx) do
6
+ example.run
7
+ end
8
+ end
9
+
10
+ before :each do
11
+ xx = { :calorie => { :days_of_the_week => ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'], } }
12
+ I18n.backend.store_translations(:xx, xx)
13
+ end
14
+
15
+ it "has a label" do
16
+ Calorie::DayOfTheWeek.new(0).label.should eq('dimanche')
17
+ end
18
+
19
+ [0, 6].each do |i|
20
+ specify { Calorie::DayOfTheWeek.new(i).weekend?.should be_true }
21
+ end
22
+
23
+ (1..5).each do |i|
24
+ specify { Calorie::DayOfTheWeek.new(i).weekend?.should be_false }
25
+ end
26
+
27
+ end
@@ -16,6 +16,10 @@ describe Calorie::Day do
16
16
  Timecop.freeze(Time.new(2010, 6, 13, 11, 40, 17))
17
17
  end
18
18
 
19
+ after :each do
20
+ Timecop.return
21
+ end
22
+
19
23
  its(:today?) { should be_true }
20
24
  end
21
25
 
@@ -24,6 +28,10 @@ describe Calorie::Day do
24
28
  Timecop.freeze(Time.new(2010, 6, 14, 20, 15, 47))
25
29
  end
26
30
 
31
+ after :each do
32
+ Timecop.return
33
+ end
34
+
27
35
  its(:today?) { should be_false }
28
36
  end
29
37
  end
@@ -36,17 +44,12 @@ describe Calorie::Day do
36
44
  its(:weekend?) { should be_false }
37
45
  its(:blank?) { should be_false}
38
46
  end
39
-
40
- context "a null day" do
41
- subject { Calorie::Day.new }
42
- its(:blank?) { should be_true }
43
- its(:number) { should be_nil }
44
- its(:weekend?) { should be_false }
45
- its(:data) { should be_nil }
46
- end
47
47
  end
48
48
 
49
- describe Calorie::NullDate do
49
+ describe Calorie::NullDay do
50
+ let(:jan1) { Date.new(2010, 1, 1) }
51
+ subject { Calorie::NullDay.new(jan1) }
52
+ its(:date) { should eq(jan1) }
50
53
  its(:mday) { should be_nil }
51
54
  its(:sunday?) { should be_false }
52
55
  its(:saturday?) { should be_false }
@@ -0,0 +1,68 @@
1
+ require 'calorie'
2
+
3
+ describe "Week number" do
4
+
5
+ context "in the first week of january" do
6
+
7
+ {2005 => 53, 2006 => 52, 2007 => 1, 2008 => 1, 2009 => 1, 2010=> 53}.each do |year, week_number|
8
+ context "with week starting monday" do
9
+ before :each do
10
+ Calorie.configuration do |config|
11
+ config.week_starts_on :monday
12
+ end
13
+ end
14
+
15
+ specify "in #{year}" do
16
+ Calorie.new(year, 1).weeks.first.number.should eq(week_number)
17
+ end
18
+ end
19
+ end
20
+
21
+ {2005 => 53, 2006 => 1, 2007 => 1, 2008 => 1, 2009 => 1, 2010=> 53}.each do |year, week_number|
22
+ # this is a bit far-fetched, as the iso-8601 week always starts on a Monday.
23
+ # on the other hand, the numbering scheme is defined as week 1 being the week
24
+ # that has the year's first Thursday in it, so it kind of works.
25
+ context "with week starting sunday" do
26
+ before :each do
27
+ Calorie.configuration do |config|
28
+ config.week_starts_on :sunday
29
+ end
30
+ end
31
+
32
+ specify "in #{year}" do
33
+ Calorie.new(year, 1).weeks.first.number.should eq(week_number)
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ describe "in the last week of december" do
40
+ {2004 => 53, 2005 => 52, 2006 => 1, 2007 => 1, 2008 => 1, 2009 => 53, 2010 => 52}.each do |year, week_number|
41
+ context "with week starting sunday" do
42
+ before :each do
43
+ Calorie.configuration do |config|
44
+ config.week_starts_on :sunday
45
+ end
46
+ end
47
+
48
+ specify "in #{year}" do
49
+ Calorie.new(year, 12).weeks.last.number.should eq(week_number)
50
+ end
51
+ end
52
+ end
53
+
54
+ context "with week starting monday" do
55
+ {2004 => 53, 2005 => 52, 2006 => 52, 2007 => 1, 2008 => 1, 2009 => 53, 2010 => 52}.each do |year, week_number|
56
+ before :each do
57
+ Calorie.configuration do |config|
58
+ config.week_starts_on :monday
59
+ end
60
+ end
61
+
62
+ specify "in #{year}" do
63
+ Calorie.new(year, 12).weeks.last.number.should eq(week_number)
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -2,23 +2,31 @@ require 'calorie/day'
2
2
  require 'calorie/week'
3
3
 
4
4
  describe Calorie::Week do
5
-
6
- it "loops through the days" do
7
- days = [
8
- Calorie::Day.new,
9
- Calorie::Day.new,
10
- Calorie::Day.new(Date.new(2010, 6, 1), "the first"),
11
- Calorie::Day.new(Date.new(2010, 6, 2), "the second"),
12
- Calorie::Day.new(Date.new(2010, 6, 3), "the third"),
13
- Calorie::Day.new(Date.new(2010, 6, 4), "the fourth"),
14
- Calorie::Day.new(Date.new(2010, 6, 5), "the fifth"),
5
+ let(:thursday) { Calorie::Day.new(Date.new(2010, 6, 3)) }
6
+ let(:days) {
7
+ [
8
+ Calorie::NullDay.new(Date.new(2010, 5, 29)),
9
+ Calorie::NullDay.new(Date.new(2010, 5, 31)),
10
+ Calorie::Day.new(Date.new(2010, 6, 1)),
11
+ Calorie::Day.new(Date.new(2010, 6, 2)),
12
+ thursday,
13
+ Calorie::Day.new(Date.new(2010, 6, 4)),
14
+ Calorie::Day.new(Date.new(2010, 6, 5)),
15
15
  ]
16
+ }
17
+
18
+ let(:week) { Calorie::Week.new(days) }
16
19
 
20
+ it "loops through the days" do
17
21
  numbers = []
18
- Calorie::Week.new(days).each_day do |day|
22
+ week.each_day do |day|
19
23
  numbers << day.number
20
24
  end
21
25
 
22
26
  numbers.should eq([nil, nil, 1, 2, 3, 4, 5])
23
27
  end
28
+
29
+ it "can find its Thursday" do
30
+ week.thursday.should eq(thursday)
31
+ end
24
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calorie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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-11-27 00:00:00.000000000Z
12
+ date: 2011-12-04 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2153896240 !ruby/object:Gem::Requirement
16
+ requirement: &2161868520 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2153896240
24
+ version_requirements: *2161868520
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: timecop
27
- requirement: &2153895820 !ruby/object:Gem::Requirement
27
+ requirement: &2161868100 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,18 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2153895820
35
+ version_requirements: *2161868100
36
+ - !ruby/object:Gem::Dependency
37
+ name: i18n
38
+ requirement: &2161867680 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2161867680
36
47
  description: A simple, ruby calendar presenter.
37
48
  email:
38
49
  - katrina.owen@gmail.com
@@ -49,12 +60,15 @@ files:
49
60
  - lib/calorie.rb
50
61
  - lib/calorie/calendar.rb
51
62
  - lib/calorie/day.rb
63
+ - lib/calorie/day_of_the_week.rb
52
64
  - lib/calorie/version.rb
53
65
  - lib/calorie/week.rb
54
66
  - lib/calorie/weeks_in_month.rb
55
67
  - spec/calendar_spec.rb
56
68
  - spec/calorie_spec.rb
69
+ - spec/day_of_the_week_spec.rb
57
70
  - spec/day_spec.rb
71
+ - spec/week_of_the_year_spec.rb
58
72
  - spec/week_spec.rb
59
73
  - spec/weeks_in_month_spec.rb
60
74
  homepage: ''