APR-Emulate-PSGI

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

Changes
inc/Module/Install.pm
inc/Module/Install/Base.pm
inc/Module/Install/Can.pm
inc/Module/Install/Fetch.pm
inc/Module/Install/Makefile.pm
inc/Module/Install/Metadata.pm
inc/Module/Install/ReadmePodFromPod.pm
inc/Module/Install/Repository.pm
inc/Module/Install/Win32.pm
inc/Module/Install/WriteAll.pm
lib/APR/Emulate/PSGI.pm
Makefile.PL
MANIFEST
META.yml
README.pod
t/00_compile.t

Makefile.PL  view on Meta::CPAN

use 5.010000;
use inc::Module::Install;

# Define metadata
name             'APR-Emulate-PSGI';
all_from         'lib/APR/Emulate/PSGI.pm';
readme_pod_from  'lib/APR/Emulate/PSGI.pm';

# Specific dependencies
requires       'URI'           => '0';
requires       'HTTP::Headers' => '0';
test_requires  'Test::More'    => '0.88';
test_requires  'IO::File'      => '0';
auto_set_repository;

inc/Module/Install/Metadata.pm  view on Meta::CPAN

#line 1
package Module::Install::Metadata;

use strict 'vars';
use Module::Install::Base ();

use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
	$VERSION = '1.06';
	@ISA     = 'Module::Install::Base';
	$ISCORE  = 1;
}

inc/Module/Install/Metadata.pm  view on Meta::CPAN

	my $type = shift;
	push @{ $self->{values}->{no_index}->{$type} }, @_ if $type;
	return $self->{values}->{no_index};
}

sub read {
	my $self = shift;
	$self->include_deps( 'YAML::Tiny', 0 );

	require YAML::Tiny;
	my $data = YAML::Tiny::LoadFile('META.yml');

	# Call methods explicitly in case user has already set some values.
	while ( my ( $key, $value ) = each %$data ) {
		next unless $self->can($key);
		if ( ref $value eq 'HASH' ) {
			while ( my ( $module, $version ) = each %$value ) {
				$self->can($key)->($self, $module => $version );
			}
		} else {
			$self->can($key)->($self, $value);
		}
	}
	return $self;

inc/Module/Install/Metadata.pm  view on Meta::CPAN

	$v =~ s/^([1-9])\.([1-9]\d?\d?)\.(0|[1-9]\d?\d?)$/sprintf("%d.%03d%03d",$1,$2,$3 || 0)/e;
	$v =~ s/(\.\d\d\d)000$/$1/;
	$v =~ s/_.+$//;
	if ( ref($v) ) {
		# Numify
		$v = $v + 0;
	}
	return $v;
}

sub add_metadata {
    my $self = shift;
    my %hash = @_;
    for my $key (keys %hash) {
        warn "add_metadata: $key is not prefixed with 'x_'.\n" .
             "Use appopriate function to add non-private metadata.\n" unless $key =~ /^x_/;
        $self->{values}->{$key} = $hash{$key};
    }
}


######################################################################
# MYMETA Support

sub WriteMyMeta {
	die "WriteMyMeta has been deprecated";
}

sub write_mymeta_yaml {
	my $self = shift;

	# We need YAML::Tiny to write the MYMETA.yml file
	unless ( eval { require YAML::Tiny; 1; } ) {
		return 1;
	}

	# Generate the data
	my $meta = $self->_write_mymeta_data or return 1;

	# Save as the MYMETA.yml file
	print "Writing MYMETA.yml\n";
	YAML::Tiny::DumpFile('MYMETA.yml', $meta);
}

sub write_mymeta_json {
	my $self = shift;

	# We need JSON to write the MYMETA.json file
	unless ( eval { require JSON; 1; } ) {
		return 1;
	}

	# Generate the data
	my $meta = $self->_write_mymeta_data or return 1;

	# Save as the MYMETA.yml file
	print "Writing MYMETA.json\n";
	Module::Install::_write(
		'MYMETA.json',
		JSON->new->pretty(1)->canonical->encode($meta),
	);
}

sub _write_mymeta_data {
	my $self = shift;

	# If there's no existing META.yml there is nothing we can do
	return undef unless -f 'META.yml';

	# We need Parse::CPAN::Meta to load the file
	unless ( eval { require Parse::CPAN::Meta; 1; } ) {
		return undef;
	}

t/10_psgi.t  view on Meta::CPAN


# Create instance.
my $r = APR::Emulate::PSGI->new($psgi_env);

isa_ok(
    $r,
    'APR::Emulate::PSGI',
    'Object is instantiated.',
);

# Verify that data is going in as expected (request).

SKIP: {
    skip(
        'Not yet implemented: $r->connection()',
        1,
    ) unless $r->can('connection');
    is(
        $r->connection()->remote_ip(),
        '192.168.1.1',
        'Remote address is available.',

t/10_psgi.t  view on Meta::CPAN

    1,
    'Header added.',
);

is(
    $r->content_type('text/html'),
    'text/html',
    'Content-type is set.',
);

# Verify that data comes out as expected (response).

is(
    $r->psgi_status(),
    '200',
    'Received expected status.',
);

my $headers = +{ @{$r->psgi_headers()} };
is(
    $headers->{'Content-Type'},

t/20_cgi_mode.t  view on Meta::CPAN


# Create instance.
my $r = APR::Emulate::PSGI->new();  # In CGI mode, no environment is passed in.

isa_ok(
    $r,
    'APR::Emulate::PSGI',
    'Object is instantiated.',
);

# Verify that data is going in as expected (request).

SKIP: {
    skip(
        'Not yet implemented: $r->connection()',
        1,
    ) unless $r->can('connection');
    is(
        $r->connection()->remote_ip(),
        '192.168.1.1',
        'Remote address is available.',

t/20_cgi_mode.t  view on Meta::CPAN

        'POST content is read.',
    );

    is(
        $actual,
        $request_body,
        'POST content is correct.',
    );
}

# Verify that data comes out as expected (response).

is(
    $r->headers_out()->add('X-Foo' => 'Bar'),
    1,
    'Header added.',
);

my $headers_fh  = IO::File->new_tmpfile();
{
    local *STDOUT = $headers_fh;



( run in 0.272 second using v1.01-cache-2.11-cpan-8d75d55dd25 )