holidays 6.5.0 → 6.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +1 -1
  3. data/CHANGELOG.md +10 -0
  4. data/Makefile +17 -4
  5. data/README.md +7 -9
  6. data/Rakefile +1 -1
  7. data/doc/CONTRIBUTING.md +71 -0
  8. data/{MAINTAINERS.md → doc/MAINTAINERS.md} +5 -6
  9. data/{REFERENCES → doc/REFERENCES} +0 -0
  10. data/holidays.gemspec +4 -5
  11. data/lib/generated_definitions/REGIONS.rb +1 -1
  12. data/lib/generated_definitions/cl.rb +0 -3
  13. data/lib/generated_definitions/europe.rb +1 -1
  14. data/lib/generated_definitions/gb.rb +1 -1
  15. data/lib/generated_definitions/jp.rb +2 -0
  16. data/lib/generated_definitions/south_america.rb +0 -3
  17. data/lib/holidays/definition/context/load.rb +1 -1
  18. data/lib/holidays/definition/generator/regions.rb +7 -2
  19. data/lib/holidays/definition/parser/custom_method.rb +2 -2
  20. data/lib/holidays/definition/repository/cache.rb +2 -1
  21. data/lib/holidays/finder/context/dates_driver_builder.rb +5 -11
  22. data/lib/holidays/finder/context/parse_options.rb +0 -6
  23. data/lib/holidays/version.rb +1 -1
  24. data/test/coverage_report.rb +0 -2
  25. data/test/defs/test_defs_at.rb +5 -3
  26. data/test/defs/test_defs_au.rb +11 -0
  27. data/test/defs/test_defs_be_fr.rb +10 -0
  28. data/test/defs/test_defs_be_nl.rb +10 -0
  29. data/test/defs/test_defs_europe.rb +33 -3
  30. data/test/defs/test_defs_gb.rb +8 -0
  31. data/test/holidays/definition/context/test_load.rb +3 -3
  32. data/test/holidays/definition/parser/test_custom_method.rb +4 -4
  33. data/test/holidays/finder/context/test_parse_options.rb +0 -10
  34. data/test/integration/test_multiple_regions.rb +54 -6
  35. metadata +12 -26
  36. data/CONTRIBUTING.md +0 -51
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b334c3ebec3562f4855ca608d4cd685dc223bad374bb4e15dcd64a61b3abe0d
4
- data.tar.gz: bd53c8ff4bc93522c6ac997080a5315e38b3e10cd66654cfeade2674bb1e8249
3
+ metadata.gz: 10ac53801a7e5df310c955e2d14eff378b5486e7f6b8e6e55c2f2f680c3bc68f
4
+ data.tar.gz: 249638ac1590932582342b2f6d39eaffca6d408f275420711916d94dce1eadbc
5
5
  SHA512:
6
- metadata.gz: 124f5e256062ec52db46603b8854bd3eafcdabb699b77e26766c9bd3d7aba51bc821b9438051956f451b8aec47b83e0f6fccf2855b38cf5862c0262799c8c51b
7
- data.tar.gz: 8412d3f181987241a802e64d5a6b562e6ef89f9336f05c4d281df4b84eb6c03e6728d403b3666323a9ebaa8bed703db8d0e40eae4d48cc1412be004a36182954
6
+ metadata.gz: 6a53bd90098905e561558ccc5c1adc42a40bbf19647ff70bb5cf846ffa7350cf6ef7958d251e8d6644d0e0ba5d3ef48a5c3fd008fb6c159b82df948a33fb72c5
7
+ data.tar.gz: dc023803f7dea3acb449e58c4756b3408586f92b9f83620af72f9c84f712cbec50383198ff455ad97dfc151d1bf7f6e97d40a542dfab014000acace307bd0551
@@ -1,3 +1,3 @@
1
1
  [submodule "definitions"]
2
2
  path = definitions
3
- url = https://github.com/holidays/definitions
3
+ url = https://github.com/holidays/definitions
@@ -1,5 +1,15 @@
1
1
  # Ruby Holidays Gem CHANGELOG
2
2
 
