Today I am going to add in another attribute called 'all_errors' a simple Boolean flag so my end user can either get a single error message of all the errors found or the 'MooseX::Constructor::AllErrors' object with all the errors when using the 'new'. Simple enough I can just add it here
The Hacktoberfest Challenge 2018 is on and it is my fourth attempt. As always, I am very excited about the event.
September 2018 has been very special month so far for me. Why? In this very month, I submitted my 1000th Pull Request. Also as of today 1st Oct 2018, I have completed 407th days of daily upload to CPAN. My next target is reach 500 days mark, which I am hoping to reach by new year. I also submitted my talk proposal to London Perl Workshop 2018. The title of my proposed talk is "The power of mentoring". For a change, I have also submitted proposal for lightning talk "What after the Pull Request Challenge?". If you haven't submitted your talk proposal yet, then please do so now. I would like to
share one sweet moment with everyone. After submitting my 1000th PR, the first PR that got merged after that had the following message for me.
Here’s a pattern which took me a while to figure out this past week, and therefore seemed worthy of sharing with you guys.
First, let’s set the situation. (These are certainly not the only conditions under which you could use this pattern, but it’ll probably be easier to grasp it with a concrete example.) Let’s say you have a script which you’re going to use to launch your other Perl scripts. This script (in my example, it’s a bash script, but it could also be a super-minimal Perl script) has exactly one job: set up the Perl environment for all your personal or company modules. That may even include pointing your $PATH at a different Perl (e.g. one installed via perlbrew or plenv) so you’re not reliant on the system Perl. Here’s a typical example of what such a (bash) script might look like:
I have been asked this question many times since I submitted over 1000 PR. Before I answer this question, I would like to share a secret with you all.
It all started in the month of Jan 2015 with Pull Request Challenge (PRC) pioneered by Neil Bowers. Although I was already submitting PR before that but without any target. With PRC, I got direction where to go. I must admit taking on PRC wasn't easy one. I didn't want to make a fool of myself by joining PRC and not submitting PR regularly. I still remember first couple of months, so many Perl hackers joining the PRC but not every one actually submit PR regularly. Some even dropped after a while. But I kept it going as I was enjoying it. Although I was hardly getting any acknowledgement from the distribution author. It can be discouraging for the beginners.
It's not super usable and this moment and will likely explode if you try to have too much fun.
Hopefully this example will be replaced by something much more awesome soon.
Parcel.js is a web application bundler so it will take care of combining the JavaScript code Rakudo.js spits out with everything else your app needs to run.
Why Parcel.js instead of Webpack?
Mostly because Parcel while seemingly more buggy doesn't insist that hard on re-parsing the generated code.
I had a webpack plugin working for NQP at some point so it definitely is doable so webpack afficionados are welcome to contribute a plugin or entice me to write one.
Currently I'm using some cutting edge JS features (like BigInt) so I'm focusing on supporting Chrome.
I plan to spend some time on supporting other common browsers when Rakudo.js is more mature but luckily the evergreen browsers are constantly updating themselves and implementing new stuff so hopefully the problem will solve itself.
I've just released revision 3 of the @Starter plugin bundle for the Dist::Zilla CPAN distribution authoring tool. There's no changes to the base configuration from revision 2, but there are now additional options to help manage common authoring tasks using modern best practices. You must set your revision to 3 to enable these new options, as a safety measure to make sure you have a new enough version of the bundle to support them.
I my last post I figured out how to set up Database:Accessor to get the 'MooseX::Constructor::AllErrors' object in the 'around BUILDARGS' and then play with it, without breaking my existing code.
Today I want to see if I can change my error messages. I started by poking about in guts of ' MooseX::Constructor::AllErrors' and I discovered the the error messages are rather had coded;
sub message {
my $self = shift;
return sprintf 'Attribute (%s) is required',
$self->attribute->name;
}
Now that does not do me much good as I can't just do this in my 'around' sub
package Point;
sub new {
my $class = shift;
my $self = {
x => 0,
y => 0,
@_,
};
bless $self, $class;
return $self;
}
sub x { shift->{x} }
sub y { shift->{y} }
my $point = Point->new(x => 1, y => 2);
my $x = $point->x;
my $y = $point->y;
In order to quickly install a set of Perl modules for a given task, it is nice to have some kind of meta-package serving no other purpose than pulling in a set of other more specific packages. Traditional ways of doing this with CPAN can be found in the Bundle:: and Task:: namespaces. Recent developments, however, seem to have put meta-package maintainers in a predicament. Technologies are shifting once more. In this article, I explain how I rescued my meta-packages with minimal changes.
Still make errors pretty day here in the Moose-Pen.
Yesterday I re-discovered that I had 'MooseX::Constructor::AllErrors' set up in my code. I was even using it to test fail conditions like this test;
In this guide about what to consider when writing a Perl 6 module, we (after part I and part II) will reach Perl 6's great power of signatures. They enable a feature, that is very often used in Perl 6 (internally and externally). Here are my arguments when the usage of MMD makes the most sense.
In an attempt to standardise vector graphical operations in GUIDeFATE (the world's simplest GUI designer) across different back-ends and keep things simple, a little diversion was needed. For a standard vector drawing one might use the computationally cumbersome SVG format directly and draw that on the widget. The problem is that one needs to be able to manipulate the graphics easily and AFTER deployment. I needed to script the creation of the drawing. Now lots of applications use a script language of their own, e.g. gnuplot, matlab, Kalgebra, R etc, so clearly this is a useful functionality on its own. What would be also useful is a portable scripting platform. This platform could serve my purpose, but being modular, could be easily repurposed for other applications.
I recently received a bug report about installing Image::PNG::Libpng on Strawberry Perl. It was failing to install due to using the wrong C compiler.
Up to version 0.44 of the module, I'd been checking for the presence of libpng using Devel::CheckLib, however somehow or another that didn't seem to be working and I'd gone back to using my own module to detect the library.
Although this improvised detecting module was getting its information about the compiler flags and library flags from Config, I'd omitted to use the information about what the C compiler might be. Once I changed my module to get its information on the C compiler from $Config::Config{cc}, it worked on Strawberry Perl too.
One thing I wanted to try and do was have a little more meaning in my error-messages much like I did yesterday when my error message put out something like this
Database::Accessor create( $db 'Class', $container 'Hash-Ref||Class||Array-Ref of [Hash-ref||Class]', $options 'Hash-Ref'); Error: Incorrect Usage: The $container 'Array-Ref' must contain only Hash-refs or Classes. $container=$VAR1 = [
1,
{
'last_name' => 1
},
bless( {
'first_name' => 'test',
'last_name' => 'test'
}, 'Data::Test' )
…
Version 0.04 of SQL::Translator::Parser::OpenAPI has just been uploaded to CPAN. You can give it an OpenAPI 2 spec and it will generate a relational database from it. How is that useful?
Normally when you want to make an information service, you'll start by manually making a database, or writing the API code, possibly writing tests along the way, and then writing an OpenAPI spec after that - see this excellent article by Jan Henning Thorsen for more on using OpenAPI with Perl.
With this module, you can start by writing a spec, and letting code generate a lot of the infrastructure. This has a number of advantages:
it's quicker
it's easier
it's more reliable - let solved problems stay solved rather than reinvent the wheel!
it lets you keep an eye on the big picture
The distribution uses for its tests, as well as one that tests that many-to-many relationships are correctly generated, a couple of specs written by others:
In this series of articles I reflect and expand on a talk I gave this year in Glasgow were I spoke about writing Perl 6 modules in general and Math::Matrix in particular. Part I was about data types I used or wanted to use, because my approach is it to think first about data structures and built later the code around that. It is also crucial because this module basically provides the user a new data type.