PrePAN

Sign in to PrePAN

PrePAN provides a place
to discuss your modules.

CLOSE

Requests for Reviews Feed

Try::Catch A try::Tiny copy but much faster

Well, Try::Tiny is great, I used it a lot and was totally satisfied until I had to deal with some very intensive script where I needed several thousands catch blocks, so I rolled this module, it boost the speed up to 250%

Please note that this is not yet well tested and I'm posting here to see if the whole thing worth more work and uploading to CPAN.

mamod@github 3 comments

CatalystX::Eta::Controller::REST Set of Moose::Roles to extend and reduce repeatable tasks I had to do to make REST/CRUD stuff

First, why "CatalystX::Eta": I have no ideia what is correct namespace for this. I think CatalystX would fit, because it needs catalyst to works with. And "Eta" is just a greek letter η. We use Greek Letters to name projects here on Aware, because sometimes, projects don't have good names for Module::Names!

So, copying from github:

What CatalystX::Eta is and why did you do that?

I started (although not with this name) as set of Catalyst Controller Roles to extend and reduce repeatable tasks I had to do to make REST/CRUD stuff.

More later, I had to start many Catalyst projects. Then, I started teaching others collaborators how to use it on their projects. After a while, they made some modifications on they ::Roles project, but does not pass all ::Roles. So, I'm using this namespace to group and keep those changes together.

This module may not fit for you, but it's a very simple way to make CRUD schemas on REST, without prohibit or complicate use of catalyst power, like chains or anything else.

Depends on...

In order to extends CatalystX::Eta::Controller::AutoObject you need need /error_404 Catalyst Private action defined.

CatalystX::Eta::Controller::SimpleCRUD and CatalystX::Eta::Controller::AssignCollection extends CEC::AutoObject, so you will need in a way, or in another.

CatalystX::Eta::Controller::REST extends Catalyst::Controller::REST and make errors from DBIx::Class::Exception more 'api friendly' than HTML with '(en) Please come back later\n...'

All your controllers should extends CatalystX::Eta::Controller::REST.

EtaMu::TraitFor::Controller::TypesValidation add validate_request_params use Moose::Util::TypeConstraints::find_or_parse_type_constraint so you can do things like:

$self->validate_request_params(
    $c,
    extra_days => {
        type     => 'Int',
        required => 0,
    },
    credit_card_id => {
        type     => 'Int',
        required => 0,
    },
);

on your controllers, and it does the $c->status_bad_request or $c->detach for you.

Why is not on CPAN yet:

I don't like the ideia that you need implement my name methods Maybe, I should use subrotines attributes to do that, what you all think about it?

Oh, and theres too, CatalystX::Eta::Test::REST

CatalystX::Eta::Test::REST exports all Test::More methods, and create a $stash = {} for testing, and add some methods (like rest_put and rest_post) that can create/update and tests/expects some results in order to populate $stash correctly.

Then, you have some prototyped routines, like stash_test and stash that, respectively, execute a CODE for determined context, and return a value for a stash key.

renatocron@github 0 comments

Net::Twitch::Oauth2 Net::Twitch::Oauth2 - a simple Perl wrapper around Twitch OAuth v2.0 protocol

This is a simple Perl wrapper around the Twitch OAuth2 API. I created this based on the Net::Facebook::Oauth2 module that already exists.

RJReed67@github 0 comments

Mojo::Reactor::Glib Glib main loop based Mojo::Reactor

Mojo::Reactor (so Mojo::IOLoop and so on) runs on either a pure-perl loop or can use EV. This module allows Mojo to run on Glib and thus it's possible to embed it into Gtk applications. EV::Glib and Glib::EV exist, of course, but they seem to come with severe speed sacrifices at least on Win32, so rather use Glib directly.

Of course Mojolicious is a web framework, but there are some pretty cool and useful parts of it for other purposes too — such as Mojo::UserAgent, a HTTP and WebSockets client that can do blocking and non-blocking easily and cleanly.

So I thought this might be useful for others too :)

ralesk@github 0 comments

Image::Hash A module for perceptual image hashing [aHash, pHash, dHash] in Perl.

Image::Hash allows you to calculate the average hash, difference hash and perception hash of an image.

Depending on what is available on your system Image::Hash will use GD, Image::Magick or Imager to interact with your image.

It is based on the ideas given here http://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html and http://www.hackerfactor.com/blog/?/archives/529-Kind-of-Like-That.html .

