Date::Holidays releases – adapter pattern at large

Since the post on the release 1.10 of Date::Holidays I have released:

1.11 Improved support for Date::Holidays::SK
1.12 Improved support for Date::Holidays::USFederal as US
1.13 Support for Date::Holidays::CA_ES, via Date::Holidays::ES
1.14 Marking of Date::Holidays::UK and Date::Holidays::UK::EnglandAndWales as unsupported, using Date::Holidays::GB instead
1.15 Improved support for Date::Holidays::DE
– and 1.16 Support for Date::Holidays::CZ

And I have more releases in the pipeline.

All of this work started out primarily as an attempt at getting to the bottom of the issue list, new issues do pop up as I get around the different corners and adaptations, but that is perfectly okay and I might never get to the bottom of the issue list, but at least the Date::Holidays distribution will improve and stabilise.

The work is also caused by a change in perspective, where my original motivation was to create a way to consolidate and use all of the different Date::Holidays::* distributions without having to adjust the differing interfaces of all of them.

I just spotted that my documentation lacks a section on motivation, describing the why of Date::Holidays – one more thing to the issue list.

The new perspective is that many of the distributions are not really being updated (which is a pity), but instead of creating a patch for the relevant distributions I am adjusting the adapters in Date::Holidays to implement the lacking features where possible instead of sending patches to the authors of respective distributions – I might do this afterwards, but since this will require a lot of effort, the other way around is faster and easier in most cases. Unfortunately there is also the chance that the original authors are unresponsive and my patches will never be released, so the strategy could be described as a “better safe than sorry” implementation.

About faster and easier, I am creating small tasks, which can be accomplished, while commuting. I have always been inspired by Ricardo Signes (GitHub), who I think have coded more commuting, than I have in front of my computer. This might be a slight exaggeration and Ricardo must correct me if I my description of this is out of proportion, at the same time there is nothing like a good programmer’s myth – well Ricardo is truly a prolific CPAN contributor and he does as such not require a myth.

Anyway – I am not a regular commuter and I will primarily be biking over the summer, so this will possibly not continue with this frequency, but I do enjoy bite-size tasks and I will try to squeeze them in when I can.

The whole change of perspective (and my reading of “Clean Code” by Robert C. Martin) has engaged me a lot and as I deal with all the practical issues I am also giving some thought to the bigger picture.

Date::Holidays have always and will always be a side project, once in a while I get contacted by somebody who use it or is trying it out and it makes me immensely happy, but I am not fooling myself – I do not think Date::Holidays has a big audience. I do get PRs with new implementations and that is awesome and I will keeping pushing for more integrations and adaptations, but it does not change the fact that the user base is limited.

So why do I keep coding on Date::Holidays?

Well, it is incredibly educational.

When I started out it was an exercise in the Adapter Pattern and it probably still is, but things have changed. Now I am reading “Clean Code” as mentioned and I am trying to adopt and learn some of the principles from that book.

Which leads me to the new road map for Date::Holidays, which is slowly taking shape.

– Adopt some “Clean Code” principles
– Factor out the “nocheck” flag (this is one of the principles)
– Factor out general features working on implicit country lists, this does simply not belong in the class (this might be one of the principles)
– Evaluate possible adoption of format parameter from Date::Holidays::* distributions
– Evaluate possible implement localisation of data from Date::Holidays::* distributions

So for now there will be a lot of smaller releases improving the actual adapters and at some point, I will look into making a major release, taking Date::Holidays to the next level, with a lot of clean code and hopefully I will be learning a lot during the proces.

Advertisements
Date::Holidays releases – adapter pattern at large

Date::Holidays 1.10 released

Release 1.08 of Date::Holidays had some issues with the test suite, which resulted in numerous failure reports from CPAN-testers, please see issue #21 for details.

This resulted in release 1.09, which addressed the problem with the bad tests. At the same time it however demonstrated issues with the integration towards Date::Holidays::NZ and Date::Holidays::SK, so issues #22 and #23 was created respectively.

Issue #22 has now been addressed in release 1.10 and next up is 1.11, which is planned to address issue #23 unless something else comes up.

The adaptation of Date::Holidays::NZ also supports the regional parameter described in: Date::Holidays::NZ.

So checking if New Years Day is a holiday in New Zealand, via Date::Holidays:

use Date::Holidays;

