calendar_helper 0.2.4 → 0.2.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/{History.txt → History.rdoc} +0 -1
- data/{README.txt → README.rdoc} +24 -2
- data/{generators/calendar_styles/templates/blue/style.css → app/assets/stylesheets/calendar_styles/blue.css} +0 -0
- data/{generators/calendar_styles/templates/grey/style.css → app/assets/stylesheets/calendar_styles/grey.css} +0 -0
- data/{generators/calendar_styles/templates/red/style.css → app/assets/stylesheets/calendar_styles/red.css} +0 -0
- data/lib/calendar_helper.rb +93 -51
- data/test/test_calendar_helper.rb +72 -12
- metadata +94 -68
- data/.gemtest +0 -0
- data/Manifest.txt +0 -12
- data/Rakefile +0 -40
- data/generators/calendar_styles/calendar_styles_generator.rb +0 -20
data/{README.txt → README.rdoc}
RENAMED
@@ -1,10 +1,23 @@
|
|
1
1
|
= CalendarHelper
|
2
2
|
|
3
|
+
{<img src="https://secure.travis-ci.org/topfunky/calendar_helper.png?branch=master" alt="Build Status" />}[http://travis-ci.org/topfunky/calendar_helper]
|
4
|
+
|
3
5
|
== DESCRIPTION:
|
4
6
|
|
5
|
-
A simple helper for creating an HTML calendar. The "calendar" method will be
|
7
|
+
A simple helper for creating an HTML calendar. The "calendar" method will be
|
8
|
+
automatically available to your Rails view templates, or can be used with
|
9
|
+
Sinatra or other webapps.
|
10
|
+
|
11
|
+
Some example stylesheets are provided via the Rails asset pipeline. Add to
|
12
|
+
your main stylesheet with one of the following:
|
6
13
|
|
7
|
-
|
14
|
+
/*
|
15
|
+
*= require 'calendar_styles/grey'
|
16
|
+
* OR
|
17
|
+
*= require 'calendar_styles/red'
|
18
|
+
* OR
|
19
|
+
*= require 'calendar_styles/blue'
|
20
|
+
*/
|
8
21
|
|
9
22
|
== SYNOPSIS:
|
10
23
|
|
@@ -41,6 +54,14 @@ In Sinatra, include the CalendarHelper module in your helpers:
|
|
41
54
|
include CalendarHelper
|
42
55
|
end
|
43
56
|
|
57
|
+
|
58
|
+
== Accessibility & 508 Compliance:
|
59
|
+
|
60
|
+
* The table tag has a summary attribute (overridable).
|
61
|
+
* Each th has an id.
|
62
|
+
* Each td as a headers attribute, containing the element id of the appropriate th.
|
63
|
+
|
64
|
+
|
44
65
|
== AUTHORS:
|
45
66
|
|
46
67
|
Jeremy Voorhis -- http://jvoorhis.com
|
@@ -54,6 +75,7 @@ Test suite and conversion to a Rails plugin
|
|
54
75
|
* Jarkko Laine http://jlaine.net/
|
55
76
|
* Tom Armitage http://infovore.org
|
56
77
|
* Bryan Larsen http://larsen.st
|
78
|
+
* Eric Anderson http://saveyourcall.com
|
57
79
|
|
58
80
|
== USAGE:
|
59
81
|
|
File without changes
|
File without changes
|
File without changes
|
data/lib/calendar_helper.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: UTF-8
|
1
2
|
require 'date'
|
2
3
|
|
3
4
|
# CalendarHelper allows you to draw a databound calendar with fine-grained CSS formatting
|
@@ -9,35 +10,36 @@ module CalendarHelper
|
|
9
10
|
# calendar (which can then be customized using CSS) for a given month and year.
|
10
11
|
# However, this may be customized in a variety of ways -- changing the default CSS
|
11
12
|
# classes, generating the individual day entries yourself, and so on.
|
12
|
-
#
|
13
|
+
#
|
13
14
|
# The following options are required:
|
14
15
|
# :year # The year number to show the calendar for.
|
15
16
|
# :month # The month number to show the calendar for.
|
16
|
-
#
|
17
|
+
#
|
17
18
|
# The following are optional, available for customizing the default behaviour:
|
19
|
+
# :table_id => "calendar-2008-08" # The id for the <table> tag.
|
18
20
|
# :table_class => "calendar" # The class for the <table> tag.
|
21
|
+
# :summary => "Calendar for August 2008" # The summary attribute for the <table> tag. Required for 508 compliance.
|
19
22
|
# :month_name_class => "monthName" # The class for the name of the month, at the top of the table.
|
20
|
-
# :other_month_class => "otherMonth" #
|
23
|
+
# :other_month_class => "otherMonth" # The class for individual day cells for previous and next months.
|
21
24
|
# :day_name_class => "dayName" # The class is for the names of the weekdays, at the top.
|
22
25
|
# :day_class => "day" # The class for the individual day number cells.
|
23
26
|
# This may or may not be used if you specify a block (see below).
|
24
|
-
# :abbrev =>
|
25
|
-
#
|
26
|
-
# (0..-1) for the entire name.
|
27
|
+
# :abbrev => true # This option specifies whether day names should be displayed abbrevidated (true)
|
28
|
+
# or in full (false)
|
27
29
|
# :first_day_of_week => 0 # Renders calendar starting on Sunday. Use 1 for Monday, and so on.
|
28
30
|
# :accessible => true # Turns on accessibility mode. This suffixes dates within the
|
29
|
-
# # calendar that are outside the range defined in the <caption> with
|
31
|
+
# # calendar that are outside the range defined in the <caption> with
|
30
32
|
# # <span class="hidden"> MonthName</span>
|
31
33
|
# # Defaults to false.
|
32
|
-
# # You'll need to define an appropriate style in order to make this disappear.
|
34
|
+
# # You'll need to define an appropriate style in order to make this disappear.
|
33
35
|
# # Choose your own method of hiding content appropriately.
|
34
36
|
#
|
35
|
-
# :show_today => false # Highlights today on the calendar using the CSS class 'today'.
|
37
|
+
# :show_today => false # Highlights today on the calendar using the CSS class 'today'.
|
36
38
|
# # Defaults to true.
|
37
39
|
# :previous_month_text => nil # Displayed left of the month name if set
|
38
40
|
# :next_month_text => nil # Displayed right of the month name if set
|
39
41
|
# :month_header => false # If you use false, the current month header will disappear.
|
40
|
-
# :calendar_title =>
|
42
|
+
# :calendar_title => month_names[options[:month]] # Pass in a custom title for the calendar. Defaults to month name
|
41
43
|
#
|
42
44
|
# For more customization, you can pass a code block to this method, that will get one argument, a Date object,
|
43
45
|
# and return a values for the individual table cells. The block can return an array, [cell_text, cell_attrs],
|
@@ -45,7 +47,7 @@ module CalendarHelper
|
|
45
47
|
# (this can be used to change the <td>'s class for customization with CSS).
|
46
48
|
# This block can also return the cell_text only, in which case the <td>'s class defaults to the value given in
|
47
49
|
# +:day_class+. If the block returns nil, the default options are used.
|
48
|
-
#
|
50
|
+
#
|
49
51
|
# Example usage:
|
50
52
|
# calendar(:year => 2005, :month => 6) # This generates the simplest possible calendar.
|
51
53
|
# calendar({:year => 2005, :month => 6, :table_class => "calendar_helper"}) # This generates a calendar, as
|
@@ -62,30 +64,39 @@ module CalendarHelper
|
|
62
64
|
# end
|
63
65
|
# end
|
64
66
|
#
|
65
|
-
# An additional 'weekend' class is applied to weekend days.
|
67
|
+
# An additional 'weekend' class is applied to weekend days.
|
66
68
|
#
|
67
69
|
# For consistency with the themes provided in the calendar_styles generator, use "specialDay" as the CSS class for marked days.
|
68
|
-
#
|
70
|
+
#
|
71
|
+
# Accessibility & 508 Compliance:
|
72
|
+
# The table tag has a summary attribute (overridable).
|
73
|
+
# Each th has an id.
|
74
|
+
# Each td has a headers attribute, containing the element id of the appropriate th.
|
75
|
+
#
|
69
76
|
def calendar(options = {}, &block)
|
70
77
|
raise(ArgumentError, "No year given") unless options.has_key?(:year)
|
71
78
|
raise(ArgumentError, "No month given") unless options.has_key?(:month)
|
72
79
|
|
73
80
|
block ||= Proc.new {|d| nil}
|
74
81
|
|
82
|
+
month_names = (!defined?(I18n) || I18n.t("date.month_names").include?("missing")) ? Date::MONTHNAMES.dup : I18n.t("date.month_names")
|
83
|
+
|
75
84
|
defaults = {
|
85
|
+
:table_id => "calendar-#{options[:year]}-#{"%02d" % options[:month]}",
|
76
86
|
:table_class => 'calendar',
|
77
87
|
:month_name_class => 'monthName',
|
78
88
|
:other_month_class => 'otherMonth',
|
79
89
|
:day_name_class => 'dayName',
|
80
90
|
:day_class => 'day',
|
81
|
-
:abbrev =>
|
91
|
+
:abbrev => true,
|
82
92
|
:first_day_of_week => 0,
|
83
93
|
:accessible => false,
|
84
94
|
:show_today => true,
|
85
95
|
:previous_month_text => nil,
|
86
96
|
:next_month_text => nil,
|
87
97
|
:month_header => true,
|
88
|
-
:calendar_title =>
|
98
|
+
:calendar_title => month_names[options[:month]],
|
99
|
+
:summary => "Calendar for #{month_names[options[:month]]} #{options[:year]}"
|
89
100
|
}
|
90
101
|
options = defaults.merge options
|
91
102
|
|
@@ -94,16 +105,18 @@ module CalendarHelper
|
|
94
105
|
|
95
106
|
first_weekday = first_day_of_week(options[:first_day_of_week])
|
96
107
|
last_weekday = last_day_of_week(options[:first_day_of_week])
|
97
|
-
|
98
|
-
day_names = Date::DAYNAMES.
|
108
|
+
|
109
|
+
day_names = (!defined?(I18n) || I18n.t("date.day_names").include?("missing")) ? Date::DAYNAMES : I18n.t("date.day_names")
|
110
|
+
abbr_day_names = (!defined?(I18n) || I18n.t("date.abbr_day_names").include?("missing")) ? Date::ABBR_DAYNAMES : I18n.t("date.abbr_day_names")
|
111
|
+
week_days = (0..6).to_a
|
99
112
|
first_weekday.times do
|
100
|
-
|
113
|
+
week_days.push(week_days.shift)
|
101
114
|
end
|
102
115
|
|
103
116
|
# TODO Use some kind of builder instead of straight HTML
|
104
|
-
cal = %(<table class="#{options[:table_class]}" border="0" cellspacing="0" cellpadding="0">)
|
117
|
+
cal = %(<table id="#{options[:table_id]}" class="#{options[:table_class]}" border="0" cellspacing="0" cellpadding="0" summary="#{options[:summary]}">)
|
105
118
|
cal << %(<thead>)
|
106
|
-
|
119
|
+
|
107
120
|
if (options[:month_header])
|
108
121
|
cal << %(<tr>)
|
109
122
|
if options[:previous_month_text] or options[:next_month_text]
|
@@ -116,56 +129,51 @@ module CalendarHelper
|
|
116
129
|
cal << %(<th colspan="2">#{options[:next_month_text]}</th>) if options[:next_month_text]
|
117
130
|
cal << %(</tr>)
|
118
131
|
end
|
119
|
-
|
132
|
+
|
120
133
|
cal << %(<tr class="#{options[:day_name_class]}">)
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
cal << "<th scope='col'>#{d[options[:abbrev]]}</th>"
|
127
|
-
end
|
134
|
+
|
135
|
+
week_days.each do |wday|
|
136
|
+
cal << %(<th id="#{th_id(Date::DAYNAMES[wday], options[:table_id])}" scope="col">)
|
137
|
+
cal << (options[:abbrev] ? %(<abbr title="#{day_names[wday]}">#{abbr_day_names[wday]}</abbr>) : day_names[wday])
|
138
|
+
cal << %(</th>)
|
128
139
|
end
|
140
|
+
|
129
141
|
cal << "</tr></thead><tbody><tr>"
|
142
|
+
|
143
|
+
# previous month
|
130
144
|
beginning_of_week(first, first_weekday).upto(first - 1) do |d|
|
131
|
-
cal <<
|
132
|
-
cal << " weekendDay" if weekend?(d)
|
133
|
-
if options[:accessible]
|
134
|
-
cal << %(">#{d.day}<span class="hidden"> #{Date::MONTHNAMES[d.month]}</span></td>)
|
135
|
-
else
|
136
|
-
cal << %(">#{d.day}</td>)
|
137
|
-
end
|
145
|
+
cal << generate_other_month_cell(d, options)
|
138
146
|
end unless first.wday == first_weekday
|
147
|
+
|
139
148
|
first.upto(last) do |cur|
|
140
149
|
cell_text, cell_attrs = block.call(cur)
|
141
150
|
cell_text ||= cur.mday
|
142
151
|
cell_attrs ||= {}
|
152
|
+
cell_attrs[:headers] = th_id(cur, options[:table_id])
|
143
153
|
cell_attrs[:class] ||= options[:day_class]
|
144
154
|
cell_attrs[:class] += " weekendDay" if [0, 6].include?(cur.wday)
|
145
155
|
today = (Time.respond_to?(:zone) && !(zone = Time.zone).nil? ? zone.now.to_date : Date.today)
|
146
156
|
cell_attrs[:class] += " today" if (cur == today) and options[:show_today]
|
147
|
-
|
148
|
-
cal <<
|
157
|
+
|
158
|
+
cal << generate_cell(cell_text, cell_attrs)
|
149
159
|
cal << "</tr><tr>" if cur.wday == last_weekday
|
150
160
|
end
|
161
|
+
|
162
|
+
# next month
|
151
163
|
(last + 1).upto(beginning_of_week(last + 7, first_weekday) - 1) do |d|
|
152
|
-
cal <<
|
153
|
-
cal << " weekendDay" if weekend?(d)
|
154
|
-
if options[:accessible]
|
155
|
-
cal << %(">#{d.day}<span class='hidden'> #{Date::MONTHNAMES[d.mon]}</span></td>)
|
156
|
-
else
|
157
|
-
cal << %(">#{d.day}</td>)
|
158
|
-
end
|
164
|
+
cal << generate_other_month_cell(d, options)
|
159
165
|
end unless last.wday == last_weekday
|
166
|
+
|
160
167
|
cal << "</tr></tbody></table>"
|
168
|
+
cal.respond_to?(:html_safe) ? cal.html_safe : cal
|
161
169
|
end
|
162
|
-
|
170
|
+
|
163
171
|
private
|
164
|
-
|
172
|
+
|
165
173
|
def first_day_of_week(day)
|
166
174
|
day
|
167
175
|
end
|
168
|
-
|
176
|
+
|
169
177
|
def last_day_of_week(day)
|
170
178
|
if day > 0
|
171
179
|
day - 1
|
@@ -173,7 +181,7 @@ module CalendarHelper
|
|
173
181
|
6
|
174
182
|
end
|
175
183
|
end
|
176
|
-
|
184
|
+
|
177
185
|
def days_between(first, second)
|
178
186
|
if first > second
|
179
187
|
second + (7 - first)
|
@@ -181,14 +189,48 @@ module CalendarHelper
|
|
181
189
|
second - first
|
182
190
|
end
|
183
191
|
end
|
184
|
-
|
192
|
+
|
185
193
|
def beginning_of_week(date, start = 1)
|
186
194
|
days_to_beg = days_between(start, date.wday)
|
187
195
|
date - days_to_beg
|
188
196
|
end
|
189
|
-
|
197
|
+
|
198
|
+
def generate_cell(cell_text, cell_attrs)
|
199
|
+
cell_attrs = cell_attrs.map {|k, v| %(#{k}="#{v}") }.join(" ")
|
200
|
+
"<td #{cell_attrs}>#{cell_text}</td>"
|
201
|
+
end
|
202
|
+
|
203
|
+
def generate_other_month_cell(date, options)
|
204
|
+
cell_attrs = {}
|
205
|
+
cell_attrs[:headers] = th_id(date, options[:table_id])
|
206
|
+
cell_attrs[:class] = options[:other_month_class]
|
207
|
+
cell_attrs[:class] += " weekendDay" if weekend?(date)
|
208
|
+
|
209
|
+
cell_text = date.day
|
210
|
+
if options[:accessible]
|
211
|
+
cell_text += %(<span class="hidden"> #{month_names[date.month]}</span>)
|
212
|
+
end
|
213
|
+
|
214
|
+
generate_cell(date.day, cell_attrs)
|
215
|
+
end
|
216
|
+
|
217
|
+
# Calculates id for th element.
|
218
|
+
# derived from calendar_id and dow.
|
219
|
+
#
|
220
|
+
# Params:
|
221
|
+
# `day` can be either Date or DOW('Sunday', 'Monday')
|
222
|
+
def th_id(day, calendar_id)
|
223
|
+
return th_id(Date::DAYNAMES[day.wday], calendar_id) if day.is_a?(Date)
|
224
|
+
"#{calendar_id}-#{day[0..2].downcase}"
|
225
|
+
end
|
226
|
+
|
190
227
|
def weekend?(date)
|
191
228
|
[0, 6].include?(date.wday)
|
192
229
|
end
|
193
|
-
|
230
|
+
|
231
|
+
class Engine < Rails::Engine # :nodoc:
|
232
|
+
ActiveSupport.on_load(:action_view) do
|
233
|
+
include CalendarHelper
|
234
|
+
end
|
235
|
+
end if defined? Rails::Engine
|
194
236
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: UTF-8
|
1
2
|
require 'rubygems'
|
2
3
|
require 'test/unit'
|
3
4
|
require 'fileutils'
|
@@ -42,11 +43,11 @@ class CalendarHelperTest < Test::Unit::TestCase
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def test_default_css_classes
|
45
|
-
# :other_month_class is not implemented yet
|
46
46
|
{ :table_class => "calendar",
|
47
47
|
:month_name_class => "monthName",
|
48
48
|
:day_name_class => "dayName",
|
49
|
-
:day_class => "day"
|
49
|
+
:day_class => "day",
|
50
|
+
:other_month_class => "otherMonth"
|
50
51
|
}.each do |key, value|
|
51
52
|
assert_correct_css_class_for_default value
|
52
53
|
end
|
@@ -54,21 +55,19 @@ class CalendarHelperTest < Test::Unit::TestCase
|
|
54
55
|
|
55
56
|
def test_custom_css_classes
|
56
57
|
# Uses the key name as the CSS class name
|
57
|
-
|
58
|
-
[:table_class, :month_name_class, :day_name_class, :day_class].each do |key|
|
58
|
+
[:table_class, :month_name_class, :day_name_class, :day_class, :other_month_class].each do |key|
|
59
59
|
assert_correct_css_class_for_key key.to_s, key
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
def test_abbrev
|
64
|
-
assert_match %r{>Mon<}, calendar_with_defaults(
|
65
|
-
assert_match %r{>
|
66
|
-
assert_match %r{>Monday<}, calendar_with_defaults(:abbrev => (0..-1))
|
64
|
+
assert_match %r{>Mon<}, calendar_with_defaults()
|
65
|
+
assert_match %r{>Monday<}, calendar_with_defaults(:abbrev => false)
|
67
66
|
end
|
68
67
|
|
69
68
|
def test_block
|
70
69
|
# Even days are special
|
71
|
-
assert_match %r{class="special_day"
|
70
|
+
assert_match %r{class="special_day"[^>]*>2<}, calendar(:year => 2006, :month => 8) { |d|
|
72
71
|
if d.mday % 2 == 0
|
73
72
|
[d.mday, {:class => 'special_day'}]
|
74
73
|
end
|
@@ -76,15 +75,15 @@ class CalendarHelperTest < Test::Unit::TestCase
|
|
76
75
|
end
|
77
76
|
|
78
77
|
def test_first_day_of_week
|
79
|
-
assert_match %r{<tr class="dayName">\s*<th scope=
|
78
|
+
assert_match %r{<tr class="dayName">\s*<th [^>]*scope="col"><abbr title="Sunday">Sun}, calendar_with_defaults
|
80
79
|
# testing that if the abbrev and contracted version are the same, there should be no abbreviation.
|
81
|
-
assert_match %r{<tr class="dayName">\s*<th scope=
|
82
|
-
assert_match %r{<tr class="dayName">\s*<th scope=
|
80
|
+
assert_match %r{<tr class="dayName">\s*<th [^>]*scope="col">Sunday}, calendar_with_defaults(:abbrev => false)
|
81
|
+
assert_match %r{<tr class="dayName">\s*<th [^>]*scope="col"><abbr title="Monday">Mon}, calendar_with_defaults(:first_day_of_week => 1)
|
83
82
|
end
|
84
83
|
|
85
84
|
def test_today_is_in_calendar
|
86
85
|
todays_day = Date.today.day
|
87
|
-
assert_match %r{class="day.+today"
|
86
|
+
assert_match %r{class="day.+today"[^>]*>#{todays_day}<}, calendar_for_this_month
|
88
87
|
end
|
89
88
|
|
90
89
|
def test_should_not_show_today
|
@@ -100,6 +99,67 @@ class CalendarHelperTest < Test::Unit::TestCase
|
|
100
99
|
assert_match %r{<thead><tr>.*</tr><tr.*</tr></thead>}, html
|
101
100
|
end
|
102
101
|
|
102
|
+
def test_table_summary_defaults_to_calendar_period
|
103
|
+
html = calendar_with_defaults(:year => 1967, :month => 4)
|
104
|
+
assert_match %r{<table [^>]*summary="Calendar for April 1967"}, html
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_custom_summary_attribute
|
108
|
+
html = calendar_with_defaults(:summary => 'TEST SUMMARY')
|
109
|
+
assert_match %r{<table [^>]*summary="TEST SUMMARY">}, html
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_table_id_defaults_calendar_year_single_digit_month
|
113
|
+
html = calendar_with_defaults(:year => 1967, :month => 4)
|
114
|
+
assert_match %r{<table [^>]*id="calendar-1967-04"}, html
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_table_id_defaults_calendar_year_double_digit_month
|
118
|
+
html = calendar_with_defaults(:year => 1967, :month => 12)
|
119
|
+
assert_match %r{<table [^>]*id="calendar-1967-12"}, html
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_custom_table_id
|
123
|
+
html = calendar_with_defaults(:year => 1967, :month => 4, :table_id => 'test-the-id')
|
124
|
+
assert_match %r{<table [^>]*id="test-the-id"}, html
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_th_id_defaults_calendar_year_month_dow
|
128
|
+
html = calendar_with_defaults(:year => 1967, :month => 4)
|
129
|
+
assert_match %r{<tr class=\"dayName\"><th [^>]*id=\"calendar-1967-04-sun\"}, html
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_each_td_is_associated_with_appriopriate_th
|
133
|
+
html = calendar_with_defaults(:year => 2011, :month => 8)
|
134
|
+
assert_match %r{<td [^>]*headers=\"calendar-2011-08-sun\"[^>]*>31</td>}, html
|
135
|
+
assert_match %r{<td [^>]*headers=\"calendar-2011-08-mon\"[^>]*>1</td>}, html
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_non_english_language
|
139
|
+
# mock I18n.t to simulate internationalized setting
|
140
|
+
CalendarHelper.const_set :I18n, Class.new {
|
141
|
+
def self.t(key)
|
142
|
+
if key == "date.day_names"
|
143
|
+
["Neděle", "Pondělí", "Úterý", "Středa", "Čtvrtek", "Pátek", "Sobota"]
|
144
|
+
elsif key == "date.abbr_day_names"
|
145
|
+
["Ne", "Po", "Út", "St", "Čt", "Pá", "So"]
|
146
|
+
elsif key == "date.month_names"
|
147
|
+
["", "Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec"]
|
148
|
+
end
|
149
|
+
end
|
150
|
+
}
|
151
|
+
|
152
|
+
html = calendar_with_defaults(:year => 2012, :month => 4)
|
153
|
+
|
154
|
+
# unmock I18n.t again
|
155
|
+
CalendarHelper.send(:remove_const, :I18n)
|
156
|
+
|
157
|
+
# make sure all the labels are in english and don't use i18n abbreviation (Neděle)
|
158
|
+
assert_no_match %r(calendar-2012-04-ned), html
|
159
|
+
assert_equal 6, html.scan("calendar-2012-04-sun").size # 6 = 5 + header
|
160
|
+
end
|
161
|
+
|
162
|
+
|
103
163
|
private
|
104
164
|
|
105
165
|
def assert_correct_css_class_for_key(css_class, key)
|
metadata
CHANGED
@@ -1,99 +1,125 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: calendar_helper
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.5
|
4
5
|
prerelease:
|
5
|
-
version: 0.2.4
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Geoffrey Grosenbach
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-02-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
17
15
|
name: open4
|
18
|
-
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
20
17
|
none: false
|
21
|
-
requirements:
|
22
|
-
- -
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
25
22
|
type: :runtime
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: hoe
|
29
23
|
prerelease: false
|
30
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rdoc
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.10'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
57
|
none: false
|
32
|
-
requirements:
|
33
|
-
- -
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version:
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.10'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: flexmock
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
36
70
|
type: :development
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: ! " A simple helper for creating an HTML calendar. The \"calendar\"
|
79
|
+
method will\n be automatically available to your Rails view templates, or can
|
80
|
+
be used\n with Sinatra or other webapps.\n\n There is also a Rails generator
|
81
|
+
that copies some stylesheets for use alone\n or alongside existing stylesheets.\n"
|
82
|
+
email: boss@topfunky.com
|
44
83
|
executables: []
|
45
|
-
|
46
84
|
extensions: []
|
47
|
-
|
48
|
-
|
49
|
-
- History.
|
50
|
-
|
51
|
-
- README.txt
|
52
|
-
files:
|
53
|
-
- History.txt
|
85
|
+
extra_rdoc_files:
|
86
|
+
- README.rdoc
|
87
|
+
- History.rdoc
|
88
|
+
files:
|
54
89
|
- MIT-LICENSE
|
55
|
-
-
|
56
|
-
-
|
57
|
-
- Rakefile
|
58
|
-
- generators/calendar_styles/calendar_styles_generator.rb
|
59
|
-
- generators/calendar_styles/templates/blue/style.css
|
60
|
-
- generators/calendar_styles/templates/grey/style.css
|
61
|
-
- generators/calendar_styles/templates/red/style.css
|
90
|
+
- README.rdoc
|
91
|
+
- History.rdoc
|
62
92
|
- init.rb
|
63
93
|
- lib/calendar_helper.rb
|
94
|
+
- app/assets/stylesheets/calendar_styles/blue.css
|
95
|
+
- app/assets/stylesheets/calendar_styles/grey.css
|
96
|
+
- app/assets/stylesheets/calendar_styles/red.css
|
64
97
|
- test/test_calendar_helper.rb
|
65
|
-
- .gemtest
|
66
|
-
has_rdoc: true
|
67
98
|
homepage:
|
68
99
|
licenses: []
|
69
|
-
|
70
100
|
post_install_message:
|
71
|
-
rdoc_options:
|
101
|
+
rdoc_options:
|
72
102
|
- --main
|
73
|
-
- README.
|
74
|
-
require_paths:
|
103
|
+
- README.rdoc
|
104
|
+
require_paths:
|
75
105
|
- lib
|
76
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
107
|
none: false
|
78
|
-
requirements:
|
79
|
-
- -
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
|
82
|
-
|
83
|
-
- 0
|
84
|
-
version: "0"
|
85
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
113
|
none: false
|
87
|
-
requirements:
|
88
|
-
- -
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version:
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
91
118
|
requirements: []
|
92
|
-
|
93
|
-
|
94
|
-
rubygems_version: 1.6.2
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 1.8.23
|
95
121
|
signing_key:
|
96
122
|
specification_version: 3
|
97
123
|
summary: A simple helper for creating an HTML calendar
|
98
|
-
test_files:
|
124
|
+
test_files:
|
99
125
|
- test/test_calendar_helper.rb
|
data/.gemtest
DELETED
File without changes
|
data/Manifest.txt
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
History.txt
|
2
|
-
MIT-LICENSE
|
3
|
-
Manifest.txt
|
4
|
-
README.txt
|
5
|
-
Rakefile
|
6
|
-
generators/calendar_styles/calendar_styles_generator.rb
|
7
|
-
generators/calendar_styles/templates/blue/style.css
|
8
|
-
generators/calendar_styles/templates/grey/style.css
|
9
|
-
generators/calendar_styles/templates/red/style.css
|
10
|
-
init.rb
|
11
|
-
lib/calendar_helper.rb
|
12
|
-
test/test_calendar_helper.rb
|
data/Rakefile
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'isolate/now'
|
3
|
-
require 'rake'
|
4
|
-
require 'rake/rdoctask'
|
5
|
-
require 'hoe'
|
6
|
-
require './lib/calendar_helper.rb'
|
7
|
-
|
8
|
-
Hoe.spec 'calendar_helper' do
|
9
|
-
developer('Geoffrey Grosenbach', 'boss@topfunky.com')
|
10
|
-
|
11
|
-
extra_deps << ['open4']
|
12
|
-
|
13
|
-
# self.rubyforge_name = 'osxscreenshotx' # if different than 'osxscreenshot'
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
# Hoe.new('calendar_helper', CalendarHelper::VERSION) do |p|
|
18
|
-
# p.rubyforge_name = 'seattlerb'
|
19
|
-
# p.summary = 'Generates a configurable, CSS-tagged HTML calendar.'
|
20
|
-
# p.description = "A simple method to create an HTML calendar for a single month. Can be styled with CSS. Usable with Ruby on Rails."
|
21
|
-
# p.url = "http://rubyforge.org/projects/seattlerb"
|
22
|
-
# p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
23
|
-
# p.clean_globs = ['test/output']
|
24
|
-
# end
|
25
|
-
|
26
|
-
# desc "Test task (actually runs specs)"
|
27
|
-
# task "test" do
|
28
|
-
# system "spec --format specdoc --color spec/*_spec.rb"
|
29
|
-
# end
|
30
|
-
|
31
|
-
# -- Rails-specific --
|
32
|
-
|
33
|
-
desc 'Generate documentation for the calendar_helper plugin.'
|
34
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
35
|
-
rdoc.rdoc_dir = 'rdoc'
|
36
|
-
rdoc.title = 'CalendarHelper'
|
37
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
38
|
-
rdoc.rdoc_files.include('README.txt')
|
39
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
40
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
class CalendarStylesGenerator < Rails::Generator::Base
|
2
|
-
|
3
|
-
def manifest
|
4
|
-
record do |m|
|
5
|
-
calendar_themes_dir = "public/stylesheets/calendar"
|
6
|
-
m.directory calendar_themes_dir
|
7
|
-
|
8
|
-
# Copy files
|
9
|
-
%w(red blue grey).each do |dir|
|
10
|
-
m.directory File.join(calendar_themes_dir, dir)
|
11
|
-
m.file File.join("#{dir}/style.css"), File.join(calendar_themes_dir, "#{dir}/style.css")
|
12
|
-
end
|
13
|
-
|
14
|
-
# Dir.read("vendor/public/calendar_helper/generators/calendar_styles/templates").each do |dir|
|
15
|
-
# m.file "orig", File.join(calendar_themes_dir, dir.name, "some_file.css")
|
16
|
-
# end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|