Tip-toe in the Moose Patch

Well my last post I explored a little bit of the shinny new Test::Moose::More by adding a few tests to my Acme::Moose class.

I left off with the idea that I could use a test that tells me that I have extra attributes in my 'class'. Not being much afraid to muck about in source code I had a look in 'Test::Moose::More' to see what would be involved in creating such a test.

Well after a few min of poking about I settled on just extending the 'validate_thing' sub by adding in a new Key, 'no_extra_attributes', on the attributes hash. If this key is present then my little test will kick in and report any attributes that are not on the list passed in via the 'attributes' key.

Here is the patch

Back to Zurich

I'm just putting the final touches on another speaking tour through Europe (so expect more posts as I nail down destinations and events). I seem to be working backwards though, because the very last event of the visit—in Switzerland in early April—is already solid.

Once again I'll be offering a week of public classes at ETHZ, including:


You can view the complete list of courses and even sign up for them now.

We're also hoping to offer a free public talk in Zurich one evening during that week. I'll blog the details of that event as soon as we know them.

A newer Shell::Perl

While trying to install Pod::Server under Perl 5.18.2, I found 2 problems:

  • Text::VimColor dies with encoding issues. These are being investigated by Randy Stauner.

  • Shell::Perl died. I forked the github project and fixed it. So, if you need it, try:
    https://github.com/ronsavage/pirl

Cheers
Ron

Another time-tracking post

Following Steven Haryanto's post on how he tracks his time, I thought some people might be interested in the time tracking solution I'm currently using.

My colleagues and I are required to track our daily activities for billing purposes. Ultimately the information needs to end up in the company work-request management system ('WRMS') but that system's user interface for timesheeting is somewhat frustrating. In response to this, two colleagues (Martyn Smith and Nigel McNie) wrote a Perl script called TKS. This allowed people to enter their activities in a plain text file in a format similar to Steven's. Then they could run the TKS script periodically to sync the contents of the file into WRMS (a modular architecture allows different backend systems to be supported).

An example of a day's entries might look like this:

Does it Pass the Moose Test?

The title of this entry will only mean something to a very select few in the world and if you think it has anything to do with perl look below

Jeep-Grand-Cherokee-Moose-Test.jpg

Anyway I just finished my version .02 of Acme::Moose as I totally botched version .01 as it is a llama not a moose.

However, that is another story. At least I decided to add in a little testing to this version and what the heck I might as well use the fancy new Test::Moose::More and see what it has to offer.

So after about 10 mins of installation from CPAN I was ready to give it a try.

Well at first glance it took a few mins and a couple of runs of my .t to figure out that 'Test::Moose::More' is really just for testing Moose classes so you have to fall back to something like 'Test::More' if you want to run regular type test, but no matter.

So my first test looked like this

fatal warnings are a ticking time bomb (via chromatic)

chromatic just blogged about the perils of fatal warnings pushed down CPAN by the otherwise exceedingly useful Moo perl library. Since his comment system is perpetually broken, with his permission I am moving the discussion here, where the comment system is... right, anyhow.

What follows is the verbatim text of chromatic's post. My own thoughts are going to be in the form of a comment.

The behavior in scalar context is undefined.

I was just reading the docs of Email::Address when I encountered this warning. I know this is not the only place where the behavior in scalar context is undefined, but I wonder. Wouldn't it be better to throw an exception or at least print a warning when a function such as the parse method of Email::Address is called in scalar (or void) context?

That would eliminate the incorrect usage faster probably also reducing the questions asked by users. It will also make it easier to add a different functionality later on, without surprising the people who used the method incorrectly.

Downloading age-restricted videos from YouTube

booTube.png

First off, I'd like to compliment Yuji Shimada on his fantastic module WWW::YouTube::Download. I'm sure the module requires a lot of maintenance (as sites like YouTube can change their design quite a bit) and for that I'm grateful.

Now, the module worked perfectly for my downloading needs *except* that I could not fetch age-restricted videos. Instead I received a message that the module could not find any video URLs. The bright side to this problem was that Shimada's module made it *very* easy to come to a solution, thanks to the module's ua method which accepts a LWP::UserAgent object.

TL;DR - cookies

In my case, I was using Mechanize, so I passed the Mech object to the ua method, like so:

Not a Llama

Really did not have much to do before heading out to a show and was randomly looking at a few things and bumbled across this pic

moose_plus_llama_makes_____by_iceclanwolfwarrior-d39um8i.png


Then being inspired to look on CPAN I found this ACME::Llama so I just had to do this

Announcing Pinto 0.099

CPAN-Gump.png

Pinto is a powerful tool for creating and managing a private CPAN. Pinto make it easy to control your dependencies and ensure your app is built with the right module versions every time. The latest release (0.099) includes a boatload of exciting enhancements. Here are the highlights[1]:

MongoDB wants Perl programmers

If you love Perl and are interested in MongoDB, we want to hire you. Feel free to drop me a line at friedo@mongodb.com if you're interested, or take a look at the official posting here. The full job description is below.

Installing modules from CPAN *and* your own DarkPAN

I currently maintain several DarkPAN's. A DarkPAN, as some of you might already know, is a CPAN-like repository but which is not CPAN. The "dark" term refers to the fact that it is not being published on the Internet, but usually behind a corporate firewall. The most common use-case is for companies creating their code as Perl distributions and wanting to use the CPAN toolchain to deploy modules. In my case, some of the DarkPANs are not actually "dark" because I publish them on the Internet.

