[Catalyst-commits] r9203 - in Test-WWW-Mechanize-Catalyst/trunk: .
lib/Test/WWW/Mechanize
ash at dev.catalyst.perl.org
ash at dev.catalyst.perl.org
Wed Feb 4 20:10:19 GMT 2009
Author: ash
Date: 2009-02-04 20:10:18 +0000 (Wed, 04 Feb 2009)
New Revision: 9203
Modified:
Test-WWW-Mechanize-Catalyst/trunk/Makefile.PL
Test-WWW-Mechanize-Catalyst/trunk/lib/Test/WWW/Mechanize/Catalyst.pm
Log:
Moosify TWMC
Modified: Test-WWW-Mechanize-Catalyst/trunk/Makefile.PL
===================================================================
--- Test-WWW-Mechanize-Catalyst/trunk/Makefile.PL 2009-02-04 20:06:52 UTC (rev 9202)
+++ Test-WWW-Mechanize-Catalyst/trunk/Makefile.PL 2009-02-04 20:10:18 UTC (rev 9203)
@@ -1,23 +1,22 @@
#!perl
+use inc::Module::Install 0.77;
+
use strict;
use warnings;
-use ExtUtils::MakeMaker;
-WriteMakefile(
- 'NAME' => 'Test::WWW::Mechanize::Catalyst',
- 'VERSION_FROM' => 'lib/Test/WWW/Mechanize/Catalyst.pm',
- 'AUTHOR' => 'Leon Brocard <acme at astray.com>',
- 'ABSTRACT' => 'Test::WWW::Mechanize for Catalyst',
- 'LICENSE' => 'perl',
- 'PREREQ_PM' => {
- 'Catalyst' => '5.00',
- 'Catalyst::Plugin::Session::State::Cookie' => '0',
- 'Catalyst::Plugin::Session::Store::Dummy' => '0',
- 'LWP' => '5.816',
- 'Test::Exception' => '0',
- 'Test::More' => '0',
- 'Test::WWW::Mechanize' => '1.14',
- 'WWW::Mechanize' => '1.50',
- },
-);
+name 'Test-WWW-Mechanize-Catalyst';
+all_from 'lib/Test/WWW/Mechanize/Catalyst.pm';
+requires 'Catalyst' => '5.00';
+requires 'LWP' => '5.816';
+requires 'Test::WWW::Mechanize' => '1.14';
+requires 'WWW::Mechanize' => '1.50';
+requires 'Moose' => '0.67';
+requires 'namespace::clean' => '0.09';
+
+test_requires 'Catalyst::Plugin::Session::State::Cookie' => '0';
+test_requires 'Catalyst::Plugin::Session::Store::Dummy' => '0';
+test_requires 'Test::Exception' => '0';
+test_requires 'Test::More' => '0';
+
+WriteAll;
Modified: Test-WWW-Mechanize-Catalyst/trunk/lib/Test/WWW/Mechanize/Catalyst.pm
===================================================================
--- Test-WWW-Mechanize-Catalyst/trunk/lib/Test/WWW/Mechanize/Catalyst.pm 2009-02-04 20:06:52 UTC (rev 9202)
+++ Test-WWW-Mechanize-Catalyst/trunk/lib/Test/WWW/Mechanize/Catalyst.pm 2009-02-04 20:10:18 UTC (rev 9203)
@@ -1,7 +1,6 @@
package Test::WWW::Mechanize::Catalyst;
-use strict;
-use warnings;
+use Moose;
use Carp qw/croak/;
require Catalyst::Test; # Do not call import
@@ -9,41 +8,41 @@
use HTML::Entities;
use Test::WWW::Mechanize;
-use base qw(Test::WWW::Mechanize);
+extends 'Test::WWW::Mechanize', 'Moose::Object';
+use namespace::clean -execept => 'meta';
+
our $VERSION = '0.45';
+our $APP_CLASS;
my $Test = Test::Builder->new();
-# the reason for the auxiliary package is that both WWW::Mechanize and
-# Catalyst::Test have a subroutine named 'request'
+has catalyst_app => (
+ is => 'ro',
+ required => 1,
+ default => sub { $APP_CLASS },
+);
-our $APP_CLASS;
+has allow_external => (
+ is => 'rw',
+ isa => 'Bool',
+ default => 0
+);
+
sub new {
- my ($class, %args) = @_;
+ my $class = shift;
- my $app;
- if (exists $args{catalyst_app}) {
- $app = $args{catalyst_app};
+ my $obj = $class->SUPER::new(@_);
+ my $self = $class->meta->new_object(
+ __INSTANCE__ => $obj,
+ @_
+ );
- require Class::Inspector->filename( $app )
- unless Class::Inspector->loaded( $app );
- } elsif (!defined $APP_CLASS) {
- croak 'Please provide a catalyst_app option or import Test::WWW::Mechanize::Catalyst with a class name';
- } else {
- $app = $APP_CLASS;
- }
+ Class::MOP::load_class($self->catalyst_app)
+ unless (Class::MOP::is_class_loaded($self->catalyst_app));
- my $self = $class->SUPER::new(%args);
- $self->{catalyst_app} = $app;
return $self;
}
-sub allow_external {
- my ( $self, $value ) = @_;
- return $self->{allow_external} unless defined $value;
- $self->{allow_external} = $value;
-}
-
sub _make_request {
my ( $self, $request ) = @_;
$self->cookie_jar->add_cookie_header($request) if $self->cookie_jar;
@@ -120,11 +119,13 @@
sub import {
my ($class, $app) = @_;
+
if (defined $app) {
- require Class::Inspector->filename( $app )
- unless Class::Inspector->loaded( $app );
+ Class::MOP::load_class($app)
+ unless (Class::MOP::is_class_loaded($app));
$APP_CLASS = $app;
}
+
}
@@ -378,9 +379,9 @@
=head1 AUTHOR
-Current Maintainer: Ash Berlin C<< <ash at cpan.org> >>
+Ash Berlin C<< <ash at cpan.org> >> (current maintiner)
-Leon Brocard, C<< <acme at astray.com> >>
+Original Author: Leon Brocard, C<< <acme at astray.com> >>
=head1 COPYRIGHT
More information about the Catalyst-commits
mailing list