Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Released version 0.30

  • Loading branch information...
commit 35a0a1d19865174083728416f72cd351ba8c5f3c 1 parent b9e0480
@ingydotnet authored
Showing with 122 additions and 47 deletions.
  1. +6 −0 Changes
  2. +3 −0  Makefile.PL
  3. +2 −2 lib/Mo.pm
  4. +1 −1  lib/Mo/Moose.pm
  5. +1 −1  lib/Mo/Mouse.pm
  6. +1 −1  lib/Mo/build.pm
  7. +1 −1  lib/Mo/builder.pm
  8. +1 −1  lib/Mo/chain.pm
  9. +1 −1  lib/Mo/coerce.pm
  10. +1 −1  lib/Mo/default.pm
  11. +1 −1  lib/Mo/exporter.pm
  12. +1 −1  lib/Mo/import.pm
  13. +3 −0  lib/Mo/importer.pm
  14. +27 −0 lib/Mo/importer.pod
  15. +1 −1  lib/Mo/is.pm
  16. +1 −1  lib/Mo/option.pm
  17. +1 −1  lib/Mo/required.pm
  18. +2 −2 lib/Mo/xs.pm
  19. +1 −0  src/Makefile
  20. +3 −2 src/Mo.pm
  21. +1 −1  src/Mo/Moose.pm
  22. +1 −1  src/Mo/Mouse.pm
  23. +1 −1  src/Mo/build.pm
  24. +1 −1  src/Mo/builder.pm
  25. +1 −1  src/Mo/chain.pm
  26. +1 −1  src/Mo/coerce.pm
  27. +1 −1  src/Mo/default.pm
  28. +1 −1  src/Mo/exporter.pm
  29. +1 −1  src/Mo/import.pm
  30. +10 −0 src/Mo/importer.pm
  31. +1 −1  src/Mo/is.pm
  32. +1 −1  src/Mo/option.pm
  33. +1 −1  src/Mo/required.pm
  34. +4 −4 src/Mo/xs.pm
  35. +8 −1 t/Moose.t
  36. +8 −1 t/Mouse.t
  37. +12 −0 t/importer.t
  38. +9 −11 t/xs.t