There are two general ways to create a DarkPAN. First, you start with an existing CPAN mirror and then "inject" additional modules (you can use CPAN::Mini::Inject for this). Second, you start empty and create the CPAN-like structure using modules like CPAN::Faker and OrePAN.

The inject way is not really proper (akin to monkey-patching) but works with the old standard CPAN client. The latter is supported by cpanminus using multiple --mirror options. For example:

% cpanm --mirror http://first-darkpan --mirror http://second-darkpan --mirror http://cpan-mirror --mirror-only Foo::Bar

Building A Better Moose Trap

Seem there are a number of little oddities in Moose that take a little time to absorb, but once you figure them out you wonder what you ever did before. In my last post I was doing a little refactoring and I decide to look at a few more things.

the_mighty_moose_god_by_sutsuki_sensei-d6x0kru.jpg

You may recall early on in my 'Character' class I had the following attribute

has 'class' =>(
	is		=>'ro',
	isa		=>'HashRef|Str',
	
);
Meaning that I could enter a hashref or a string for 'class'. Well there is a much better way to do this sort of thing and that is with 'coercion'.

blogs.perl.org statistics

A few weeks ago I posted some numbers regarding the popularity of Perl. Among the numbers I published two graphs. The data collected by Google Analytics on Meta CPAN and on Perl Maven. (It became the most visited Perl-site after search.cpan.org, perl.org, Perlmonks, and Meta CPAN.)

Today I got access to the Google Analytics panel of blogs.perl.org as well.

Perl and Me, Part 8: Endless Forms Most Beautiful and Most Wonderful

This is part 8 of an ongoing series where I explore my relationship with Perl.  You may wish to begin at the beginning.

This week we look at the ongoing evolution of Perl.

Last week I closed with the observation that it’s difficult for other languages to evolve beyond Perl because Perl keeps evolving.  And it does: it evolves at quite a bewildering pace, compared to other languages.  Take a look at the evolution of C, for instance.  Oh, sure: we can talk about C++, and C#, and D, and even Java, as evolutions of C, but they are different languages, far more so than Perl 6 is a different language than Perl 5.  If you look at the C language itself, it’s changed several times throughout its history, but the C we have today doesn’t look that different from the original K&R.  It’s no more different than, say, American English is to British English.1

Perl at Fosdem - 1 & 2 February 2014 in Brussels

Perl will be big at Fosdem in Brussels with a big booth on both days of Fosdem and a devroom on the first day, Saturday 1 February. At the booth you will find a lot of interesting stuff, like the largest library of Perl-books in the world, the big stuffed toy camel, Tuits, buttons, books, brochures and whatnot.
The schedule is filled with great speakers and nice presentations. This year, the devroom and the booth will be in the same building (building K).
We will have beer on Friday at Delirium, go to a nice restaurant on both Saturday and Sunday, and we will be in the presence of 5,000 to 7,000 open source enthusiasts. This is going to be a wonderful event.
Read all about it, and much more:
http://wendyga.wordpress.com/2014/01/26/fosdem-perl-devroom-schedule-1feb2014-and-booth-12feb2014/
Hope to see you in Brussels, Belgium!

Moose Fine Print

Well scooping about looking at way to refactor some of my AD&D 'Creator' class code I stumbled on a nice little feature of Moose.

cook-nicerack-s.gif

Though not really standing out in the Moose documentation and not really hidden either is the fact that all of the declarative keywords are really just function calls.

So you might recall that I had this in my 'Creator' Class

with 
 	 'MooseX::Role::BuildInstanceOf' => {
		target => 'RPG::ADD::Creator::Wisdom',
		prefix => 'Wisdom',
 	        constructor => 'new',
 	        inherited_args  => [{roll=>'wisdom'}],
 	    },
...

How I track my time with Org document and a couple of Perl scripts

Many of you track time when you work on the computer, either to bill your client or just to find out how long you have worked so you can track/summarize your progress. There are various ways to do this. This article will describe my own particular way which I have been using for almost 2 years. I hope you'll find it useful. Comments and suggestions are very welcome.

Before discussing my solution, let's consider some of the alternatives. First there is the CPAN module App::TimeTracker. It is a command-line application. To use it, first cd to your project directory and type tracker init. This will create a .tracker.json configuration file. Then you type tracker start when you start work on a project and tracker stop when you finish working. The timers are stored JSON record files in $HOME/.TimeTracker/YYYY/*.trc files such as this:

Low hanging fruit

Once in a while people ask me how could the get involved in Open Source/Perl.
Here is something, I feel is a low hanging fruit:

Add some instructions to the
README file of DB_File.

It will require contacting Paul Marquess, the author of the module and maybe finding out if he has a public VCS for his modules.

Other low hanging fruits could be updating Changes files or doing other quests.

Using perl to create a Wikitionary database


Perl was known for its unmatched text processing but I couldn't quite catch it till I had used it for my personal project. I am still using only baby Perl that I am learning from 'Learning Perl' . I want to make an android app with content from wikitionary to create a database of words, parts of speech and meaning as three fields database with each word as a table. I downloaded the Wikitionary dump which is a Tab Separated Values file.

English\t\t\t

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.