bjeanes-holidays 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/CHANGELOG +15 -0
  2. data/LICENSE +21 -0
  3. data/README.rdoc +77 -0
  4. data/REFERENCES +16 -0
  5. data/data/SYNTAX +111 -0
  6. data/data/au.yaml +111 -0
  7. data/data/build_defs.rb +152 -0
  8. data/data/ca.yaml +141 -0
  9. data/data/de.yaml +111 -0
  10. data/data/dk.yaml +117 -0
  11. data/data/es.yaml +161 -0
  12. data/data/fr.yaml +70 -0
  13. data/data/gb.yaml +106 -0
  14. data/data/ie.yaml +58 -0
  15. data/data/index.yaml +23 -0
  16. data/data/is.yaml +136 -0
  17. data/data/it.yaml +66 -0
  18. data/data/mx.yaml +106 -0
  19. data/data/nl.yaml +67 -0
  20. data/data/north_america_informal.yaml +49 -0
  21. data/data/nyse.yaml +63 -0
  22. data/data/pt.yaml +85 -0
  23. data/data/se.yaml +91 -0
  24. data/data/united_nations.yaml +188 -0
  25. data/data/ups.yaml +56 -0
  26. data/data/us.yaml +81 -0
  27. data/data/za.yaml +78 -0
  28. data/lib/holidays.rb +404 -0
  29. data/lib/holidays/MANIFEST +25 -0
  30. data/lib/holidays/au.rb +42 -0
  31. data/lib/holidays/ca.rb +68 -0
  32. data/lib/holidays/de.rb +50 -0
  33. data/lib/holidays/dk.rb +47 -0
  34. data/lib/holidays/es.rb +52 -0
  35. data/lib/holidays/europe.rb +214 -0
  36. data/lib/holidays/fr.rb +36 -0
  37. data/lib/holidays/gb.rb +40 -0
  38. data/lib/holidays/ie.rb +32 -0
  39. data/lib/holidays/is.rb +61 -0
  40. data/lib/holidays/it.rb +35 -0
  41. data/lib/holidays/mx.rb +51 -0
  42. data/lib/holidays/nl.rb +36 -0
  43. data/lib/holidays/north_america.rb +107 -0
  44. data/lib/holidays/nyse.rb +32 -0
  45. data/lib/holidays/pt.rb +43 -0
  46. data/lib/holidays/scandinavia.rb +114 -0
  47. data/lib/holidays/se.rb +52 -0
  48. data/lib/holidays/united_nations.rb +24 -0
  49. data/lib/holidays/ups.rb +31 -0
  50. data/lib/holidays/us.rb +48 -0
  51. data/lib/holidays/za.rb +35 -0
  52. data/rakefile.rb +150 -0
  53. data/test/defs/test_defs_au.rb +36 -0
  54. data/test/defs/test_defs_ca.rb +29 -0
  55. data/test/defs/test_defs_de.rb +49 -0
  56. data/test/defs/test_defs_dk.rb +30 -0
  57. data/test/defs/test_defs_es.rb +57 -0
  58. data/test/defs/test_defs_europe.rb +243 -0
  59. data/test/defs/test_defs_fr.rb +26 -0
  60. data/test/defs/test_defs_gb.rb +36 -0
  61. data/test/defs/test_defs_ie.rb +21 -0
  62. data/test/defs/test_defs_is.rb +33 -0
  63. data/test/defs/test_defs_it.rb +25 -0
  64. data/test/defs/test_defs_mx.rb +22 -0
  65. data/test/defs/test_defs_nl.rb +24 -0
  66. data/test/defs/test_defs_north_america.rb +54 -0
  67. data/test/defs/test_defs_nyse.rb +22 -0
  68. data/test/defs/test_defs_pt.rb +56 -0
  69. data/test/defs/test_defs_scandinavia.rb +75 -0
  70. data/test/defs/test_defs_se.rb +32 -0
  71. data/test/defs/test_defs_ups.rb +21 -0
  72. data/test/defs/test_defs_us.rb +23 -0
  73. data/test/defs/test_defs_za.rb +25 -0
  74. metadata +132 -0
