Moved tests into YAML files
This commit is contained in:
parent
4c19694ef8
commit
f90e48d353
30 changed files with 394 additions and 12 deletions
|
@ -10,6 +10,7 @@ def parse_holiday_defs(module_name, files)
|
|||
regions = []
|
||||
rules_by_month = {}
|
||||
custom_methods = {}
|
||||
test_strs = []
|
||||
|
||||
files.each do |file|
|
||||
def_file = YAML.load_file(file)
|
||||
|
@ -50,6 +51,10 @@ def parse_holiday_defs(module_name, files)
|
|||
end # /methods.each
|
||||
end
|
||||
|
||||
if def_file['tests']
|
||||
puts " - importing testings..."
|
||||
test_strs << def_file['tests']
|
||||
end
|
||||
end
|
||||
|
||||
# Build the definitions
|
||||
|
@ -95,8 +100,8 @@ def parse_holiday_defs(module_name, files)
|
|||
end
|
||||
|
||||
|
||||
# Build the output file
|
||||
out =<<-EOC
|
||||
# Build the module file
|
||||
module_src =<<-EOM
|
||||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
|
@ -121,9 +126,29 @@ module Holidays
|
|||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::#{module_name}::DEFINED_REGIONS, Holidays::#{module_name}::HOLIDAYS_BY_MONTH)
|
||||
EOC
|
||||
EOM
|
||||
|
||||
|
||||
# Build the test file
|
||||
unless test_strs.empty?
|
||||
test_src =<<-EndOfTests
|
||||
require File.dirname(__FILE__) + '/test_helper'
|
||||
require 'holidays/#{module_name.downcase}'
|
||||
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: #{files.join(', ')}
|
||||
class #{module_name.capitalize}DefinitionTests < Test::Unit::TestCase # :nodoc:
|
||||
|
||||
def test_#{module_name.downcase}
|
||||
#{test_strs.join("\n\n")}
|
||||
end
|
||||
end
|
||||
EndOfTests
|
||||
end
|
||||
|
||||
return module_src, test_src || ''
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
26
data/au.yaml
26
data/au.yaml
|
@ -78,3 +78,29 @@ months:
|
|||
- name: Boxing Day
|
||||
regions: [au]
|
||||
mday: 26
|
||||
tests: |
|
||||
{Date.civil(2007,1,1) => 'New Year\'s Day',
|
||||
Date.civil(2007,1,26) => 'Australia Day',
|
||||
Date.civil(2007,4,6) => 'Good Friday',
|
||||
Date.civil(2007,4,9) => 'Easter Monday',
|
||||
Date.civil(2007,4,25) => 'ANZAC Day',
|
||||
Date.civil(2007,12,25) => 'Christmas Day',
|
||||
Date.civil(2007,12,26) => 'Boxing Day'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :au, :informal)[0][:name]
|
||||
end
|
||||
|
||||
[:au_sa, :au_act, :au_nsw, :au_].each do |r|
|
||||
assert_equal 'Labour Day', Date.civil(2007,10,1).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
[:au_sa, :au_act, :au_nsw, :au_vic, :au_tas, :au_qld, :au_nt, :au_].each do |r|
|
||||
assert_equal 'Queen\'s Birthday', Date.civil(2007,6,11).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
assert_equal 'Labour Day', Date.civil(2007,3,5).holidays(:au_wa)[0][:name]
|
||||
assert_equal 'Labour Day', Date.civil(2007,3,12).holidays(:au_vic)[0][:name]
|
||||
assert_equal 'Labour Day', Date.civil(2007,5,7).holidays(:au_qld)[0][:name]
|
||||
|
||||
assert_equal 'May Day', Date.civil(2007,5,7).holidays(:au_nt)[0][:name]
|
||||
|
||||
assert_equal 'Eight Hours Day', Date.civil(2007,3,12).holidays(:au_tas)[0][:name]
|
19
data/ca.yaml
19
data/ca.yaml
|
@ -119,4 +119,23 @@ methods:
|
|||
date -= 6
|
||||
end
|
||||
date
|
||||
end
|
||||
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,5,19) => 'Victoria Day',
|
||||
Date.civil(2008,7,1) => 'Canada Day',
|
||||
Date.civil(2008,9,1) => 'Labour Day',
|
||||
Date.civil(2008,10,13) => 'Thanksgiving',
|
||||
Date.civil(2008,11,11) => 'Rememberance 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
|
37
data/de.yaml
37
data/de.yaml
|
@ -77,4 +77,39 @@ methods:
|
|||
date -= (date.wday + 4)
|
||||
end
|
||||
date
|
||||
end
|
||||
end
|
||||
tests: |
|
||||
{Date.civil(2009,1,1) => 'Neujahrstag',
|
||||
Date.civil(2009,4,10) => 'Karfreitag',
|
||||
Date.civil(2009,4,12) => 'Ostern',
|
||||
Date.civil(2009,4,13) => 'Ostermontag',
|
||||
Date.civil(2009,5,1) => 'Tag der Arbeit',
|
||||
Date.civil(2009,5,21) => 'Christi Himmelfahrt',
|
||||
Date.civil(2009,6,1) => 'Pfingstmontag',
|
||||
Date.civil(2009,10,3) => 'Tag der Deutschen Einheit',
|
||||
Date.civil(2009,12,25) => '1. Weihnachtstag',
|
||||
Date.civil(2009,12,26) => '2. Weihnachtstag'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :de, :informal)[0][:name]
|
||||
end
|
||||
|
||||
[:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn, :de_th, :de_].each do |r|
|
||||
assert_equal 'Fronleichnam', Date.civil(2009,6,11).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
[:de_by, :de_sl, :de_].each do |r|
|
||||
assert_equal 'Mariä Himmelfahrt', Date.civil(2009,8,15).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
[:de_bb, :de_mv, :de_sn, :de_st, :de_th, :de_].each do |r|
|
||||
assert_equal 'Reformationstag', Date.civil(2009,10,31).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
[:de_bw, :de_by, :de_nw, :de_rp, :de_sl, :de_].each do |r|
|
||||
assert_equal 'Allerheiligen', Date.civil(2009,11,1).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
# Repentance Day
|
||||
assert_equal 'Buß- und Bettag', Date.civil(2004,11,17).holidays(:de_sn)[0][:name]
|
||||
assert_equal 'Buß- und Bettag', Date.civil(2005,11,16).holidays(:de_sn)[0][:name]
|
||||
assert_equal 'Buß- und Bettag', Date.civil(2006,11,22).holidays(:de_sn)[0][:name]
|
||||
assert_equal 'Buß- und Bettag', Date.civil(2009,11,18).holidays(:de_sn)[0][:name]
|
||||
|
|
20
data/dk.yaml
20
data/dk.yaml
|
@ -95,3 +95,23 @@ months:
|
|||
- name: 2. juledag
|
||||
regions: [dk]
|
||||
mday: 26
|
||||
tests: |
|
||||
{Date.civil(2007,1,1) => 'Nytårsdag',
|
||||
Date.civil(2007,2,18) => 'Fastelavn',
|
||||
Date.civil(2007,4,9) => 'Danmarks besættelse',
|
||||
Date.civil(2007,4,16) => 'Dronningens fødselsdag',
|
||||
Date.civil(2007,4,5) => 'Skærtorsdag',
|
||||
Date.civil(2007,4,6) => 'Langfredag',
|
||||
Date.civil(2007,4,8) => 'Påskedag',
|
||||
Date.civil(2007,4,9) => '2. påskedag',
|
||||
Date.civil(2007,5,1) => 'Arbejdernes kampdag',
|
||||
Date.civil(2007,5,4) => 'Store Bededag',
|
||||
Date.civil(2007,5,17) => 'Kristi Himmelfartsdag',
|
||||
Date.civil(2007,5,27) => 'Pinsedag',
|
||||
Date.civil(2007,5,28) => '2. Pinsedag',
|
||||
Date.civil(2007,6,5) => 'Grundlovsdag',
|
||||
Date.civil(2007,12,24) => 'Juleaftensdag',
|
||||
Date.civil(2007,12,25) => '1. juledag',
|
||||
Date.civil(2007,12,26) => '2. juledag'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :dk, :informal)[0][:name]
|
||||
end
|
47
data/es.yaml
47
data/es.yaml
|
@ -112,3 +112,50 @@ months:
|
|||
- name: San Esteban
|
||||
regions: [es_ib, es_ct]
|
||||
mday: 26
|
||||
tests: |
|
||||
{Date.civil(2009,1,1) => 'Año Nuevo',
|
||||
Date.civil(2009,1,6) => 'Día de Reyes',
|
||||
Date.civil(2009,4,10) => 'Viernes Santo',
|
||||
Date.civil(2009,5,1) => 'Día del Trabajador',
|
||||
Date.civil(2009,8,15) => 'Asunción',
|
||||
Date.civil(2009,10,12) => 'Día de la Hispanidad',
|
||||
Date.civil(2009,11,1) => 'Todos los Santos',
|
||||
Date.civil(2009,12,6) => 'Día de la Constitución',
|
||||
Date.civil(2009,12,8) => 'Inmaculada Concepción',
|
||||
Date.civil(2009,12,25) => 'Navidad del Señor'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :es, :informal)[0][:name]
|
||||
end
|
||||
|
||||
[:es_pv, :es_ct, :es_na, :es_v, :es_vc, :es_].each do |r|
|
||||
assert_equal 'Jueves Santo', Date.civil(2009,4,9).holidays(r)[0][:name]
|
||||
assert_equal 'Lunes de Pascua', Date.civil(2009,4,13).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
[:es_v, :es_vc, :es_cm, :es_mu, :es_m, :es_].each do |r|
|
||||
assert_equal 'San José', Date.civil(2009,3,19).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
[:es_ar, :es_cl, :es_].each do |r|
|
||||
assert_equal 'San Jorge', Date.civil(2009,4,23).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
[:es_vc, :es_v, :es_].each do |r|
|
||||
assert_equal 'Día de Valencia', Date.civil(2009,10,9).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
[:es_ib, :es_ct, :es_].each do |r|
|
||||
assert_equal 'San Esteban', Date.civil(2009,12,26).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
assert_equal 'Día de Andalucía', Date.civil(2009,2,28).holidays(:es_an)[0][:name]
|
||||
assert_equal 'Día de las Islas Baleares', Date.civil(2009,3,1).holidays(:es_ib)[0][:name]
|
||||
assert_equal 'Fiesta de la Comunidad', Date.civil(2006,5,2).holidays(:es_m)[0][:name]
|
||||
assert_equal 'Día de las Canarias', Date.civil(2006,5,30).holidays(:es_cn)[0][:name]
|
||||
assert_equal 'Día de la Región Castilla-La Mancha', Date.civil(2009,5,31).holidays(:es_cm)[0][:name]
|
||||
assert_equal 'Día de la Región de Murcia', Date.civil(2009,6,9).holidays(:es_mu)[0][:name]
|
||||
assert_equal 'Día de La Rioja', Date.civil(2009,6,9).holidays(:es_lo)[0][:name]
|
||||
assert_equal 'Santiago Apostol', Date.civil(2009,7,23).holidays(:es_ga)[0][:name]
|
||||
assert_equal 'Día de Ceuta', Date.civil(2009,9,2).holidays(:es_ce)[0][:name]
|
||||
assert_equal 'Día de Asturias', Date.civil(2009,9,8).holidays(:es_o)[0][:name]
|
||||
assert_equal 'Día de Extremadura', Date.civil(2009,9,8).holidays(:es_ex)[0][:name]
|
||||
assert_equal 'Fiesta Nacional de Cataluña', Date.civil(2009,9,11).holidays(:es_ct)[0][:name]
|
17
data/fr.yaml
17
data/fr.yaml
|
@ -52,4 +52,19 @@ months:
|
|||
- name: Nöel
|
||||
regions: [fr]
|
||||
mday: 25
|
||||
|
||||
tests: |
|
||||
{Date.civil(2007,1,1) => 'Jour de l\'an',
|
||||
Date.civil(2007,4,8) => 'Pâques',
|
||||
Date.civil(2007,4,9) => 'Lundi de Pâques',
|
||||
Date.civil(2007,5,1) => 'Fête du travail',
|
||||
Date.civil(2007,5,8) => 'Victoire 1945',
|
||||
Date.civil(2007,5,17) => 'Ascension',
|
||||
Date.civil(2007,5,27) => 'Pentecôte',
|
||||
Date.civil(2007,5,28) => 'Lundi de Pentecôte',
|
||||
Date.civil(2007,7,14) => 'Fête nationale',
|
||||
Date.civil(2007,8,15) => 'Assomption',
|
||||
Date.civil(2007,11,1) => 'Toussaint',
|
||||
Date.civil(2007,11,11) => 'Armistice 1918',
|
||||
Date.civil(2007,12,25) => 'Nöel'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :fr, :informal)[0][:name]
|
||||
end
|
26
data/gb.yaml
26
data/gb.yaml
|
@ -78,3 +78,29 @@ months:
|
|||
regions: [gb]
|
||||
mday: 26
|
||||
observed: to_weekday_if_boxing_weekend
|
||||
tests: |
|
||||
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
||||
Date.civil(2008,3,21) => 'Good Friday',
|
||||
Date.civil(2008,3,23) => 'Easter Sunday',
|
||||
Date.civil(2008,5,5) => 'May Day',
|
||||
Date.civil(2008,5,26) => 'Bank Holiday',
|
||||
Date.civil(2008,11,5) => 'Guy Fawkes 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, :gb, :informal)[0][:name]
|
||||
end
|
||||
|
||||
assert_equal 'St. Patrick\'s Day', Date.civil(2008,3,17).holidays(:gb_nir, :informal)[0][:name]
|
||||
|
||||
assert_equal 'Christmas Day', Date.civil(2008,12,25).holidays(:gb_, :observed)[0][:name]
|
||||
assert_equal 'Christmas Day', Date.civil(2009,12,25).holidays(:gb_, :observed)[0][:name]
|
||||
assert_equal 'Christmas Day', Date.civil(2010,12,27).holidays(:gb_, :observed)[0][:name]
|
||||
|
||||
assert_equal 'Boxing Day', Date.civil(2008,12,26).holidays(:gb_, :observed)[0][:name]
|
||||
assert_equal 'Boxing Day', Date.civil(2009,12,28).holidays(:gb_, :observed)[0][:name]
|
||||
assert_equal 'Boxing Day', Date.civil(2010,12,28).holidays(:gb_, :observed)[0][:name]
|
||||
|
||||
[:gb_wls, :gb_eng, :gb_nir, :gb_eaw, :gb_].each do |r|
|
||||
assert_equal 'Easter Monday', Date.civil(2008,3,24).holidays(r)[0][:name]
|
||||
assert_equal 'Bank Holiday', Date.civil(2008,8,25).holidays(r)[0][:name]
|
||||
end
|
12
data/ie.yaml
12
data/ie.yaml
|
@ -45,4 +45,14 @@ months:
|
|||
- name: St. Stephen's Day
|
||||
regions: [ie]
|
||||
mday: 26
|
||||
|
||||
tests: |
|
||||
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
||||
Date.civil(2008,3,17) => 'St. Patrick\'s Day',
|
||||
Date.civil(2008,3,24) => 'Easter Monday',
|
||||
Date.civil(2008,5,5) => 'May Day',
|
||||
Date.civil(2008,6,2) => 'Bank Holiday',
|
||||
Date.civil(2008,8,4) => 'Bank Holiday',
|
||||
Date.civil(2008,12,25) => 'Christmas Day',
|
||||
Date.civil(2008,12,26) => 'St. Stephen\'s Day'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :ie, :informal)[0][:name]
|
||||
end
|
23
data/is.yaml
23
data/is.yaml
|
@ -110,4 +110,27 @@ methods:
|
|||
date += (11 - date.wday)
|
||||
end
|
||||
date
|
||||
end
|
||||
tests: |
|
||||
{Date.civil(2007,1,1) => 'Nýársdagur',
|
||||
Date.civil(2007,1,6) => 'Þrettándinn',
|
||||
Date.civil(2007,1,19) => 'Bóndadagur',
|
||||
Date.civil(2007,2,18) => 'Konudagur',
|
||||
Date.civil(2007,4,5) => 'Skírdagur',
|
||||
Date.civil(2007,4,6) => 'Föstudaginn langi',
|
||||
Date.civil(2007,4,8) => 'Páskadagur',
|
||||
Date.civil(2007,4,9) => 'Annar í páskum',
|
||||
Date.civil(2007,4,19) => 'Sumardagurinn fyrsti',
|
||||
Date.civil(2007,5,1) => 'Verkalýðsdagurinn',
|
||||
Date.civil(2007,5,17) => 'Uppstigningardagur',
|
||||
Date.civil(2007,5,27) => 'Hvítasunnudagur',
|
||||
Date.civil(2007,5,28) => 'Annar í hvítasunnu',
|
||||
Date.civil(2007,6,3) => 'Sjómannadagurinn',
|
||||
Date.civil(2007,6,17) => 'Lýðveldisdagurinn',
|
||||
Date.civil(2007,8,6) => 'Frídagur verslunarmanna',
|
||||
Date.civil(2007,12,24) => 'Jól',
|
||||
Date.civil(2007,12,25) => 'Jól',
|
||||
Date.civil(2007,12,26) => 'Jól',
|
||||
Date.civil(2007,12,31) => 'Gamlárskvöld'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :is, :informal)[0][:name]
|
||||
end
|
15
data/it.yaml
15
data/it.yaml
|
@ -49,3 +49,18 @@ months:
|
|||
- name: Santo Stefano
|
||||
regions: [it]
|
||||
mday: 26
|
||||
tests: |
|
||||
{Date.civil(2007,1,1) => 'Capodanno',
|
||||
Date.civil(2007,1,6) => 'Epifania',
|
||||
Date.civil(2007,4,8) => 'Pasqua',
|
||||
Date.civil(2007,4,9) => 'Lunedì dell\'Angelo',
|
||||
Date.civil(2007,4,25) => 'Festa della Liberazione',
|
||||
Date.civil(2007,5,1) => 'Festa dei Lavoratori',
|
||||
Date.civil(2007,6,2) => 'Festa della Repubblica',
|
||||
Date.civil(2007,8,15) => 'Assunzione',
|
||||
Date.civil(2007,11,1) => 'Ognissanti',
|
||||
Date.civil(2007,12,8) => 'Immacolata Concezione',
|
||||
Date.civil(2007,12,25) => 'Natale',
|
||||
Date.civil(2007,12,26) => 'Santo Stefano'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :it, :informal)[0][:name]
|
||||
end
|
17
data/mx.yaml
17
data/mx.yaml
|
@ -1,5 +1,8 @@
|
|||
# Mexican holiday definitions for the Ruby Holiday gem.
|
||||
# Updated 2008-11-24.
|
||||
# Updated 2008-12-05.
|
||||
# Sources:
|
||||
# - http://www.britishembassy.gov.uk/servlet/Front?pagename=OpenMarket/Xcelerate/ShowPage&c=Page&cid=1125561634963
|
||||
# - http://www.usembassy-mexico.gov/eng/holidays.html
|
||||
---
|
||||
months:
|
||||
1:
|
||||
|
@ -89,3 +92,15 @@ months:
|
|||
- name: Los Santos Inocentes
|
||||
regions: [mx]
|
||||
mday: 28
|
||||
tests: |
|
||||
{Date.civil(2007,1,1) => 'Año nuevo',
|
||||
Date.civil(2007,2,5) => 'Día de la Constitución',
|
||||
Date.civil(2007,5,1) => 'Día del Trabajo',
|
||||
Date.civil(2007,5,5) => 'Cinco de Mayo',
|
||||
Date.civil(2007,9,16) => 'Día de la Independencia',
|
||||
Date.civil(2007,11,1) => 'Todos los Santos',
|
||||
Date.civil(2007,11,2) => 'Los Fieles Difuntos',
|
||||
Date.civil(2007,11,19) => 'Día de la Revolución',
|
||||
Date.civil(2007,12,25) => 'Navidad'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :mx, :informal)[0][:name]
|
||||
end
|
14
data/nl.yaml
14
data/nl.yaml
|
@ -51,3 +51,17 @@ months:
|
|||
- name: Kerstmis
|
||||
regions: [nl]
|
||||
mday: 26
|
||||
tests: |
|
||||
{Date.civil(2008,1,1) => 'Nieuwjaar',
|
||||
Date.civil(2008,3,21) => 'Goede Vrijdag',
|
||||
Date.civil(2008,3,23) => 'Pasen',
|
||||
Date.civil(2008,3,24) => 'Pasen',
|
||||
Date.civil(2008,4,30) => 'Koninginnedag',
|
||||
Date.civil(2008,5,1) => 'Hemelvaartsdag', # Ascension, Easter+39
|
||||
Date.civil(2008,5,5) => 'Bevrijdingsdag',
|
||||
Date.civil(2008,5,11) => 'Pinksteren', # Pentecost, Easter+49
|
||||
Date.civil(2008,5,12) => 'Pinksteren', # Pentecost, Easter+50
|
||||
Date.civil(2008,12,25) => 'Kerstmis',
|
||||
Date.civil(2008,12,26) => 'Kerstmis'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :nl, :informal)[0][:name]
|
||||
end
|
22
data/pt.yaml
22
data/pt.yaml
|
@ -61,3 +61,25 @@ months:
|
|||
- name: Natal
|
||||
regions: [pt]
|
||||
mday: 25
|
||||
tests: |
|
||||
{Date.civil(2008,1,1) => 'Ano Novo',
|
||||
Date.civil(2005,2,8) => 'Carnaval',
|
||||
Date.civil(2006,2,28) => 'Carnaval',
|
||||
Date.civil(2007,2,20) => 'Carnaval',
|
||||
Date.civil(2008,2,5) => 'Carnaval',
|
||||
Date.civil(2008,3,21) => 'Sexta-feira Santa',
|
||||
Date.civil(2008,3,23) => 'Páscoa',
|
||||
Date.civil(2008,4,25) => 'Dia da Liberdade',
|
||||
Date.civil(2008,5,1) => 'Dia do Trabalhador',
|
||||
Date.civil(2005,5,26) => 'Corpo de Deus',
|
||||
Date.civil(2007,6,7) => 'Corpo de Deus',
|
||||
Date.civil(2008,5,22) => 'Corpo de Deus',
|
||||
Date.civil(2008,6,10) => 'Dia de Portugal',
|
||||
Date.civil(2008,8,15) => 'Assunção de Nossa Senhora',
|
||||
Date.civil(2008,10,5) => 'Implantação da República',
|
||||
Date.civil(2008,11,1) => 'Todos os Santos',
|
||||
Date.civil(2008,12,1) => 'Restauração da Independência',
|
||||
Date.civil(2008,12,8) => 'Imaculada Conceição',
|
||||
Date.civil(2008,12,25) => 'Natal'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :pt, :informal)[0][:name]
|
||||
end
|
22
data/se.yaml
22
data/se.yaml
|
@ -67,3 +67,25 @@ methods:
|
|||
date += (6 - date.wday)
|
||||
date
|
||||
end
|
||||
tests: |
|
||||
{Date.civil(2008,1,1) => 'Nyårsdagen',
|
||||
Date.civil(2008,1,6) => 'Trettondedag jul',
|
||||
Date.civil(2008,3,21) => 'Långfredagen',
|
||||
Date.civil(2008,3,23) => 'Påskdagen',
|
||||
Date.civil(2008,3,24) => 'Annandag påsk',
|
||||
Date.civil(2008,5,1) => 'Första maj',
|
||||
Date.civil(2008,5,1) => 'Kristi himmelsfärdsdag',
|
||||
Date.civil(2008,5,11) => 'Pingstdagen',
|
||||
Date.civil(2008,6,6) => 'Nationaldagen',
|
||||
Date.civil(2005,6,25) => 'Midsommardagen',
|
||||
Date.civil(2006,6,24) => 'Midsommardagen',
|
||||
Date.civil(2007,6,23) => 'Midsommardagen',
|
||||
Date.civil(2008,6,21) => 'Midsommardagen',
|
||||
Date.civil(2005,11,5) => 'Alla helgons dag',
|
||||
Date.civil(2006,11,4) => 'Alla helgons dag',
|
||||
Date.civil(2007,11,3) => 'Alla helgons dag',
|
||||
Date.civil(2008,11,1) => 'Alla helgons dag',
|
||||
Date.civil(2008,12,25) => 'Juldagen',
|
||||
Date.civil(2008,12,26) => 'Annandag jul'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :se, :informal)[0][:name]
|
||||
end
|
13
data/us.yaml
13
data/us.yaml
|
@ -65,4 +65,17 @@ methods:
|
|||
# January 20, every fourth year, following Presidential election
|
||||
def self.us_inauguration_day(year)
|
||||
year % 4 == 1 ? 20 : nil
|
||||
end
|
||||
tests: |
|
||||
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
||||
Date.civil(2008,1,21) => 'Martin Luther King, Jr. Day',
|
||||
Date.civil(2008,2,18) => 'Presidents\' Day',
|
||||
Date.civil(2008,5,26) => 'Memorial Day',
|
||||
Date.civil(2008,7,4) => 'Independence Day',
|
||||
Date.civil(2008,9,1) => 'Labor Day',
|
||||
Date.civil(2008,10,13) => 'Columbus Day',
|
||||
Date.civil(2008,11,11) => 'Veterans Day',
|
||||
Date.civil(2008,11,27) => 'Thanksgiving',
|
||||
Date.civil(2008,12,25) => 'Christmas Day'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :us)[0][:name]
|
||||
end
|
16
data/za.yaml
16
data/za.yaml
|
@ -61,4 +61,18 @@ months:
|
|||
regions: [za]
|
||||
mday: 26
|
||||
observed: to_weekday_if_boxing_weekend
|
||||
|
||||
tests: |
|
||||
{Date.civil(2007,1,1) => 'New Year\'s Day',
|
||||
Date.civil(2007,3,21) => 'Human Rights Day',
|
||||
Date.civil(2007,4,6) => 'Good Friday',
|
||||
Date.civil(2007,4,9) => 'Family Day',
|
||||
Date.civil(2007,4,27) => 'Freedom Day',
|
||||
Date.civil(2007,5,1) => 'Workers Day',
|
||||
Date.civil(2007,6,16) => 'Youth Day',
|
||||
Date.civil(2007,8,9) => 'National Women\'s Day',
|
||||
Date.civil(2007,9,24) => 'Heritage Day',
|
||||
Date.civil(2007,12,16) => 'Day of Reconciliation',
|
||||
Date.civil(2007,12,25) => 'Christmas Day',
|
||||
Date.civil(2007,12,26) => 'Day of Goodwill'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :za, :informal)[0][:name]
|
||||
end
|
|
@ -62,6 +62,7 @@ def self.ca_victoria_day(year)
|
|||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::CA::DEFINED_REGIONS, Holidays::CA::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -46,6 +46,7 @@ def self.de_buss_und_bettag(year)
|
|||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::DE::DEFINED_REGIONS, Holidays::DE::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -209,6 +209,7 @@ def self.de_buss_und_bettag(year)
|
|||
date
|
||||
end
|
||||
|
||||
|
||||
# Iceland: first day of summer (Thursday after 18 April)
|
||||
def self.is_sumardagurinn_fyrsti(year)
|
||||
date = Date.civil(year,4,18)
|
||||
|
@ -220,6 +221,7 @@ def self.is_sumardagurinn_fyrsti(year)
|
|||
date
|
||||
end
|
||||
|
||||
|
||||
# Sweden: All Saint's Day (Saturday between Oct 31 and Nov 6)
|
||||
def self.se_alla_helgons_dag(year)
|
||||
date = Date.civil(year,10,31)
|
||||
|
|
|
@ -55,6 +55,7 @@ def self.is_sumardagurinn_fyrsti(year)
|
|||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::IS::DEFINED_REGIONS, Holidays::IS::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -94,12 +94,14 @@ def self.ca_victoria_day(year)
|
|||
date
|
||||
end
|
||||
|
||||
|
||||
# January 20, every fourth year, following Presidential election
|
||||
def self.us_inauguration_day(year)
|
||||
year % 4 == 1 ? 20 : nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::NORTH_AMERICA::DEFINED_REGIONS, Holidays::NORTH_AMERICA::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -91,6 +91,7 @@ def self.is_sumardagurinn_fyrsti(year)
|
|||
date
|
||||
end
|
||||
|
||||
|
||||
# Sweden: All Saint's Day (Saturday between Oct 31 and Nov 6)
|
||||
def self.se_alla_helgons_dag(year)
|
||||
date = Date.civil(year,10,31)
|
||||
|
|
|
@ -42,6 +42,7 @@ def self.us_inauguration_day(year)
|
|||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::US::DEFINED_REGIONS, Holidays::US::HOLIDAYS_BY_MONTH)
|
||||
|
|
19
rakefile.rb
19
rakefile.rb
|
@ -58,9 +58,14 @@ namespace 'definitions' do
|
|||
def_list.each do |region, files|
|
||||
puts "Building #{region.to_s.upcase} definition module:"
|
||||
files.uniq!
|
||||
parsed = parse_holiday_defs(region.to_s.upcase, files)
|
||||
module_src, test_src = parse_holiday_defs(region.to_s.upcase, files)
|
||||
File.open("lib/holidays/#{region.to_s}.rb","w") do |file|
|
||||
file.puts parsed
|
||||
file.puts module_src
|
||||
end
|
||||
unless test_src.empty?
|
||||
File.open("test/test_defs_#{region.to_s}.rb","w") do |file|
|
||||
file.puts test_src
|
||||
end
|
||||
end
|
||||
puts "Done.\n\n"
|
||||
end
|
||||
|
@ -74,10 +79,16 @@ namespace 'definitions' do
|
|||
#def_list.each do |region, files|
|
||||
puts "Building #{region.to_s.upcase} definition module:"
|
||||
files.uniq!
|
||||
parsed = parse_holiday_defs(region.to_s.upcase, files)
|
||||
module_src, test_src = parse_holiday_defs(region.to_s.upcase, files)
|
||||
File.open("lib/holidays/#{region.to_s}.rb","w") do |file|
|
||||
file.puts parsed
|
||||
file.puts module_src
|
||||
end
|
||||
unless test_src.empty?
|
||||
File.open("test/test_defs_#{region.to_s}.rb","w") do |file|
|
||||
file.puts test_src
|
||||
end
|
||||
end
|
||||
|
||||
puts "Done.\n\n"
|
||||
#end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__), '../'))
|
||||
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__), '../lib/'))
|
||||
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__), '../../lib/'))
|
||||
|
||||
$KCODE = 'u'
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue