From f7118f37adb08ef8fde8118fdcb36c1d712997e9 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Sun, 28 Mar 2010 15:23:35 +1300 Subject: [PATCH 01/33] Fix spelling mistake in errors --- lib/holidays.rb | 4 ++-- test/test_holidays.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/holidays.rb b/lib/holidays.rb index 4efde5e..b3c8b76 100644 --- a/lib/holidays.rb +++ b/lib/holidays.rb @@ -41,7 +41,7 @@ require 'date' # Holidays.between(from, to, :ca_bc, :informal) module Holidays # Exception thrown when an unknown region is requested. - class UnkownRegionError < ArgumentError; end + class UnknownRegionError < ArgumentError; end VERSION = '0.9.2' @@ -257,7 +257,7 @@ private regions.flatten! - raise UnkownRegionError unless regions.all? { |r| r == :any or @@regions.include?(r) } + raise UnknownRegionError unless regions.all? { |r| r == :any or @@regions.include?(r) } regions end diff --git a/test/test_holidays.rb b/test/test_holidays.rb index 760d33b..6da051b 100644 --- a/test/test_holidays.rb +++ b/test/test_holidays.rb @@ -31,15 +31,15 @@ class HolidaysTests < Test::Unit::TestCase end def test_requires_valid_regions - assert_raises Holidays::UnkownRegionError do + assert_raises Holidays::UnknownRegionError do Holidays.on(Date.civil(2008,1,1), :xx) end - assert_raises Holidays::UnkownRegionError do + assert_raises Holidays::UnknownRegionError do Holidays.on(Date.civil(2008,1,1), [:ca,:xx]) end - assert_raises Holidays::UnkownRegionError do + assert_raises Holidays::UnknownRegionError do Holidays.between(Date.civil(2008,1,1), Date.civil(2008,12,31), [:ca,:xx]) end end From bac7659a6d6e99b5907efc7e758c486fd421ab11 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Mon, 29 Mar 2010 08:51:32 +1300 Subject: [PATCH 02/33] ignore netbeans stuff --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ab05049..39272ef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .DS_Store -*.gem \ No newline at end of file +*.gem +nbproject From 0cd4bae37ab3c1940ee354960b6dc307e664359c Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Mon, 29 Mar 2010 08:52:00 +1300 Subject: [PATCH 03/33] add nz holidays --- data/index.yaml | 1 + data/nz.yaml | 141 ++++++++++++++++++++++++++++++++++++++ lib/holidays/MANIFEST | 1 + lib/holidays/nz.rb | 69 +++++++++++++++++++ test/defs/test_defs_nz.rb | 22 ++++++ 5 files changed, 234 insertions(+) create mode 100644 data/nz.yaml create mode 100644 lib/holidays/nz.rb create mode 100644 test/defs/test_defs_nz.rb diff --git a/data/index.yaml b/data/index.yaml index 61f5391..aa9d14f 100644 --- a/data/index.yaml +++ b/data/index.yaml @@ -16,6 +16,7 @@ defs: NL: ['nl.yaml'] "NO": ['no.yaml'] NYSE: ['nyse.yaml'] + NZ: ['nz.yaml'] PT: ['pt.yaml'] US: ['us.yaml', 'north_america_informal.yaml'] United_Nations: ['united_nations.yaml'] diff --git a/data/nz.yaml b/data/nz.yaml new file mode 100644 index 0000000..2b461ef --- /dev/null +++ b/data/nz.yaml @@ -0,0 +1,141 @@ +# New Zealand holiday definitions for the Ruby Holiday gem. +# Updated: 2010-03-28. +# Sources: +# - http://en.wikipedia.org/wiki/Public_holidays_in_New_Zealand +--- +months: + 0: + - name: Good Friday + regions: [nz] + function: easter(year)-2 + - name: Easter Saturday + regions: [nz] + function: easter(year)-1 + - name: Easter Monday + regions: [nz] + function: easter(year)+1 + 1: + - name: New Year's Day + regions: [nz] + mday: 1 + observed: to_monday_if_weekend + - name: Day after New Year's Day + regions: [nz] + mday: 2 + observed: to_weekday_if_boxing_weekend + - name: Southland Anniversary Day + regions: [nz_sl] + mday: 17 + - name: Wellington Anniversary Day + regions: [nz_we] + mday: 22 + observed: closest_monday + - name: Auckland Anniversary Day + regions: [nz_ak] + mday: 29 + observed: closest_monday + - name: Northland Anniversary Day + regions: [nz_nl] + mday: 29 + observed: closest_monday + 2: + - name: Nelson Anniversary Day + regions: [nz_ak] + mday: 1 + observed: closest_monday + - name: Waitangi Day + regions: [au] + mday: 6 + 3: + - name: Otago Anniversary Day + regions: [nz_ot] + mday: 23 + observed: closest_monday + - name: Taranaki Anniversary Day + regions: [nz_ak] + week: 2 + wday: 1 + 4: + - name: ANZAC Day + regions: [au] + mday: 25 + 6: + - name: Queen's Birthday + regions: [nz] + week: 1 + wday: 1 + 9: + - name: Dominion Day + regions: [nz_sc] + week: 4 + wday: 1 + 10: + - name: Hawke's bay Anniversary Day + regions: [nz_hb] + week: 1 + wday: 1 + observed: previous_friday + - name: Labour Day + regions: [nz] + week: 4 + wday: 1 + - name: Marlborough Anniversary Day + regions: [nz_mb] + week: 4 + wday: 1 + observed: next_week + 11: + - name: Canterbury Anniversary Day + regions: [nz_ca] + week: 2 + wday: 5 + - name: Chatham Island Anniversary Day + regions: [nz_ch] + mday: 30 + observed: closest_monday + 12: + - name: Westland Anniversary Day + regions: [nz_wl] + mday: 1 + observed: closest_monday + - name: Christmas Day + regions: [nz] + mday: 25 + observed: to_monday_if_weekend + - name: Boxing Day + regions: [nz] + mday: 26 + observed: to_weekday_if_boxing_weekend +tests: | + {Date.civil(2007,1,1) => 'New Year\'s Day', + Date.civil(2007,1,2) => 'Day after New Year\'s Day', + Date.civil(2007,2,6) => 'Waitangi', + 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, :nz, :informal)[0][:name] + end +methods: + closest_monday: | + def self.closest_monday(date) + if [1, 2, 3, 4].include?(date.wday) + date -= (date.wday - 1) + elsif 0 == date.wday + date += 1 + else + date += 8 - date.wday + end + date + end + + previous_friday: | + def self.previous_friday(date) + date - 3 + end + + next_week: | + def self.next_week(date) + date + 7 + end \ No newline at end of file diff --git a/lib/holidays/MANIFEST b/lib/holidays/MANIFEST index 277e7a9..c88f543 100644 --- a/lib/holidays/MANIFEST +++ b/lib/holidays/MANIFEST @@ -17,6 +17,7 @@ The following definition files are included in this installation: * holidays/nl * holidays/north_america * holidays/nyse +* holidays/nz * holidays/pt * holidays/scandinavia * holidays/se diff --git a/lib/holidays/nz.rb b/lib/holidays/nz.rb new file mode 100644 index 0000000..6a1d5d9 --- /dev/null +++ b/lib/holidays/nz.rb @@ -0,0 +1,69 @@ +# coding: utf-8 +module Holidays + # This file is generated by the Ruby Holiday gem. + # + # Definitions loaded: data/nz.yaml + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/nz' + # + # More definitions are available at http://code.dunae.ca/holidays. + module NZ # :nodoc: + DEFINED_REGIONS = [:nz_ca, :nz_ch, :nz, :nz_wl, :nz_sl, :nz_we, :nz_ak, :nz_nl, :au, :nz_ot, :nz_sc, :nz_hb, :nz_mb] + + HOLIDAYS_BY_MONTH = { + 0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:nz]}, + {:function => lambda { |year| Holidays.easter(year)-1 }, :function_id => "easter(year)-1", :name => "Easter Saturday", :regions => [:nz]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Easter Monday", :regions => [:nz]}], + 11 => [{:wday => 5, :week => 2, :name => "Canterbury Anniversary Day", :regions => [:nz_ca]}, + {:mday => 30, :observed => lambda { |date| Holidays.closest_monday(date) }, :observed_id => "closest_monday", :name => "Chatham Island Anniversary Day", :regions => [:nz_ch]}], + 6 => [{:wday => 1, :week => 1, :name => "Queen's Birthday", :regions => [:nz]}], + 1 => [{:mday => 1, :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "New Year's Day", :regions => [:nz]}, + {:mday => 2, :observed => lambda { |date| Holidays.to_weekday_if_boxing_weekend(date) }, :observed_id => "to_weekday_if_boxing_weekend", :name => "Day after New Year's Day", :regions => [:nz]}, + {:mday => 17, :name => "Southland Anniversary Day", :regions => [:nz_sl]}, + {:mday => 22, :observed => lambda { |date| Holidays.closest_monday(date) }, :observed_id => "closest_monday", :name => "Wellington Anniversary Day", :regions => [:nz_we]}, + {:mday => 29, :observed => lambda { |date| Holidays.closest_monday(date) }, :observed_id => "closest_monday", :name => "Auckland Anniversary Day", :regions => [:nz_ak]}, + {:mday => 29, :observed => lambda { |date| Holidays.closest_monday(date) }, :observed_id => "closest_monday", :name => "Northland Anniversary Day", :regions => [:nz_nl]}], + 12 => [{:mday => 1, :observed => lambda { |date| Holidays.closest_monday(date) }, :observed_id => "closest_monday", :name => "Westland Anniversary Day", :regions => [:nz_wl]}, + {:mday => 25, :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "Christmas Day", :regions => [:nz]}, + {:mday => 26, :observed => lambda { |date| Holidays.to_weekday_if_boxing_weekend(date) }, :observed_id => "to_weekday_if_boxing_weekend", :name => "Boxing Day", :regions => [:nz]}], + 2 => [{:mday => 1, :observed => lambda { |date| Holidays.closest_monday(date) }, :observed_id => "closest_monday", :name => "Nelson Anniversary Day", :regions => [:nz_ak]}, + {:mday => 6, :name => "Waitangi Day", :regions => [:au]}], + 3 => [{:mday => 23, :observed => lambda { |date| Holidays.closest_monday(date) }, :observed_id => "closest_monday", :name => "Otago Anniversary Day", :regions => [:nz_ot]}, + {:wday => 1, :week => 2, :name => "Taranaki Anniversary Day", :regions => [:nz_ak]}], + 9 => [{:wday => 1, :week => 4, :name => "Dominion Day", :regions => [:nz_sc]}], + 4 => [{:mday => 25, :name => "ANZAC Day", :regions => [:au]}], + 10 => [{:wday => 1, :week => 1, :observed => lambda { |date| Holidays.previous_friday(date) }, :observed_id => "previous_friday", :name => "Hawke's bay Anniversary Day", :regions => [:nz_hb]}, + {:wday => 1, :week => 4, :name => "Labour Day", :regions => [:nz]}, + {:wday => 1, :week => 4, :observed => lambda { |date| Holidays.next_week(date) }, :observed_id => "next_week", :name => "Marlborough Anniversary Day", :regions => [:nz_mb]}] + } + end + +def self.closest_monday(date) + if [1, 2, 3, 4].include?(date.wday) + date -= (date.wday - 1) + elsif 0 == date.wday + date += 1 + else + date += 8 - date.wday + end + date +end + + +def self.next_week(date) + date + 7 +end + +def self.previous_friday(date) + date - 3 +end + + + +end + +Holidays.merge_defs(Holidays::NZ::DEFINED_REGIONS, Holidays::NZ::HOLIDAYS_BY_MONTH) diff --git a/test/defs/test_defs_nz.rb b/test/defs/test_defs_nz.rb new file mode 100644 index 0000000..b6b7287 --- /dev/null +++ b/test/defs/test_defs_nz.rb @@ -0,0 +1,22 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/nz' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/nz.yaml +class NzDefinitionTests < Test::Unit::TestCase # :nodoc: + + def test_nz +{Date.civil(2007,1,1) => 'New Year\'s Day', + Date.civil(2007,1,2) => 'Day after New Year\'s Day', + Date.civil(2007,2,6) => 'Waitangi', + 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, :nz, :informal)[0][:name] +end + + end +end From 0a3e9aa10af57d05ce3eada4cf1332f07adbc49a Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Wed, 28 Apr 2010 18:28:39 +1200 Subject: [PATCH 04/33] A few holidays were still referring to .au --- data/nz.yaml | 6 +++--- lib/holidays/nz.rb | 6 +++--- test/defs/test_defs_nz.rb | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/data/nz.yaml b/data/nz.yaml index 2b461ef..ef452cf 100644 --- a/data/nz.yaml +++ b/data/nz.yaml @@ -44,7 +44,7 @@ months: mday: 1 observed: closest_monday - name: Waitangi Day - regions: [au] + regions: [nz] mday: 6 3: - name: Otago Anniversary Day @@ -57,7 +57,7 @@ months: wday: 1 4: - name: ANZAC Day - regions: [au] + regions: [nz] mday: 25 6: - name: Queen's Birthday @@ -109,7 +109,7 @@ months: tests: | {Date.civil(2007,1,1) => 'New Year\'s Day', Date.civil(2007,1,2) => 'Day after New Year\'s Day', - Date.civil(2007,2,6) => 'Waitangi', + Date.civil(2007,2,6) => 'Waitangi Day', Date.civil(2007,4,6) => 'Good Friday', Date.civil(2007,4,9) => 'Easter Monday', Date.civil(2007,4,25) => 'ANZAC Day', diff --git a/lib/holidays/nz.rb b/lib/holidays/nz.rb index 6a1d5d9..3e61468 100644 --- a/lib/holidays/nz.rb +++ b/lib/holidays/nz.rb @@ -12,7 +12,7 @@ module Holidays # # More definitions are available at http://code.dunae.ca/holidays. module NZ # :nodoc: - DEFINED_REGIONS = [:nz_ca, :nz_ch, :nz, :nz_wl, :nz_sl, :nz_we, :nz_ak, :nz_nl, :au, :nz_ot, :nz_sc, :nz_hb, :nz_mb] + DEFINED_REGIONS = [:nz_ca, :nz_ch, :nz, :nz_wl, :nz_sl, :nz_we, :nz_ak, :nz_nl, :nz_ot, :nz_sc, :nz_hb, :nz_mb] HOLIDAYS_BY_MONTH = { 0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:nz]}, @@ -31,11 +31,11 @@ module Holidays {:mday => 25, :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "Christmas Day", :regions => [:nz]}, {:mday => 26, :observed => lambda { |date| Holidays.to_weekday_if_boxing_weekend(date) }, :observed_id => "to_weekday_if_boxing_weekend", :name => "Boxing Day", :regions => [:nz]}], 2 => [{:mday => 1, :observed => lambda { |date| Holidays.closest_monday(date) }, :observed_id => "closest_monday", :name => "Nelson Anniversary Day", :regions => [:nz_ak]}, - {:mday => 6, :name => "Waitangi Day", :regions => [:au]}], + {:mday => 6, :name => "Waitangi Day", :regions => [:nz]}], 3 => [{:mday => 23, :observed => lambda { |date| Holidays.closest_monday(date) }, :observed_id => "closest_monday", :name => "Otago Anniversary Day", :regions => [:nz_ot]}, {:wday => 1, :week => 2, :name => "Taranaki Anniversary Day", :regions => [:nz_ak]}], 9 => [{:wday => 1, :week => 4, :name => "Dominion Day", :regions => [:nz_sc]}], - 4 => [{:mday => 25, :name => "ANZAC Day", :regions => [:au]}], + 4 => [{:mday => 25, :name => "ANZAC Day", :regions => [:nz]}], 10 => [{:wday => 1, :week => 1, :observed => lambda { |date| Holidays.previous_friday(date) }, :observed_id => "previous_friday", :name => "Hawke's bay Anniversary Day", :regions => [:nz_hb]}, {:wday => 1, :week => 4, :name => "Labour Day", :regions => [:nz]}, {:wday => 1, :week => 4, :observed => lambda { |date| Holidays.next_week(date) }, :observed_id => "next_week", :name => "Marlborough Anniversary Day", :regions => [:nz_mb]}] diff --git a/test/defs/test_defs_nz.rb b/test/defs/test_defs_nz.rb index b6b7287..02b19d7 100644 --- a/test/defs/test_defs_nz.rb +++ b/test/defs/test_defs_nz.rb @@ -9,7 +9,7 @@ class NzDefinitionTests < Test::Unit::TestCase # :nodoc: def test_nz {Date.civil(2007,1,1) => 'New Year\'s Day', Date.civil(2007,1,2) => 'Day after New Year\'s Day', - Date.civil(2007,2,6) => 'Waitangi', + Date.civil(2007,2,6) => 'Waitangi Day', Date.civil(2007,4,6) => 'Good Friday', Date.civil(2007,4,9) => 'Easter Monday', Date.civil(2007,4,25) => 'ANZAC Day', From 328584540ddd5409b1fad41dc3eaa9144ac3a690 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 00:49:55 +1200 Subject: [PATCH 05/33] Handle not requiring the locale off the bat. --- data/build_defs.rb | 1 - lib/holidays.rb | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/data/build_defs.rb b/data/build_defs.rb index 2255a96..2397fd4 100644 --- a/data/build_defs.rb +++ b/data/build_defs.rb @@ -134,7 +134,6 @@ EOM 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. # diff --git a/lib/holidays.rb b/lib/holidays.rb index b3c8b76..80b9735 100644 --- a/lib/holidays.rb +++ b/lib/holidays.rb @@ -83,6 +83,8 @@ module Holidays # => [{:name => 'Canada Day', :regions => [:ca]...} # {:name => 'Independence Day'', :regions => [:us], ...}] def self.between(start_date, end_date, *options) + start_date = start_date.to_date if start_date.respond_to?(:to_date) + end_date = end_date.to_date if end_date.respond_to?(:to_date) regions, observed, informal = parse_options(options) holidays = [] @@ -257,8 +259,7 @@ private regions.flatten! - raise UnknownRegionError unless regions.all? { |r| r == :any or @@regions.include?(r) } - + raise UnknownRegionError unless regions.all? { |r| r == :any or @@regions.include?(r) or begin require "holidays/#{r.to_s}"; rescue LoadError; false; end } regions end From 7294779692ab843cc753e71290a83d7bfb1c021b Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 00:50:16 +1200 Subject: [PATCH 06/33] Update tests to give more useful information when they fail. --- data/SYNTAX | 2 +- data/au.yaml | 2 +- data/ca.yaml | 2 +- data/cz.yaml | 2 +- data/de.yaml | 2 +- data/dk.yaml | 2 +- data/es.yaml | 2 +- data/fr.yaml | 2 +- data/gb.yaml | 2 +- data/ie.yaml | 2 +- data/is.yaml | 2 +- data/it.yaml | 2 +- data/mx.yaml | 2 +- data/nl.yaml | 2 +- data/no.yaml | 2 +- data/nyse.yaml | 2 +- data/nz.yaml | 2 +- data/pt.yaml | 2 +- data/se.yaml | 2 +- data/ups.yaml | 2 +- data/us.yaml | 2 +- data/za.yaml | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/data/SYNTAX b/data/SYNTAX index bf6384d..b870253 100644 --- a/data/SYNTAX +++ b/data/SYNTAX @@ -101,7 +101,7 @@ All definition files should have tests included. In the YAML file, tests are ju 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] + assert_equal name, (Holidays.on(date, :ca, :informal)[0] || {})[:name] end # Victoria Day diff --git a/data/au.yaml b/data/au.yaml index da7ec70..909612c 100644 --- a/data/au.yaml +++ b/data/au.yaml @@ -91,7 +91,7 @@ tests: | 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] + assert_equal name, (Holidays.on(date, :au, :informal)[0] || {})[:name] end [:au_sa, :au_act, :au_nsw, :au_].each do |r| diff --git a/data/ca.yaml b/data/ca.yaml index 2bcd540..451a764 100644 --- a/data/ca.yaml +++ b/data/ca.yaml @@ -131,7 +131,7 @@ tests: | 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] + assert_equal name, (Holidays.on(date, :ca, :informal)[0] || {})[:name] end # Victoria Day diff --git a/data/cz.yaml b/data/cz.yaml index aad4314..a873fce 100644 --- a/data/cz.yaml +++ b/data/cz.yaml @@ -63,6 +63,6 @@ tests: | Date.civil(2010,12,24) => 'Štědrý den', Date.civil(2010,12,25) => '1. svátek vánoční', Date.civil(2010,12,26) => '2. svátek vánoční'}.each do |date, name| - assert_equal name, Holidays.on(date, :cz, :informal)[0][:name] + assert_equal name, (Holidays.on(date, :cz, :informal)[0] || {})[:name] end diff --git a/data/de.yaml b/data/de.yaml index c7c5d6a..d4bfa76 100644 --- a/data/de.yaml +++ b/data/de.yaml @@ -81,7 +81,7 @@ tests: | 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] + assert_equal name, (Holidays.on(date, :de, :informal)[0] || {})[:name] end [:de_bw, :de_by, :de_st, :de_].each do |r| diff --git a/data/dk.yaml b/data/dk.yaml index b0c94d8..ea1f0fc 100644 --- a/data/dk.yaml +++ b/data/dk.yaml @@ -113,5 +113,5 @@ tests: | 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] + assert_equal name, (Holidays.on(date, :dk, :informal)[0] || {})[:name] end \ No newline at end of file diff --git a/data/es.yaml b/data/es.yaml index 3741f2b..5f531c3 100644 --- a/data/es.yaml +++ b/data/es.yaml @@ -123,7 +123,7 @@ tests: | 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] + 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| diff --git a/data/fr.yaml b/data/fr.yaml index b3c0fcd..0cfe761 100644 --- a/data/fr.yaml +++ b/data/fr.yaml @@ -66,5 +66,5 @@ tests: | 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] + assert_equal name, (Holidays.on(date, :fr, :informal)[0] || {})[:name] end \ No newline at end of file diff --git a/data/gb.yaml b/data/gb.yaml index 1c5377a..ff6e890 100644 --- a/data/gb.yaml +++ b/data/gb.yaml @@ -87,7 +87,7 @@ tests: | 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] + 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] diff --git a/data/ie.yaml b/data/ie.yaml index 83c1d7b..784fda0 100644 --- a/data/ie.yaml +++ b/data/ie.yaml @@ -54,5 +54,5 @@ tests: | 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] + assert_equal name, (Holidays.on(date, :ie, :informal)[0] || {})[:name] end \ No newline at end of file diff --git a/data/is.yaml b/data/is.yaml index 061737f..e4c96ae 100644 --- a/data/is.yaml +++ b/data/is.yaml @@ -132,5 +132,5 @@ tests: | 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] + assert_equal name, (Holidays.on(date, :is, :informal)[0] || {})[:name] end \ No newline at end of file diff --git a/data/it.yaml b/data/it.yaml index 8c8ef32..d187957 100644 --- a/data/it.yaml +++ b/data/it.yaml @@ -62,5 +62,5 @@ tests: | 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] + assert_equal name, (Holidays.on(date, :it, :informal)[0] || {})[:name] end \ No newline at end of file diff --git a/data/mx.yaml b/data/mx.yaml index 1683c3a..c22d97f 100644 --- a/data/mx.yaml +++ b/data/mx.yaml @@ -102,5 +102,5 @@ tests: | 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] + assert_equal name, (Holidays.on(date, :mx, :informal)[0] || {})[:name] end \ No newline at end of file diff --git a/data/nl.yaml b/data/nl.yaml index 420ac52..83fe0c7 100644 --- a/data/nl.yaml +++ b/data/nl.yaml @@ -63,5 +63,5 @@ tests: | 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] + assert_equal name, (Holidays.on(date, :nl, :informal)[0] || {})[:name] end \ No newline at end of file diff --git a/data/no.yaml b/data/no.yaml index dff6dcf..249fb1b 100644 --- a/data/no.yaml +++ b/data/no.yaml @@ -78,5 +78,5 @@ tests: | Date.civil(2010,5,13) => 'Kristi Himmelfartsdag', Date.civil(2010,5,23) => '1. pinsedag', Date.civil(2010,5,24) => '2. pinsedag'}.each do |date, name| - assert_equal name, Holidays.on(date, :no, :informal)[0][:name] + assert_equal name, (Holidays.on(date, :no, :informal)[0] || {})[:name] end \ No newline at end of file diff --git a/data/nyse.yaml b/data/nyse.yaml index 9c40b4d..fd1e233 100644 --- a/data/nyse.yaml +++ b/data/nyse.yaml @@ -59,5 +59,5 @@ tests: | Date.civil(2008,9,1) => 'Labor Day', Date.civil(2008,11,27) => 'Thanksgiving', Date.civil(2008,12,25) => 'Christmas Day'}.each do |date, name| - assert_equal name, Holidays.on(date, :nyse)[0][:name] + assert_equal name, (Holidays.on(date, :nyse)[0] || {})[:name] end \ No newline at end of file diff --git a/data/nz.yaml b/data/nz.yaml index ef452cf..6b61486 100644 --- a/data/nz.yaml +++ b/data/nz.yaml @@ -115,7 +115,7 @@ tests: | 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, :nz, :informal)[0][:name] + assert_equal name, (Holidays.on(date, :nz, :informal)[0] || {})[:name] end methods: closest_monday: | diff --git a/data/pt.yaml b/data/pt.yaml index 168cb74..d528e64 100644 --- a/data/pt.yaml +++ b/data/pt.yaml @@ -81,5 +81,5 @@ tests: | 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] + assert_equal name, (Holidays.on(date, :pt, :informal)[0] || {})[:name] end \ No newline at end of file diff --git a/data/se.yaml b/data/se.yaml index 7324c25..7694f48 100644 --- a/data/se.yaml +++ b/data/se.yaml @@ -87,5 +87,5 @@ tests: | 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] + assert_equal name, (Holidays.on(date, :se, :informal)[0] || {})[:name] end \ No newline at end of file diff --git a/data/ups.yaml b/data/ups.yaml index 4ffcf17..02e3c1b 100644 --- a/data/ups.yaml +++ b/data/ups.yaml @@ -52,5 +52,5 @@ tests: | Date.civil(2008,11,28) => 'Day After Thanksgiving', Date.civil(2008,12,25) => 'Christmas Day', Date.civil(2008,12,31) => 'New Year\'s Eve',}.each do |date, name| - assert_equal name, Holidays.on(date, :ups)[0][:name] + assert_equal name, (Holidays.on(date, :ups)[0] || {})[:name] end \ No newline at end of file diff --git a/data/us.yaml b/data/us.yaml index 0137baa..9ceb13e 100644 --- a/data/us.yaml +++ b/data/us.yaml @@ -77,5 +77,5 @@ tests: | 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] + assert_equal name, (Holidays.on(date, :us)[0] || {})[:name] end \ No newline at end of file diff --git a/data/za.yaml b/data/za.yaml index 4560ca2..38b5079 100644 --- a/data/za.yaml +++ b/data/za.yaml @@ -74,5 +74,5 @@ tests: | 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] + assert_equal name, (Holidays.on(date, :za, :informal)[0] || {})[:name] end \ No newline at end of file From 43f1bfd748663a38db9e09d976861d806e4240f8 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 01:12:14 +1200 Subject: [PATCH 07/33] Fixes north america/US crosslinking stuff --- lib/holidays.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/holidays.rb b/lib/holidays.rb index 80b9735..4e38caf 100644 --- a/lib/holidays.rb +++ b/lib/holidays.rb @@ -259,6 +259,8 @@ private regions.flatten! + require "holidays/north_america" if regions.include?(:us) # special case for north_america/US cross-linking + raise UnknownRegionError unless regions.all? { |r| r == :any or @@regions.include?(r) or begin require "holidays/#{r.to_s}"; rescue LoadError; false; end } regions end From 4ab8d781ecda309dd5140b8cb3ed28343dd9078c Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 01:13:56 +1200 Subject: [PATCH 08/33] Update generate test_defs --- test/defs/test_defs_au.rb | 3 +-- test/defs/test_defs_ca.rb | 3 +-- test/defs/test_defs_cz.rb | 3 +-- test/defs/test_defs_de.rb | 3 +-- test/defs/test_defs_dk.rb | 3 +-- test/defs/test_defs_es.rb | 3 +-- test/defs/test_defs_europe.rb | 25 ++++++++++++------------- test/defs/test_defs_fr.rb | 3 +-- test/defs/test_defs_gb.rb | 3 +-- test/defs/test_defs_ie.rb | 3 +-- test/defs/test_defs_is.rb | 3 +-- test/defs/test_defs_it.rb | 3 +-- test/defs/test_defs_mx.rb | 3 +-- test/defs/test_defs_nl.rb | 3 +-- test/defs/test_defs_no.rb | 3 +-- test/defs/test_defs_north_america.rb | 7 +++---- test/defs/test_defs_nyse.rb | 3 +-- test/defs/test_defs_nz.rb | 3 +-- test/defs/test_defs_pt.rb | 3 +-- test/defs/test_defs_scandinavia.rb | 6 +++--- test/defs/test_defs_se.rb | 2 +- test/defs/test_defs_ups.rb | 3 +-- test/defs/test_defs_us.rb | 3 +-- test/defs/test_defs_za.rb | 3 +-- 24 files changed, 39 insertions(+), 61 deletions(-) diff --git a/test/defs/test_defs_au.rb b/test/defs/test_defs_au.rb index a9af891..d9204d8 100644 --- a/test/defs/test_defs_au.rb +++ b/test/defs/test_defs_au.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/au' # This file is generated by the Ruby Holiday gem. # @@ -14,7 +13,7 @@ class AuDefinitionTests < Test::Unit::TestCase # :nodoc: 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] + assert_equal name, (Holidays.on(date, :au, :informal)[0] || {})[:name] end [:au_sa, :au_act, :au_nsw, :au_].each do |r| diff --git a/test/defs/test_defs_ca.rb b/test/defs/test_defs_ca.rb index 664c107..13d6d23 100644 --- a/test/defs/test_defs_ca.rb +++ b/test/defs/test_defs_ca.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/ca' # This file is generated by the Ruby Holiday gem. # @@ -17,7 +16,7 @@ class CaDefinitionTests < Test::Unit::TestCase # :nodoc: 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] + assert_equal name, (Holidays.on(date, :ca, :informal)[0] || {})[:name] end # Victoria Day diff --git a/test/defs/test_defs_cz.rb b/test/defs/test_defs_cz.rb index 60310a3..2a05b57 100644 --- a/test/defs/test_defs_cz.rb +++ b/test/defs/test_defs_cz.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/cz' # This file is generated by the Ruby Holiday gem. # @@ -19,7 +18,7 @@ class CzDefinitionTests < Test::Unit::TestCase # :nodoc: Date.civil(2010,12,24) => 'Štědrý den', Date.civil(2010,12,25) => '1. svátek vánoční', Date.civil(2010,12,26) => '2. svátek vánoční'}.each do |date, name| - assert_equal name, Holidays.on(date, :cz, :informal)[0][:name] + assert_equal name, (Holidays.on(date, :cz, :informal)[0] || {})[:name] end end diff --git a/test/defs/test_defs_de.rb b/test/defs/test_defs_de.rb index e3bc159..991e659 100644 --- a/test/defs/test_defs_de.rb +++ b/test/defs/test_defs_de.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/de' # This file is generated by the Ruby Holiday gem. # @@ -16,7 +15,7 @@ class DeDefinitionTests < Test::Unit::TestCase # :nodoc: 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] + assert_equal name, (Holidays.on(date, :de, :informal)[0] || {})[:name] end [:de_bw, :de_by, :de_st, :de_].each do |r| diff --git a/test/defs/test_defs_dk.rb b/test/defs/test_defs_dk.rb index 5515006..8b105bd 100644 --- a/test/defs/test_defs_dk.rb +++ b/test/defs/test_defs_dk.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/dk' # This file is generated by the Ruby Holiday gem. # @@ -24,7 +23,7 @@ class DkDefinitionTests < Test::Unit::TestCase # :nodoc: 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] + assert_equal name, (Holidays.on(date, :dk, :informal)[0] || {})[:name] end end end diff --git a/test/defs/test_defs_es.rb b/test/defs/test_defs_es.rb index 24c2185..75924cb 100644 --- a/test/defs/test_defs_es.rb +++ b/test/defs/test_defs_es.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/es' # This file is generated by the Ruby Holiday gem. # @@ -17,7 +16,7 @@ class EsDefinitionTests < Test::Unit::TestCase # :nodoc: 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] + 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| diff --git a/test/defs/test_defs_europe.rb b/test/defs/test_defs_europe.rb index 838da90..87ab5f0 100644 --- a/test/defs/test_defs_europe.rb +++ b/test/defs/test_defs_europe.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/europe' # This file is generated by the Ruby Holiday gem. # @@ -19,7 +18,7 @@ class EuropeDefinitionTests < Test::Unit::TestCase # :nodoc: Date.civil(2010,12,24) => 'Štědrý den', Date.civil(2010,12,25) => '1. svátek vánoční', Date.civil(2010,12,26) => '2. svátek vánoční'}.each do |date, name| - assert_equal name, Holidays.on(date, :cz, :informal)[0][:name] + assert_equal name, (Holidays.on(date, :cz, :informal)[0] || {})[:name] end @@ -40,7 +39,7 @@ end 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] + assert_equal name, (Holidays.on(date, :dk, :informal)[0] || {})[:name] end {Date.civil(2009,1,1) => 'Neujahrstag', @@ -52,7 +51,7 @@ end 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] + assert_equal name, (Holidays.on(date, :de, :informal)[0] || {})[:name] end [:de_bw, :de_by, :de_st, :de_].each do |r| @@ -92,7 +91,7 @@ assert_equal 'Buß- und Bettag', Date.civil(2009,11,18).holidays(:de_sn)[0][:nam 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] + 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| @@ -142,7 +141,7 @@ assert_equal 'Fiesta Nacional de Cataluña', Date.civil(2009,9,11).holidays(:es_ 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] + assert_equal name, (Holidays.on(date, :fr, :informal)[0] || {})[:name] end {Date.civil(2008,1,1) => 'New Year\'s Day', @@ -153,7 +152,7 @@ end 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] + 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] @@ -179,7 +178,7 @@ end 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] + assert_equal name, (Holidays.on(date, :ie, :informal)[0] || {})[:name] end {Date.civil(2007,1,1) => 'Nýársdagur', @@ -202,7 +201,7 @@ end 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] + assert_equal name, (Holidays.on(date, :is, :informal)[0] || {})[:name] end {Date.civil(2007,1,1) => 'Capodanno', @@ -217,7 +216,7 @@ end 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] + assert_equal name, (Holidays.on(date, :it, :informal)[0] || {})[:name] end {Date.civil(2008,1,1) => 'Nieuwjaar', @@ -231,7 +230,7 @@ end 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] + assert_equal name, (Holidays.on(date, :nl, :informal)[0] || {})[:name] end {Date.civil(2010,1,1) => 'Nyttårsdag', @@ -250,7 +249,7 @@ end Date.civil(2010,5,13) => 'Kristi Himmelfartsdag', Date.civil(2010,5,23) => '1. pinsedag', Date.civil(2010,5,24) => '2. pinsedag'}.each do |date, name| - assert_equal name, Holidays.on(date, :no, :informal)[0][:name] + assert_equal name, (Holidays.on(date, :no, :informal)[0] || {})[:name] end {Date.civil(2008,1,1) => 'Ano Novo', @@ -272,7 +271,7 @@ end 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] + assert_equal name, (Holidays.on(date, :pt, :informal)[0] || {})[:name] end end end diff --git a/test/defs/test_defs_fr.rb b/test/defs/test_defs_fr.rb index a3ca364..18d3cab 100644 --- a/test/defs/test_defs_fr.rb +++ b/test/defs/test_defs_fr.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/fr' # This file is generated by the Ruby Holiday gem. # @@ -20,7 +19,7 @@ class FrDefinitionTests < Test::Unit::TestCase # :nodoc: 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] + assert_equal name, (Holidays.on(date, :fr, :informal)[0] || {})[:name] end end end diff --git a/test/defs/test_defs_gb.rb b/test/defs/test_defs_gb.rb index 565a2c9..b51ae95 100644 --- a/test/defs/test_defs_gb.rb +++ b/test/defs/test_defs_gb.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/gb' # This file is generated by the Ruby Holiday gem. # @@ -15,7 +14,7 @@ class GbDefinitionTests < Test::Unit::TestCase # :nodoc: 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] + 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] diff --git a/test/defs/test_defs_ie.rb b/test/defs/test_defs_ie.rb index 5391547..ceecba1 100644 --- a/test/defs/test_defs_ie.rb +++ b/test/defs/test_defs_ie.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/ie' # This file is generated by the Ruby Holiday gem. # @@ -15,7 +14,7 @@ class IeDefinitionTests < Test::Unit::TestCase # :nodoc: 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] + assert_equal name, (Holidays.on(date, :ie, :informal)[0] || {})[:name] end end end diff --git a/test/defs/test_defs_is.rb b/test/defs/test_defs_is.rb index a3ee66f..cc679b2 100644 --- a/test/defs/test_defs_is.rb +++ b/test/defs/test_defs_is.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/is' # This file is generated by the Ruby Holiday gem. # @@ -27,7 +26,7 @@ class IsDefinitionTests < Test::Unit::TestCase # :nodoc: 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] + assert_equal name, (Holidays.on(date, :is, :informal)[0] || {})[:name] end end end diff --git a/test/defs/test_defs_it.rb b/test/defs/test_defs_it.rb index 49a6b26..4669829 100644 --- a/test/defs/test_defs_it.rb +++ b/test/defs/test_defs_it.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/it' # This file is generated by the Ruby Holiday gem. # @@ -19,7 +18,7 @@ class ItDefinitionTests < Test::Unit::TestCase # :nodoc: 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] + assert_equal name, (Holidays.on(date, :it, :informal)[0] || {})[:name] end end end diff --git a/test/defs/test_defs_mx.rb b/test/defs/test_defs_mx.rb index d3eef11..dca3f25 100644 --- a/test/defs/test_defs_mx.rb +++ b/test/defs/test_defs_mx.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/mx' # This file is generated by the Ruby Holiday gem. # @@ -16,7 +15,7 @@ class MxDefinitionTests < Test::Unit::TestCase # :nodoc: 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] + assert_equal name, (Holidays.on(date, :mx, :informal)[0] || {})[:name] end end end diff --git a/test/defs/test_defs_nl.rb b/test/defs/test_defs_nl.rb index 67aaabe..ed59bc6 100644 --- a/test/defs/test_defs_nl.rb +++ b/test/defs/test_defs_nl.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/nl' # This file is generated by the Ruby Holiday gem. # @@ -18,7 +17,7 @@ class NlDefinitionTests < Test::Unit::TestCase # :nodoc: 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] + assert_equal name, (Holidays.on(date, :nl, :informal)[0] || {})[:name] end end end diff --git a/test/defs/test_defs_no.rb b/test/defs/test_defs_no.rb index 75d9051..fcd703c 100644 --- a/test/defs/test_defs_no.rb +++ b/test/defs/test_defs_no.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/no' # This file is generated by the Ruby Holiday gem. # @@ -23,7 +22,7 @@ class NoDefinitionTests < Test::Unit::TestCase # :nodoc: Date.civil(2010,5,13) => 'Kristi Himmelfartsdag', Date.civil(2010,5,23) => '1. pinsedag', Date.civil(2010,5,24) => '2. pinsedag'}.each do |date, name| - assert_equal name, Holidays.on(date, :no, :informal)[0][:name] + assert_equal name, (Holidays.on(date, :no, :informal)[0] || {})[:name] end end end diff --git a/test/defs/test_defs_north_america.rb b/test/defs/test_defs_north_america.rb index 508189d..6ddea0e 100644 --- a/test/defs/test_defs_north_america.rb +++ b/test/defs/test_defs_north_america.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/north_america' # This file is generated by the Ruby Holiday gem. # @@ -17,7 +16,7 @@ class North_americaDefinitionTests < Test::Unit::TestCase # :nodoc: 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] + assert_equal name, (Holidays.on(date, :ca, :informal)[0] || {})[:name] end # Victoria Day @@ -35,7 +34,7 @@ end 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] + assert_equal name, (Holidays.on(date, :mx, :informal)[0] || {})[:name] end {Date.civil(2008,1,1) => 'New Year\'s Day', @@ -48,7 +47,7 @@ end 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] + assert_equal name, (Holidays.on(date, :us)[0] || {})[:name] end end end diff --git a/test/defs/test_defs_nyse.rb b/test/defs/test_defs_nyse.rb index 76cf37f..0f01446 100644 --- a/test/defs/test_defs_nyse.rb +++ b/test/defs/test_defs_nyse.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/nyse' # This file is generated by the Ruby Holiday gem. # @@ -16,7 +15,7 @@ class NyseDefinitionTests < Test::Unit::TestCase # :nodoc: Date.civil(2008,9,1) => 'Labor Day', Date.civil(2008,11,27) => 'Thanksgiving', Date.civil(2008,12,25) => 'Christmas Day'}.each do |date, name| - assert_equal name, Holidays.on(date, :nyse)[0][:name] + assert_equal name, (Holidays.on(date, :nyse)[0] || {})[:name] end end end diff --git a/test/defs/test_defs_nz.rb b/test/defs/test_defs_nz.rb index 02b19d7..e8f43d8 100644 --- a/test/defs/test_defs_nz.rb +++ b/test/defs/test_defs_nz.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/nz' # This file is generated by the Ruby Holiday gem. # @@ -15,7 +14,7 @@ class NzDefinitionTests < Test::Unit::TestCase # :nodoc: 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, :nz, :informal)[0][:name] + assert_equal name, (Holidays.on(date, :nz, :informal)[0] || {})[:name] end end diff --git a/test/defs/test_defs_pt.rb b/test/defs/test_defs_pt.rb index 0a3ee20..7f6a757 100644 --- a/test/defs/test_defs_pt.rb +++ b/test/defs/test_defs_pt.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/pt' # This file is generated by the Ruby Holiday gem. # @@ -26,7 +25,7 @@ class PtDefinitionTests < Test::Unit::TestCase # :nodoc: 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] + assert_equal name, (Holidays.on(date, :pt, :informal)[0] || {})[:name] end end end diff --git a/test/defs/test_defs_scandinavia.rb b/test/defs/test_defs_scandinavia.rb index 106556a..aa1c6a9 100644 --- a/test/defs/test_defs_scandinavia.rb +++ b/test/defs/test_defs_scandinavia.rb @@ -24,7 +24,7 @@ class ScandinaviaDefinitionTests < Test::Unit::TestCase # :nodoc: 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] + assert_equal name, (Holidays.on(date, :dk, :informal)[0] || {})[:name] end {Date.civil(2007,1,1) => 'Nýársdagur', @@ -47,7 +47,7 @@ end 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] + assert_equal name, (Holidays.on(date, :is, :informal)[0] || {})[:name] end {Date.civil(2008,1,1) => 'Nyårsdagen', @@ -69,7 +69,7 @@ end 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] + assert_equal name, (Holidays.on(date, :se, :informal)[0] || {})[:name] end end end diff --git a/test/defs/test_defs_se.rb b/test/defs/test_defs_se.rb index 6dd005a..901e8c5 100644 --- a/test/defs/test_defs_se.rb +++ b/test/defs/test_defs_se.rb @@ -26,7 +26,7 @@ class SeDefinitionTests < Test::Unit::TestCase # :nodoc: 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] + assert_equal name, (Holidays.on(date, :se, :informal)[0] || {})[:name] end end end diff --git a/test/defs/test_defs_ups.rb b/test/defs/test_defs_ups.rb index c77390c..b4daf8b 100644 --- a/test/defs/test_defs_ups.rb +++ b/test/defs/test_defs_ups.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/ups' # This file is generated by the Ruby Holiday gem. # @@ -15,7 +14,7 @@ class UpsDefinitionTests < Test::Unit::TestCase # :nodoc: Date.civil(2008,11,28) => 'Day After Thanksgiving', Date.civil(2008,12,25) => 'Christmas Day', Date.civil(2008,12,31) => 'New Year\'s Eve',}.each do |date, name| - assert_equal name, Holidays.on(date, :ups)[0][:name] + assert_equal name, (Holidays.on(date, :ups)[0] || {})[:name] end end end diff --git a/test/defs/test_defs_us.rb b/test/defs/test_defs_us.rb index 0c4b527..c199f08 100644 --- a/test/defs/test_defs_us.rb +++ b/test/defs/test_defs_us.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/us' # This file is generated by the Ruby Holiday gem. # @@ -17,7 +16,7 @@ class UsDefinitionTests < Test::Unit::TestCase # :nodoc: 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] + assert_equal name, (Holidays.on(date, :us)[0] || {})[:name] end end end diff --git a/test/defs/test_defs_za.rb b/test/defs/test_defs_za.rb index db9f476..ecaf398 100644 --- a/test/defs/test_defs_za.rb +++ b/test/defs/test_defs_za.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/za' # This file is generated by the Ruby Holiday gem. # @@ -19,7 +18,7 @@ class ZaDefinitionTests < Test::Unit::TestCase # :nodoc: 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] + assert_equal name, (Holidays.on(date, :za, :informal)[0] || {})[:name] end end end From adc5cfcc59c877bea86aeea0fb221466f47ef270 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 01:27:28 +1200 Subject: [PATCH 09/33] Version bump to 0.0.0 --- VERSION | 1 + 1 file changed, 1 insertion(+) create mode 100644 VERSION diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..77d6f4c --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.0.0 From d9c7e829dd71e0fdaf3f856077ad8a125c47e771 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 01:28:23 +1200 Subject: [PATCH 10/33] Version bump to 0.1.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 77d6f4c..6e8bf73 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.0 +0.1.0 From c6a2001aee9b90c7ec761c3269139253ad02fed8 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 01:28:24 +1200 Subject: [PATCH 11/33] Version bump to 0.2.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 6e8bf73..0ea3a94 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.0 +0.2.0 From 06fd515be320dd68629c6110c6003131d899cfd4 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 01:28:26 +1200 Subject: [PATCH 12/33] Version bump to 0.3.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 0ea3a94..0d91a54 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.0 +0.3.0 From 8377f836c896677d69078ad28b73d86fe3bfedd9 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 01:28:26 +1200 Subject: [PATCH 13/33] Version bump to 0.4.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 0d91a54..1d0ba9e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.0 +0.4.0 From 0f25db8280494152fdea45f1b9891ee2f3adee37 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 01:28:27 +1200 Subject: [PATCH 14/33] Version bump to 0.5.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 1d0ba9e..8f0916f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.0 +0.5.0 From ae22b6185d5000dcfd42034fdcda7b470d0adf1f Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 01:28:28 +1200 Subject: [PATCH 15/33] Version bump to 0.6.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 8f0916f..a918a2a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.0 +0.6.0 From f9994238d835b87a2a788a41d3074dc20855a004 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 01:28:29 +1200 Subject: [PATCH 16/33] Version bump to 0.7.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index a918a2a..faef31a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.6.0 +0.7.0 From 0b0d77fea26ef3c1cc880d50810d1a50c5f72b5e Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 01:28:30 +1200 Subject: [PATCH 17/33] Version bump to 0.8.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index faef31a..a3df0a6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.7.0 +0.8.0 From 1a7a358f5db4044c0a28176d44f001eb48a559f1 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 01:28:30 +1200 Subject: [PATCH 18/33] Version bump to 0.9.0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index a3df0a6..ac39a10 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.8.0 +0.9.0 From 29b3572a9140aeea5b9ec5470681eef16c2c53ce Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 01:28:35 +1200 Subject: [PATCH 19/33] Version bump to 0.9.1 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index ac39a10..f374f66 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.0 +0.9.1 From 15bc19082badd953dba056866fa87b66cf1eb61f Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 01:28:36 +1200 Subject: [PATCH 20/33] Version bump to 0.9.2 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index f374f66..2003b63 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.1 +0.9.2 From b4376c3712a2a4749a513b3dfa3eb1de0f32b823 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 01:28:36 +1200 Subject: [PATCH 21/33] Version bump to 0.9.3 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 2003b63..965065d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.2 +0.9.3 From 81f24a7cf49b8641c01e94043b6d0ca1eecf1b7b Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 01:28:37 +1200 Subject: [PATCH 22/33] Version bump to 0.9.4 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 965065d..a602fc9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.3 +0.9.4 From e9970c2fcb22dcd684b5df177cf3d053bc6dae70 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 01:28:38 +1200 Subject: [PATCH 23/33] Version bump to 0.9.5 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index a602fc9..b0bb878 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.4 +0.9.5 From b8b74917c93c16c67096c28810ee59e74a502e80 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Thu, 29 Apr 2010 01:28:39 +1200 Subject: [PATCH 24/33] Version bump to 0.9.6 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index b0bb878..85b7c69 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.5 +0.9.6 From 0813ac7125827bcd05d6f6f04f575b44b66e7701 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Sat, 1 May 2010 22:07:43 +1200 Subject: [PATCH 25/33] Version bump to 0.9.7 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 85b7c69..c81aa44 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.6 +0.9.7 From 8fe1e0ed3472773188b13b641f73e15ec6e82d84 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Sat, 1 May 2010 22:09:09 +1200 Subject: [PATCH 26/33] Going to version 0.9.7 to fix issue with include :gb_ and so forth. --- lib/holidays.rb | 2 +- lib/holidays/MANIFEST | 33 ++++---- rakefile.rb | 16 +++- wombleton-holidays.gemspec | 156 +++++++++++++++++++++++++++++++++++++ 4 files changed, 189 insertions(+), 18 deletions(-) create mode 100644 wombleton-holidays.gemspec diff --git a/lib/holidays.rb b/lib/holidays.rb index 4e38caf..a1e0a5d 100644 --- a/lib/holidays.rb +++ b/lib/holidays.rb @@ -261,7 +261,7 @@ private require "holidays/north_america" if regions.include?(:us) # special case for north_america/US cross-linking - raise UnknownRegionError unless regions.all? { |r| r == :any or @@regions.include?(r) or begin require "holidays/#{r.to_s}"; rescue LoadError; false; end } + raise UnknownRegionError unless regions.all? { |r| r == :any or @@regions.include?(r) or begin require "holidays/#{r.to_s.split('_').first}"; rescue LoadError; false; end } regions end diff --git a/lib/holidays/MANIFEST b/lib/holidays/MANIFEST index c88f543..db7fffa 100644 --- a/lib/holidays/MANIFEST +++ b/lib/holidays/MANIFEST @@ -1,27 +1,28 @@ ==== Regional definitions The following definition files are included in this installation: +* holidays/nyse +* holidays/no +* holidays/es +* holidays/ie +* holidays/united_nations * holidays/au +* holidays/mx +* holidays/za +* holidays/scandinavia * holidays/ca -* holidays/cz +* holidays/us +* holidays/nl +* holidays/it * holidays/de * holidays/dk -* holidays/es +* holidays/cz +* holidays/nz +* holidays/ups +* holidays/pt * holidays/europe +* holidays/se +* holidays/north_america * holidays/fr * holidays/gb -* holidays/ie * holidays/is -* holidays/it -* holidays/mx -* holidays/nl -* holidays/north_america -* holidays/nyse -* holidays/nz -* holidays/pt -* holidays/scandinavia -* holidays/se -* holidays/united_nations -* holidays/ups -* holidays/us -* holidays/za diff --git a/rakefile.rb b/rakefile.rb index 1c9bef8..1070e2b 100644 --- a/rakefile.rb +++ b/rakefile.rb @@ -86,4 +86,18 @@ The following definition files are included in this installation: end end end -end \ No newline at end of file +end + +begin + require 'jeweler' + Jeweler::Tasks.new do |gemspec| + gemspec.name = "wombleton-holidays" + gemspec.summary = "A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!" + gemspec.description = "A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!" + gemspec.email = "wombleton@gmail.com" + gemspec.homepage = "http://github.com/wombleton/holidays" + gemspec.authors = ["Alex Dunae", "Rowan Crawford"] + end +rescue LoadError + puts "Jeweler not available. Install it with: gem install jeweler" +end diff --git a/wombleton-holidays.gemspec b/wombleton-holidays.gemspec new file mode 100644 index 0000000..1d0678a --- /dev/null +++ b/wombleton-holidays.gemspec @@ -0,0 +1,156 @@ +# Generated by jeweler +# DO NOT EDIT THIS FILE DIRECTLY +# Instead, edit Jeweler::Tasks in rakefile.rb, and run the gemspec command +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{wombleton-holidays} + s.version = "0.9.7" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Alex Dunae", "Rowan Crawford"] + s.date = %q{2010-05-01} + s.description = %q{A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!} + s.email = %q{wombleton@gmail.com} + s.extra_rdoc_files = [ + "LICENSE", + "README.rdoc" + ] + s.files = [ + ".gitignore", + "CHANGELOG", + "LICENSE", + "README.rdoc", + "REFERENCES", + "VERSION", + "data/SYNTAX", + "data/au.yaml", + "data/build_defs.rb", + "data/ca.yaml", + "data/cz.yaml", + "data/de.yaml", + "data/dk.yaml", + "data/es.yaml", + "data/fr.yaml", + "data/gb.yaml", + "data/ie.yaml", + "data/index.yaml", + "data/is.yaml", + "data/it.yaml", + "data/mx.yaml", + "data/nl.yaml", + "data/no.yaml", + "data/north_america_informal.yaml", + "data/nyse.yaml", + "data/nz.yaml", + "data/pt.yaml", + "data/se.yaml", + "data/united_nations.yaml", + "data/ups.yaml", + "data/us.yaml", + "data/za.yaml", + "holidays.gemspec", + "lib/holidays.rb", + "lib/holidays/MANIFEST", + "lib/holidays/au.rb", + "lib/holidays/ca.rb", + "lib/holidays/cz.rb", + "lib/holidays/de.rb", + "lib/holidays/dk.rb", + "lib/holidays/es.rb", + "lib/holidays/europe.rb", + "lib/holidays/fr.rb", + "lib/holidays/gb.rb", + "lib/holidays/ie.rb", + "lib/holidays/is.rb", + "lib/holidays/it.rb", + "lib/holidays/mx.rb", + "lib/holidays/nl.rb", + "lib/holidays/no.rb", + "lib/holidays/north_america.rb", + "lib/holidays/nyse.rb", + "lib/holidays/nz.rb", + "lib/holidays/pt.rb", + "lib/holidays/scandinavia.rb", + "lib/holidays/se.rb", + "lib/holidays/united_nations.rb", + "lib/holidays/ups.rb", + "lib/holidays/us.rb", + "lib/holidays/za.rb", + "rakefile.rb", + "test/defs/test_defs_au.rb", + "test/defs/test_defs_ca.rb", + "test/defs/test_defs_cz.rb", + "test/defs/test_defs_de.rb", + "test/defs/test_defs_dk.rb", + "test/defs/test_defs_es.rb", + "test/defs/test_defs_europe.rb", + "test/defs/test_defs_fr.rb", + "test/defs/test_defs_gb.rb", + "test/defs/test_defs_ie.rb", + "test/defs/test_defs_is.rb", + "test/defs/test_defs_it.rb", + "test/defs/test_defs_mx.rb", + "test/defs/test_defs_nl.rb", + "test/defs/test_defs_no.rb", + "test/defs/test_defs_north_america.rb", + "test/defs/test_defs_nyse.rb", + "test/defs/test_defs_nz.rb", + "test/defs/test_defs_pt.rb", + "test/defs/test_defs_scandinavia.rb", + "test/defs/test_defs_se.rb", + "test/defs/test_defs_ups.rb", + "test/defs/test_defs_us.rb", + "test/defs/test_defs_za.rb", + "test/test_date.rb", + "test/test_helper.rb", + "test/test_holidays.rb", + "test/test_multiple_regions.rb" + ] + s.homepage = %q{http://github.com/wombleton/holidays} + s.rdoc_options = ["--charset=UTF-8"] + s.require_paths = ["lib"] + s.rubygems_version = %q{1.3.6} + s.summary = %q{A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!} + s.test_files = [ + "test/test_helper.rb", + "test/test_date.rb", + "test/test_multiple_regions.rb", + "test/defs/test_defs_au.rb", + "test/defs/test_defs_no.rb", + "test/defs/test_defs_ups.rb", + "test/defs/test_defs_nyse.rb", + "test/defs/test_defs_scandinavia.rb", + "test/defs/test_defs_dk.rb", + "test/defs/test_defs_se.rb", + "test/defs/test_defs_north_america.rb", + "test/defs/test_defs_europe.rb", + "test/defs/test_defs_nl.rb", + "test/defs/test_defs_fr.rb", + "test/defs/test_defs_us.rb", + "test/defs/test_defs_it.rb", + "test/defs/test_defs_ca.rb", + "test/defs/test_defs_mx.rb", + "test/defs/test_defs_es.rb", + "test/defs/test_defs_de.rb", + "test/defs/test_defs_cz.rb", + "test/defs/test_defs_pt.rb", + "test/defs/test_defs_is.rb", + "test/defs/test_defs_nz.rb", + "test/defs/test_defs_za.rb", + "test/defs/test_defs_gb.rb", + "test/defs/test_defs_ie.rb", + "test/test_holidays.rb" + ] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + else + end + else + end +end + From 6f63d6cfcdec24a5130a64b5452bf7f8f38dc8bf Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Sat, 1 May 2010 22:09:14 +1200 Subject: [PATCH 27/33] Regenerated gemspec for version 0.9.7 --- wombleton-holidays.gemspec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wombleton-holidays.gemspec b/wombleton-holidays.gemspec index 1d0678a..1c14479 100644 --- a/wombleton-holidays.gemspec +++ b/wombleton-holidays.gemspec @@ -105,7 +105,8 @@ Gem::Specification.new do |s| "test/test_date.rb", "test/test_helper.rb", "test/test_holidays.rb", - "test/test_multiple_regions.rb" + "test/test_multiple_regions.rb", + "wombleton-holidays.gemspec" ] s.homepage = %q{http://github.com/wombleton/holidays} s.rdoc_options = ["--charset=UTF-8"] From a77ab4fd175411113488ee2ae8a911e1c4f667a6 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Sat, 1 May 2010 22:25:09 +1200 Subject: [PATCH 28/33] Sort holidays in ascending date so we can reason on a collection of holidays a bit better --- lib/holidays.rb | 2 +- test/test_holidays.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/holidays.rb b/lib/holidays.rb index a1e0a5d..223ffbf 100644 --- a/lib/holidays.rb +++ b/lib/holidays.rb @@ -141,7 +141,7 @@ module Holidays end end - holidays + holidays.sort{|a, b| a[:date] <=> b[:date] } end # Merge a new set of definitions into the Holidays module. diff --git a/test/test_holidays.rb b/test/test_holidays.rb index 6da051b..e7ad2dc 100644 --- a/test/test_holidays.rb +++ b/test/test_holidays.rb @@ -114,4 +114,15 @@ class HolidaysTests < Test::Unit::TestCase assert_equal 'Easter Monday', Holidays.on(date, :ca_qc, :informal)[0][:name] end end + + def test_sorting + (1..10).each{|year| + (1..12).each{|month| + holidays = Holidays.between(Date.civil(year, month, 1), Date.civil(year, month, 28), :gb_) + holidays.each_with_index{|holiday, index| + assert holiday[:date] >= holidays[index - 1][:date] if index > 0 + } + } + } + end end From cc349f316b02d5d814e6230341e1e4e31c067513 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Sat, 1 May 2010 22:25:29 +1200 Subject: [PATCH 29/33] Version bump to 0.9.8 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index c81aa44..e3e1807 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.7 +0.9.8 From debbf6d4117abcfab43347e368c89215eb5ae39c Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Sat, 1 May 2010 22:26:02 +1200 Subject: [PATCH 30/33] updated gemspec --- wombleton-holidays.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wombleton-holidays.gemspec b/wombleton-holidays.gemspec index 1c14479..addcba8 100644 --- a/wombleton-holidays.gemspec +++ b/wombleton-holidays.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = %q{wombleton-holidays} - s.version = "0.9.7" + s.version = "0.9.8" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Alex Dunae", "Rowan Crawford"] From f62d0780f55575724369585e25a6e864cd87cfed Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Sat, 1 May 2010 23:11:58 +1200 Subject: [PATCH 31/33] proper test for multi-region requiring --- lib/holidays.rb | 4 +++- test/test_multiple_regions.rb | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/holidays.rb b/lib/holidays.rb index 223ffbf..10b0890 100644 --- a/lib/holidays.rb +++ b/lib/holidays.rb @@ -252,6 +252,8 @@ private # Found sub region wild-card regions.delete_if do |reg| if reg.to_s =~ /_$/ + prefix = reg.to_s.split('_').first + raise UnknownRegionError unless @@regions.include?(prefix.to_sym) or begin require "holidays/#{prefix}"; rescue LoadError; false; end regions << @@regions.select { |dr| dr.to_s =~ Regexp.new("^#{reg}") } true end @@ -261,7 +263,7 @@ private require "holidays/north_america" if regions.include?(:us) # special case for north_america/US cross-linking - raise UnknownRegionError unless regions.all? { |r| r == :any or @@regions.include?(r) or begin require "holidays/#{r.to_s.split('_').first}"; rescue LoadError; false; end } + raise UnknownRegionError unless regions.all? { |r| r == :any or @@regions.include?(r) or begin require "holidays/#{r.to_s}"; rescue LoadError; false; end } regions end diff --git a/test/test_multiple_regions.rb b/test/test_multiple_regions.rb index da4629f..56fb3f0 100644 --- a/test/test_multiple_regions.rb +++ b/test/test_multiple_regions.rb @@ -1,6 +1,4 @@ require File.dirname(__FILE__) + '/test_helper' -require 'holidays/gb' -require 'holidays/ie' class MultipleRegionsTests < Test::Unit::TestCase def setup @@ -11,6 +9,10 @@ class MultipleRegionsTests < Test::Unit::TestCase h = Holidays.on(Date.civil(2008,12,26), :ie) assert_equal 'St. Stephen\'s Day', h[0][:name] + h = Holidays.on(Date.civil(2008,5,9), :gb_) + assert_equal 'Liberation Day', (h[0] || {})[:name] + + h = Holidays.on(Date.civil(2008,5,9), :je) assert_equal 'Liberation Day', h[0][:name] From 0cdc9c1387c1de855951efff95d9fd24de0beaf4 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Sat, 1 May 2010 23:12:21 +1200 Subject: [PATCH 32/33] Version bump to 0.9.9 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index e3e1807..7e310ba 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.8 +0.9.9 From 202fc7a1e639c235697466dfebd875d6bd363751 Mon Sep 17 00:00:00 2001 From: Rowan Crawford Date: Sat, 1 May 2010 23:12:26 +1200 Subject: [PATCH 33/33] Regenerated gemspec for version 0.9.9 --- wombleton-holidays.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wombleton-holidays.gemspec b/wombleton-holidays.gemspec index addcba8..98a64c7 100644 --- a/wombleton-holidays.gemspec +++ b/wombleton-holidays.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = %q{wombleton-holidays} - s.version = "0.9.8" + s.version = "0.9.9" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Alex Dunae", "Rowan Crawford"]