holidays 0.9.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/.gitignore +3 -0
  2. data/CHANGELOG +7 -0
  3. data/{README → README.rdoc} +36 -39
  4. data/data/SYNTAX +1 -1
  5. data/data/au.yaml +110 -105
  6. data/data/build_defs.rb +4 -3
  7. data/data/ca.yaml +140 -140
  8. data/data/cz.yaml +68 -0
  9. data/data/de.yaml +12 -14
  10. data/data/dk.yaml +1 -1
  11. data/data/es.yaml +1 -1
  12. data/data/fr.yaml +1 -1
  13. data/data/gb.yaml +1 -1
  14. data/data/ie.yaml +1 -1
  15. data/data/index.yaml +7 -2
  16. data/data/is.yaml +1 -1
  17. data/data/it.yaml +1 -1
  18. data/data/mx.yaml +1 -1
  19. data/data/nl.yaml +1 -1
  20. data/data/no.yaml +82 -0
  21. data/data/nyse.yaml +1 -1
  22. data/data/nz.yaml +141 -0
  23. data/data/pt.yaml +1 -1
  24. data/data/se.yaml +1 -1
  25. data/data/united_nations.yaml +188 -188
  26. data/data/ups.yaml +55 -55
  27. data/data/us.yaml +80 -80
  28. data/data/za.yaml +1 -1
  29. data/holidays.gemspec +155 -0
  30. data/lib/holidays.rb +424 -403
  31. data/lib/holidays/MANIFEST +28 -25
  32. data/lib/holidays/au.rb +43 -41
  33. data/lib/holidays/ca.rb +69 -68
  34. data/lib/holidays/cz.rb +36 -0
  35. data/lib/holidays/de.rb +51 -52
  36. data/lib/holidays/dk.rb +48 -47
  37. data/lib/holidays/es.rb +53 -52
  38. data/lib/holidays/europe.rb +236 -215
  39. data/lib/holidays/fr.rb +37 -36
  40. data/lib/holidays/gb.rb +41 -40
  41. data/lib/holidays/ie.rb +33 -32
  42. data/lib/holidays/is.rb +62 -61
  43. data/lib/holidays/it.rb +36 -35
  44. data/lib/holidays/mx.rb +52 -51
  45. data/lib/holidays/nl.rb +37 -36
  46. data/lib/holidays/no.rb +40 -0
  47. data/lib/holidays/north_america.rb +108 -107
  48. data/lib/holidays/nyse.rb +33 -32
  49. data/lib/holidays/nz.rb +69 -0
  50. data/lib/holidays/pt.rb +38 -52
  51. data/lib/holidays/scandinavia.rb +124 -114
  52. data/lib/holidays/se.rb +53 -52
  53. data/lib/holidays/united_nations.rb +25 -24
  54. data/lib/holidays/ups.rb +32 -31
  55. data/lib/holidays/us.rb +49 -48
  56. data/lib/holidays/za.rb +36 -35
  57. data/rakefile.rb +105 -113
  58. data/test/defs/test_defs_au.rb +36 -36
  59. data/test/defs/test_defs_ca.rb +29 -29
  60. data/test/defs/test_defs_cz.rb +26 -0
  61. data/test/defs/test_defs_de.rb +51 -46
  62. data/test/defs/test_defs_dk.rb +30 -30
  63. data/test/defs/test_defs_es.rb +57 -57
  64. data/test/defs/test_defs_europe.rb +280 -240
  65. data/test/defs/test_defs_fr.rb +26 -26
  66. data/test/defs/test_defs_gb.rb +36 -36
  67. data/test/defs/test_defs_ie.rb +21 -21
  68. data/test/defs/test_defs_is.rb +33 -33
  69. data/test/defs/test_defs_it.rb +25 -25
  70. data/test/defs/test_defs_mx.rb +22 -22
  71. data/test/defs/test_defs_nl.rb +24 -24
  72. data/test/defs/test_defs_no.rb +29 -0
  73. data/test/defs/test_defs_north_america.rb +54 -54
  74. data/test/defs/test_defs_nyse.rb +22 -22
  75. data/test/defs/test_defs_nz.rb +22 -0
  76. data/test/defs/test_defs_pt.rb +32 -32
  77. data/test/defs/test_defs_scandinavia.rb +94 -75
  78. data/test/defs/test_defs_se.rb +32 -32
  79. data/test/defs/test_defs_ups.rb +21 -21
  80. data/test/defs/test_defs_us.rb +23 -23
  81. data/test/defs/test_defs_za.rb +25 -25
  82. data/test/test_date.rb +123 -0
  83. data/test/test_helper.rb +22 -0
  84. data/test/test_holidays.rb +128 -0
  85. data/test/test_multiple_regions.rb +24 -0
  86. metadata +126 -73
