Updated docs

master
Alex Dunae 2007-12-19 22:16:30 +00:00
parent 20d513c455
commit 9b04ebefcd
2 changed files with 21 additions and 4 deletions

View File

@ -13,6 +13,4 @@ I am grateful to the following sources.
* http://www.un.org/geninfo/faq/factsheets/FS18.HTM
* http://en.wikipedia.org/wiki/List_of_holidays_by_country
==== US dates
* http://www.opm.gov/Operating_Status_Schedules/fedhol/index.asp
* http://www.smart.net/~mmontes/ushols.html

View File

@ -1,6 +1,6 @@
== Holiday Gem Definition Syntax
Definition files have two main parts: *months* and *methods*. Before you start, you may want to look some of the existing files at http://code.dunae.ca/svn/holidays/trunk/data.
All holidays are defined in YAML files in the <tt>data/</tt> directory. These definition files have three main parts: *months*, *methods* and *tests*. Before you start, you may want to look some of the existing files at http://code.dunae.ca/svn/holidays/trunk/data.
=== Months
@ -90,3 +90,22 @@ Observed-date functions take a Date object as a parameter and must return either
=== Tests
All definition files should have tests included. In the YAML file, tests are just a block of Ruby code.
tests: |
{Date.civil(2008,1,1) => 'New Year\'s Day',
Date.civil(2008,3,21) => 'Good Friday',
Date.civil(2008,3,24) => 'Easter Monday',
Date.civil(2008,9,1) => 'Labour Day',
Date.civil(2008,12,25) => 'Christmas Day',
Date.civil(2008,12,26) => 'Boxing Day'}.each do |date, name|
assert_equal name, Holidays.on(date, :ca, :informal)[0][:name]
end
# Victoria Day
[Date.civil(2004,5,24), Date.civil(2005,5,23), Date.civil(2006,5,22),
Date.civil(2007,5,21), Date.civil(2008,5,19)].each do |date|
assert_equal 'Victoria Day', Holidays.on(date, :ca)[0][:name]
end