alexdunae/holidays — pull request #57 by ptrimble (2013-11-03 04:43:41+00:00)
Title: Add ability to load custom holidays on the fly

At my company we have several company-specific holidays (special payroll days, important company holidays, etc). Since they are not general holidays we wouldn't want them added to the overall definitions available in the gem but we would still want them included in the gem calculations as needed for our own purposes. To accomplish this I have added the ability to load custom definitions on the fly and have them be immediately available for use.

In order to do this I've moved the parsing of definition files into the main Holidays module instead of having the logic reside in the 'data/build_defs.rb' file. I've split up the logic into multiple methods for code clarity and renamed a few variables but the core logic is unchanged. All definition files are generated the same and all tests still pass. With the parsing logic inside the Holidays module we can now call it when loading custom files on the fly.

I decided in the end to simply add these changes into the 'lib/holidays.rb' file but it could be added into a separate file instead if you feel that would make for a cleaner codebase.