3
+ ## 6.6.0
4
+
5
+ * Update to [v3.0.0 definitions](https://github.com/holidays/definitions/releases/tag/v3.0.0). This required updates to the custom method parser but no behavior changes.
6
+ * Remove unused `simplecov-rcov` from gemspec dev dependencies
7
+ * Fix parent region loading bug [PR](https://github.com/holidays/holidays/pull/320) (thanks to chadrschroeder)
8
+ * Fix `ruby-head` build caused by new 'endless range' feature in ruby 2.6.0 [PR](https://github.com/holidays/holidays/pull/321)
9
+ * Refactor definition search logic for improved readability [PR](https://github.com/holidays/holidays/pull/318) (thanks to https://github.com/guizma)
10
+ * Reorganize most documentation into the `docs/` directory
11
+ * Fix list of covered rubies in README
12
+
3
13
  ## 6.5.0
4
14
 
5
15
  * Update to [v2.5.2 definitions](https://github.com/holidays/definitions/releases/tag/v2.5.2). Please see the changelog for the definition details.
data/Makefile CHANGED
@@ -1,6 +1,6 @@
1
1
  default: test
2
2
 
3
- setup: update_defs
3
+ setup: update-defs
4
4
  bundle install
5
5
 
6
6
  generate:
@@ -12,7 +12,7 @@ test:
12
12
  console:
13
13
  bundle exec rake console
14
14
 
15
- test_region:
15
+ test-region:
16
16
  bundle exec rake test_region $(REGION)
17
17
 
18
18
  build: clean
@@ -21,12 +21,25 @@ build: clean
21
21
  push:
22
22
  bundle exec gem push $(GEM)
23
23
 
24
- update_defs:
24
+ update-defs: definitions/
25
25
  git submodule update --init --remote --recursive
26
26
 
27
+ definitions: point-to-defs-master
28
+
29
+ point-to-defs-branch:
30
+ git submodule add -b $(BRANCH) git@github.com:$(USER)/definitions.git definitions/
31
+
32
+ point-to-defs-master:
33
+ git submodule add https://github.com/holidays/definitions definitions/
34
+
35
+ clean-defs:
36
+ git rm -f definitions
37
+ rm -rf .git/modules/definitions
38
+ git config -f .git/config --remove-section submodule.definitions 2> /dev/null
39
+
27
40
  clean:
28
41
  rm -rf holidays-*.gem
29
42
  rm -rf reports
30
43
  rm -rf coverage
31
44
 
32
- .PHONY: setup test generate
45
+ .PHONY: setup test generate console build push update-defs test-region clean-defs point-to-defs-master point-to-defs-branch clean definitions
data/README.md CHANGED
@@ -4,22 +4,20 @@ A set of functions to deal with holidays in Ruby.
4
4
 
5
5
  Extends Ruby's built-in Date class and supports custom holiday definition lists.
6
6
 
7
- Full documentation can be found [here](http://www.rubydoc.info/github/alexdunae/holidays/master/frames).
8
-
9
7
  ## Installation
10
8
 
11
9
  To install the gem from RubyGems:
12
10
 
13
11
  gem install holidays
14
12
 
15
- The Holidays gem is tested on Ruby 2.2.0, 2.3.0, 2.4.0 and JRuby.
13
+ This gem is tested with the following ruby versions: 2.2.0, 2.3.0, 2.4.0, 2.5.0, JRuby
14
+
15
+ This gem follows [semantic versioning](http://semver.org/). The guarantee specifically covers:
16
16
 
17
- This gem follows [semantic versioning](http://semver.org/). The only methods covered by this guarantee are under the
18
- `Holidays` namespace specifically. Anything that is not a method off of `Holidays` or the core extension is not covered by
19
- semver. Please take this into account when relying on this gem as a dependency.
17
+ * methods in the topmost `Holidays` namespace e.g. `Holidays.<method>`
18
+ * the [core extension](#extending-rubys-date-and-time-classes)
20
19
 
21
- Also note that we consider definition changes as 'minor' bumps, meaning they are backwards compatible with your code
22
- but might give different holiday results!
20
+ Please note that we consider definition changes to be 'minor' bumps, meaning they are backwards compatible with your code but might give different holiday results!
23
21
 
24
22
  ## Time zones
25
23
 
@@ -175,7 +173,7 @@ Holidays for the regions specified within the dates specified will be pre-calcul
175
173
 
176
174
  ### How to contribute
177
175
 
178
- See our [contribution guidelines](CONTRIBUTING.md) for information on how to help out!
176
+ See our [contribution guidelines](doc/CONTRIBUTING.md) for information on how to help out!
179
177
 
180
178
  ### Credits and code
181
179
 
data/Rakefile CHANGED
@@ -41,7 +41,7 @@ end
41
41
 
42
42
  desc 'Launch IRB session'
43
43
  task :console do
44
- sh "irb -rubygems -I lib -r holidays.rb"
44
+ sh "irb -r rubygems -I lib -r holidays.rb"
45
45
  end
46
46
 
47
47
  desc 'Generate definitions and tests used in main holiday logic based on raw YAML definitions'
@@ -0,0 +1,71 @@
1
+ # How to contribute
2
+
3
+ There are multiple ways to help! We rely on users around the world to help keep our definitions accurate and up to date. In addition, pull requests to address bugs or implement new features are always welcome.
4
+
5
+ ## Code of Conduct
6
+
7
+ Please read our [Code of Conduct](../CODE_OF_CONDUCT.md) before contributing. Everyone interacting with this project (or associated projects) is expected to abide by its terms.
8
+
9
+ ## General note
10
+
11
+ The definitions for this project are housed in a submodule. When pulling this repo please make sure to run `git clone --recursive git@github.com/holidays/holidays`
12
+ or, if you forgot to do so, run `make update-defs` so that all of the submodule data is pulled correctly.
13
+
14
+ ## For definition updates
15
+
16
+ Our definitions are written in YAML. They are housed in a [separate repository](https://github.com/holidays/definitions) so that they can be used by tools written in other languages. You can find a complete guide to our format in the [definitions SYNTAX guide](https://github.com/holidays/definitions/blob/master/doc/SYNTAX.md).
17
+
18
+ In this ruby project we take the YAML definitions and generate final ruby classes that are loaded at runtime for fast calculations.
19
+
20
+ Once you have a good idea on what you want to change, please see the [CONTRIBUTING guide](https://github.com/holidays/definitions/blob/master/doc/CONTRIBUTING.md) in the `definitions` repository.
21
+
22
+ The idea is that if the validation passes on the other repo then you shouldn't have to worry about generating and testing here. We'll see how that goes!
23
+
24
+ Once that PR is accepted the maintainers of this project will be responsible for generating the updated definitions here and releasing a new gem. Don't worry about versioning, we'll take care of it!
25
+
26
+ #### Testing out your definitions locally
27
+
28
+ As mentioned above we use a git submodule for the definitions. Sometimes you might want to manually test out how this ruby project will behave with your changes. To facilitate that we provide some commands for pointing the definitions submodule to your fork/branch.
29
+
30
+ To point at your fork/branch:
31
+
32
+ ```sh
33
+ make clean-defs
34
+ BRANCH=<branch-name> USER=<user> make point-to-defs-branch
35
+ ```
36
+
37
+ Example:
38
+
39
+ ```sh
40
+ make clean-defs
41
+ BRANCH=issue-24 USER=ppeble make point-to-defs-branch
42
+ ```
43
+
44
+ This will pull everything down for the latest commit on that fork/branch. When you are done testing and want to point back at the master definitions:
45
+
46
+ ```sh
47
+ make clean-defs
48
+ make point-to-defs-master
49
+ ```
50
+
51
+ ## For non-definition functionality
52
+
53
+ * Fork this repository
54
+ * Make your changes
55
+ * Create a PR pointing back to `master`
56
+
57
+ Don't worry about versioning, we'll handle it on our end.
58
+
59
+ *Tests are required*. If your PR results in lower test coverage then it will not be accepted.
60
+
61
+ ## Local development helpers
62
+
63
+ We have included a few handy tasks to help you troubleshoot and test:
64
+
65
+ * `make test` - runs the entire suite
66
+ * `REGION=<region> make test-region` - runs the tests for just that region
67
+ * `make console` - launches an IRB session with the 'holidays' gem loaded for quick testing
68
+ * `make update-defs` - runs the appropriate git submodule commands to pull the latest definitions
69
+ * `make clean-defs` - removes the definitions submodule, useful for switching between a fork and the main definitions repository
70
+ * `BRANCH=<branch> USER=<user> make point-to-defs-branch` - updates your definitions submodule to point at a fork/branch
71
+ * `make point-to-defs-master` - updates your definitions submodule to point back at the `holidays/definitions` repo and master branch
@@ -49,19 +49,19 @@ sections below.
49
49
  ### Release flow
50
50
 
51
51
  * Does this update require definition updates? If YES, then:
52
- * Pull the latest `master` version of this ruby repository and run `make update_defs`. This will grab the latest version from the [definitions](https://github.com/holidays/definitions) repository. Run `git diff` to verify that the version of the submodule for the definitions matches the correct commit in the [definitions](https://github.com/holidays/definitions) repo.
52
+ * Pull the latest `master` version of this ruby repository and run `make update-defs`. This will grab the latest version from the [definitions](https://github.com/holidays/definitions) repository. Run `git diff` to verify that the version of the submodule for the definitions matches the latest commit in the [definitions](https://github.com/holidays/definitions) repo.
53
53
  * Run the `make generate` command. This will 'recompile' the ruby sources with the latest definitions.
54
54
  * Run `make test` and ensure that all of the tests pass. If any tests fail then do *not* merge and contact a [core member](https://github.com/orgs/holidays/teams/core/members) for assistance.
55
55
  * If all of the tests pass, update the `lib/holidays/version.rb` file to the new version. Reference the above [semver](http://semver.org/) rules for how to update versions.
56
- * Make a branch on your fork and update the [CHANGELOG](https://github.com/holidays/holidays/blob/master/CHANGELOG.md) to reflect the latest changes. You do not need to put in all of the definition changes in this update, you can simply reference the other repository. See other entries in the CHANGELOG for examples.
57
- * Open a PR against the new branch and merge it (this may require another maintainer for safety)
56
+ * Make a branch on your fork and update the [CHANGELOG](../CHANGELOG.md) to reflect the latest changes. You do not need to put in all of the definition changes in this update, you can simply reference the other repository. See other entries in the CHANGELOG for examples.
57
+ * Open a PR against the new branch and merge it (another maintainer will need to review before you can merge)
58
58
  * Once the branch is merged, pull down the latest master from Github and run `make build`. This will generate a new `gem` file with the new version. The new version number is pulled from the above `version.rb` update.
59
59
  * If the build was successful then you can run the following to push up to rubygems.org: `GEM=<gem> make push`. Example: `GEM=holidays-6.2.0.gem make push`
60
60
  * Does this update require functionality additions or bug fixes? If YES, then:
61
61
  * Run `make test` and ensure that all of the tests pass. If any tests fail then do *not* merge and contact a [core member](https://github.com/orgs/holidays/teams/core/members) for assistance.
62
- * If all of the tests pass, make a branch on your fork and update the [CHANGELOG](https://github.com/holidays/holidays/blob/master/CHANGELOG.md) to reflect the latest changes.
62
+ * If all of the tests pass, make a branch on your fork and update the [CHANGELOG](../CHANGELOG.md) to reflect the latest changes.
63
63
  * Update the `lib/holidays/version.rb` file to the new version. Reference the above [semver](http://semver.org/) rules for how to update versions.
64
- * Open a PR against the new branch and merge it (this may require another maintainer for safety)
64
+ * Open a PR against the new branch and merge it (another maintainer will need to review before you can merge)
65
65
  * Once the branch is merged, pull down the latest master from Github and run `make build`. This will generate a new `gem` file with the new version. The new version number is pulled from the above `version.rb` update.
66
66
  * If the build was successful then you can run the following to push up to rubygems.org: `GEM=<gem> make push`. Example: `GEM=holidays-6.2.0.gem make push`
67
67
 
@@ -79,4 +79,3 @@ are that there are issues in the definition-specific tests. This is most likely
79
79
  It is a known issue that the definitions do not have a good set of self-tests to ensure that they are internally consistent. This means that a failure in this
80
80
  repository could NOT be related to ruby specifically. It could be that the 'tests' specified in in the YAML files are incorrect! If you encounter errors here
81
81
  make sure that you don't assume that it is just a ruby error that is causing the issues!
82
-
File without changes
@@ -7,7 +7,7 @@ require 'holidays/version'
7
7
  Gem::Specification.new do |gem|
8
8
  gem.name = 'holidays'
9
9
  gem.version = Holidays::VERSION
10
- gem.authors = ['Alex Dunae', 'Phil Trimble']
10
+ gem.authors = ['Alex Dunae', 'Phil Peble']
11
11
  gem.email = ['holidaysgem@gmail.com']
12
12
  gem.homepage = 'https://github.com/holidays/holidays'
13
13
  gem.description = %q(A collection of Ruby methods to deal with statutory and other holidays. You deserve a holiday!)
@@ -19,9 +19,8 @@ Gem::Specification.new do |gem|
19
19
  gem.required_ruby_version = '~> 2.2'
20
20
  gem.add_development_dependency 'bundler'
21
21
  gem.add_development_dependency 'rake', '~> 12.0'
22
- gem.add_development_dependency 'simplecov', '~> 0.15'
23
- gem.add_development_dependency 'simplecov-rcov', '~> 0.2'
22
+ gem.add_development_dependency 'simplecov', '~> 0.16'
24
23
  gem.add_development_dependency 'test-unit', '~> 3.2'
25
- gem.add_development_dependency 'mocha', '~> 1.0'
26
- gem.add_development_dependency 'pry', '~> 0.10'
24
+ gem.add_development_dependency 'mocha', '~> 1.7'
25
+ gem.add_development_dependency 'pry', '~> 0.11'
27
26
  end
@@ -2,5 +2,5 @@
2
2
  module Holidays
3
3
  REGIONS = [:ar, :at, :au, :au_nsw, :au_vic, :au_qld, :au_nt, :au_act, :au_sa, :au_wa, :au_tas, :au_tas_south, :au_qld_cairns, :au_qld_brisbane, :au_tas_north, :au_vic_melbourne, :be_fr, :be_nl, :br, :bg_en, :bg_bg, :ca, :ca_qc, :ca_ab, :ca_sk, :ca_on, :ca_bc, :ca_nb, :ca_mb, :ca_ns, :ca_pe, :ca_nl, :ca_nt, :ca_nu, :ca_yt, :us, :ch_zh, :ch_be, :ch_lu, :ch_ur, :ch_sz, :ch_ow, :ch_nw, :ch_gl, :ch_zg, :ch_fr, :ch_so, :ch_bs, :ch_bl, :ch_sh, :ch_ar, :ch_ai, :ch_sg, :ch_gr, :ch_ag, :ch_tg, :ch_ti, :ch_vd, :ch_ne, :ch_ge, :ch_ju, :ch_vs, :ch, :cl, :co, :cr, :cz, :dk, :de, :de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn_sorbian, :de_th_cath, :de_sn, :de_st, :de_by_cath, :de_by_augsburg, :de_bb, :de_mv, :de_th, :de_hb, :de_hh, :de_ni, :de_sh, :ecb_target, :ee, :el, :es_pv, :es_na, :es_an, :es_ib, :es_cm, :es_mu, :es_m, :es_ar, :es_cl, :es_cn, :es_lo, :es_ga, :es_ce, :es_o, :es_ex, :es, :es_ct, :es_v, :es_vc, :federal_reserve, :fedex, :fi, :fr_a, :fr_m, :fr, :gb, :gb_eng, :gb_wls, :gb_eaw, :gb_nir, :je, :gb_jsy, :gg, :gb_gsy, :gb_sct, :gb_con, :im, :gb_iom, :ge, :hr, :hk, :hu, :ie, :is, :it, :kr, :li, :lt, :ma, :mt_mt, :mt_en, :mx, :mx_pue, :nerc, :nl, :lu, :no, :nyse, :nz, :nz_sl, :nz_we, :nz_ak, :nz_nl, :nz_ne, :nz_ot, :nz_ta, :nz_sc, :nz_hb, :nz_mb, :nz_ca, :nz_ch, :nz_wl, :pe, :ph, :pl, :pt, :pt_li, :pt_po, :ro, :rs_cyrl, :rs_la, :ru, :se, :tn, :tr, :us_fl, :us_la, :us_ct, :us_de, :us_gu, :us_hi, :us_in, :us_ky, :us_nj, :us_nc, :us_nd, :us_pr, :us_tn, :us_ms, :us_id, :us_ar, :us_tx, :us_dc, :us_md, :us_va, :us_il, :us_vt, :us_ak, :us_ca, :us_me, :us_ma, :us_al, :us_ga, :us_ne, :us_mo, :us_sc, :us_wv, :us_vi, :us_ut, :us_ri, :us_az, :us_co, :us_mt, :us_nm, :us_ny, :us_oh, :us_pa, :us_mi, :us_mn, :us_nv, :us_or, :us_sd, :us_wa, :us_wi, :us_wy, :us_ia, :us_ks, :us_nh, :us_ok, :united_nations, :ups, :za, :ve, :sk, :si, :jp, :vi, :sg, :my]
4
4
 
5
- PARENT_REGION_LOOKUP = {:ar=>:ar, :at=>:at, :au=>:au, :au_nsw=>:au, :au_vic=>:au, :au_qld=>:au, :au_nt=>:au, :au_act=>:au, :au_sa=>:au, :au_wa=>:au, :au_tas=>:au, :au_tas_south=>:au, :au_qld_cairns=>:au, :au_qld_brisbane=>:au, :au_tas_north=>:au, :au_vic_melbourne=>:au, :be_fr=>:be_fr, :be_nl=>:be_nl, :br=>:br, :bg_en=>:bg, :bg_bg=>:bg, :ca=>:ca, :ca_qc=>:ca, :ca_ab=>:ca, :ca_sk=>:ca, :ca_on=>:ca, :ca_bc=>:ca, :ca_nb=>:ca, :ca_mb=>:ca, :ca_ns=>:ca, :ca_pe=>:ca, :ca_nl=>:ca, :ca_nt=>:ca, :ca_nu=>:ca, :ca_yt=>:ca, :us=>:ca, :ch_zh=>:ch, :ch_be=>:ch, :ch_lu=>:ch, :ch_ur=>:ch, :ch_sz=>:ch, :ch_ow=>:ch, :ch_nw=>:ch, :ch_gl=>:ch, :ch_zg=>:ch, :ch_fr=>:ch, :ch_so=>:ch, :ch_bs=>:ch, :ch_bl=>:ch, :ch_sh=>:ch, :ch_ar=>:ch, :ch_ai=>:ch, :ch_sg=>:ch, :ch_gr=>:ch, :ch_ag=>:ch, :ch_tg=>:ch, :ch_ti=>:ch, :ch_vd=>:ch, :ch_ne=>:ch, :ch_ge=>:ch, :ch_ju=>:ch, :ch_vs=>:ch, :ch=>:ch, :cl=>:cl, :co=>:co, :cr=>:cr, :cz=>:cz, :dk=>:dk, :de=>:de, :de_bw=>:de, :de_by=>:de, :de_he=>:de, :de_nw=>:de, :de_rp=>:de, :de_sl=>:de, :de_sn_sorbian=>:de, :de_th_cath=>:de, :de_sn=>:de, :de_st=>:de, :de_by_cath=>:de, :de_by_augsburg=>:de, :de_bb=>:de, :de_mv=>:de, :de_th=>:de, :de_hb=>:de, :de_hh=>:de, :de_ni=>:de, :de_sh=>:de, :ecb_target=>:ecb_target, :ee=>:ee, :el=>:el, :es_pv=>:es, :es_na=>:es, :es_an=>:es, :es_ib=>:es, :es_cm=>:es, :es_mu=>:es, :es_m=>:es, :es_ar=>:es, :es_cl=>:es, :es_cn=>:es, :es_lo=>:es, :es_ga=>:es, :es_ce=>:es, :es_o=>:es, :es_ex=>:es, :es=>:es, :es_ct=>:es, :es_v=>:es, :es_vc=>:es, :federal_reserve=>:federal_reserve, :fedex=>:fedex, :fi=>:fi, :fr_a=>:fr, :fr_m=>:fr, :fr=>:fr, :gb=>:gb, :gb_eng=>:gb, :gb_wls=>:gb, :gb_eaw=>:gb, :gb_nir=>:gb, :je=>:gb, :gb_jsy=>:gb, :gg=>:gb, :gb_gsy=>:gb, :gb_sct=>:gb, :gb_con=>:gb, :im=>:gb, :gb_iom=>:gb, :ge=>:ge, :hr=>:hr, :hk=>:hk, :hu=>:hu, :ie=>:ie, :is=>:is, :it=>:it, :kr=>:kr, :li=>:li, :lt=>:lt, :ma=>:ma, :mt_mt=>:mt_mt, :mt_en=>:mt_en, :mx=>:mx, :mx_pue=>:mx, :nerc=>:nerc, :nl=>:nl, :lu=>:lu, :no=>:no, :nyse=>:nyse, :nz=>:nz, :nz_sl=>:nz, :nz_we=>:nz, :nz_ak=>:nz, :nz_nl=>:nz, :nz_ne=>:nz, :nz_ot=>:nz, :nz_ta=>:nz, :nz_sc=>:nz, :nz_hb=>:nz, :nz_mb=>:nz, :nz_ca=>:nz, :nz_ch=>:nz, :nz_wl=>:nz, :pe=>:pe, :ph=>:ph, :pl=>:pl, :pt=>:pt, :pt_li=>:pt, :pt_po=>:pt, :ro=>:ro, :rs_cyrl=>:rs_cyrl, :rs_la=>:rs_la, :ru=>:ru, :se=>:se, :tn=>:tn, :tr=>:tr, :us_fl=>:us, :us_la=>:us, :us_ct=>:us, :us_de=>:us, :us_gu=>:us, :us_hi=>:us, :us_in=>:us, :us_ky=>:us, :us_nj=>:us, :us_nc=>:us, :us_nd=>:us, :us_pr=>:us, :us_tn=>:us, :us_ms=>:us, :us_id=>:us, :us_ar=>:us, :us_tx=>:us, :us_dc=>:us, :us_md=>:us, :us_va=>:us, :us_il=>:us, :us_vt=>:us, :us_ak=>:us, :us_ca=>:us, :us_me=>:us, :us_ma=>:us, :us_al=>:us, :us_ga=>:us, :us_ne=>:us, :us_mo=>:us, :us_sc=>:us, :us_wv=>:us, :us_vi=>:us, :us_ut=>:us, :us_ri=>:us, :us_az=>:us, :us_co=>:us, :us_mt=>:us, :us_nm=>:us, :us_ny=>:us, :us_oh=>:us, :us_pa=>:us, :us_mi=>:us, :us_mn=>:us, :us_nv=>:us, :us_or=>:us, :us_sd=>:us, :us_wa=>:us, :us_wi=>:us, :us_wy=>:us, :us_ia=>:us, :us_ks=>:us, :us_nh=>:us, :us_ok=>:us, :united_nations=>:united_nations, :ups=>:ups, :za=>:za, :ve=>:south_america, :sk=>:europe, :si=>:europe, :jp=>:jp, :vi=>:vi, :sg=>:sg, :my=>:my}
5
+ PARENT_REGION_LOOKUP = {:ar=>:ar, :at=>:at, :au=>:au, :au_nsw=>:au, :au_vic=>:au, :au_qld=>:au, :au_nt=>:au, :au_act=>:au, :au_sa=>:au, :au_wa=>:au, :au_tas=>:au, :au_tas_south=>:au, :au_qld_cairns=>:au, :au_qld_brisbane=>:au, :au_tas_north=>:au, :au_vic_melbourne=>:au, :be_fr=>:be_fr, :be_nl=>:be_nl, :br=>:br, :bg_en=>:bg, :bg_bg=>:bg, :ca=>:ca, :ca_qc=>:ca, :ca_ab=>:ca, :ca_sk=>:ca, :ca_on=>:ca, :ca_bc=>:ca, :ca_nb=>:ca, :ca_mb=>:ca, :ca_ns=>:ca, :ca_pe=>:ca, :ca_nl=>:ca, :ca_nt=>:ca, :ca_nu=>:ca, :ca_yt=>:ca, :us=>:us, :ch_zh=>:ch, :ch_be=>:ch, :ch_lu=>:ch, :ch_ur=>:ch, :ch_sz=>:ch, :ch_ow=>:ch, :ch_nw=>:ch, :ch_gl=>:ch, :ch_zg=>:ch, :ch_fr=>:ch, :ch_so=>:ch, :ch_bs=>:ch, :ch_bl=>:ch, :ch_sh=>:ch, :ch_ar=>:ch, :ch_ai=>:ch, :ch_sg=>:ch, :ch_gr=>:ch, :ch_ag=>:ch, :ch_tg=>:ch, :ch_ti=>:ch, :ch_vd=>:ch, :ch_ne=>:ch, :ch_ge=>:ch, :ch_ju=>:ch, :ch_vs=>:ch, :ch=>:ch, :cl=>:cl, :co=>:co, :cr=>:cr, :cz=>:cz, :dk=>:dk, :de=>:de, :de_bw=>:de, :de_by=>:de, :de_he=>:de, :de_nw=>:de, :de_rp=>:de, :de_sl=>:de, :de_sn_sorbian=>:de, :de_th_cath=>:de, :de_sn=>:de, :de_st=>:de, :de_by_cath=>:de, :de_by_augsburg=>:de, :de_bb=>:de, :de_mv=>:de, :de_th=>:de, :de_hb=>:de, :de_hh=>:de, :de_ni=>:de, :de_sh=>:de, :ecb_target=>:ecb_target, :ee=>:ee, :el=>:el, :es_pv=>:es, :es_na=>:es, :es_an=>:es, :es_ib=>:es, :es_cm=>:es, :es_mu=>:es, :es_m=>:es, :es_ar=>:es, :es_cl=>:es, :es_cn=>:es, :es_lo=>:es, :es_ga=>:es, :es_ce=>:es, :es_o=>:es, :es_ex=>:es, :es=>:es, :es_ct=>:es, :es_v=>:es, :es_vc=>:es, :federal_reserve=>:federal_reserve, :fedex=>:fedex, :fi=>:fi, :fr_a=>:fr, :fr_m=>:fr, :fr=>:fr, :gb=>:gb, :gb_eng=>:gb, :gb_wls=>:gb, :gb_eaw=>:gb, :gb_nir=>:gb, :je=>:gb, :gb_jsy=>:gb, :gg=>:gb, :gb_gsy=>:gb, :gb_sct=>:gb, :gb_con=>:gb, :im=>:gb, :gb_iom=>:gb, :ge=>:ge, :hr=>:hr, :hk=>:hk, :hu=>:hu, :ie=>:ie, :is=>:is, :it=>:it, :kr=>:kr, :li=>:li, :lt=>:lt, :ma=>:ma, :mt_mt=>:mt_mt, :mt_en=>:mt_en, :mx=>:mx, :mx_pue=>:mx, :nerc=>:nerc, :nl=>:nl, :lu=>:lu, :no=>:no, :nyse=>:nyse, :nz=>:nz, :nz_sl=>:nz, :nz_we=>:nz, :nz_ak=>:nz, :nz_nl=>:nz, :nz_ne=>:nz, :nz_ot=>:nz, :nz_ta=>:nz, :nz_sc=>:nz, :nz_hb=>:nz, :nz_mb=>:nz, :nz_ca=>:nz, :nz_ch=>:nz, :nz_wl=>:nz, :pe=>:pe, :ph=>:ph, :pl=>:pl, :pt=>:pt, :pt_li=>:pt, :pt_po=>:pt, :ro=>:ro, :rs_cyrl=>:rs_cyrl, :rs_la=>:rs_la, :ru=>:ru, :se=>:se, :tn=>:tn, :tr=>:tr, :us_fl=>:us, :us_la=>:us, :us_ct=>:us, :us_de=>:us, :us_gu=>:us, :us_hi=>:us, :us_in=>:us, :us_ky=>:us, :us_nj=>:us, :us_nc=>:us, :us_nd=>:us, :us_pr=>:us, :us_tn=>:us, :us_ms=>:us, :us_id=>:us, :us_ar=>:us, :us_tx=>:us, :us_dc=>:us, :us_md=>:us, :us_va=>:us, :us_il=>:us, :us_vt=>:us, :us_ak=>:us, :us_ca=>:us, :us_me=>:us, :us_ma=>:us, :us_al=>:us, :us_ga=>:us, :us_ne=>:us, :us_mo=>:us, :us_sc=>:us, :us_wv=>:us, :us_vi=>:us, :us_ut=>:us, :us_ri=>:us, :us_az=>:us, :us_co=>:us, :us_mt=>:us, :us_nm=>:us, :us_ny=>:us, :us_oh=>:us, :us_pa=>:us, :us_mi=>:us, :us_mn=>:us, :us_nv=>:us, :us_or=>:us, :us_sd=>:us, :us_wa=>:us, :us_wi=>:us, :us_wy=>:us, :us_ia=>:us, :us_ks=>:us, :us_nh=>:us, :us_ok=>:us, :united_nations=>:united_nations, :ups=>:ups, :za=>:za, :ve=>:south_america, :sk=>:europe, :si=>:europe, :jp=>:jp, :vi=>:vi, :sg=>:sg, :my=>:my}
6
6
  end
@@ -41,7 +41,6 @@ if [2,3,4].include?(date.wday)
41
41
  elsif date.wday == 5
42
42
  date += 3
43
43
  end
44
-
45
44
  date
46
45
  },
47
46
 
@@ -52,7 +51,6 @@ if [2,3,4].include?(date.wday)
52
51
  elsif date.wday == 5
53
52
  date += 3
54
53
  end
55
-
56
54
  date
57
55
  },
58
56
 
@@ -63,7 +61,6 @@ if date.wday == 2
63
61
  elsif date.wday == 3
64
62
  date += 2
65
63
  end
66
-
67
64
  date
68
65
  },
69
66
 
@@ -410,7 +410,7 @@ module Holidays
410
410
  {:mday => 1, :observed => "to_monday_if_sunday(date)", :observed_arguments => [:date], :name => "Día de las Islas Baleares", :regions => [:es_ib]},
411
411
  {:mday => 19, :observed => "to_monday_if_sunday(date)", :observed_arguments => [:date], :name => "San José", :regions => [:es_v, :es_vc, :es_cm, :es_mu, :es_m]},
412
412
  {:mday => 5, :name => "St. Piran's Day", :regions => [:gb_con]},
413
- {:mday => 17, :name => "St. Patrick's Day", :regions => [:gb_nir]},
413
+ {:mday => 17, :observed => "to_monday_if_weekend(date)", :observed_arguments => [:date], :name => "St. Patrick's Day", :regions => [:gb_nir]},
414
414
  {:mday => 15, :name => "1848/49-es forradalom és szabadságharc ünnepe", :regions => [:hu]},
415
415
  {:mday => 17, :observed => "to_monday_if_weekend(date)", :observed_arguments => [:date], :name => "St. Patrick's Day", :regions => [:ie]},
416
416
  {:mday => 19, :name => "St. Josef", :regions => [:li]},
@@ -18,7 +18,7 @@ module Holidays
18
18
  1 => [{:mday => 1, :observed => "to_monday_if_weekend(date)", :observed_arguments => [:date], :name => "New Year's Day", :regions => [:gb]},
19
19
  {:mday => 2, :observed => "to_weekday_if_boxing_weekend(date)", :observed_arguments => [:date], :name => "2nd January", :regions => [:gb_sct]}],
20
20
  3 => [{:mday => 5, :name => "St. Piran's Day", :regions => [:gb_con]},
21
- {:mday => 17, :name => "St. Patrick's Day", :regions => [:gb_nir]}],
21
+ {:mday => 17, :observed => "to_monday_if_weekend(date)", :observed_arguments => [:date], :name => "St. Patrick's Day", :regions => [:gb_nir]}],
22
22
  5 => [{:wday => 1, :week => 1, :name => "May Day", :regions => [:gb]},
23
23
  {:mday => 9, :name => "Liberation Day", :regions => [:je, :gb_jsy, :gg, :gb_gsy]},
24
24
  {:wday => 1, :week => -1, :name => "Bank Holiday", :regions => [:gb]}],
@@ -136,6 +136,8 @@ date.wday == 0 ? (Holidays::Factory::Definition.custom_methods_repository.find("
136
136
  },
137
137
 
138
138
  "jp_next_weekday(date)" => Proc.new { |date|
139
+ # This suuuucks. I have no idea how to make this not reach into our interal ruby API to do this.
140
+ # I'm punting, I'll come back to this.
139
141
  is_holiday = Holidays::JP.holidays_by_month[date.month].any? do |holiday|
140
142
  holiday[:mday] == date.day
141
143
  end
@@ -119,7 +119,6 @@ if [2,3,4].include?(date.wday)
119
119
  elsif date.wday == 5
120
120
  date += 3
121
121
  end
122
-
123
122
  date
124
123
  },
125
124
 
@@ -130,7 +129,6 @@ if [2,3,4].include?(date.wday)
130
129
  elsif date.wday == 5
131
130
  date += 3
132
131
  end
133
-
134
132
  date
135
133
  },
136
134
 
@@ -141,7 +139,6 @@ if date.wday == 2
141
139
  elsif date.wday == 3
142
140
  date += 2
143
141
  end
144
-
145
142
  date
146
143
  },
147
144
 
@@ -14,7 +14,7 @@ module Holidays
14
14
  target_region_module = Module.const_get("Holidays").const_get(region.upcase)
15
15
 
16
16
  @definition_merger.call(
17
- target_region_module.defined_regions,
17
+ region,
18
18
  target_region_module.holidays_by_month,
19
19
  target_region_module.custom_methods,
20
20
  )
@@ -2,6 +2,10 @@ module Holidays
2
2
  module Definition
3
3
  module Generator
4
4
  class Regions
5
+ # The "ca", "mx", and "us" holiday definitions include the "north_america_informal"
6
+ # holiday definitions, but that does not make these countries subregions of one another.
7
+ NORTH_AMERICA_REGIONS = %i[ca mx us].freeze
8
+
5
9
  def call(regions)
6
10
  validate!(regions)
7
11
 
@@ -37,8 +41,9 @@ EOF
37
41
  lookup = {}
38
42
 
39
43
  regions.each do |region, subregions|
40
- subregions.each do |s|
41
- lookup[s] = region unless lookup.has_key?(s)
44
+ subregions.each do |subregion|
45
+ parent_region = NORTH_AMERICA_REGIONS.include?(subregion) ? subregion : region
46
+ lookup[subregion] = parent_region unless lookup.has_key?(subregion)
42
47
  end
43
48
  end
44
49
 
@@ -21,7 +21,7 @@ module Holidays
21
21
  custom_methods[method_key(name, arguments)] = Entity::CustomMethod.new({
22
22
  name: name,
23
23
  arguments: arguments,
24
- source: pieces["source"],
24
+ source: pieces["ruby"],
25
25
  })
26
26
  end
27
27
 
@@ -36,7 +36,7 @@ module Holidays
36
36
  {
37
37
  :name => name,
38
38
  :arguments => pieces["arguments"],
39
- :source => pieces["source"]
39
+ :source => pieces["ruby"]
40
40
  }
41
41
  )
42
42
  end
@@ -8,6 +8,7 @@ module Holidays
8
8
 
9
9
  def cache_between(start_date, end_date, cache_data, options)
10
10
  raise ArgumentError unless cache_data
11
+ raise ArgumentError unless start_date && end_date
11
12
 
12
13
  @cache_range[options] = start_date..end_date
13
14
  @cache[options] = cache_data.group_by { |holiday| holiday[:date] }
@@ -15,7 +16,7 @@ module Holidays
15
16
 
16
17
  def find(start_date, end_date, options)
17
18
  return nil unless in_cache_range?(start_date, end_date, options)
18
-
19
+
19
20
  if start_date == end_date
20
21
  @cache[options].fetch(start_date, [])
21
22
  else
@@ -11,20 +11,14 @@ module Holidays
11
11
  def call(start_date, end_date)
12
12
  dates_driver = {}
13
13
 
14
- (start_date..end_date).map{|current_date|build(dates_driver, current_date)}
14
+ (start_date..end_date).each do |date|
15
+ dates_driver[date.year] = [] unless dates_driver[date.year]
16
+ dates_driver[date.year] << date.month
17
+ dates_driver = add_border_months(date, dates_driver)
18
+ end
15
19
  clean(dates_driver)
16
20
  end
17
21
 
18
- #FIXME Why is the date_driver set to optional as the first param? That's
19
- # just plain wrong...
20
- def build(dates_driver = {}, date)
21
- raise ArgumentError unless dates_driver
22
- raise ArgumentError unless date
23
- dates_driver[date.year] = [] unless dates_driver[date.year]
24
- dates_driver[date.year] << date.month
25
- dates_driver = add_border_months(date, dates_driver)
26
- end
27
-
28
22
  private
29
23
 
30
24
  # As part of https://github.com/holidays/holidays/issues/146 I am returning
@@ -42,12 +42,6 @@ module Holidays
42
42
 
43
43
  loaded_regions = []
44
44
 
45
- #FIXME I don't know what this means or why we have it! I'm reluctant to remove it
46
- # at this time without understanding more. -PP 2017/3/29
47
- #
48
- # special case for north_america/US cross-linking
49
- load_region!(:north_america) if regions.include?(:us)
50
-
51
45
  if regions.include?(:any)
52
46
  @regions_repo.all_generated.each do |r|
53
47
  if @regions_repo.loaded?(r)
@@ -1,3 +1,3 @@
1
1
  module Holidays
2
- VERSION = '6.5.0'
2
+ VERSION = '6.6.0'
3
3
  end
@@ -1,8 +1,6 @@
1
1
  require 'simplecov'
2
- require 'simplecov-rcov'
3
2
 
4
3
  SimpleCov.minimum_coverage 99
5
- SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
6
4
  SimpleCov.coverage_dir 'reports/coverage'
7
5
  SimpleCov.start do
8
6
  add_filter 'lib/generated_definitions/'
@@ -9,11 +9,11 @@ class AtDefinitionTests < Test::Unit::TestCase # :nodoc:
9
9
  def test_at
10
10
  assert_equal "Neujahrstag", (Holidays.on(Date.civil(2009, 1, 1), [:at], [:informal])[0] || {})[:name]
11
11
 
12
- assert_equal "Ostermontag", (Holidays.on(Date.civil(2009, 4, 13), [:at], [:informal])[0] || {})[:name]
12
+ assert_equal "Ostermontag", (Holidays.on(Date.civil(2009, 4, 13), [:at])[0] || {})[:name]
13
13
 
14
- assert_equal "Christi Himmelfahrt", (Holidays.on(Date.civil(2009, 5, 21), [:at], [:informal])[0] || {})[:name]
14
+ assert_equal "Christi Himmelfahrt", (Holidays.on(Date.civil(2009, 5, 21), [:at])[0] || {})[:name]
15
15
 
16
- assert_equal "Pfingstmontag", (Holidays.on(Date.civil(2009, 6, 1), [:at], [:informal])[0] || {})[:name]
16
+ assert_equal "Pfingstmontag", (Holidays.on(Date.civil(2009, 6, 1), [:at])[0] || {})[:name]
17
17
 
18
18
  assert_equal "Nationalfeiertag", (Holidays.on(Date.civil(2009, 10, 26), [:at], [:informal])[0] || {})[:name]
19
19
 
@@ -25,5 +25,7 @@ class AtDefinitionTests < Test::Unit::TestCase # :nodoc:
25
25
 
26
26
  assert_nil (Holidays.on(Date.civil(2010, 5, 8), [:at])[0] || {})[:name]
27
27
 
28
+ assert_equal "Fronleichnam", (Holidays.on(Date.civil(2017, 6, 15), [:at])[0] || {})[:name]
29
+
28
30
  end
29
31
  end
@@ -7,6 +7,13 @@ require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
7
7
  class AuDefinitionTests < Test::Unit::TestCase # :nodoc:
8
8
 
9
9
  def test_au
10
+ assert_equal "Good Friday", (Holidays.on(Date.civil(2017, 4, 14), [:au])[0] || {})[:name]
11
+
12
+ assert_equal "Easter Saturday", (Holidays.on(Date.civil(2017, 4, 15), [:au_nsw])[0] || {})[:name]
13
+
14
+ assert_equal "Easter Sunday", (Holidays.on(Date.civil(2010, 4, 4), [:au_nsw])[0] || {})[:name]
15
+ assert_equal "Easter Sunday", (Holidays.on(Date.civil(2017, 4, 16), [:au_nsw])[0] || {})[:name]
16
+
10
17
  assert_equal "Labour Day", (Holidays.on(Date.civil(2013, 10, 7), [:au_qld])[0] || {})[:name]
11
18
 
12
19
  assert_equal "Labour Day", (Holidays.on(Date.civil(2012, 5, 7), [:au_qld])[0] || {})[:name]
@@ -183,7 +190,11 @@ assert_equal "Queen's Birthday", (Holidays.on(Date.civil(2016, 9, 26), [:au_wa])
183
190
 
184
191
  assert_equal "New Year's Day", (Holidays.on(Date.civil(2017, 1, 2), [:au_tas])[0] || {})[:name]
185
192
 
193
+ assert_nil (Holidays.on(Date.civil(2016, 3, 27), [:au_qld])[0] || {})[:name]
194
+
186
195
  assert_equal "Easter Sunday", (Holidays.on(Date.civil(2017, 4, 16), [:au_qld])[0] || {})[:name]
187
196
 
197
+ assert_equal "G20 Day", (Holidays.on(Date.civil(2014, 11, 14), [:au_qld_brisbane])[0] || {})[:name]
198
+
188
199
  end
189
200
  end
@@ -31,5 +31,15 @@ class Be_frDefinitionTests < Test::Unit::TestCase # :nodoc:
31
31
 
32
32
  assert_equal "Noël", (Holidays.on(Date.civil(2007, 12, 25), [:be_fr], [:informal])[0] || {})[:name]
33
33
 
34
+ assert_equal "Pâques", (Holidays.on(Date.civil(2017, 4, 16), [:be_fr])[0] || {})[:name]
35
+
36
+ assert_equal "Lundi de Pâques", (Holidays.on(Date.civil(2017, 4, 17), [:be_fr])[0] || {})[:name]
37
+
38
+ assert_equal "Ascension", (Holidays.on(Date.civil(2017, 5, 25), [:be_fr])[0] || {})[:name]
39
+
40
+ assert_equal "Pentecôte", (Holidays.on(Date.civil(2017, 6, 4), [:be_fr])[0] || {})[:name]
41
+
42
+ assert_equal "Lundi de Pentecôte", (Holidays.on(Date.civil(2017, 6, 5), [:be_fr])[0] || {})[:name]
43
+
34
44
  end
35
45
  end
@@ -31,5 +31,15 @@ class Be_nlDefinitionTests < Test::Unit::TestCase # :nodoc:
31
31
 
32
32
  assert_equal "Kerstmis", (Holidays.on(Date.civil(2007, 12, 25), [:be_nl], [:informal])[0] || {})[:name]
33
33
 
34
+ assert_equal "Pasen", (Holidays.on(Date.civil(2017, 4, 16), [:be_nl])[0] || {})[:name]
35
+
36
+ assert_equal "Paasmaandag", (Holidays.on(Date.civil(2017, 4, 17), [:be_nl])[0] || {})[:name]
37
+
38
+ assert_equal "O.H. Hemelvaart", (Holidays.on(Date.civil(2017, 5, 25), [:be_nl])[0] || {})[:name]
39
+
40
+ assert_equal "Pinksteren", (Holidays.on(Date.civil(2017, 6, 4), [:be_nl])[0] || {})[:name]
41
+
42
+ assert_equal "Pinkstermaandag", (Holidays.on(Date.civil(2017, 6, 5), [:be_nl])[0] || {})[:name]
43
+
34
44
  end
35
45
  end
@@ -9,11 +9,11 @@ class EuropeDefinitionTests < Test::Unit::TestCase # :nodoc:
9
9
  def test_europe
10
10
  assert_equal "Neujahrstag", (Holidays.on(Date.civil(2009, 1, 1), [:at], [:informal])[0] || {})[:name]
11
11
 
12
- assert_equal "Ostermontag", (Holidays.on(Date.civil(2009, 4, 13), [:at], [:informal])[0] || {})[:name]
12
+ assert_equal "Ostermontag", (Holidays.on(Date.civil(2009, 4, 13), [:at])[0] || {})[:name]
13
13
 
14
- assert_equal "Christi Himmelfahrt", (Holidays.on(Date.civil(2009, 5, 21), [:at], [:informal])[0] || {})[:name]
14
+ assert_equal "Christi Himmelfahrt", (Holidays.on(Date.civil(2009, 5, 21), [:at])[0] || {})[:name]
15
15
 
16
- assert_equal "Pfingstmontag", (Holidays.on(Date.civil(2009, 6, 1), [:at], [:informal])[0] || {})[:name]
16
+ assert_equal "Pfingstmontag", (Holidays.on(Date.civil(2009, 6, 1), [:at])[0] || {})[:name]
17
17
 
18
18
  assert_equal "Nationalfeiertag", (Holidays.on(Date.civil(2009, 10, 26), [:at], [:informal])[0] || {})[:name]
19
19
 
@@ -25,6 +25,8 @@ class EuropeDefinitionTests < Test::Unit::TestCase # :nodoc:
25
25
 
26
26
  assert_nil (Holidays.on(Date.civil(2010, 5, 8), [:at])[0] || {})[:name]
27
27
 
28
+ assert_equal "Fronleichnam", (Holidays.on(Date.civil(2017, 6, 15), [:at])[0] || {})[:name]
29
+
28
30
  assert_equal "Jour de l'an", (Holidays.on(Date.civil(2007, 1, 1), [:be_fr], [:informal])[0] || {})[:name]
29
31
 
30
32
  assert_equal "Pâques", (Holidays.on(Date.civil(2007, 4, 8), [:be_fr], [:informal])[0] || {})[:name]
@@ -49,6 +51,16 @@ class EuropeDefinitionTests < Test::Unit::TestCase # :nodoc:
49
51
 
50
52
  assert_equal "Noël", (Holidays.on(Date.civil(2007, 12, 25), [:be_fr], [:informal])[0] || {})[:name]
51
53
 
54
+ assert_equal "Pâques", (Holidays.on(Date.civil(2017, 4, 16), [:be_fr])[0] || {})[:name]
55
+
56
+ assert_equal "Lundi de Pâques", (Holidays.on(Date.civil(2017, 4, 17), [:be_fr])[0] || {})[:name]
57
+
58
+ assert_equal "Ascension", (Holidays.on(Date.civil(2017, 5, 25), [:be_fr])[0] || {})[:name]
59
+
60
+ assert_equal "Pentecôte", (Holidays.on(Date.civil(2017, 6, 4), [:be_fr])[0] || {})[:name]
61
+
62
+ assert_equal "Lundi de Pentecôte", (Holidays.on(Date.civil(2017, 6, 5), [:be_fr])[0] || {})[:name]
63
+
52
64
  assert_equal "Nieuwjaar", (Holidays.on(Date.civil(2007, 1, 1), [:be_nl], [:informal])[0] || {})[:name]
53
65
 
54
66
  assert_equal "Pasen", (Holidays.on(Date.civil(2007, 4, 8), [:be_nl], [:informal])[0] || {})[:name]
@@ -73,6 +85,16 @@ class EuropeDefinitionTests < Test::Unit::TestCase # :nodoc:
73
85
 
74
86
  assert_equal "Kerstmis", (Holidays.on(Date.civil(2007, 12, 25), [:be_nl], [:informal])[0] || {})[:name]
75
87
 
88
+ assert_equal "Pasen", (Holidays.on(Date.civil(2017, 4, 16), [:be_nl])[0] || {})[:name]
89
+
90
+ assert_equal "Paasmaandag", (Holidays.on(Date.civil(2017, 4, 17), [:be_nl])[0] || {})[:name]
91
+
92
+ assert_equal "O.H. Hemelvaart", (Holidays.on(Date.civil(2017, 5, 25), [:be_nl])[0] || {})[:name]
93
+
94
+ assert_equal "Pinksteren", (Holidays.on(Date.civil(2017, 6, 4), [:be_nl])[0] || {})[:name]
95
+
96
+ assert_equal "Pinkstermaandag", (Holidays.on(Date.civil(2017, 6, 5), [:be_nl])[0] || {})[:name]
97
+
76
98
  assert_equal "Bundesfeiertag", (Holidays.on(Date.civil(2012, 8, 1), [:ch])[0] || {})[:name]
77
99
 
78
100
  assert_equal "Weihnachten", (Holidays.on(Date.civil(2012, 12, 25), [:ch])[0] || {})[:name]
@@ -435,6 +457,14 @@ class EuropeDefinitionTests < Test::Unit::TestCase # :nodoc:
435
457
 
436
458
  assert_equal "St. Patrick's Day", (Holidays.on(Date.civil(2008, 3, 17), [:gb_nir], [:informal])[0] || {})[:name]
437
459
 
460
+ assert_equal "St. Patrick's Day", (Holidays.on(Date.civil(2018, 3, 17), [:gb_nir], [:informal])[0] || {})[:name]
461
+
462
+ assert_equal "St. Patrick's Day", (Holidays.on(Date.civil(2018, 3, 19), [:gb_nir], [:observed, :informal])[0] || {})[:name]
463
+
464
+ assert_equal "St. Patrick's Day", (Holidays.on(Date.civil(2019, 3, 17), [:gb_nir], [:informal])[0] || {})[:name]
465
+
466
+ assert_equal "St. Patrick's Day", (Holidays.on(Date.civil(2019, 3, 18), [:gb_nir], [:observed, :informal])[0] || {})[:name]
467
+
438
468
  assert_equal "St. Andrew's Day", (Holidays.on(Date.civil(2006, 11, 30), [:gb_sct], [:informal])[0] || {})[:name]
439
469
 
440
470
  assert_equal "St. Andrew's Day", (Holidays.on(Date.civil(2006, 11, 30), [:gb_sct], [:informal, :observed])[0] || {})[:name]
@@ -23,6 +23,14 @@ class GbDefinitionTests < Test::Unit::TestCase # :nodoc:
23
23
 
24
24
  assert_equal "St. Patrick's Day", (Holidays.on(Date.civil(2008, 3, 17), [:gb_nir], [:informal])[0] || {})[:name]
25
25
 
26
+ assert_equal "St. Patrick's Day", (Holidays.on(Date.civil(2018, 3, 17), [:gb_nir], [:informal])[0] || {})[:name]
27
+
28
+ assert_equal "St. Patrick's Day", (Holidays.on(Date.civil(2018, 3, 19), [:gb_nir], [:observed, :informal])[0] || {})[:name]
29
+
30
+ assert_equal "St. Patrick's Day", (Holidays.on(Date.civil(2019, 3, 17), [:gb_nir], [:informal])[0] || {})[:name]
31
+
32
+ assert_equal "St. Patrick's Day", (Holidays.on(Date.civil(2019, 3, 18), [:gb_nir], [:observed, :informal])[0] || {})[:name]
33
+
26
34
  assert_equal "St. Andrew's Day", (Holidays.on(Date.civil(2006, 11, 30), [:gb_sct], [:informal])[0] || {})[:name]
27
35
 
28
36
  assert_equal "St. Andrew's Day", (Holidays.on(Date.civil(2006, 11, 30), [:gb_sct], [:informal, :observed])[0] || {})[:name]
@@ -14,7 +14,7 @@ class LoadTests < Test::Unit::TestCase
14
14
  end
15
15
 
16
16
  def test_region_is_found_and_loaded_and_merged
17
- @definition_merger.expects(:call).with([:test_region, :test_region2], {}, {})
17
+ @definition_merger.expects(:call).with(:test_region, {}, {})
18
18
  @subject.call(:test_region)
19
19
  end
20
20
 
@@ -31,7 +31,7 @@ class LoadTests < Test::Unit::TestCase
31
31
  end
32
32
 
33
33
  def test_returns_list_of_loaded_regions
34
- @definition_merger.expects(:call).with([:test_region, :test_region2], {}, {})
35
- assert_equal([:test_region, :test_region2], @subject.call(:test_region))
34
+ @definition_merger.expects(:call).with(:test_region, {}, {})
35
+ assert_equal([:test_region, :test_region2], @subject.call(:test_region), "Should cache subregions under the parent region's name")
36
36
  end
37
37
  end
@@ -11,7 +11,7 @@ class ParserCustomMethodTests < Test::Unit::TestCase
11
11
  end
12
12
 
13
13
  def test_parse_happy_single_method
14
- input = {"custom_method"=>{"arguments"=>"year", "source"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}}
14
+ input = {"custom_method"=>{"arguments"=>"year", "ruby"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}}
15
15
  @validator.expects(:valid?).with({:name => "custom_method", :arguments => "year", :source => "d = Date.civil(year, 1, 1)\nd + 2\n"}).returns(true)
16
16
 
17
17
  result = @parser.call(input)
@@ -28,7 +28,7 @@ class ParserCustomMethodTests < Test::Unit::TestCase
28
28
  end
29
29
 
30
30
  def test_call_happy_with_multiple_methods
31
- input = {"custom_method"=>{"arguments"=>"year", "source"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}, "second_method"=>{"arguments"=>"month","source"=>"source"}}
31
+ input = {"custom_method"=>{"arguments"=>"year", "ruby"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}, "second_method"=>{"arguments"=>"month","ruby"=>"source"}}
32
32
  @validator.expects(:valid?).with({:name => "custom_method", :arguments => "year", :source => "d = Date.civil(year, 1, 1)\nd + 2\n"}).returns(true)
33
33
  @validator.expects(:valid?).with({:name => "second_method", :arguments => "month", :source => "source"}).returns(true)
34
34
 
@@ -59,7 +59,7 @@ class ParserCustomMethodTests < Test::Unit::TestCase
59
59
  end
60
60
 
61
61
  def test_call_raises_error_if_validator_returns_false_for_single_method
62
- input = {"custom_method"=>{"arguments"=>"year", "source"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}}
62
+ input = {"custom_method"=>{"arguments"=>"year", "ruby"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}}
63
63
  @validator.expects(:valid?).with({:name => "custom_method", :arguments => "year", :source => "d = Date.civil(year, 1, 1)\nd + 2\n"}).returns(false)
64
64
 
65
65
  assert_raises ArgumentError do
@@ -68,7 +68,7 @@ class ParserCustomMethodTests < Test::Unit::TestCase
68
68
  end
69
69
 
70
70
  def test_call_raises_error_if_validator_returns_false_for_one_of_multiple_methods
71
- input = {"custom_method"=>{"arguments"=>"year", "source"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}, "second_method"=>{"arguments"=>"month","source"=>"source"}}
71
+ input = {"custom_method"=>{"arguments"=>"year", "ruby"=>"d = Date.civil(year, 1, 1)\nd + 2\n"}, "second_method"=>{"arguments"=>"month","ruby"=>"source"}}
72
72
  @validator.expects(:valid?).with({:name => "custom_method", :arguments => "year", :source => "d = Date.civil(year, 1, 1)\nd + 2\n"}).returns(true)
73
73
  @validator.expects(:valid?).with({:name => "second_method", :arguments => "month", :source => "source"}).returns(false)
74
74
 
@@ -138,14 +138,4 @@ class ParseOptionsTests < Test::Unit::TestCase
138
138
  regions = @subject.call(:any).first
139
139
  assert_equal([:region1, :region2], regions)
140
140
  end
141
-
142
- # This is a legacy thing...we currently have this in the code and...I don't fully
143
- # understand why. I don't want to remove it as part of this refactor.
144
- def test_load_north_america_if_regions_include_us
145
- @regions_repo.expects(:parent_region_lookup).with(:us).returns(nil)
146
- @definition_loader.expects(:call).with(:north_america)
147
-
148
- regions = @subject.call([:us]).first
149
- assert_equal([:us], regions)
150
- end
151
141
  end
@@ -3,21 +3,69 @@ require "#{Holidays::DEFINITIONS_PATH}/gb"
3
3
  require "#{Holidays::DEFINITIONS_PATH}/ie"
4
4
 
5
5
  class MultipleRegionsTests < Test::Unit::TestCase
6
- def setup
7
- @date = Date.civil(2008,1,1)
6
+ # Simulate load of new environment where the repositories begin empty
7
+ def reset_cache
8
+ Holidays::Factory::Definition.instance_variable_set(:@regions_repo, nil)
9
+ Holidays::Factory::Definition.instance_variable_set(:@holidays_repo, nil)
8
10
  end
9
11
 
10
12
  def test_defining_holidays
11
- h = Holidays.on(Date.civil(2008,12,26), :ie)
13
+ h = Holidays.on(Date.new(2008, 12, 26), :ie)
12
14
  assert_equal 'St. Stephen\'s Day', h[0][:name]
13
15
 
14
- h = Holidays.on(Date.civil(2008,5,9), :gb_)
16
+ h = Holidays.on(Date.new(2008, 5, 9), :gb_)
15
17
  assert_equal 'Liberation Day', (h[0] || {})[:name]
16
18
 
17
- h = Holidays.on(Date.civil(2008,5,9), :je)
19
+ h = Holidays.on(Date.new(2008, 5, 9), :je)
18
20
  assert_equal 'Liberation Day', h[0][:name]
19
21
 
20
- h = Holidays.on(Date.civil(2008,5,9), :gb)
22
+ h = Holidays.on(Date.new(2008, 5, 9), :gb)
21
23
  assert h.empty?
22
24
  end
25
+
26
+ def test_north_american_parent_region_lookup
27
+ assert_equal :ca, Holidays::PARENT_REGION_LOOKUP[:ca]
28
+ assert_equal :ca, Holidays::PARENT_REGION_LOOKUP[:ca_qc]
29
+ assert_equal :mx, Holidays::PARENT_REGION_LOOKUP[:mx]
30
+ assert_equal :mx, Holidays::PARENT_REGION_LOOKUP[:mx_pue]
31
+ assert_equal :us, Holidays::PARENT_REGION_LOOKUP[:us]
32
+ assert_equal :us, Holidays::PARENT_REGION_LOOKUP[:us_fl]
33
+ end
34
+
35
+ def test_north_american_subregion_caching
36
+ { ca: :ca_qc, mx: :mx_pue, us: :us_fl }.each do |region, subregion|
37
+ module_name = region.upcase
38
+
39
+ reset_cache
40
+ Holidays.on(Date.new(2018, 1, 1), region) # Test check on regional holidays
41
+ assert_equal [region], Holidays::Factory::Definition.regions_repository.all_loaded, "Only Holidays::#{module_name} should be loaded"
42
+ holiday_regions = Holidays::Factory::Definition.holidays_by_month_repository.all.values.flatten.map { |h| h[:regions] }.uniq.flatten
43
+ assert_includes holiday_regions, region, 'Region holidays should be loaded'
44
+ assert_includes holiday_regions, subregion, 'Subregion holidays should be loaded'
45
+
46
+ reset_cache
47
+ Holidays.on(Date.new(2018, 1, 1), subregion) # Test check on subregional holidays
48
+ assert_equal [region], Holidays::Factory::Definition.regions_repository.all_loaded, "Only Holidays::#{module_name} should be loaded"
49
+ holiday_regions = Holidays::Factory::Definition.holidays_by_month_repository.all.values.flatten.map { |h| h[:regions] }.uniq.flatten
50
+ assert_includes holiday_regions, region, 'Region holidays should be loaded'
51
+ assert_includes holiday_regions, subregion, 'Subregion holidays should be loaded'
52
+ end
53
+ end
54
+
55
+ def test_north_american_cross_region_caching
56
+ reset_cache
57
+ Holidays.on(Date.new(2018, 1, 1), :us)
58
+ assert_equal [:us], Holidays::Factory::Definition.regions_repository.all_loaded, 'Only Holidays::US should be loaded'
59
+ holiday_regions = Holidays::Factory::Definition.holidays_by_month_repository.all.values.flatten.map { |h| h[:regions] }.uniq.flatten
60
+ assert_includes holiday_regions, :us, 'Region holidays should be loaded'
61
+ assert_includes holiday_regions, :us_fl, 'Subregion holidays should be loaded'
62
+
63
+ Holidays.on(Date.new(2018, 1, 1), :ca)
64
+ assert_equal [:us, :ca], Holidays::Factory::Definition.regions_repository.all_loaded, 'Only Holidays::US and Holidays::CA should be loaded'
65
+ holiday_regions = Holidays::Factory::Definition.holidays_by_month_repository.all.values.flatten.map { |h| h[:regions] }.uniq.flatten
66
+ assert_includes holiday_regions, :us, 'Region holidays should be loaded'
67
+ assert_includes holiday_regions, :ca, 'Region holidays should be loaded'
68
+ assert_includes holiday_regions, :us_fl, 'Subregion holidays should be loaded'
69
+ assert_includes holiday_regions, :ca_qc, 'Subregion holidays should be loaded'
70
+ end
23
71
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: holidays
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.5.0
4
+ version: 6.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Dunae
8
- - Phil Trimble
8
+ - Phil Peble
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-09-21 00:00:00.000000000 Z
12
+ date: 2018-10-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -45,28 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '0.15'
48
+ version: '0.16'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '0.15'
56
- - !ruby/object:Gem::Dependency
57
- name: simplecov-rcov
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: '0.2'
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: '0.2'
55
+ version: '0.16'
70
56
  - !ruby/object:Gem::Dependency
71
57
  name: test-unit
72
58
  requirement: !ruby/object:Gem::Requirement
@@ -87,28 +73,28 @@ dependencies:
87
73
  requirements:
88
74
  - - "~>"
89
75
  - !ruby/object:Gem::Version
90
- version: '1.0'
76
+ version: '1.7'
91
77
  type: :development
92
78
  prerelease: false
93
79
  version_requirements: !ruby/object:Gem::Requirement
94
80
  requirements:
95
81
  - - "~>"
96
82
  - !ruby/object:Gem::Version
97
- version: '1.0'
83
+ version: '1.7'
98
84
  - !ruby/object:Gem::Dependency
99
85
  name: pry
100
86
  requirement: !ruby/object:Gem::Requirement
101
87
  requirements:
102
88
  - - "~>"
103
89
  - !ruby/object:Gem::Version
104
- version: '0.10'
90
+ version: '0.11'
105
91
  type: :development
106
92
  prerelease: false
107
93
  version_requirements: !ruby/object:Gem::Requirement
108
94
  requirements:
109
95
  - - "~>"
110
96
  - !ruby/object:Gem::Version
111
- version: '0.10'
97
+ version: '0.11'
112
98
  description: A collection of Ruby methods to deal with statutory and other holidays.
113
99
  You deserve a holiday!
114
100
  email:
@@ -120,16 +106,16 @@ files:
120
106
  - ".gitmodules"
121
107
  - CHANGELOG.md
122
108
  - CODE_OF_CONDUCT.md
123
- - CONTRIBUTING.md
124
109
  - Gemfile
125
110
  - LICENSE
126
- - MAINTAINERS.md
127
111
  - Makefile
128
112
  - README.md
129
- - REFERENCES
130
113
  - Rakefile
131
114
  - bin/console
132
115
  - bin/setup
116
+ - doc/CONTRIBUTING.md
117
+ - doc/MAINTAINERS.md
118
+ - doc/REFERENCES
133
119
  - holidays.gemspec
134
120
  - lib/generated_definitions/MANIFEST
135
121
  - lib/generated_definitions/REGIONS.rb
@@ -1,51 +0,0 @@
1
- # How to contribute
2
-
3
- There are multiple ways to help! We rely on users around the world to help keep our definitions accurate and up to date. In addition, pull requests to address bugs or implement new features are always welcome.
4
-
5
- ## Code of Conduct
6
-
7
- Please read our [Code of Conduct](CODE_OF_CONDUCT.md) before contributing. Everyone interacting with this project (or associated projects) is expected to abide by its terms.
8
-
9
- ## General note
10
-
11
- The definitions for this project are housed in a submodule. Please make sure to run `git clone --recursive git@github.com/holidays/holidays`
12
- or, if you forgot to do so, run `make update_defs` so that all of the submodule data is pulled down.
13
-
14
- ## For definition updates
15
-
16
- Our definitions are written in YAML. They are housed in a [separate repository](https://github.com/holidays/definitions) so
17
- that they can be used by tools written in other languages. You can find a complete guide to our format in the
18
- [definitions SYNTAX guide](https://github.com/holidays/definitions/blob/master/SYNTAX.md).
19
-
20
- In this ruby project we take the YAML definitions and generate final ruby classes that are loaded at runtime for fast
21
- calculations.
22
-
23
- Once you have a good idea on what you want to change, please see the [contributing guide](https://github.com/holidays/definitions/blob/master/CONTRIBUTING.md) in the `definitions` repository.
24
-
25
- *NOTICE* - this whole submodule-definitions-thing is brand-new. If you are confused or run into issues please open an issue.
26
- The maintainers will respond immediately to help you out. :)
27
-
28
- The idea is that if the validation passes on the other repo then you shouldn't have to worry about generating and testing
29
- here. We'll see how that goes!
30
-
31
- Once that PR is accepted the maintainers of this project will be responsible for generating the updated definitions and
32
- releasing a new gem. Don't worry about versioning, we'll take care of it!
33
-
34
- ## For non-definition functionality
35
-
36
- * Fork this repository
37
- * Make your changes
38
- * Create a PR pointing back to `master`
39
-
40
- Don't worry about versioning, we'll handle it on our end.
41
-
42
- *Tests are required*. If your PR results in lower test coverage then it will not be accepted.
43
-
44
- ## Local development helpers
45
-
46
- We have included a few handy tasks to help you troubleshoot and test:
47
-
48
- * `make test` - runs the entire suite
49
- * `REGION=<region> make test_region` - runs the tests for just that region
50
- * `make console` - launches an IRB session with the 'holidays' gem loaded for quick testing
51
- * `make update_defs` - this will run the appropriate git submodule commands to pull the latest definitions