olauzon-weekender 0.0.0 → 0.0.1

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.
@@ -26,6 +26,7 @@ A simple Ruby library for creating calendars based on weeks rather than months.
26
26
  >> weekender.display
27
27
  => Outputs HTML calendar
28
28
 
29
+ View examples at http://weekender.heroku.com/
29
30
 
30
31
  == Inspiration
31
32
 
@@ -0,0 +1,4 @@
1
+ ---
2
+ :minor: 0
3
+ :patch: 1
4
+ :major: 0
@@ -55,7 +55,10 @@ private
55
55
  def day_cell(week, day)
56
56
  date = date_on(week, day)
57
57
  output = '<td>'
58
- output << '<a href="#" class="weekender_date">'
58
+ output << '<a href="#" class="weekender_date'
59
+ output << ' weekender_event' if event_on?(date.to_s)
60
+ output << html_classes_on(date.to_s)
61
+ output << '">'
59
62
  output << date.strftime(date_format)
60
63
  output << '</a>'
61
64
  output << content_on(date.to_s)
@@ -21,15 +21,15 @@ class Weekender
21
21
  :events
22
22
 
23
23
  def initialize(options={})
24
- @year = options[:year] || Date.today.year
25
- @month = options[:month] || Date.today.month
26
- @day = options[:day] || Date.today.day
27
- @year_end = options[:year_end] || year
28
- @month_end = options[:month_end] || month
29
- @day_end = options[:day_end] || day
30
- @before = options[:before] || 0
31
- @after = options[:after] || 0
32
- @events = options[:events] || []
24
+ @year = (options[:year] || Date.today.year ).to_i
25
+ @month = (options[:month] || Date.today.month).to_i
26
+ @day = (options[:day] || Date.today.day ).to_i
27
+ @year_end = (options[:year_end] || year ).to_i
28
+ @month_end = (options[:month_end] || month ).to_i
29
+ @day_end = (options[:day_end] || day ).to_i
30
+ @before = (options[:before] || 0 ).to_i
31
+ @after = (options[:after] || 0 ).to_i
32
+ @events = options[:events] || []
33
33
  end
34
34
 
35
35
  def weeks
@@ -65,11 +65,7 @@ class Weekender
65
65
  end
66
66
 
67
67
  def event_on?(date)
68
- if events.empty?
69
- false
70
- else
71
- events_dates.include?(date)
72
- end
68
+ events_dates.include?(date)
73
69
  end
74
70
 
75
71
  def events_dates
@@ -77,28 +73,17 @@ class Weekender
77
73
  end
78
74
 
79
75
  def events_on(date)
80
- if event_on?(date)
81
- events.select { |event| event[0] == date }
82
- else
83
- []
84
- end
76
+ events.select { |event| event[0] == date }
85
77
  end
86
78
 
87
79
  def content_on(date)
88
- content = ''
89
- events_on(date).each do |event|
90
- content << event[1][:content]
91
- end
92
- content
80
+ events_on(date).reject { |event| event[1][:content].nil? }.
81
+ map { |event| event[1][:content] }.join('')
93
82
  end
94
83
 
95
84
  def html_classes_on(date)
96
- classes = ''
97
- events_on(date).each do |event|
98
- classes << ' ' unless classes == ''
99
- classes << event[1][:html_class]
100
- end
101
- classes
85
+ events_on(date).reject { |event| event[1][:html_class].nil? }.
86
+ map { |event| event[1][:html_class] }.join(' ')
102
87
  end
103
88
 
104
89
  def previous
@@ -121,8 +106,6 @@ class Weekender
121
106
  )
122
107
  end
123
108
 
124
- # private
125
-
126
109
  def date
127
110
  Date.new(year, month, day)
128
111
  end
@@ -22,8 +22,8 @@
22
22
  <td><a href="#" class="weekender_date">2009-04-28</a></td>
23
23
  <td><a href="#" class="weekender_date">2009-04-29</a></td>
24
24
  <td><a href="#" class="weekender_date">2009-04-30</a></td>
25
- <td><a href="#" class="weekender_date">2009-05-01</a><p>This is an event</p></td>
26
- <td><a href="#" class="weekender_date">2009-05-02</a><p>This is another event</p></td>
25
+ <td><a href="#" class="weekender_date weekender_event">2009-05-01</a><p>This is an event</p></td>
26
+ <td><a href="#" class="weekender_date weekender_event">2009-05-02</a><p>This is another event</p></td>
27
27
  <td><a href="#" class="weekender_date">2009-05-03</a></td>
28
28
  </tr>
29
29
  <tr>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: olauzon-weekender
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olivier Lauzon
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-19 00:00:00 -07:00
12
+ date: 2009-08-20 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -24,6 +24,7 @@ extra_rdoc_files:
24
24
  files:
25
25
  - README.rdoc
26
26
  - Rakefile
27
+ - VERSION.yml
27
28
  - lib/core_ext/date.rb
28
29
  - lib/core_ext/string.rb
29
30
  - lib/weekender.rb