@@ -1,31 +1,32 @@
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)
1
+ # encoding: utf-8
2
+ module Holidays
3
+ # This file is generated by the Ruby Holiday gem.
4
+ #
5
+ # Definitions loaded: data/ups.yaml
6
+ #
7
+ # To use the definitions in this file, load them right after you load the
8
+ # Holiday gem:
9
+ #
10
+ # require 'holidays'
11
+ # require 'holidays/ups'
12
+ #
13
+ # More definitions are available at http://code.dunae.ca/holidays.
14
+ module UPS # :nodoc:
15
+ DEFINED_REGIONS = [:ups]
16
+
17
+ HOLIDAYS_BY_MONTH = {
18
+ 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]}],
19
+ 5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:ups]}],
20
+ 7 => [{:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Independence Day", :regions => [:ups]}],
21
+ 9 => [{:wday => 1, :week => 1, :name => "Labor Day", :regions => [:ups]}],
22
+ 11 => [{:wday => 4, :week => 4, :name => "Thanksgiving", :regions => [:ups]},
23
+ {:wday => 5, :week => 4, :name => "Day After Thanksgiving", :regions => [:ups]}],
24
+ 12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas Day", :regions => [:ups]},
25
+ {:mday => 31, :name => "New Year's Eve", :regions => [:ups]}]
26
+ }
27
+ end
28
+
29
+
30
+ end
31
+
32
+ Holidays.merge_defs(Holidays::UPS::DEFINED_REGIONS, Holidays::UPS::HOLIDAYS_BY_MONTH)
@@ -1,48 +1,49 @@
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)
1
+ # encoding: utf-8
2
+ module Holidays
3
+ # This file is generated by the Ruby Holiday gem.
4
+ #
5
+ # Definitions loaded: data/us.yaml, data/north_america_informal.yaml
6
+ #
7
+ # To use the definitions in this file, load them right after you load the
8
+ # Holiday gem:
9
+ #
10
+ # require 'holidays'
11
+ # require 'holidays/us'
12
+ #
13
+ # More definitions are available at http://code.dunae.ca/holidays.
14
+ module US # :nodoc:
15
+ DEFINED_REGIONS = [:us, :us_dc, :ca]
16
+
17
+ HOLIDAYS_BY_MONTH = {
18
+ 0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :type => :informal, :name => "Good Friday", :regions => [:us]}],
19
+ 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]},
20
+ {:wday => 1, :week => 3, :name => "Martin Luther King, Jr. Day", :regions => [:us]},
21
+ {:function => lambda { |year| Holidays.us_inauguration_day(year) }, :function_id => "us_inauguration_day(year)", :name => "Inauguration Day", :regions => [:us_dc]}],
22
+ 2 => [{:wday => 1, :week => 3, :name => "Presidents' Day", :regions => [:us]},
23
+ {:mday => 2, :type => :informal, :name => "Groundhog Day", :regions => [:us, :ca]},
24
+ {:mday => 14, :type => :informal, :name => "Valentine's Day", :regions => [:us, :ca]}],
25
+ 5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:us]},
26
+ {:wday => 0, :week => 3, :type => :informal, :name => "Father's Day", :regions => [:us, :ca]}],
27
+ 7 => [{:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Independence Day", :regions => [:us]}],
28
+ 9 => [{:wday => 1, :week => 1, :name => "Labor Day", :regions => [:us]}],
29
+ 10 => [{:wday => 1, :week => 2, :name => "Columbus Day", :regions => [:us]},
30
+ {:mday => 31, :type => :informal, :name => "Halloween", :regions => [:us, :ca]}],
31
+ 11 => [{:mday => 11, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Veterans Day", :regions => [:us]},
32
+ {:wday => 4, :week => 4, :name => "Thanksgiving", :regions => [:us]}],
33
+ 12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas Day", :regions => [:us]}],
34
+ 3 => [{:mday => 17, :type => :informal, :name => "St. Patrick's Day", :regions => [:us, :ca]}],
35
+ 4 => [{:mday => 1, :type => :informal, :name => "April Fool's Day", :regions => [:us, :ca]},
36
+ {:mday => 22, :type => :informal, :name => "Earth Day", :regions => [:us, :ca]}]
37
+ }
38
+ end
39
+
40
+ # January 20, every fourth year, following Presidential election
41
+ def self.us_inauguration_day(year)
42
+ year % 4 == 1 ? 20 : nil
43
+ end
44
+
45
+
46
+
47
+ end
48
+
49
+ Holidays.merge_defs(Holidays::US::DEFINED_REGIONS, Holidays::US::HOLIDAYS_BY_MONTH)
@@ -1,35 +1,36 @@
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)
1
+ # encoding: utf-8
2
+ module Holidays
3
+ # This file is generated by the Ruby Holiday gem.
4
+ #
5
+ # Definitions loaded: data/za.yaml
6
+ #
7
+ # To use the definitions in this file, load them right after you load the
8
+ # Holiday gem:
9
+ #
10
+ # require 'holidays'
11
+ # require 'holidays/za'
12
+ #
13
+ # More definitions are available at http://code.dunae.ca/holidays.
14
+ module ZA # :nodoc:
15
+ DEFINED_REGIONS = [:za]
16
+
17
+ HOLIDAYS_BY_MONTH = {
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
+ 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]}],
21
+ 3 => [{:mday => 21, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Human Rights Day", :regions => [:za]}],
22
+ 4 => [{:mday => 27, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Freedom Day", :regions => [:za]}],
23
+ 5 => [{:mday => 1, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Workers Day", :regions => [:za]}],
24
+ 6 => [{:mday => 16, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Youth Day", :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
+ 9 => [{:mday => 24, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Heritage Day", :regions => [:za]}],
27
+ 12 => [{:mday => 16, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Day of Reconciliation", :regions => [:za]},
28
+ {:mday => 25, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Christmas Day", :regions => [:za]},
29
+ {: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]}]
30
+ }
31
+ end
32
+
33
+
34
+ end
35
+
36
+ Holidays.merge_defs(Holidays::ZA::DEFINED_REGIONS, Holidays::ZA::HOLIDAYS_BY_MONTH)
@@ -1,113 +1,105 @@
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')
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
- spec = Gem::Specification.new do |s|
48
- s.name = 'holidays'
49
- s.version = '0.9.3'
50
- s.author = 'Alex Dunae'
51
- s.homepage = 'http://code.dunae.ca/holidays'
52
- s.platform = Gem::Platform::RUBY
53
- s.description = <<-EOF
54
- A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!
55
- EOF
56
- s.summary = 'A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!'
57
- s.files = FileList["{lib}/**/*", "{data}/**/*", "*.rb"].to_a
58
- s.test_files = FileList['test/defs/test*.rb'].exclude('test_helper.rb')
59
- s.has_rdoc = true
60
- s.extra_rdoc_files = ['README', 'data/SYNTAX', 'lib/holidays/MANIFEST', 'REFERENCES', 'CHANGELOG', 'LICENSE']
61
- s.rdoc_options << '--all' << '--inline-source' << '--line-numbers' << '--charset' << 'utf-8'
62
- end
63
-
64
- desc 'Build the gem.'
65
- Rake::GemPackageTask.new(spec) do |pkg|
66
- pkg.need_zip = true
67
- pkg.need_tar = true
68
- end
69
-
70
- desc 'Definition file tasks'
71
- namespace :defs do
72
- DATA_PATH = 'data'
73
-
74
- desc 'Build holiday definition files'
75
- task :build_all do
76
- # load the index
77
- def_index = YAML.load_file("#{DATA_PATH}/index.yaml")
78
-
79
- # create a dir for the generated tests
80
- FileUtils.mkdir_p('test/defs')
81
-
82
- def_index['defs'].each do |region, files|
83
- puts "Building #{region} definition module:"
84
- files = files.collect { |f| "#{DATA_PATH}/#{f}" }
85
- files.uniq!
86
-
87
- module_src, test_src = parse_holiday_defs(region, files)
88
- File.open("lib/holidays/#{region.downcase.to_s}.rb","w") do |file|
89
- file.puts module_src
90
- end
91
- unless test_src.empty?
92
- File.open("test/defs/test_defs_#{region.downcase.to_s}.rb","w") do |file|
93
- file.puts test_src
94
- end
95
- end
96
- puts "Done.\n\n"
97
- end
98
- end
99
-
100
- desc 'Build the definition manifest.'
101
- task :manifest do
102
- File.open("lib/holidays/MANIFEST","w") do |file|
103
- file.puts <<-EOH
104
- ==== Regional definitions
105
- The following definition files are included in this installation:
106
-
107
- EOH
108
- FileList.new('lib/holidays/*.rb').each do |str|
109
- file.puts('* ' + str.gsub(/^lib\/|\.rb$/, ''))
110
- end
111
- end
112
- end
113
- end
1
+ $:.unshift File.expand_path('../lib', __FILE__)
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+ require 'rake/rdoctask'
5
+ require 'rake/gempackagetask'
6
+ require 'yaml'
7
+ require 'fileutils'
8
+ require 'holidays'
9
+ require File.expand_path('data/build_defs')
10
+
11
+ desc 'Run all tests'
12
+ task :test => ["test:lib", "test:defs"]
13
+
14
+ namespace :test do
15
+ desc 'Run the unit tests.'
16
+ Rake::TestTask.new(:defs) do |t|
17
+ t.libs << 'lib'
18
+ t.test_files = FileList['test/defs/test*.rb'].exclude('test_helper.rb')
19
+ t.verbose = false
20
+ end
21
+
22
+ desc 'Run the definition tests.'
23
+ Rake::TestTask.new(:lib) do |t|
24
+ t.libs << 'lib'
25
+ t.test_files = FileList['test/test*.rb'].exclude('test_helper.rb')
26
+ t.verbose = false
27
+ end
28
+ end
29
+
30
+ task :doc => ["defs:manifest", :rdoc]
31
+
32
+ desc 'Generate documentation.'
33
+ Rake::RDocTask.new(:rdoc) do |rdoc|
34
+ rdoc.rdoc_dir = 'doc'
35
+ rdoc.title = 'Ruby Holidays Gem'
36
+ rdoc.options << '--all' << '--inline-source' << '--line-numbers'
37
+ rdoc.options << '--charset' << 'utf-8'
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
+ desc 'Definition file tasks'
48
+ namespace :defs do
49
+ DATA_PATH = 'data'
50
+
51
+ desc 'Build holiday definition files'
52
+ task :build_all do
53
+ # load the index
54
+ def_index = YAML.load_file("#{DATA_PATH}/index.yaml")
55
+
56
+ # create a dir for the generated tests
57
+ FileUtils.mkdir_p('test/defs')
58
+
59
+ def_index['defs'].each do |region, files|
60
+ puts "Building #{region} definition module:"
61
+ files = files.collect { |f| "#{DATA_PATH}/#{f}" }
62
+ files.uniq!
63
+
64
+ module_src, test_src = parse_holiday_defs(region, files)
65
+ File.open("lib/holidays/#{region.downcase.to_s}.rb","w") do |file|
66
+ file.puts module_src
67
+ end
68
+ unless test_src.empty?
69
+ File.open("test/defs/test_defs_#{region.downcase.to_s}.rb","w") do |file|
70
+ file.puts test_src
71
+ end
72
+ end
73
+ puts "Done.\n\n"
74
+ end
75
+ end
76
+
77
+ desc 'Build the definition manifest.'
78
+ task :manifest do
79
+ File.open("lib/holidays/MANIFEST","w") do |file|
80
+ file.puts <<-EOH
81
+ ==== Regional definitions
82
+ The following definition files are included in this installation:
83
+
84
+ EOH
85
+ FileList.new('lib/holidays/*.rb').each do |str|
86
+ file.puts('* ' + str.gsub(/^lib\/|\.rb$/, ''))
87
+ end
88
+ end
89
+ end
90
+ end
91
+
92
+ begin
93
+ require 'jeweler'
94
+ Jeweler::Tasks.new do |gemspec|
95
+ gemspec.name = "holidays"
96
+ gemspec.summary = "A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!"
97
+ gemspec.description = "A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!"
98
+ gemspec.email = "code@dunae.ca"
99
+ gemspec.homepage = "https://github.com/alexdunae/holidays"
100
+ gemspec.version = Holidays::VERSION
101
+ gemspec.authors = ["Alex Dunae", "Rowan Crawford"]
102
+ end
103
+ rescue LoadError
104
+ puts "Jeweler not available. Install it with: gem install jeweler"
105
+ end