A new request with request id 16199 has been created by koha-devel-request@lists.koha-community.org. Short info on the request is :
Title : Koha-devel Digest, Vol 189, Issue 16
Category :
Description : Send Koha-devel mailing list submissions to
koha-devel@lists.koha-community.org
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
or, via email, send a message with subject or body 'help' to
koha-devel-request@lists.koha-community.org
You can reach the person managing the list at
koha-devel-owner@lists.koha-community.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Koha-devel digest..."
Today's Topics:
1. Koha Community Newsletter: August 2021 (Koha Newsletter)
2. Perl advice for checking hash content (Victor Grousset/tuxayo)
----------------------------------------------------------------------
Message: 1
Date: Fri, 27 Aug 2021 17:59:37 +0200
From: Koha Newsletter <kohanews@gmail.com>
To: koha <koha@lists.katipo.co.nz>, koha-devel
<koha-devel@lists.koha-community.org>
Subject: [Koha-devel] Koha Community Newsletter: August 2021
Message-ID:
<CAEqgz_=1b0-PSQp2oypKZvPhYs1mQPHju93OBHaOfnYmRbcyzw@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
The Koha Community Newsletter for August 2021 is here:
* https://koha-community.org/koha-community-newsletter-august-2021/
Many thanks to everyone who submitted articles and news this newsletter!
Please feel free to email me with any corrections or suggestions.
--
Michael Kuhn
Editor, Koha Community Newsletter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20210827/1ff47f9f/attachment-0001.htm>
------------------------------
Message: 2
Date: Sat, 28 Aug 2021 09:38:04 +0200
From: Victor Grousset/tuxayo <victor@tuxayo.net>
To: koha-devel <koha-devel@lists.koha-community.org>
Subject: [Koha-devel] Perl advice for checking hash content
Message-ID: <4aeca8ca-6b49-d8a6-35ee-8829e68d41b2@tuxayo.net>
Content-Type: text/plain; charset=utf-8; format=flowed
Hi :)
For a development, I'm adding additional keys to
C4::Reserves::CanItemBeReserved returned hash.
But there are a bunch of tests that match the whole return value and
thus don't expect the new keys in the hash.
Here is the best way so far I've found to adapt it.
is_deeply(
CanItemBeReserved( $patron->borrowernumber, $itemnumber_2 ),
{ status => 'tooManyReservesToday', limit => 0 },
'Patron cannot reserve if holds_per_day is 0 (i.e. 0 is 0)'
);
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
my @status_and_limit = @{CanItemBeReserved( $patron->borrowernumber,
$itemnumber_2 )}{"status", "limit"};
is_deeply(
\@status_and_limit,
['tooManyReservesToday', 0],
'Patron cannot reserve if holds_per_day is 0 (i.e. 0 is 0)'
);
How could this be better?
Since it took me more than two hours only to have something that works
and without warnings. There are surely other ways to do it™, and
hopefully a nicer one.
Most of the time was reading and learning by trial and error about
referencing and dereferencing and the specifics or Perl hashes and
array. It's odd to have been working 3.5 years on Koha closer to the
code than to the librarian stuff and only have to really start learning
Perl now ^^
Away, this is why advice is needed to have something that fit the good
practices :)
Key/Value Hash Slices would allow to not change the expected param of
is_deeply() but that doesn't really look different for the readability.
And isn't worth having Koha bump minimal Perl version from 5.14 (2011)
to 5.20 (2014). Ok it's just for running the tests and not production
but still. -> very minor or inexistent readability improvement.
https://perldoc.perl.org/perldata#Key/Value-Hash-Slices
Having two assertions (is() calls) for status and limit would allow a
simpler syntax but add duplication.
Cheers,
--
Victor Grousset/tuxayo
------------------------------
Subject: Digest Footer
_______________________________________________
Koha-devel mailing list
Koha-devel@lists.koha-community.org
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
website : https://www.koha-community.org/
git : https://git.koha-community.org/
bugs : https://bugs.koha-community.org/
------------------------------
End of Koha-devel Digest, Vol 189, Issue 16
*******************************************
NOTE: You are receiving this mail because, the Requester/Technician wanted you to get notified on this request creation.