Today in the Moose-Pen I am going to cleanup up more Moose droppings. Now I already added in the Function and Expression class and came up with a few modest tests case for them '19_function_expression.t'.
Not that is fine and good for a unit test on that class but the problem is these two classes will never be used as stand alone classes they will always be used inside other objects typically in the same place I would use a Param or Element class and most of the time in a Predicate object.
The best place to basic unit tests of both Function and Expression is in the predicate unit tests case '
14_predicate.t
' so in there I add firsts added;
Mojolicious::Plugin::OpenAPI is close to being stable so i figured it was time to migrate from our use of Mojolicious::Plugin::Swagger2. Here's the differences i found, with the observation that perhaps some of these were down to having an older version of Swagger2 (0.79, although Changes log suggests that might not be the case):
Today in the Moose-Pen I am going to look at something new 'Native Delegations' on attributes or to say it another less wordy way 'Traits'
Native Delegation
is a way to let you treat standard Perl data structure as if they where objects. So to take an example from my test cases say you have this
foreach my $index2 (0..(scalar(@{$predicates[$index]->predicates()})-1)) {
that (scalar(@{$predicates[$index]->predicates()})-1)) is not very readable. Now suppose we could just have this
I like to keep my perl modules lean when it comes to dependencies. But then again, CPAN is just so wonderful with all the helpful packages available. So there are always dependencies.
When writing perl modules, more often than not a few dependencies creep in … which makes it a whee bit awkward when developing the module, because I then have to somehow install these dependencies, and I would rather not get them all over the place but neatly in the module directory so that I have at least a semblance of a stable development environment.
So here goes my solution: A little postamble method for my Makefile.PL.
Portable GitHub system "GitPrep 2.3" is released at 2016-08-06.
Finally, "issues" system is added. You can use "Bug tracking" on GitPrep.
And contain bug fixing, added features.
support issues system
support markdown table
support markdown foo_bar_baz
At first, Let's try GitPrep example. You will find GitPrep is real portable GitHub system.
The features of GitPrep
I introduce the featrues of GitPrep for people who see GitPrep for the first time.
Github clone: GitPrep has the same interface as GitHub.
Support issue system
Portable: You can install GitPrep on your own Unix/Linux server.
Only needs Perl 5.10.1+.
Smart HTTP support: you can pull and push repository via HTTP.
Built-in web server, and reverse proxy support.
CGI support.
SSL support.
Public key authentication support
Installation is very easy. You run only two commands. Difficult settings is unnecessary.
Even if you have troubles by your mistake, for example "git push -f origin master", you can access all of your git repositories directory and fix them.
i'm using padre editor with strawberry perl bundled in
dwimperl
i have multiple files open, then when i click on one of the
tabs to close 1 file, padre crashes without an error message,
the application just closes.
this also happens when i save the session.
kinda frustrating.
do you discuss padre here or am i in the wrong forum?
thank a bunch in advance
Well more testing and re-factoring with just a little Moose in the Moose-Pen today. So I spend a good deal of time getting my tests cases all in a row. Now just a few interesting details on that, I created a number of generic utility tests that can be reused in my test cases. What I did was take the 'cmp_deeply' test like this on in
33_constants.t
Imagine you were playing with Perl 6 and you came across a buglet
or you were having some fun with the Perl 6 bug
queue—you'd like to debug a particular core
subroutine or method, so where's the source for it at?
Asked such a question, you might be told it's in Rakudo compiler's
GitHub repository. Depending on how deep
down the rabbit hole you wish to go, you may also stop by NQP's
repo, which is a subset of Perl 6 that's used
in Rakudo, or the MoarVM's repo, which
is the leading virtual machine Perl 6 runs on.
The answer is fine, but we can do better. We'd like to know exactly where
da sauce is.
Stick to The Basics
The most obvious way is to just use grep command in the source repository.
The code is likely in src/ directory, or src/core more specifically.
We'll use a regex that catches sub, method, and multi keywords. For
example, here's our search for path sub or method:
We recently came across Pegex and found it to be an interesting module for parsing text data. Instead of using regular expressions directly, the user can write a grammar for the data to be parsed. The data can be automatically converted to a native Perl object or, if the user desires, it's possible to use actions to handle the grammar while parsing using a Pegex::Receiver class.
Pegex uses the type of grammars called Parsing Expression Grammars (PEG), which is an unambiguous form of writing a grammar. Each parsed string will in effect have a single valid parse tree. Since Pegex converts the rules of the grammar to regular expressions, it is a greedy parser.
In this blog post we demonstrate how to easily use Pegex to parse an /etc/hosts file on Linux and convert the result into Perl objects automatically without having to manually create any object.
For more details check out the original blog post by me here.
Since the Perl Magazine sadly had to close i didn't wrote as many Perl articles anymore. Because I miss it sometimes I recently agreed to write for DZone. Its a Java- centric site with many light weight pieces. I read it myself, since you can find interesting stuff here and there.
But why I'm writing this here? In order to publish, it has to be transported from your blog. And since I don't own another blog and the Perl 6, Perl 5 and software engineering stuff I want to write about fits here nicely : I will use this blog as transport. for that purpose. So please don't wonder if some of my next text are here sound like I assume you never heard about Perl. If the entry is marked with the category DZone you know why.
But there is also another reason why I use this Blog. Since I will be a kind of press secretary for Perl in that area, I actually want to be controlled and corrected by you and also encourage you to engage in the discussions below these articles on DZone (link will be provided in comments), to make Perl more visible to outside world.
Well it clean-up and re-factor day in the Moose-pen. So no new Moose Majick today just cleaning up and adding in stuff that I have left out (forgotten actually) and moving things about.
Well the first thing I did was finish off the last three of my remaining Accessor attibutes, 'gathers', 'filters' and 'sort' or if you are SQL inclined 'group by', 'having'. and 'sorts'.
The 'gathers' and 'sorts' attributes are just a pair of 'ArrayRefofElements' which I covered off in this post and types and the 'filters' is a 'ArrayRefofConditions' which I covered in this post. I did of course spend a little time making sure that my DAD role attributes matched up with the accessosr ones and as this is me programming I created two new test cases, 37_gathers.t that handles filters as well, and 39_sorts.t
While testing a fix for one of the Less Than Awesome behaviours in standalone
Signature objects, I came across
a bugglet. Smartmatching two Signatures throws, while spilling a bit of the
guts:
<Zoffix> m: my $m = method ($a: $b) { }; say $m.signature ~~ :($a, $b);
<camelia> rakudo-moar 46838d: OUTPUT«Method 'type' not found
for invocant of class 'Any' in block at line 1»
So I figured I'll write about fixing it, 'cause hacking on internals is lots of
fun. Let's roll!
Golf It Down
The less code there is to reproduces the bug, the fewer places there are
for that bug to hide. We have a detached method and then we smartmatch
its signature against something else. Let's try to golf it down a bit
and smartmatch two Signatures, without involving a method:
So today in the Moose-pen I am going to move onto something a little differtn and that is my Accessor 'links' attribute which I am going to cover with the 35_links.t test suite.
I did a quick review of the bits and pieces I had stubbed in so far and I notices I need a few thing. First had a look at my Accessor 'links' attribute and I will need a new type for that. So to get this new 'ArrayRefofLinks' type I just did what we have seen in a number of older posts, namely add in a 'use', a 'class_type' and a 'subtype' into my Types.pm, I will hold off on a coercion for now till I get a little deeper into my post. So that takes case of 'links'.
I also noticed that 'Links' attribute of my DAD now had the wrong type as well so that was change to the 'ArrayRefofLinks' type
Looking at my 'Database::Accessor::Link' class I have never liked this two attributes
I wrote my first Perl 6 program—a New Years IRC Party bot—around Christmas,
2015. The work included releasing the IRC::Client
module, and given my
virginity with the language and blood alcohol level appropriate for the Holiday
Season, the module ended up sufficiently craptastic.
Recently, I needed a tool for some Perl 6 bug queue work, so I decided to lock
myself up for a weekend and re-design and re-write the module from scratch.
Multiple people bugged me to do so over the past months, so I figured I'd also
write a tutorial for how to use the module—as an apology for being a master
procrastinator. And should IRC be of no interest to you, I hope the tutorial
will prove useful as a general example of async, non-blocking interfaces
in Perl 6.