I choose to name it Image::Hash because there is also a Python module named ImageHash ( https://github.com/JohannesBuchner/imagehash ) and a public PHP class named ImageHash ( http://jax-work-archive.blogspot.no/2013/05/php-ahash-phash-dhash.html ) that dos the same thing.

Any spelling corrections are welcome. English is not my first language.

runarbu@github 2 comments

Test::MethodFixtures Record and playback method arguments and return values

I thought something like this might already exist, but haven't seen anything, so the code is just a basic working prototype.

This module makes it easy to mock methods by recording arguments and their corresponding return values, and then replaying them during normal test runs. Some people advocate just mocking the smallest possible part(s) of a system.

For example, if you have a client that contacts an external webservice you can just mock the method that makes the call itself, and leave the rest of the code as-is. Creating a full mock object is time-consuming and would mean that you are not testing the real client object.

Not sure on name either, doesn't call any Test methods, and "Fixtures" might have too many DB connotations...

use Test::MethodFixtures mode => 'record'; # set mode for all mocking objects

my $mocker = Test::MethodFixtures( mode => 'record' ); # alternatively specify mode here

# simple function - can store all arguments
$mocker->mock("My::Package::Method");

# object method - need to turn $_[0] ($self) into an
# identifier for the object, not memory reference
$mocker->mock( "My::Object::Method",
    sub { $_[0]->firstname . '-' . $_[0]->lastname } );

# do the same for other arguments
$mocker->mock(
    "My::Package::Method",
    sub {
        (   $_[0],                                       # use as-is
            $_[1]->firstname . '-' . $_[1]->lastname,    # object in $_[1]
             # no need to list further arguments if no more changes required
        );
    }
);

Currently saves input/output of methods to disk (.methodfixtures directory), but can subclass the store() and retrieve() methods (and if necessary the get_key_sub() method) to store somewhere else (e.g. database)

mjemmeson@github 3 comments

Test::TrapWarnings Trap warnings in the called code and test their contents. The return value of the code being called is also preserved.

Sometimes when you test a certain code you want to check whether this code emits (or doesn't emit) any warnings, and if so, check the content of these warnings. When you're using modules like Test::Warn or Test::NoWarning, you need to call your code 2 times: one for testing its warnings, another to test return values.

Functions of this module allow you to do that by calling your code only once because its functions return the same results as your code returns - whether in scalar or list context.

In other words this module is similar to Test::Trap by its functionality, but is more simple and only targeted to trapping warnings.

ichesnokov@github 1 comment

File::Parser::Role A small but convenient framework for parsing files

A role that accepts a single filename or a normal hash[ref] to constructor with a file argument

It requires and runs $self->parse after construction.

It provides a fh method that gives a file handle seek'ed to 0 (when it's seekable), which is nice to have in sub parse.

And:

  • if given a local file resource: checks that the file exists and is readable
  • also accepts a file handle
  • also accepts a scalar ref to some content to be parsed
  • accepts url's

In short - all those boring tedious things that you have to re-do every time you want to parse a file.

With this shiny role you can skip all that and get straight to the fun bit: The parsing.

torbjorn@github 0 comments

File::FindLocalLib easier loading of local libs

I'm usually using a setup like this:

 .
 ├── AProject
 │   ├── bin
 │   │   ├── db
 │   │   │   └── init.pl
 │   │   ├── onetime
 │   │   │   ├── fixup
 │   │   │   │   └── RT666_fix_up_fubared_data.pl
 │   │   │   └── import_data.pl
 │   │   └── web.psgi
 │   ├── lib
 │   └── local
 ├── MyHelperStuff
 │   └── lib
 └── CoolLib-NotYetOnCPAN
     └── lib

There is AProject, which is the actual code I'm working on. There is also probably BProject, e.g. another microservice for the same customer. A-Project has it's own code in lib and it's CPAN dependencies in local (managed via Carton and used via local::lib). There are a bunch of scripts / "binaries" in bin, in a lot of different directories of varying depth.

I have some generic helper code I use in several projects in MyHelperStuff/lib. It will never go to CPAN. I have some other code in CoolLib-NotYetOnCPAN/lib (but it might end up on CPAN if I ever get to clean it up...)

File::FindLocalLib makes it easy to add all these paths to @INC so I can use the code.

In each script, I just have to say:

use File::FindLocalLib qw(lib local::lib=local);

lib is added to the beginning of @INC, and local is loaded via local::lib, without me having to know how deep in bin the current script is located.

I can also add

File::FindLocalLib->load_extra(qw(MyHelperStuff CoolLib-NotYetOnCPAN));

to get my other code pushed to @INC. (Though currently I put this line, and some other setup code like initialising Log::Any into AProject::Run, and just use AProject::Run;)

domm@github 6 comments

Google::BigQuery Google BigQuery Client Library for Perl

Since Google BigQuery Client Library for Perl has not been provided, I made it. Please see details at https://github.com/shojikai/Google-BigQuery.

shojikai@github 3 comments