my $dh = Date::Holidays->new( countrycode => 'nz' );
if ($dh->is_holiday(year => 2018, month => 1, day => 1) {
        print “It is\n”;
}

And in particular for the region of Auckland (see Date::Holidays::NZ for details).

use Date::Holidays;

my $dh = Date::Holidays->new( countrycode => 'nz' );
if ($dh->is_holiday(year => 2018, month => 1, day => 1, region => 2) {
        print “In Auckland it is\n”;
}

You can also get a list of holidays:

use Date::Holidays;
use Data::Dumper;

my $dh = Date::Holidays->new( countrycode => 'nz' );

my $holidays_hashref = $dh->holidays(year => 2018);
print STDERR Dumper $holidays_hashref;

$VAR1 = {
    '0206' => 'Waitangi Day',
    '0402' => 'Easter Monday',
    '0102' => 'Day after New Years Day',
    '1022' => 'Labour Day',
    '1226' => 'Boxing Day',
    '1225' => 'Christmas Day',
    '0330' => 'Good Friday',
    '0425' => 'ANZAC Day',
    '0604' => 'Queens Birthday',
    '0101' => 'New Years Day'
};

And based on region:

use Date::Holidays;
use Data::Dumper;

my $dh = Date::Holidays->new( countrycode => 'nz' );

my $holidays_hashref = $dh->holidays(year => 2018, region => 2);
print STDERR Dumper $holidays_hashref;

$VAR1 = {
    '0129' => 'Auckland Anniversary Day',
    '1022' => 'Labour Day',
    '0101' => 'New Years Day',
    '0402' => 'Easter Monday',
    '1225' => 'Christmas Day',
    '0330' => 'Good Friday',
    '1226' => 'Boxing Day',
    '0102' => 'Day after New Years Day',
    '0425' => 'ANZAC Day',
    '0206' => 'Waitangi Day',
    '0604' => 'Queens Birthday'
};

Feedback most welcome,

jonasbn

Date::Holidays 1.10 released

Date::Holidays 1.08 released

I have just uploaded Date::Holidays 1.08 to PAUSE/CPAN.

It holds a new adapter class for Date::Holidays::USFederal (US) in response to a request from a user.

The implementation required a lot of changes to the internal code, due to the variation in the adapted Date::Holidays class name, Date::Holidays::USFederal, which is not an ISO compatible country code. I am pondering supporting this as US as well.

At the same time the test suite was restructured. I hope I did not break anything, all tests pass currently locally and with Travis via GitHub. I moved a lot of tests from *.t files into Test::Class based implementations, which I find much easier to work with.

Upon upload I did observe a failure in the indexing:

Status: Permission missing
 ==========================

module : Date::Holidays::Adapter::Local
 version: 1.08
 in file: lib/Date/Holidays/Adapter/Local.pm
 status : Not indexed because of case mismatch.

I am not sure what this error means, but I will investigate if this has raises any issues or give complications. The class was called Date::Holidays::Adapter::LOCAL earlier, so this might be the cause of the problem.

CPAN-testers are reporting a lot of failing tests, which I will also investigate (issue #21). I do not suspect the indexing issue to be related, currently I can see that this seems to be an issue with the include path (@INC) for the test classes in the distribution, but I have not been able to reproduce the issue with either prove, make test (based on Makefile.PL) or ./Build test (based on Build.PL).

Date::Holidays 1.08 released

Test::Timer Release 2.00

Received some feedback on release 1.00 of Test::Timer, this has resulted in further improvements and release 2.00.

The diagnostics of failing tests using Test::Timer, now also presents the actual execution time observed.

Next goal of the next feature release, is to handle higher resolution than seconds. In the mean time a release with improved documentation is planned to go out.

Until next Timer – release, take care

jonasbn

Test::Timer Release 2.00

Date::Holidays 1.06 Release

I have uploaded a maintenance release of Date::Holidays to CPAN.

I am planning a lot of activities in relation to Date::Holidays (more on this is an upcoming blog post).

For now I have added a lot of tests of some of all the modules that Date::Holidays has adapters for and some which have not been evaluated completely yet. I am trying to get an overview of the actual status of Date::Holidays and related modules in order to plan further progress.

A part of the larger plan, is the introduction of a proper homepage. So just as for Test::Timer, Date:.Holidays now has a more appropriate representation on the web build using Github pages (also described in a blog post).

So more activity will follow in relation to Date::Holidays – I just need to flesh out the details and the plan.

Take care,

jonasbn

Date::Holidays 1.06 Release

Test::Timer Release 1.00

Yesterday while sitting at the computer working on a release Workflow I received a Github issue.

Test::Timer is a Perl test module that can assist in specifying timing thresholds for code execution. You can then specify that your test suite should break if the code takes too little or too much time.

The concept requested was simple, in the diagnostic messages emitted from the module, the thresholds specified should be mentioned. The implementation did not take long to implement.

However since the diagnostic messages was changed and somebody might be relying on these I decided to make it a major release to indicate this somewhat breaking change.

Thanks to Nigel Horne for the issue report I hope the implementation meets your needs and expectations.

Test::Timer 1.00 has been uploaded to CPAN, feedback most welcome.

Have a nice weekend,

jonasbn

Test::Timer Release 1.00

Workflow Release 1.43

First release of Workflow in a long time, but luckily I received a pull request from Oliver Welter

Oliver Welter has earlier offered patches implementing custom workflows (1.35 and 1.37) and factory subclassing (1.35) and now improvements in logging for condition validation with the latest release 1.43 – thanks Oliver, you make me look lazy 🙂

During the testing of the release I ran into an issue with the Dist::Zilla plugin: Dist::Zilla::Plugins::CJM. Related to failing tests due to deprecation. David Golden has offered a pull request, but the author Christopher J. Madsen seems unresponsive and his activity level on Github has flatlined :-/

Changed configuration to an alternative by Dave Rolsky and everything seems to be running as expected.

Release should be available on CPAN shortly – have a nice weekend,

jonasbn

Workflow Release 1.43