View
6 Changes
@@ -1,4 +1,10 @@
---
+version: 0.30
+date: Tue Oct 11 19:36:07 EDT 2011
+changes:
+- Don't run moose/mouse tests unless deps exist
+- Add Mo::importer
+---
version: 0.29
date: Mon Oct 10 22:46:50 EDT 2011
changes:
View
3  Makefile.PL
@@ -9,4 +9,7 @@ all_from 'lib/Mo.pod';
recommends 'IO::All';
recommends 'Class::XSAccessor';
+recommends 'Moose';
+recommends 'Mouse';
+
no_index 'directory' => 'src';
View
4 lib/Mo.pm
@@ -1,3 +1,3 @@
package Mo;
-$VERSION=0.29;
-no warnings;my$M=__PACKAGE__.::;*{$M.Object::new}=sub{bless{@_[1..$#_]},$_[0]};*{$M.import}=sub{import warnings;$^H|=1538;my($P,%e,%o)=caller.::;shift;eval"no Mo::$_",&{$M.$_.::e}($P,\%e,\%o)for@_;return if$e{M};%e=(extends,sub{eval"no $_[0]()";@{$P.ISA}=$_[0]},has,sub{my$n=shift;my$m=sub{$#_?$_[0]{$n}=$_[1]:$_[0]{$n}};$m=$o{$_}->($m,$n,@_)for sort keys%o;*{$P.$n}=$m},%e,);*{$P.$_}=$e{$_}for keys%e;@{$P.ISA}=$M.Object};
+$VERSION='0.30';
+no warnings;my$M=__PACKAGE__.::;*{$M.Object::new}=sub{bless{@_[1..$#_]},$_[0]};*{$M.import}=sub{import warnings;$^H|=1538;my($P,%e,%o)=caller.::;shift;eval"no Mo::$_",&{$M.$_.::e}($P,\%e,\%o,\@_)for@_;return if$e{M};%e=(extends,sub{eval"no $_[0]()";@{$P.ISA}=$_[0]},has,sub{my$n=shift;my$m=sub{$#_?$_[0]{$n}=$_[1]:$_[0]{$n}};$m=$o{$_}->($m,$n,@_)for sort keys%o;*{$P.$n}=$m},%e,);*{$P.$_}=$e{$_}for keys%e;@{$P.ISA}=$M.Object};
View
2  lib/Mo/Moose.pm
@@ -1,3 +1,3 @@
package Mo::Moose;$M="Mo::";
-$VERSION=0.29;
+$VERSION=0.30;
*{$M.'Moose::e'}=sub{my($P,$e)=@_;$P=~s/::$//;%$e=(M=>1);require Moose;Moose->import({into=>$P});Moose::Util::MetaRole::apply_metaroles(for=>$P,class_metaroles=>{attribute=>['Attr::Trait']},)};BEGIN{package Attr::Trait;use Moose::Role;around _process_options=>sub{my$orig=shift;my$c=shift;my($n,$o)=@_;$o->{is}||='rw';$o->{lazy}||=1 if defined$o->{default}or defined$o->{builder};$c->$orig(@_)};$INC{'Attr/Trait.pm'}=1}
View
2  lib/Mo/Mouse.pm
@@ -1,3 +1,3 @@
package Mo::Mouse;$M="Mo::";
-$VERSION=0.29;
+$VERSION=0.30;
*{$M.'Mouse::e'}=sub{my($P,$e)=@_;$P=~s/::$//;%$e=(M=>1);require Mouse;require Mouse::Util::MetaRole;Mouse->import({into=>$P});Mouse::Util::MetaRole::apply_metaroles(for=>$P,class_metaroles=>{attribute=>['Attr::Trait']},)};BEGIN{package Attr::Trait;use Mouse::Role;around _process_options=>sub{my$orig=shift;my$c=shift;my($n,$o)=@_;$o->{is}||='rw';$o->{lazy}||=1 if defined$o->{default}or defined$o->{builder};$c->$orig(@_)};$INC{'Attr/Trait.pm'}=1}
View
2  lib/Mo/build.pm
@@ -1,3 +1,3 @@
package Mo::build;my$M="Mo::";
-$VERSION=0.29;
+$VERSION=0.30;
*{$M.'build::e'}=sub{my($P,$e)=@_;$e->{new}=sub{$c=shift;my$s=bless{@_},$c;my@B;do{@B=($c.::BUILD,@B)}while($c)=@{$c.::ISA};exists&$_&&&$_($s)for@B;$s}};
View
2  lib/Mo/builder.pm
@@ -1,3 +1,3 @@
package Mo::builder;my$M="Mo::";
-$VERSION=0.29;
+$VERSION=0.30;
*{$M.'builder::e'}=sub{my($P,$e,$o)=@_;$o->{builder}=sub{my($m,$n,%a)=@_;my$b=$a{builder}or return$m;sub{$#_?$m->(@_):!exists$_[0]{$n}?$_[0]{$n}=$_[0]->$b:$m->(@_)}}};
View
2  lib/Mo/chain.pm
@@ -1,3 +1,3 @@
package Mo::chain;my$M="Mo::";
-$VERSION=0.29;
+$VERSION=0.30;
*{$M.'chain::e'}=sub{my($P,$e,$o)=@_;$o->{chain}=sub{my($m,$n,%a)=@_;$a{chain}or return$m;sub{$#_?($m->(@_),return$_[0]):$m->(@_)}}};
View
2  lib/Mo/coerce.pm
@@ -1,3 +1,3 @@
package Mo::coerce;my$M="Mo::";
-$VERSION=0.29;
+$VERSION=0.30;
*{$M.'coerce::e'}=sub{my($P,$e,$o)=@_;$o->{coerce}=sub{my($m,$n,%a)=@_;$a{coerce}or return$m;sub{$#_?$m->($_[0],$a{coerce}->($_[1])):$m->(@_)}};my$C=$e->{new}||*{$M.Object::new}{CODE};$e->{new}=sub{my$s=$C->(@_);$s->$_($s->{$_})for keys%$s;$s}};
View
2  lib/Mo/default.pm
@@ -1,3 +1,3 @@
package Mo::default;my$M="Mo::";
-$VERSION=0.29;
+$VERSION=0.30;
*{$M.'default::e'}=sub{my($P,$e,$o)=@_;$o->{default}=sub{my($m,$n,%a)=@_;$a{default}or return$m;sub{$#_?$m->(@_):!exists$_[0]{$n}?$_[0]{$n}=$a{default}->(@_):$m->(@_)}}};
View
2  lib/Mo/exporter.pm
@@ -1,3 +1,3 @@
package Mo::exporter;my$M="Mo::";
-$VERSION=0.29;
+$VERSION=0.30;
*{$M.'exporter::e'}=sub{my($P)=@_;if(defined@{$M.EXPORT}){*{$P.$_}=\&{$M.$_}for@{$M.EXPORT}}};
View
2  lib/Mo/import.pm
@@ -1,3 +1,3 @@
package Mo::import;my$M="Mo::";
-$VERSION=0.29;
+$VERSION=0.30;
my$i=\&import;*{$M.import}=sub{(@_==2 and not $_[1])?pop@_:@_==1?push@_,grep!/import/,@f:();goto&$i};
View
3  lib/Mo/importer.pm
@@ -0,0 +1,3 @@
+package Mo::importer;my$M="Mo::";
+$VERSION=0.30;
+*{$M.'importer::e'}=sub{my($P,$e,$o,$f)=@_;(my$pkg=$P)=~s/::$//;&{$P.'importer'}($pkg,@$f)if defined&{$P.'importer'}};
View
27 lib/Mo/importer.pod
@@ -0,0 +1,27 @@
+=encoding utf8
+
+=head1 Name
+
+Mo::importer - Write your own import() extension
+
+=head1 Synopsis
+
+ package MyMo;
+
+ sub importer {
+ my ($caller, @args) = @_;
+ ...
+ }
+
+ use Mo qw[importer other features];
+
+=head1 Description
+
+Sometimes you need to add your own logic during Mo::import time. This feature
+lets you do that by defining your own C<importer> subroutine. It will pass you
+the original caller pkg and the args passed in.
+
+=head1 Note
+
+You need to define the C<importer> sub before you C<use Mo ...>, for
+(hopefully) obvious reasons. :\
View
2  lib/Mo/is.pm
@@ -1,3 +1,3 @@
package Mo::is;$M="Mo::";
-$VERSION=0.29;
+$VERSION=0.30;
*{$M.'is::e'}=sub{my($P,$e,$o)=@_;$o->{is}=sub{my($m,$n,%a)=@_;$a{is}or return$m;sub{$#_&&$a{is}eq 'ro'&&caller ne 'Mo::coerce'?die:$m->(@_)}}};
View
2  lib/Mo/option.pm
@@ -1,3 +1,3 @@
package Mo::option;my$M="Mo::";
-$VERSION=0.29;
+$VERSION=0.30;
*{$M.'option::e'}=sub{my($P,$e,$o)=@_;$o->{option}=sub{my($m,$n,%a)=@_;$a{option}or return$m;my$n2=$n;*{$P."read_$n2"}=sub{$_[0]->{$n2}};sub{$#_?$m->(@_):$m->(@_,1);$_[0]}}};
View
2  lib/Mo/required.pm
@@ -1,3 +1,3 @@
package Mo::required;my$M="Mo::";
-$VERSION=0.29;
+$VERSION=0.30;
*{$M.'required::e'}=sub{my($P,$e,$o)=@_;$o->{required}=sub{my($m,$n,%a)=@_;if($a{required}){my$C=*{$P."new"}{CODE}||*{$M.Object::new}{CODE};no warnings 'redefine';*{$P."new"}=sub{my$s=$C->(@_);my%a=@_[1..$#_];die if!$a{$n};$s}}$m}};
View
4 lib/Mo/xs.pm
@@ -1,3 +1,3 @@
package Mo::xs;my$M="Mo::";
-$VERSION=0.29;
-require Class::XSAccessor;*{$M.'xs::e'}=sub{my($P,$e,$o,$f)=@_;$P=~s/::$//;$e->{has}=sub{my($n,%a)=@_;Class::XSAccessor->import(class=>$P,accessors=>{$n=>$n})}if grep!/^xs$/,@$f};
+$VERSION=0.30;
+require Class::XSAccessor;*{$M.'xs::e'}=sub{my($P,$e,$o,$f)=@_;$P=~s/::$//;$e->{has}=sub{my($n,%a)=@_;Class::XSAccessor->import(class=>$P,accessors=>{$n=>$n})}if!grep!/^xs$/,@$f};
View
1  src/Makefile
@@ -8,6 +8,7 @@ ALL := \
../lib/Mo/exporter.pm \
../lib/Mo/has.pm \
../lib/Mo/import.pm \
+ ../lib/Mo/importer.pm \
../lib/Mo/is.pm \
../lib/Mo/option.pm \
../lib/Mo/required.pm \
View
5 src/Mo.pm
@@ -1,6 +1,6 @@
# The first two lines are left alone in the compressed source.
package Mo;
-$VERSION = 0.29;
+$VERSION = '0.30';
# 'no' is a shorter 'use', but we really don't want warnings.
no warnings;
@@ -27,7 +27,8 @@ my $MoPKG = __PACKAGE__.::;
&{$MoPKG.$_.::e}(
$caller_pkg,
\%exports,
- \%options
+ \%options,
+ \@_
) for @_;
return if $exports{M};
%exports = (
View
2  src/Mo/Moose.pm
@@ -1,5 +1,5 @@
package Mo::Moose;$MoPKG = "Mo::";
-$VERSION = 0.29;
+$VERSION = 0.30;
*{$MoPKG.'Moose::e'} = sub {
my ($caller_pkg, $exports) = @_;
View
2  src/Mo/Mouse.pm
@@ -1,5 +1,5 @@
package Mo::Mouse;$MoPKG = "Mo::";
-$VERSION = 0.29;
+$VERSION = 0.30;
*{$MoPKG.'Mouse::e'} = sub {
my ($caller_pkg, $exports) = @_;
View
2  src/Mo/build.pm
@@ -1,6 +1,6 @@
package Mo::build;
my $MoPKG = "Mo::";
-$VERSION = 0.29;
+$VERSION = 0.30;
*{$MoPKG.'build::e'} = sub {
my ($caller_pkg, $exports) = @_;
View
2  src/Mo/builder.pm
@@ -1,6 +1,6 @@
package Mo::builder;
my $MoPKG = "Mo::";
-$VERSION = 0.29;
+$VERSION = 0.30;
*{$MoPKG.'builder::e'} = sub {
my ($caller_pkg, $exports, $options) = @_;
View
2  src/Mo/chain.pm
@@ -1,6 +1,6 @@
package Mo::chain;
my $MoPKG = "Mo::";
-$VERSION = 0.29;
+$VERSION = 0.30;
*{$MoPKG.'chain::e'} = sub {
my ($caller_pkg, $exports, $options) = @_;
View
2  src/Mo/coerce.pm
@@ -1,6 +1,6 @@
package Mo::coerce;
my $MoPKG = "Mo::";
-$VERSION = 0.29;
+$VERSION = 0.30;
*{$MoPKG.'coerce::e'} = sub {
my ($caller_pkg, $exports, $options) = @_;
View
2  src/Mo/default.pm
@@ -1,6 +1,6 @@
package Mo::default;
my $MoPKG = "Mo::";
-$VERSION = 0.29;
+$VERSION = 0.30;
*{$MoPKG.'default::e'} = sub {
my ($caller_pkg, $exports, $options) = @_;
View
2  src/Mo/exporter.pm
@@ -1,6 +1,6 @@
package Mo::exporter;
my $MoPKG = "Mo::";
-$VERSION = 0.29;
+$VERSION = 0.30;
*{$MoPKG.'exporter::e'} = sub {
my ($caller_pkg) = @_;
View
2  src/Mo/import.pm
@@ -1,6 +1,6 @@
package Mo::import;
my $MoPKG = "Mo::";
-$VERSION = 0.29;
+$VERSION = 0.30;
my $import = \&import;
*{$MoPKG.import} = sub {
View
10 src/Mo/importer.pm
@@ -0,0 +1,10 @@
+package Mo::importer;
+my $MoPKG = "Mo::";
+$VERSION = 0.30;
+
+*{$MoPKG.'importer::e'} = sub {
+ my ($caller_pkg, $exports, $options, $features) = @_;
+ (my $pkg = $caller_pkg) =~ s/::$//;
+ &{$caller_pkg.'importer'}($pkg, @$features)
+ if defined &{$caller_pkg.'importer'};
+};
View
2  src/Mo/is.pm
@@ -1,5 +1,5 @@
package Mo::is;$MoPKG = "Mo::";
-$VERSION = 0.29;
+$VERSION = 0.30;
*{$MoPKG.'is::e'} = sub {
my ($caller_pkg, $exports, $options) = @_;
View
2  src/Mo/option.pm
@@ -1,6 +1,6 @@
package Mo::option;
my $MoPKG = "Mo::";
-$VERSION = 0.29;
+$VERSION = 0.30;
*{$MoPKG.'option::e'} = sub {
my ($caller_pkg, $exports, $options) = @_;
View
2  src/Mo/required.pm
@@ -1,6 +1,6 @@
package Mo::required;
my $MoPKG = "Mo::";
-$VERSION = 0.29;
+$VERSION = 0.30;
*{$MoPKG.'required::e'} = sub {
my ($caller_pkg, $exports, $options) = @_;
View
8 src/Mo/xs.pm
@@ -1,6 +1,6 @@
package Mo::xs;
my $MoPKG = "Mo::";
-$VERSION = 0.29;
+$VERSION = 0.30;
require Class::XSAccessor;
@@ -10,8 +10,8 @@ require Class::XSAccessor;
$exports->{has} = sub {
my ( $name, %args ) = @_;
Class::XSAccessor->import(
- class => $caller_pkg,
- accessors => { $name => $name }
+ class => $caller_pkg,
+ accessors => { $name => $name }
);
- } if grep !/^xs$/, @$features;
+ } if ! grep !/^xs$/, @$features;
};
View
9 t/Moose.t
@@ -1,4 +1,11 @@
-use Test::More tests => 5;
+use Test::More;
+
+BEGIN {
+ eval "use Moose";
+ $@ and plan skip_all => "Moose is needed";
+};
+
+plan tests => 5;
{
package Foo;
View
9 t/Mouse.t
@@ -1,4 +1,11 @@
-use Test::More tests => 5;
+use Test::More;
+
+BEGIN {
+ eval "use Mouse";
+ $@ and plan skip_all => "Mouse is needed";
+};
+
+plan tests => 5;
{
package Foo;
View
12 t/importer.t
@@ -0,0 +1,12 @@
+use Test::More tests => 1;
+
+{
+ package Foo;
+
+ sub importer {
+ package main;
+ is "@_", 'Foo importer default build', 'Mo::importer works';
+ }
+
+ use Mo qw'importer default build';
+}
View
20 t/xs.t
@@ -1,25 +1,23 @@
use Test::More;
BEGIN {
- eval "use Class::XSAccessor;";
+ eval "use Class::XSAccessor";
$@ and plan skip_all => "Class::XSAccessor is needed";
};
plan tests => 4;
-#============
-package Foo;
+{
+ package Foo;
-use Mo 'xs', 'default', 'builder';
+ use Mo 'xs', 'default', 'builder';
-has 'this';
-has 'that' => (builder => 'that_builder');
-has 'them' => (default => sub {[]});
+ has 'this';
+ has 'that' => (builder => 'that_builder');
+ has 'them' => (default => sub {[]});
-use constant that_builder => 'O HAI';
-
-#============
-package main;
+ use constant that_builder => 'O HAI';
+}
my $f = Foo->new(this => 'thing');
Please sign in to comment.
Something went wrong with that request. Please try again.