Commit 7b4d0362 authored by Florian Schlichting's avatar Florian Schlichting

Imported Upstream version 0.005

parents dd3cf881 3ea375f9
Revision history for MooseX-OneArgNew
0.005 2015-07-14 21:52:35-04:00 America/New_York
- bump required version of MXRP
0.004 2013-10-05 09:05:39 America/New_York
update repo and bugtracker metadata
......
This software is copyright (c) 2013 by Ricardo Signes.
This software is copyright (c) 2015 by Ricardo Signes.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
......@@ -12,7 +12,7 @@ b) the "Artistic License"
--- The GNU General Public License, Version 1, February 1989 ---
This software is Copyright (c) 2013 by Ricardo Signes.
This software is Copyright (c) 2015 by Ricardo Signes.
This is free software, licensed under:
......@@ -22,7 +22,7 @@ This is free software, licensed under:
Version 1, February 1989
Copyright (C) 1989 Free Software Foundation, Inc.
51 Franklin St, Suite 500, Boston, MA 02110-1335 USA
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
......@@ -272,7 +272,7 @@ That's all there is to it!
--- The Artistic License 1.0 ---
This software is Copyright (c) 2013 by Ricardo Signes.
This software is Copyright (c) 2015 by Ricardo Signes.
This is free software, licensed under:
......
# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.037.
Changes
LICENSE
MANIFEST
......@@ -7,8 +8,8 @@ Makefile.PL
README
dist.ini
lib/MooseX/OneArgNew.pm
t/00-compile.t
t/000-report-versions-tiny.t
t/00-report-prereqs.dd
t/00-report-prereqs.t
t/basic.t
t/coerce.t
xt/release/changes_has_content.t
......
This diff is collapsed.
This diff is collapsed.
# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.037.
use strict;
use warnings;
use ExtUtils::MakeMaker 6.30;
use ExtUtils::MakeMaker;
my %WriteMakefileArgs = (
"ABSTRACT" => "teach ->new to accept single, non-hashref arguments",
"AUTHOR" => "Ricardo Signes <rjbs\@cpan.org>",
"BUILD_REQUIRES" => {},
"CONFIGURE_REQUIRES" => {
"ExtUtils::MakeMaker" => "6.30"
"ExtUtils::MakeMaker" => 0
},
"DISTNAME" => "MooseX-OneArgNew",
"EXE_FILES" => [],
......@@ -21,55 +18,44 @@ my %WriteMakefileArgs = (
"NAME" => "MooseX::OneArgNew",
"PREREQ_PM" => {
"Moose::Util::TypeConstraints" => 0,
"MooseX::Role::Parameterized" => 0,
"MooseX::Role::Parameterized" => "1.01",
"namespace::autoclean" => 0
},
"TEST_REQUIRES" => {
"ExtUtils::MakeMaker" => 0,
"File::Spec" => 0,
"IO::Handle" => 0,
"IPC::Open3" => 0,
"Moose" => 0,
"Test::More" => "0.96",
"strict" => 0,
"warnings" => 0
},
"VERSION" => "0.004",
"VERSION" => "0.005",
"test" => {
"TESTS" => "t/*.t"
}
);
unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
my $tr = delete $WriteMakefileArgs{TEST_REQUIRES};
my $br = $WriteMakefileArgs{BUILD_REQUIRES};
for my $mod ( keys %$tr ) {
if ( exists $br->{$mod} ) {
$br->{$mod} = $tr->{$mod} if $tr->{$mod} > $br->{$mod};
}
else {
$br->{$mod} = $tr->{$mod};
}
}
}
my %FallbackPrereqs = (
"ExtUtils::MakeMaker" => 0,
"File::Spec" => 0,
"Moose" => 0,
"Moose::Util::TypeConstraints" => 0,
"MooseX::Role::Parameterized" => "1.01",
"Test::More" => "0.96",
"namespace::autoclean" => 0,
"strict" => 0,
"warnings" => 0
);
unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) {
my $br = delete $WriteMakefileArgs{BUILD_REQUIRES};
my $pp = $WriteMakefileArgs{PREREQ_PM};
for my $mod ( keys %$br ) {
if ( exists $pp->{$mod} ) {
$pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod};
}
else {
$pp->{$mod} = $br->{$mod};
}
}
unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
delete $WriteMakefileArgs{TEST_REQUIRES};
delete $WriteMakefileArgs{BUILD_REQUIRES};
$WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
}
delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
unless eval { ExtUtils::MakeMaker->VERSION(6.52) };
WriteMakefile(%WriteMakefileArgs);
This archive contains the distribution MooseX-OneArgNew,
version 0.004:
version 0.005:
teach ->new to accept single, non-hashref arguments
This software is copyright (c) 2013 by Ricardo Signes.
This software is copyright (c) 2015 by Ricardo Signes.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
This README file was generated by Dist::Zilla::Plugin::Readme v5.037.
package MooseX::OneArgNew;
{
$MooseX::OneArgNew::VERSION = '0.004';
}
use MooseX::Role::Parameterized;
$MooseX::OneArgNew::VERSION = '0.005';
use MooseX::Role::Parameterized 1.01;
# ABSTRACT: teach ->new to accept single, non-hashref arguments
#pod =head1 SYNOPSIS
#pod
#pod In our class definition:
#pod
#pod package Delivery;
#pod use Moose;
#pod with('MooseX::OneArgNew' => {
#pod type => 'Existing::Message::Type',
#pod init_arg => 'message',
#pod });
#pod
#pod has message => (isa => 'Existing::Message::Type', required => 1);
#pod
#pod has to => (
#pod is => 'ro',
#pod isa => 'Str',
#pod lazy => 1,
#pod default => sub {
#pod my ($self) = @_;
#pod $self->message->get('To');
#pod },
#pod );
#pod
#pod When making a message:
#pod
#pod # The traditional way:
#pod
#pod my $delivery = Delivery->new({ message => $message });
#pod # or
#pod my $delivery = Delivery->new({ message => $message, to => $to });
#pod
#pod # With one-arg new:
#pod
#pod my $delivery = Delivery->new($message);
#pod
#pod =head1 DESCRIPTION
#pod
#pod MooseX::OneArgNew lets your constructor take a single argument, which will be
#pod translated into the value for a one-entry hashref. It is a L<parameterized
#pod role|MooseX::Role::Parameterized> with three parameters:
#pod
#pod =begin :list
#pod
#pod = type
#pod
#pod The Moose type that the single argument must be for the one-arg form to work.
#pod This should be an existing type, and may be either a string type or a
#pod MooseX::Type.
#pod
#pod = init_arg
#pod
#pod This is the string that will be used as the key for the hashref constructed
#pod from the one-arg call to new.
#pod
#pod = coerce
#pod
#pod If true, a single argument to new will be coerced into the expected type if
#pod possible. Keep in mind that if there are no coercions for the type, this will
#pod be an error, and that if a coercion from HashRef exists, you might be getting
#pod yourself into a weird situation.
#pod
#pod =end :list
#pod
#pod =head2 WARNINGS
#pod
#pod You can apply MooseX::OneArgNew more than once, but if more than one
#pod application's type matches a single argument to C<new>, the behavior is
#pod undefined and likely to cause bugs.
#pod
#pod It would be a B<very bad idea> to supply a type that could accept a normal
#pod hashref of arguments to C<new>.
#pod
#pod =cut
use Moose::Util::TypeConstraints;
......@@ -54,13 +125,15 @@ __END__
=pod
=encoding UTF-8
=head1 NAME
MooseX::OneArgNew - teach ->new to accept single, non-hashref arguments
=head1 VERSION
version 0.004
version 0.005
=head1 SYNOPSIS
......@@ -138,9 +211,25 @@ hashref of arguments to C<new>.
Ricardo Signes <rjbs@cpan.org>
=head1 CONTRIBUTORS
=for stopwords George Hartzell William Orr
=over 4
=item *
George Hartzell <hartzell@alerce.com>
=item *
William Orr <will@worrbase.com>
=back
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Ricardo Signes.
This software is copyright (c) 2015 by Ricardo Signes.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
......
use strict;
use warnings;
# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.033
use Test::More 0.94 tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
my @module_files = (
'MooseX/OneArgNew.pm'
);
# no fake home requested
use File::Spec;
use IPC::Open3;
use IO::Handle;
my @warnings;
for my $lib (@module_files)
{
# see L<perlfaq8/How can I capture STDERR from an external command?>
open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!";
my $stderr = IO::Handle->new;
my $pid = open3($stdin, '>&STDERR', $stderr, $^X, '-Mblib', '-e', "require q[$lib]");
binmode $stderr, ':crlf' if $^O eq 'MSWin32';
my @_warnings = <$stderr>;
waitpid($pid, 0);
is($? >> 8, 0, "$lib loaded ok");
if (@_warnings)
{
warn @_warnings;
push @warnings, @_warnings;
}
}
is(scalar(@warnings), 0, 'no warnings found') if $ENV{AUTHOR_TESTING};
BAIL_OUT("Compilation problems") if !Test::More->builder->is_passing;
do { my $x = {
'configure' => {
'requires' => {
'ExtUtils::MakeMaker' => '0'
}
},
'develop' => {
'requires' => {
'Test::Pod' => '1.41'
}
},
'runtime' => {
'requires' => {
'Moose::Util::TypeConstraints' => '0',
'MooseX::Role::Parameterized' => '1.01',
'namespace::autoclean' => '0'
}
},
'test' => {
'recommends' => {
'CPAN::Meta' => '2.120900'
},
'requires' => {
'ExtUtils::MakeMaker' => '0',
'File::Spec' => '0',
'Moose' => '0',
'Test::More' => '0.96',
'strict' => '0',
'warnings' => '0'
}
}
};
$x;
}
\ No newline at end of file
#!perl
use strict;
use warnings;
# This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.021
use Test::More tests => 1;
use ExtUtils::MakeMaker;
use File::Spec;
# from $version::LAX
my $lax_version_re =
qr/(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )?
|
(?:\.[0-9]+) (?:_[0-9]+)?
) | (?:
v (?:[0-9]+) (?: (?:\.[0-9]+)+ (?:_[0-9]+)? )?
|
(?:[0-9]+)? (?:\.[0-9]+){2,} (?:_[0-9]+)?
)
)/x;
# hide optional CPAN::Meta modules from prereq scanner
# and check if they are available
my $cpan_meta = "CPAN::Meta";
my $cpan_meta_pre = "CPAN::Meta::Prereqs";
my $HAS_CPAN_META = eval "require $cpan_meta; $cpan_meta->VERSION('2.120900')" && eval "require $cpan_meta_pre"; ## no critic
# Verify requirements?
my $DO_VERIFY_PREREQS = 1;
sub _max {
my $max = shift;
$max = ( $_ > $max ) ? $_ : $max for @_;
return $max;
}
sub _merge_prereqs {
my ($collector, $prereqs) = @_;
# CPAN::Meta::Prereqs object
if (ref $collector eq $cpan_meta_pre) {
return $collector->with_merged_prereqs(
CPAN::Meta::Prereqs->new( $prereqs )
);
}
# Raw hashrefs
for my $phase ( keys %$prereqs ) {
for my $type ( keys %{ $prereqs->{$phase} } ) {
for my $module ( keys %{ $prereqs->{$phase}{$type} } ) {
$collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module};
}
}
}
return $collector;
}
my @include = qw(
);
my @exclude = qw(
);
# Add static prereqs to the included modules list
my $static_prereqs = do 't/00-report-prereqs.dd';
# Merge all prereqs (either with ::Prereqs or a hashref)
my $full_prereqs = _merge_prereqs(
( $HAS_CPAN_META ? $cpan_meta_pre->new : {} ),
$static_prereqs
);
# Add dynamic prereqs to the included modules list (if we can)
my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml';
if ( $source && $HAS_CPAN_META ) {
if ( my $meta = eval { CPAN::Meta->load_file($source) } ) {
$full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs);
}
}
else {
$source = 'static metadata';
}
my @full_reports;
my @dep_errors;
my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs;
# Add static includes into a fake section
for my $mod (@include) {
$req_hash->{other}{modules}{$mod} = 0;
}
for my $phase ( qw(configure build test runtime develop other) ) {
next unless $req_hash->{$phase};
next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING});
for my $type ( qw(requires recommends suggests conflicts modules) ) {
next unless $req_hash->{$phase}{$type};
my $title = ucfirst($phase).' '.ucfirst($type);
my @reports = [qw/Module Want Have/];
for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) {
next if $mod eq 'perl';
next if grep { $_ eq $mod } @exclude;
my $file = $mod;
$file =~ s{::}{/}g;
$file .= ".pm";
my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC;
my $want = $req_hash->{$phase}{$type}{$mod};
$want = "undef" unless defined $want;
$want = "any" if !$want && $want == 0;
my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required";
if ($prefix) {
my $have = MM->parse_version( File::Spec->catfile($prefix, $file) );
$have = "undef" unless defined $have;
push @reports, [$mod, $want, $have];
if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META && $type eq 'requires' ) {
if ( $have !~ /\A$lax_version_re\z/ ) {
push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)";
}
elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) {
push @dep_errors, "$mod version '$have' is not in required range '$want'";
}
}
}
else {
push @reports, [$mod, $want, "missing"];
if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) {
push @dep_errors, "$mod is not installed ($req_string)";
}
}
}
if ( @reports ) {
push @full_reports, "=== $title ===\n\n";
my $ml = _max( map { length $_->[0] } @reports );
my $wl = _max( map { length $_->[1] } @reports );
my $hl = _max( map { length $_->[2] } @reports );
if ($type eq 'modules') {
splice @reports, 1, 0, ["-" x $ml, "", "-" x $hl];
push @full_reports, map { sprintf(" %*s %*s\n", -$ml, $_->[0], $hl, $_->[2]) } @reports;
}
else {
splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl];
push @full_reports, map { sprintf(" %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2]) } @reports;
}
push @full_reports, "\n";
}
}
}
if ( @full_reports ) {
diag "\nVersions for all modules listed in $source (including optional ones):\n\n", @full_reports;
}
if ( @dep_errors ) {
diag join("\n",
"\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n",
"The following REQUIRED prerequisites were not satisfied:\n",
@dep_errors,
"\n"
);
}
pass;
# vim: ts=4 sts=4 sw=4 et:
use strict;
use warnings;
use Test::More 0.88;
# This is a relatively nice way to avoid Test::NoWarnings breaking our
# expectations by adding extra tests, without using no_plan. It also helps
# avoid any other test module that feels introducing random tests, or even
# test plans, is a nice idea.
our $success = 0;
END { $success && done_testing; }
# List our own version used to generate this
my $v = "\nGenerated by Dist::Zilla::Plugin::ReportVersions::Tiny v1.10\n";
eval { # no excuses!
# report our Perl details
my $want = "any version";
$v .= "perl: $] (wanted $want) on $^O from $^X\n\n";
};
defined($@) and diag("$@");
# Now, our module version dependencies:
sub pmver {
my ($module, $wanted) = @_;
$wanted = " (want $wanted)";
my $pmver;
eval "require $module;";
if ($@) {
if ($@ =~ m/Can't locate .* in \@INC/) {
$pmver = 'module not found.';
} else {
diag("${module}: $@");
$pmver = 'died during require.';
}
} else {
my $version;
eval { $version = $module->VERSION; };
if ($@) {
diag("${module}: $@");
$pmver = 'died during VERSION check.';
} elsif (defined $version) {
$pmver = "$version";
} else {
$pmver = '<undef>';
}
}
# So, we should be good, right?
return sprintf('%-45s => %-10s%-15s%s', $module, $pmver, $wanted, "\n");
}
eval { $v .= pmver('ExtUtils::MakeMaker','6.30') };
eval { $v .= pmver('File::Spec','any version') };
eval { $v .= pmver('IO::Handle','any version') };
eval { $v .= pmver('IPC::Open3','any version') };
eval { $v .= pmver('Moose','any version') };
eval { $v .= pmver('Moose::Util::TypeConstraints','any version') };
eval { $v .= pmver('MooseX::Role::Parameterized','any version') };
eval { $v .= pmver('Test::More','0.96') };
eval { $v .= pmver('namespace::autoclean','any version') };
eval { $v .= pmver('strict','any version') };
eval { $v .= pmver('warnings','any version') };
# All done.
$v .= <<'EOT';
Thanks for using my code. I hope it works for you.
If not, please try and include this output in the bug report.
That will help me reproduce the issue and solve your problem.
EOT
diag($v);
ok(1, "we really didn't test anything, just reporting data");
$success = 1;
# Work around another nasty module on CPAN. :/
no warnings 'once';
$Template::Test::NO_FLUSH = 1;
exit 0;
......@@ -4,7 +4,7 @@ use Test::More tests => 2;
note 'Checking Changes';
my $changes_file = 'Changes';
my $newver = '0.004';
my $newver = '0.005';
my $trial_token = '-TRIAL';
SKIP: {
......
#!perl
# This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests.
use Test::More;
eval "use Test::Pod 1.41";
plan skip_all => "Test::Pod 1.41 required for testing POD" if $@;
use Test::Pod 1.41;
all_pod_files_ok();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment