From 9b04ebefcdc378e1839c2ad8c228bb06fed75a89 Mon Sep 17 00:00:00 2001 From: Alex Dunae Date: Wed, 19 Dec 2007 22:16:30 +0000 Subject: [PATCH] Updated docs --- REFERENCES | 4 +--- data/SYNTAX | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/REFERENCES b/REFERENCES index 17dba5f..715efbe 100644 --- a/REFERENCES +++ b/REFERENCES @@ -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 + diff --git a/data/SYNTAX b/data/SYNTAX index 8d37e14..bf6384d 100644 --- a/data/SYNTAX +++ b/data/SYNTAX @@ -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 data/ 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 \ No newline at end of file