PrePAN

Sign in to PrePAN

PrePAN provides a place
to discuss your modules.

CLOSE

Requests for Reviews Feed

CBitcoin provides cbitcoin perl wrapper

This module lets coders create hierarchial deterministic keys/wallets, scripts, and transactions in perl. There are plans to add network functionality that is available in the original cbitcoin library.

favioflamingo@github 0 comments

Chef::Knife A thin wrapper around the knife cmd line tool

Is this a good idea?

kablamo@github 0 comments

DBIx::Struct DBIx::Struct - convenience SQL functions with Class::Struct-like row objects

Makes SQL queries from Perl data structures. It uses SQL::Abstract module to parse "where" and "order by" structures. This module does not try to map all possible SQL features to Perl structures but it greatly simplifies really simple and most often used scenarios. Complex queries are also possible, but sometimes it'd better to use real SQL.

Some usage examples can be found here: PEF Demo Article.pm

pef-secure@github 0 comments

Logging::Trivial The simplest useful logging module

I wanted to be able to write

INFO "blah"; WARN "foo";

to output:

INFO: "blah" WARN: "foo"

and so on, and have logging to a file, and found the following modules:

Name            | Why I didn't want to use it            
--------------- | -------------------------------------- 
Log::Simplest | Ugly interface & not enough levels     
Log::Trivial  | OO interface is overkill for this task 
Log::Log4Perl | Too complicated!                       
Carp          | Not enough levels                      

So I wrote my own :)

The problems are:

  • The namespace is cluttered and I don't think my name is that useful
  • Exporting 5 functions by default is quite a few, but you wouldn't use this module if you didn't want them
  • I know that this goes against the 'don't reinvent the wheel' doctrine.

alexander-brett@github 4 comments

MooX::NonOO Allow non-OO interface for Moo modules

I have some legacy modules that allow non-OO usage, e.g. you can just call methods as functions. If the first argument isn't a blessed reference to the class, then it uses a default singleton instance.

I'd like to convert the modules to use Moo, and have realized the code can be generalized to a module.

(Yes, I know a lot of people frown on this. I do now, but I'd like to maintain backward compatibility. And arguably OO, while making this module simpler to write, is overkill for some use cases.)

I have a working prototype.

My big question is: 1. Is there already something that does this for Moo (so I don't waste timing writing another module)? 2. Is there a better name for this?

robrwo@github 8 comments

MooX::TaggedAttributes Add tags w/ values to Moo attributes

This module allows one to apply tags with values to attributes in Moo classes and Roles. Why?

Well, in my case I want to able to label attributes so that I can programatically find those with a particular label and operate on them.

For example, let's say that my class has attributes which are PDL objects (or piddles, as we call 'em), and I want to apply a transform just to those objects. Without tags, I'd have to know ahead of time which attributes were PDL objects, and which weren't. That might get complicated if I compose a bunch of roles (especially onto objects at run time).

With tagged attributes, I can do this:

package PDL::Tag;
use Moo::Role;
use MooX::TaggedAttributes -tags => 'piddle';

package MyClass;
use Moo;
use PDL::Tag;

has a => ( is => 'ro' );
has b => ( is => 'ro', piddle => 1 );

my $obj = MyClass->new( ... );

# search for attributes marked as piddles:
my @piddles = keys %{ $obj->_tags->{piddle} };

# and now do some Cool PDL stuff on 'em
$obj->$_->rotate(-1) for @piddles.

I could scan the attributes looking for a particular type, but tags are more elegant, and since they are arbitrary, can encode more information. The tag values are also arbitrary, so you can do anything you want with 'em.

djerius@github 3 comments

Date::Holidays::US Holidays for United States locales

Based on Date::Holidays::CA by Rick Scott

=head1 DESCRIPTION

Date::Holidays::US determines public holidays for United States jurisdictions. Its interface is a superset of that provided by Date::Holidays -- read on for details.

=cut

=head1 FUNCTIONS / METHODS

=head2 Class Methods

=head3 new()

Create a new Date::Holidays::US object. Parameters should be given as a hashref of key-value pairs.

my $dhc = Date::Holidays::US->new();        # defaults

my $dhc = Date::Holidays::US->new({
    state => 'US', language => 'EN', actual => 0
});

Three parameters can be specified: B<state>, B<language> and B<actual>.

=head4 State

=over

=item * US

United States Federal holidays (the default).

=item * AL AK AZ AR CA CO CT DE DC FL GA HI ID IL IN IA KS KY LA ME MD MA MI MN MS MO MT NE NV NH NJ NM NY NC ND OH OK OR PA RI SC SD TN TX UT VA VT WA WV WI WY AS GU MP PR VI FM MH PW

Holidays for the specified State. Specifying TX implies 'actual=>1'.

=back

=head4 Language

=over

=item * EN

English text.

=back

=head4 Actual

=over

=item * 0

Holiday dates are when the holiday is observed (e.g. moved to weekday if on Sat/Sun). This is the default

=item * 1

Holiday dates are when the holiday is defined (e.g. Independence Day is always July 4th, even if on a weekend). This is implied if state=='TX'

=back

=cut

snoopyjc@github 2 comments

Test::Mode Am I in test mode?

Sometimes I want my code to behave differently if its running inside a test. I could create options for the behavior but I'd have to set them in every single test.

Examples where this might be useful:

  • I may not want to hit an external service from inside a test
  • I may want to hit the test version of the external service from inside a test
  • I might want to use a different database thats preloaded with test data.
  • I might want to disable caching
  • Don't print messages to stdout in test mode
  • etc

This is probably not a problem you have if you use something like Test::Class::Moose.

The implementation would look like:

package Test::Mode;
use strict;
use warnings;

use List::AllUtils qw/any/;
use Exporter::Shiny qw/test_mode/;

sub test_mode {
    return 1 if any {$_ eq 'Test/Most.pm'} keys %INC;
    return 0;
}

kablamo@github 1 comment

WebService::Slack::IncomingWebHook client for slack incoming webhook

DESCRIPTION

WebService::Slack::IncomingWebHook is slack incoming webhooks client. Slack is chat web service. For cli, this distribution provides post-slack command.

METHOD

  • WebService::Slack::IncomingWebHook->new(%params)

    my $client = WebService::Slack::IncomingWebHook->new(
        webhook_url => 'http://xxxxxxxxxxxxxx', # required
        channel    => '#general',               # optional
        username   => 'masasuzu',               # optional
        icon_emoji => ':sushi:',                # optional
        icon_url   => 'http://xxxxx/xxx.jpeg',  # optional
    );
    

    Creates new object.

  • $client->post(%params)

    my $client->post(
        text       => 'yahoooooo!!',
        channel    => '#general',
        username   => 'masasuzu',
        icon_emoji => ':sushi:',
        icon_url   => 'http://xxxxx/xxx.jpeg',
    );
    

    Posts to slack incoming webhooks. channel, username, icon_emoji and icon_url parameters can override constructor's parameter.

    text, pretext, color, fields and attachments parameter are available. See also slack incoming webhook document.

SCRIPT

% post-slack --webhook_url='https://xxxxxx' --text='yahooo'

available options are ...

  • --webhook_url (required)
  • --text (required)
  • --channel (optional)
  • --username (optional)
  • --icon_url (optional)
  • --icon_emoji (optional)

SEE ALSO

https://my.slack.com/services/new/incoming-webhook

masasuzu@github 0 comments

WebService::Instapaper A client for the Instapaper Full API

This module is a client for the Instapaper Full API. (WWW::Instapaper::Client is for the Simple API)

takebayashi@github 0 comments