App-CamelPKI

 view release on metacpan or  search on metacpan

inc/My/Module/Build.pm  view on Meta::CPAN


=item I<package2filename($packagename)>

Converts $packagename (e.g. C<Foo::Bar>) into its OS-specific notation
(e.g. C<Foo/Bar.pm>).

=cut

sub package2filename {
    my ($self, $package) = @_;
    my @components = split m/::/, $package;
    $components[$#components] .= ".pm";
    return catfile(@components);
}

=item I<process_Inline_C_file($filename, @preload_modules)>

Arranges for L<Inline::C> code contained in $filename to be compiled
into .bs's and .so's.  @preload_modules is a list of Perl packages (in
Perl C<use> notation, eg C<Foo::Bar> instead of C<Foo/Bar.pm>) that
should be loaded with C<use> before starting the L<Inline> install

inc/My/Module/Build.pm  view on Meta::CPAN

    local *YAML::Node::new = sub {
        $node = $orig_yaml_node_new->(@_);
    };

    my $retval = $self->SUPER::ACTION_distmeta;
    die "Failed to steal the YAML node" unless defined $node;

    $node->{no_index} = $self->{properties}->{add_to_no_index} || {};
    $node->{no_index}->{directory} ||= [];
    unshift(@{$node->{no_index}->{directory}}, qw(examples inc t),
            (map { File::Spec::Unix->catdir("lib", split m/::/) }
             (@{$node->{no_index}->{namespace} || []})));

    foreach my $package (keys %{$node->{provides}}) {
        delete $node->{provides}->{$package} if
            (grep {$package =~ m/^\Q$_\E/}
             @{$node->{no_index}->{namespace} || []});
        delete $node->{provides}->{$package} if
            (grep {$package eq $_}
             @{$node->{no_index}->{package} || []});
    }

inc/My/Tests/Below.pm  view on Meta::CPAN


=cut

    ## Parse the whole source file again in order to provide said
    ## features.  Yes, seeking to start also works on main::DATA!
    ## Gotta love Perl :-)
    seek($fd, 0, 0) or die $!; $. = 0;
    my $insnippet;
    SOURCELINE: while(<$fd>) {
        if (m/^=for\s+My::Tests::Below\s+"([^"]*)"(.*)$/) {
            my $snipkey = $1; my @args = split m/\s+/, $2;
            if (grep { lc($_) eq "end" } @args) {
                die qq'Not in an "=for My::Tests::Below" directive'.
                    qq' at line $.\n' unless (defined $insnippet);
                die qq'Badly nested "=for My::Tests::Below" directives'.
                    qq' at line $.\n' unless ($insnippet eq $snipkey);
                undef $insnippet;
            } else { # Assume "begin" for compatibility with old tests
                die qq'Duplicate "=for My::Tests::Below" directive'.
                    qq' for label $snipkey at line $.\n' if
                        (exists $self->{podsnippets}{$snipkey});

inc/My/Tests/Below.pm  view on Meta::CPAN


=cut

sub pod_data_snippet {
	my ($self, $name)=@_; $self = $singleton if ! ref $self;

	local $_ = $self->{podsnippets}{$name}->{text};
	return unless defined;

    my $ragamount;
    foreach my $line (split m/\n/s) {
        next if $line =~ m/^\t/; # tab width is treated as infinite to
        # cut through the whole mess
        next if $line eq ""; # Often authors leave empty lines to
        # delimit paragraphs in SYNOPSIS, count them as undefined
        # length as well

        $line =~ m/^( *)/; my $spaceamount = length($1);
        $ragamount = $spaceamount if ((!defined $ragamount) ||
                                       ($ragamount > $spaceamount));
    }

lib/App/CamelPKI/Action/JSON.pm  view on Meta::CPAN


sub finalize_errors {
    my ($self, $c) = @_;
    if ( $c->stash->{current_view} &&
         ($c->stash->{current_view} eq "JSON") && @{$c->error} ) {
        my @folded_errors = map {
            # Wrap error messages at about 75 colums for legibility
            my @lines;
            while(s/^(.{75}\S*)\s//s) { push @lines, $1; }
            (@lines, $_);
        } (map { split m/\n/ } @{$c->error});
        $c->response->body(join("\n", @folded_errors));

        $c->response->status(500);
        $c->response->content_type("text/plain");
        $c->clear_errors;
    }
    return 1;
}

=begin internals

lib/App/CamelPKI/Controller/Root.pm  view on Meta::CPAN

        App::CamelPKI::Action::JSON->finalize_errors($c);
        $c->response->status($statuscode) if $statuscode;
        if ($c->response->content_type =~ m|^text/plain|) {
            # Make a text error, not an HTML one.  REFACTORME: code
            # copied over from App::CamelPKI::Action::JSON
            my @folded_errors = map {
                # Wrap error messages at about 75 colums for legibility
                my @lines;
                while(s/^(.{75}\S*)\s//s) { push @lines, $1; }
                (@lines, $_);
            } (map { split m/\n/ } @{$c->error});
            $c->response->body(join("\n", @folded_errors));
            $c->clear_errors;
        } elsif ($c->error->[0]
                       ->isa("App::CamelPKI::Error::Privilege")) {
        	$c->stash->{message} = "Insufficient privilege to execute this operation. Please contact the administrator if you think you should.";
        	$c->stash->{template} = 'message.tt2';                     	
        } else {
        	#Not known errors
        	$c->stash->{error} = $c->error->[0];
        	$c->stash->{template} = 'error.tt2';



( run in 0.911 second using v1.01-cache-2.11-cpan-39bf76dae61 )