@@ -0,0 +1,114 @@
1
+ module Holidays
2
+ # This file is generated by the Ruby Holiday gem.
3
+ #
4
+ # Definitions loaded: data/dk.yaml, data/is.yaml, data/se.yaml
5
+ #
6
+ # To use the definitions in this file, load them right after you load the
7
+ # Holiday gem:
8
+ #
9
+ # require 'holidays'
10
+ # require 'holidays/scandinavia'
11
+ #
12
+ # More definitions are available at http://code.dunae.ca/holidays.
13
+ module SCANDINAVIA # :nodoc:
14
+ DEFINED_REGIONS = [:dk, :is, :se]
15
+
16
+ HOLIDAYS_BY_MONTH = {
17
+ 5 => [{:mday => 1, :name => "Arbejdernes kampdag", :regions => [:dk]},
18
+ {:mday => 5, :type => :informal, :name => "Danmarks befrielse", :regions => [:dk]},
19
+ {:mday => 1, :name => "Verkalýðsdagurinn", :regions => [:is]},
20
+ {:mday => 13, :name => "Mæðradagurinn", :regions => [:is]},
21
+ {:mday => 1, :name => "Första maj", :regions => [:se]}],
22
+ 0 => [{:function => lambda { |year| Holidays.easter(year)-49 }, :function_id => "easter(year)-49", :type => :informal, :name => "Fastelavn", :regions => [:dk]},
23
+ {:function => lambda { |year| Holidays.easter(year)-7 }, :function_id => "easter(year)-7", :name => "Palmesøndag", :regions => [:dk]},
24
+ {:function => lambda { |year| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Skærtorsdag", :regions => [:dk]},
25
+ {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Langfredag", :regions => [:dk]},
26
+ {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Påskedag", :regions => [:dk]},
27
+ {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "2. påskedag", :regions => [:dk]},
28
+ {:function => lambda { |year| Holidays.easter(year)+26 }, :function_id => "easter(year)+26", :name => "Store Bededag", :regions => [:dk]},
29
+ {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Kristi Himmelfartsdag", :regions => [:dk]},
30
+ {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pinsedag", :regions => [:dk]},
31
+ {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "2. Pinsedag", :regions => [:dk]},
32
+ {:function => lambda { |year| Holidays.easter(year)-48 }, :function_id => "easter(year)-48", :name => "Bolludagur", :regions => [:is]},
33
+ {:function => lambda { |year| Holidays.easter(year)-47 }, :function_id => "easter(year)-47", :name => "Sprengidagur", :regions => [:is]},
34
+ {:function => lambda { |year| Holidays.easter(year)-46 }, :function_id => "easter(year)-46", :name => "Öskudagur", :regions => [:is]},
35
+ {:function => lambda { |year| Holidays.easter(year)-7 }, :function_id => "easter(year)-7", :name => "Pálmasunnudagur", :regions => [:is]},
36
+ {:function => lambda { |year| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Skírdagur", :regions => [:is]},
37
+ {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Föstudaginn langi", :regions => [:is]},
38
+ {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Páskadagur", :regions => [:is]},
39
+ {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Annar í páskum", :regions => [:is]},
40
+ {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Uppstigningardagur", :regions => [:is]},
41
+ {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Hvítasunnudagur", :regions => [:is]},
42
+ {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Annar í hvítasunnu", :regions => [:is]},
43
+ {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Långfredagen", :regions => [:se]},
44
+ {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Påskdagen", :regions => [:se]},
45
+ {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Annandag påsk", :regions => [:se]},
46
+ {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Kristi himmelsfärdsdag", :regions => [:se]},
47
+ {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pingstdagen", :regions => [:se]},
48
+ {:function => lambda { |year| Holidays.se_alla_helgons_dag(year) }, :function_id => "se_alla_helgons_dag(year)", :name => "Alla helgons dag", :regions => [:se]}],
49
+ 11 => [{:mday => 10, :type => :informal, :name => "Mortensaften", :regions => [:dk]},
50
+ {:mday => 16, :name => "Dagur íslenskrar tungu", :regions => [:is]}],
51
+ 6 => [{:mday => 5, :name => "Grundlovsdag", :regions => [:dk]},
52
+ {:mday => 15, :type => :informal, :name => "Valdemarsdag og Genforeningsdag", :regions => [:dk]},
53
+ {:mday => 23, :type => :informal, :name => "Sankt Hans aften", :regions => [:dk]},
54
+ {:mday => 3, :type => :informal, :name => "Sjómannadagurinn", :regions => [:is]},
55
+ {:mday => 17, :name => "Lýðveldisdagurinn", :regions => [:is]},
56
+ {:mday => 6, :name => "Nationaldagen", :regions => [:se]},
57
+ {:function => lambda { |year| Holidays.se_midsommardagen(year) }, :function_id => "se_midsommardagen(year)", :name => "Midsommardagen", :regions => [:se]}],
58
+ 1 => [{:mday => 1, :name => "Nytårsdag", :regions => [:dk]},
59
+ {:mday => 1, :name => "Nýársdagur", :regions => [:is]},
60
+ {:mday => 6, :name => "Þrettándinn", :regions => [:is]},
61
+ {:mday => 19, :type => :informal, :name => "Bóndadagur", :regions => [:is]},
62
+ {:mday => 1, :name => "Nyårsdagen", :regions => [:se]},
63
+ {:mday => 6, :name => "Trettondedag jul", :regions => [:se]}],
64
+ 12 => [{:mday => 13, :type => :informal, :name => "Sankt Lucia", :regions => [:dk]},
65
+ {:mday => 24, :name => "Juleaftensdag", :regions => [:dk]},
66
+ {:mday => 25, :name => "1. juledag", :regions => [:dk]},
67
+ {:mday => 26, :name => "2. juledag", :regions => [:dk]},
68
+ {:mday => 24, :name => "Jól", :regions => [:is]},
69
+ {:mday => 25, :name => "Jól", :regions => [:is]},
70
+ {:mday => 26, :name => "Jól", :regions => [:is]},
71
+ {:mday => 31, :name => "Gamlárskvöld", :regions => [:is]},
72
+ {:mday => 25, :name => "Juldagen", :regions => [:se]},
73
+ {:mday => 26, :name => "Annandag jul", :regions => [:se]}],
74
+ 2 => [{:mday => 18, :type => :informal, :name => "Konudagur", :regions => [:is]}],
75
+ 8 => [{:wday => 1, :week => 1, :name => "Frídagur verslunarmanna", :regions => [:is]}],
76
+ 4 => [{:mday => 1, :type => :informal, :name => "1. april", :regions => [:dk]},
77
+ {:mday => 9, :type => :informal, :name => "Danmarks besættelse", :regions => [:dk]},
78
+ {:mday => 16, :type => :informal, :name => "Dronningens fødselsdag", :regions => [:dk]},
79
+ {:function => lambda { |year| Holidays.is_sumardagurinn_fyrsti(year) }, :function_id => "is_sumardagurinn_fyrsti(year)", :name => "Sumardagurinn fyrsti", :regions => [:is]}]
80
+ }
81
+ end
82
+
83
+ # Iceland: first day of summer (Thursday after 18 April)
84
+ def self.is_sumardagurinn_fyrsti(year)
85
+ date = Date.civil(year,4,18)
86
+ if date.wday < 4
87
+ date += (4 - date.wday)
88
+ else date
89
+ date += (11 - date.wday)
90
+ end
91
+ date
92
+ end
93
+
94
+
95
+ # Sweden: All Saint's Day (Saturday between Oct 31 and Nov 6)
96
+ def self.se_alla_helgons_dag(year)
97
+ date = Date.civil(year,10,31)
98
+ date += (6 - date.wday)
99
+ date
100
+ end
101
+
102
+
103
+ # Sweden: Mid-summer (Saturday between June 20–26)
104
+ def self.se_midsommardagen(year)
105
+ date = Date.civil(year,6,20)
106
+ date += (6 - date.wday)
107
+ date
108
+ end
109
+
110
+
111
+
112
+ end
113
+
114
+ Holidays.merge_defs(Holidays::SCANDINAVIA::DEFINED_REGIONS, Holidays::SCANDINAVIA::HOLIDAYS_BY_MONTH)
@@ -0,0 +1,52 @@
1
+ module Holidays
2
+ # This file is generated by the Ruby Holiday gem.
3
+ #
4
+ # Definitions loaded: data/se.yaml
5
+ #
6
+ # To use the definitions in this file, load them right after you load the
7
+ # Holiday gem:
8
+ #
9
+ # require 'holidays'
10
+ # require 'holidays/se'
11
+ #
12
+ # More definitions are available at http://code.dunae.ca/holidays.
13
+ module SE # :nodoc:
14
+ DEFINED_REGIONS = [:se]
15
+
16
+ HOLIDAYS_BY_MONTH = {
17
+ 5 => [{:mday => 1, :name => "Första maj", :regions => [:se]}],
18
+ 0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Långfredagen", :regions => [:se]},
19
+ {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Påskdagen", :regions => [:se]},
20
+ {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Annandag påsk", :regions => [:se]},
21
+ {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Kristi himmelsfärdsdag", :regions => [:se]},
22
+ {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pingstdagen", :regions => [:se]},
23
+ {:function => lambda { |year| Holidays.se_alla_helgons_dag(year) }, :function_id => "se_alla_helgons_dag(year)", :name => "Alla helgons dag", :regions => [:se]}],
24
+ 6 => [{:mday => 6, :name => "Nationaldagen", :regions => [:se]},
25
+ {:function => lambda { |year| Holidays.se_midsommardagen(year) }, :function_id => "se_midsommardagen(year)", :name => "Midsommardagen", :regions => [:se]}],
26
+ 1 => [{:mday => 1, :name => "Nyårsdagen", :regions => [:se]},
27
+ {:mday => 6, :name => "Trettondedag jul", :regions => [:se]}],
28
+ 12 => [{:mday => 25, :name => "Juldagen", :regions => [:se]},
29
+ {:mday => 26, :name => "Annandag jul", :regions => [:se]}]
30
+ }
31
+ end
32
+
33
+ # Sweden: All Saint's Day (Saturday between Oct 31 and Nov 6)
34
+ def self.se_alla_helgons_dag(year)
35
+ date = Date.civil(year,10,31)
36
+ date += (6 - date.wday)
37
+ date
38
+ end
39
+
40
+
41
+ # Sweden: Mid-summer (Saturday between June 20–26)
42
+ def self.se_midsommardagen(year)
43
+ date = Date.civil(year,6,20)
44
+ date += (6 - date.wday)
45
+ date
46
+ end
47
+
48
+
49
+
50
+ end
51
+
52
+ Holidays.merge_defs(Holidays::SE::DEFINED_REGIONS, Holidays::SE::HOLIDAYS_BY_MONTH)
@@ -0,0 +1,24 @@
1
+ module Holidays
2
+ # This file is generated by the Ruby Holiday gem.
3
+ #
4
+ # Definitions loaded: data/united_nations.yaml
5
+ #
6
+ # To use the definitions in this file, load them right after you load the
7
+ # Holiday gem:
8
+ #
9
+ # require 'holidays'
10
+ # require 'holidays/united_nations'
11
+ #
12
+ # More definitions are available at http://code.dunae.ca/holidays.
13
+ module United_Nations # :nodoc:
14
+ DEFINED_REGIONS = [:]
15
+
16
+ HOLIDAYS_BY_MONTH = {
17
+
18
+ }
19
+ end
20
+
21
+
22
+ end
23
+
24
+ Holidays.merge_defs(Holidays::United_Nations::DEFINED_REGIONS, Holidays::United_Nations::HOLIDAYS_BY_MONTH)
@@ -0,0 +1,31 @@
1
+ module Holidays
2
+ # This file is generated by the Ruby Holiday gem.
3
+ #
4
+ # Definitions loaded: data/ups.yaml
5
+ #
6
+ # To use the definitions in this file, load them right after you load the
7
+ # Holiday gem:
8
+ #
9
+ # require 'holidays'
10
+ # require 'holidays/ups'
11
+ #
12
+ # More definitions are available at http://code.dunae.ca/holidays.
13
+ module UPS # :nodoc:
14
+ DEFINED_REGIONS = [:ups]
15
+
16
+ HOLIDAYS_BY_MONTH = {
17
+ 5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:ups]}],
18
+ 11 => [{:wday => 4, :week => 4, :name => "Thanksgiving", :regions => [:ups]},
19
+ {:wday => 5, :week => 4, :name => "Day After Thanksgiving", :regions => [:ups]}],
20
+ 1 => [{:mday => 1, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "New Year's Day", :regions => [:ups]}],
21
+ 12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas Day", :regions => [:ups]},
22
+ {:mday => 31, :name => "New Year's Eve", :regions => [:ups]}],
23
+ 7 => [{:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Independence Day", :regions => [:ups]}],
24
+ 9 => [{:wday => 1, :week => 1, :name => "Labor Day", :regions => [:ups]}]
25
+ }
26
+ end
27
+
28
+
29
+ end
30
+
31
+ Holidays.merge_defs(Holidays::UPS::DEFINED_REGIONS, Holidays::UPS::HOLIDAYS_BY_MONTH)
@@ -0,0 +1,48 @@
1
+ module Holidays
2
+ # This file is generated by the Ruby Holiday gem.
3
+ #
4
+ # Definitions loaded: data/us.yaml, data/north_america_informal.yaml
5
+ #
6
+ # To use the definitions in this file, load them right after you load the
7
+ # Holiday gem:
8
+ #
9
+ # require 'holidays'
10
+ # require 'holidays/us'
11
+ #
12
+ # More definitions are available at http://code.dunae.ca/holidays.
13
+ module US # :nodoc:
14
+ DEFINED_REGIONS = [:us, :us_dc, :ca]
15
+
16
+ HOLIDAYS_BY_MONTH = {
17
+ 5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:us]},
18
+ {:wday => 0, :week => 3, :type => :informal, :name => "Father's Day", :regions => [:us, :ca]}],
19
+ 0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :type => :informal, :name => "Good Friday", :regions => [:us]}],
20
+ 11 => [{:mday => 11, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Veterans Day", :regions => [:us]},
21
+ {:wday => 4, :week => 4, :name => "Thanksgiving", :regions => [:us]}],
22
+ 1 => [{:mday => 1, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "New Year's Day", :regions => [:us]},
23
+ {:wday => 1, :week => 3, :name => "Martin Luther King, Jr. Day", :regions => [:us]},
24
+ {:function => lambda { |year| Holidays.us_inauguration_day(year) }, :function_id => "us_inauguration_day(year)", :name => "Inauguration Day", :regions => [:us_dc]}],
25
+ 12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas Day", :regions => [:us]}],
26
+ 7 => [{:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Independence Day", :regions => [:us]}],
27
+ 2 => [{:wday => 1, :week => 3, :name => "Presidents' Day", :regions => [:us]},
28
+ {:mday => 2, :type => :informal, :name => "Groundhog Day", :regions => [:us, :ca]},
29
+ {:mday => 14, :type => :informal, :name => "Valentine's Day", :regions => [:us, :ca]}],
30
+ 3 => [{:mday => 17, :type => :informal, :name => "St. Patrick's Day", :regions => [:us, :ca]}],
31
+ 9 => [{:wday => 1, :week => 1, :name => "Labor Day", :regions => [:us]}],
32
+ 4 => [{:mday => 1, :type => :informal, :name => "April Fool's Day", :regions => [:us, :ca]},
33
+ {:mday => 22, :type => :informal, :name => "Earth Day", :regions => [:us, :ca]}],
34
+ 10 => [{:wday => 1, :week => 2, :name => "Columbus Day", :regions => [:us]},
35
+ {:mday => 31, :type => :informal, :name => "Halloween", :regions => [:us, :ca]}]
36
+ }
37
+ end
38
+
39
+ # January 20, every fourth year, following Presidential election
40
+ def self.us_inauguration_day(year)
41
+ year % 4 == 1 ? 20 : nil
42
+ end
43
+
44
+
45
+
46
+ end
47
+
48
+ Holidays.merge_defs(Holidays::US::DEFINED_REGIONS, Holidays::US::HOLIDAYS_BY_MONTH)
@@ -0,0 +1,35 @@
1
+ module Holidays
2
+ # This file is generated by the Ruby Holiday gem.
3
+ #
4
+ # Definitions loaded: data/za.yaml
5
+ #
6
+ # To use the definitions in this file, load them right after you load the
7
+ # Holiday gem:
8
+ #
9
+ # require 'holidays'
10
+ # require 'holidays/za'
11
+ #
12
+ # More definitions are available at http://code.dunae.ca/holidays.
13
+ module ZA # :nodoc:
14
+ DEFINED_REGIONS = [:za]
15
+
16
+ HOLIDAYS_BY_MONTH = {
17
+ 5 => [{:mday => 1, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Workers Day", :regions => [:za]}],
18
+ 0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:za]},
19
+ {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Family Day", :regions => [:za]}],
20
+ 6 => [{:mday => 16, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Youth Day", :regions => [:za]}],
21
+ 1 => [{:mday => 1, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "New Year's Day", :regions => [:za]}],
22
+ 12 => [{:mday => 16, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Day of Reconciliation", :regions => [:za]},
23
+ {:mday => 25, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Christmas Day", :regions => [:za]},
24
+ {:mday => 26, :observed => lambda { |date| Holidays.to_weekday_if_boxing_weekend(date) }, :observed_id => "to_weekday_if_boxing_weekend", :name => "Day of Goodwill", :regions => [:za]}],
25
+ 8 => [{:mday => 9, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "National Women's Day", :regions => [:za]}],
26
+ 3 => [{:mday => 21, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Human Rights Day", :regions => [:za]}],
27
+ 9 => [{:mday => 24, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Heritage Day", :regions => [:za]}],
28
+ 4 => [{:mday => 27, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Freedom Day", :regions => [:za]}]
29
+ }
30
+ end
31
+
32
+
33
+ end
34
+
35
+ Holidays.merge_defs(Holidays::ZA::DEFINED_REGIONS, Holidays::ZA::HOLIDAYS_BY_MONTH)
data/rakefile.rb ADDED
@@ -0,0 +1,150 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+ require 'rake/gempackagetask'
5
+ require 'yaml'
6
+ require 'fileutils'
7
+ require 'lib/holidays'
8
+ require 'data/build_defs'
9
+
10
+ desc 'Run all tests'
11
+ task :test => ["test:lib", "test:defs"]
12
+
13
+ namespace :test do
14
+ desc 'Run the unit tests.'
15
+ Rake::TestTask.new(:lib) do |t|
16
+ t.libs << 'lib'
17
+ t.test_files = FileList['test/defs/test*.rb'].exclude('test_helper.rb')
18
+ t.verbose = false
19
+ end
20
+
21
+ desc 'Run the definition tests.'
22
+ Rake::TestTask.new(:defs) do |t|
23
+ t.libs << 'lib'
24
+ t.test_files = FileList['test/test*.rb'].exclude('test_helper.rb')
25
+ t.verbose = false
26
+ end
27
+ end
28
+
29
+ task :doc => ["defs:manifest", :rdoc]
30
+
31
+ desc 'Generate documentation.'
32
+ Rake::RDocTask.new(:rdoc) do |rdoc|
33
+ rdoc.rdoc_dir = 'doc'
34
+ rdoc.title = 'Ruby Holidays Gem'
35
+ rdoc.options << '--all' << '--inline-source' << '--line-numbers'
36
+ rdoc.options << '--charset' << 'utf-8'
37
+ #rdoc.template = 'extras/rdoc_template.rb'
38
+ rdoc.rdoc_files.include('README.rdoc')
39
+ rdoc.rdoc_files.include('data/SYNTAX')
40
+ rdoc.rdoc_files.include('lib/holidays/MANIFEST')
41
+ rdoc.rdoc_files.include('REFERENCES')
42
+ rdoc.rdoc_files.include('CHANGELOG')
43
+ rdoc.rdoc_files.include('LICENSE')
44
+ rdoc.rdoc_files.include('lib/*.rb')
45
+ end
46
+
47
+
48
+
49
+
50
+ spec = Gem::Specification.new do |s|
51
+ s.name = 'bjeanes-holidays'
52
+ s.version = '0.9.5'
53
+ s.authors = ['Alex Dunae', 'Bodaniel Jeanes']
54
+ s.homepage = 'http://code.dunae.ca/holidays'
55
+ s.platform = Gem::Platform::RUBY
56
+ s.description = <<-EOF
57
+ A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!
58
+ EOF
59
+ s.summary = 'A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!'
60
+ s.files = FileList["{lib}/**/*", "{data}/**/*", "*.rb"].to_a
61
+ s.test_files = FileList['test/defs/test*.rb'].exclude('test_helper.rb')
62
+ s.has_rdoc = true
63
+ s.extra_rdoc_files = ['README.rdoc', 'data/SYNTAX', 'lib/holidays/MANIFEST', 'REFERENCES', 'CHANGELOG', 'LICENSE']
64
+
65
+ end
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+ desc 'Build the gem.'
74
+ Rake::GemPackageTask.new(spec) do |pkg|
75
+ pkg.need_zip = true
76
+ pkg.need_tar = true
77
+ end
78
+
79
+ desc 'Definition file tasks'
80
+ namespace :defs do
81
+ DATA_PATH = 'data'
82
+
83
+ desc 'Create the gem spec'
84
+ task :create_gemspec do
85
+ File.open("holidays.gemspec","w") do |file|
86
+ file.puts <<-EOH
87
+ # Auto-generated gemspec
88
+ Gem::Specification.new do |s|
89
+ s.name = "holidays"
90
+ s.version = "0.9.5"
91
+ s.date = "2008-12-29"
92
+ s.summary = "A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!"
93
+ s.email = "code@dunae.ca"
94
+ s.homepage = "http://code.dunae.ca/holidays"
95
+ s.description = "A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!"
96
+ s.has_rdoc = true
97
+ s.author = "Alex Dunae"
98
+ s.extra_rdoc_files = ['README.rdoc', 'data/SYNTAX', 'lib/holidays/MANIFEST', 'REFERENCES', 'CHANGELOG', 'LICENSE']
99
+ s.rdoc_options << '--all' << '--inline-source' << '--line-numbers' << '--charset' << 'utf-8'
100
+ EOH
101
+
102
+ file.puts " s.test_files = ['" + Dir.glob("{test}/**/*").join("','") + "']"
103
+ file.puts " s.files = ['" + Dir.glob("{data,lib,test}/**/*").join("','") + "']"
104
+ file.puts 'end'
105
+ end
106
+ end
107
+
108
+
109
+
110
+
111
+ desc 'Build holiday definition files'
112
+ task :build_all do
113
+ # load the index
114
+ def_index = YAML.load_file("#{DATA_PATH}/index.yaml")
115
+
116
+ # create a dir for the generated tests
117
+ FileUtils.mkdir_p('test/defs')
118
+
119
+ def_index['defs'].each do |region, files|
120
+ puts "Building #{region} definition module:"
121
+ files = files.collect { |f| "#{DATA_PATH}/#{f}" }
122
+ files.uniq!
123
+
124
+ module_src, test_src = parse_holiday_defs(region, files)
125
+ File.open("lib/holidays/#{region.downcase.to_s}.rb","w") do |file|
126
+ file.puts module_src
127
+ end
128
+ unless test_src.empty?
129
+ File.open("test/defs/test_defs_#{region.downcase.to_s}.rb","w") do |file|
130
+ file.puts test_src
131
+ end
132
+ end
133
+ puts "Done.\n\n"
134
+ end
135
+ end
136
+
137
+ desc 'Build the definition manifest.'
138
+ task :manifest do
139
+ File.open("lib/holidays/MANIFEST","w") do |file|
140
+ file.puts <<-EOH
141
+ ==== Regional definitions
142
+ The following definition files are included in this installation:
143
+
144
+ EOH
145
+ FileList.new('lib/holidays/*.rb').each do |str|
146
+ file.puts('* ' + str.gsub(/^lib\/|\.rb$/, ''))
147
+ end
148
+ end
149
+ end
150
+ end