Acrux

 view release on metacpan or  search on metacpan

eg/acrux_std.pl  view on Meta::CPAN

#!/usr/bin/perl -w
use strict;

# perl -Ilib eg/acrux_std.pl ver
# perl -Ilib eg/acrux_std.pl test 1 2 3
# perl -Ilib eg/acrux_std.pl error
# perl -Ilib eg/acrux_std.pl noop

package MyApp;

use parent 'Acme::Crux';

use Acrux::Util qw/dumper color/;

our $VERSION = '1.00';

sub startup {
    my $self = shift;

    print color(green => "Start application"), "\n" ;

eg/acrux_test.pl  view on Meta::CPAN

#!/usr/bin/perl -w
use strict;

# perl -Ilib eg/acrux_test.pl test 1 2 3

package MyApp;

use parent 'Acme::Crux';

use Acrux::Util qw/dumper color/;

our $VERSION = '1.00';

sub startup {
    my $self = shift;
    print sprintf(color(green => "Start application %s"), $self->project), "\n" ;

    # Set plugin 'Test'

eg/acrux_test.pl  view on Meta::CPAN


1;

package MyTestPlugin;
use warnings;
use strict;
use utf8;

our $VERSION = '0.01';

use parent 'Acme::Crux::Plugin';

use Acrux::Util qw/color/;

sub register {
    my ($self, $app, $args) = @_;
    print sprintf(color(bright_magenta => "Registered %s plugin"), $self->name), "\n";

    $app->register_method(test => sub { print color(red => "This test method created in plugin register"), "\n" });
    $app->log->debug(sprintf("Registered %s plugin", $self->name));

lib/Acme/Crux.pm  view on Meta::CPAN

Load a plugin by name or pair - name and class

=head2 pwd

    my $pwd = $app->pwd;

This method returns current/working directory

=head2 register_handler

    use parent qw/Acme::Crux/;

    __PACKAGE__->register_handler(
        handler     => "foo",
        aliases     => "one, two",
        description => "Foo handler",
        params => {
            param1 => "test",
            param2 => 123,
        },
        code => sub {

lib/Acme/Crux/Plugin.pm  view on Meta::CPAN


=encoding utf-8

=head1 NAME

Acme::Crux::Plugin - The Acme::Crux plugin base class

=head1 SYNOPSIS

    package Acme::Crux::Plugin::MyPlugin;
    use parent 'Acme::Crux::Plugin';
    sub register {
       my ($self, $app, $args) = @_;
       # ... your code here ...
    }

    # In your appliction:
    $app->plugin( myplugin => 'Acme::Crux::Plugin::MyPlugin' );

=head1 DESCRIPTION

lib/Acme/Crux/Plugin/Config.pm  view on Meta::CPAN


This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

See C<LICENSE> file and L<https://dev.perl.org/licenses/>

=cut

our $VERSION = '0.02';

use parent 'Acme::Crux::Plugin';

use Acrux::Config;
use Acrux::RefUtil qw/as_array_ref as_hash_ref is_true_flag/;

sub register {
    my ($self, $app, $args) = @_;

    # NoLoad flag: PLGARGS || OPTS || ORIG || DEFS
    my $noload = is_true_flag($args->{noload}) # From plugin arguments first
      || $app->getopt("noload")                # From command line options

lib/Acme/Crux/Plugin/Log.pm  view on Meta::CPAN


This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

See C<LICENSE> file and L<https://dev.perl.org/licenses/>

=cut

our $VERSION = '0.01';

use parent 'Acme::Crux::Plugin';

use Acrux::Log;

use Carp qw/croak/;
use Acrux::RefUtil qw/as_array_ref as_hash_ref is_code_ref is_true_flag is_ref/;

sub register {
    my ($self, $app, $args) = @_;
    my $has_config = $app->can('config') ? 1 : 0;

lib/Acrux/Digest.pm  view on Meta::CPAN

use utf8;

=encoding utf-8

=head1 NAME

Acrux::Digest - Acrux Digest base class

=head1 SYNOPSIS

    use parent qw/Acrux::Digest/;

=head1 DESCRIPTION

Acrux Digest base class

=head2 new

    my $provider = Acrux::Digest::Provider->new();

Returns Digest Provider instance

lib/Acrux/Digest/FNV32a.pm  view on Meta::CPAN


This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

See C<LICENSE> file and L<https://dev.perl.org/licenses/>

=cut

our $VERSION = '0.01';

use parent qw/Acrux::Digest/;

sub digest {
    my $self = shift;
    my $data = shift;
       $self->data($data) if defined $data;
    my $string = $self->data;
    my $hval = 0x811c9dc5;

    if ((1<<32) == 4294967296) {
        foreach my $c (unpack('C*', $string)) {

lib/Acrux/Digest/M11R.pm  view on Meta::CPAN

modify it under the same terms as Perl itself.

See C<LICENSE> file and L<https://dev.perl.org/licenses/>

=cut

our $VERSION = '0.01';

use Carp;

use parent qw/Acrux::Digest/;

sub digest {
    # See also: Algorithm::CheckDigits::M11_015 and check_okpo()
    my $self = shift;
    my $data = shift;
       $self->data($data) if defined $data;
    my $test = $self->data;
    croak "Incorrect input digit-string" if !defined($test) || $test =~ m/[^0-9]/g;
    my $len = length($test);
    my $iters = ($len + (($len & 1) ? 1 : 0)) / 2;

t/05-filepid.t  view on Meta::CPAN

    waitpid $child, 0;
    done_testing;
} else { # child process
    my $p = Acrux::FilePid->new(file => $file, autoremove => 1); # hope for the best
    unless ($p->running) {
       $p->save;
       note sprintf "Start child process (Child PID: %s; Child Owner: %s)", $p->pid, $p->owner;
       sleep 3;
       note sprintf "Finish child process (Child PID: %s; Child Owner: %s)", $p->pid, $p->owner;
    }
    #note 'parent is running' if $p->running;
}

__END__

prove -lv t/05-filepid.t

t/10-app-min.t  view on Meta::CPAN

        project => 'MyApp',
        preload => [], # Disable plugins
    )] );
    ok(!$app->error, 'No errors') or diag($app->error);
}

1;

package MyApp;

use parent 'Acme::Crux';

__PACKAGE__->register_handler; # default

__PACKAGE__->register_handler(
    handler     => "foo",
    aliases     => "one, two",
    description => "Foo handler",
    params => {
        param1 => "test",
        param2 => 123,



( run in 0.345 second using v1.01-cache-2.11-cpan-4d50c553e7e )