Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Released version 0.22

  • Loading branch information...
commit 5a2d680dcb8c9ba1d7aa67ceb6ab7ee5cc3e3698 1 parent f7cfd3e
@ingydotnet authored
View
2  Changes
@@ -1,5 +1,5 @@
version: 0.22
-date:
+date: Mon Sep 12 17:18:29 CEST 2011
changes:
- mst++ changed default base class to Mo::O to avoid inheriting import() method
---
View
2  lib/Mo.pm
@@ -1,3 +1,3 @@
package Mo;
$VERSION='0.22';
-no warnings;sub import{$_->import for strict,warnings;my$p=caller."'";@{$p.ISA}=Mo::O;*{$p.extends}=sub{@{$p.ISA}=$_[0];eval"require($_[0])"};*{$p.has}=sub{my($n,%a)=@_;my$d=$a{default}||$a{builder};*{$p.$n}=$d?sub{$#_?($_[0]{$n}=$_[1]):exists$_[0]{$n}?$_[0]{$n}:($_[0]{$n}=$_[0]->$d)}:sub{$#_?$_[0]{$n}=$_[1]:$_[0]{$n}}}}sub Mo'O'new{my$c=shift;my$s=bless{@_},$c;my@c;do{unshift@c,$c."'BUILD"}while$c=${$c."'ISA"}[0];defined&$_&&&$_($s)for@c;$s}no strict
+no warnings;sub import{$_->import for strict,warnings;my$p=caller."'";@{$p.ISA}=Mo::_;*{$p.extends}=sub{@{$p.ISA}=$_[0];eval"require $_[0]"};*{$p.has}=sub{my($n,%a)=@_;my$d=$a{default}||$a{builder};*{$p.$n}=$d?sub{$#_?($_[0]{$n}=$_[1]):exists$_[0]{$n}?$_[0]{$n}:($_[0]{$n}=$_[0]->$d)}:sub{$#_?$_[0]{$n}=$_[1]:$_[0]{$n}}}}sub Mo'_'new{my$c=shift;my$s=bless{@_},$c;my@c;do{unshift@c,$c."'BUILD"}while$c=${$c."'ISA"}[0];defined&$_&&&$_($s)for@c;$s}no strict
View
8 lib/Mo/Design.pod
@@ -146,12 +146,12 @@ Mo.pm is currently golfed, compressed and unreadable by mere mortals. It has
no comments or pod. The documentation is in Mo.pod and the comments are all in
here. This makes Mo.pm a little black box of code that you can use anywhere.
-When we hack on Mo.pm we run it through perltidy and it looks great. When we
-are done we run ./script/compress.pl on it and it turns into 2 lines.
+When we hack on Mo.pm we do it on src/Mo.pm. When we are done we run C<make -C
+src/> and it turns into 3 lines.
-The package declaration and $VERSION are on their own line. That way if
+The package declaration and $VERSION are on their own lines. That way if
someone inlines Mo, they can make their own package line more easily, and just
-grab line 2, the code.
+grab line 3, the code.
This also helps because Module::Install barfs on parsing out the VERSION
otherwise. We should fix Module::Install or consider stop using it for this.
View
8 src/Mo.pm
@@ -1,13 +1,13 @@
package Mo;
$VERSION = '0.22';
-
no warnings;
+
sub import {
$_->import for strict, warnings;
my $p = caller."'";
- @{ $p . ISA } = Mo::O;
+ @{ $p . ISA } = Mo::_;
*{ $p . extends } =
- sub { @{ $p . ISA } = $_[0]; eval "require($_[0])" };
+ sub { @{ $p . ISA } = $_[0]; eval "require $_[0]" };
*{ $p . has } = sub {
my ( $n, %a ) = @_;
my $d = $a{default}||$a{builder};
@@ -21,7 +21,7 @@ sub import {
}
}
-sub Mo'O'new {
+sub Mo'_'new {
my $c = shift;
my $s = bless {@_}, $c;
my @c;
View
1  src/compress.pl
@@ -7,5 +7,6 @@
$text =~ s/(\w)\s+([^\w])/$1$2/g;
$text =~ s/([^\w])\s+/$1/g;
$text =~ s/(\$VERSION.*?;)/\n$1\n/;
+$text =~ s/(require)/$1 /;
print $text;
View
8 t/test.t
@@ -14,8 +14,8 @@ package main;
ok defined(&Foo::has), 'Mo exports has';
ok defined(&Foo::extends), 'Mo exports extends';
ok not(defined(&Foo::new)), 'Mo does not export new';
-ok 'Foo'->isa('Mo::O'), 'Foo isa Mo::O';
-is "@Foo::ISA", "Mo::O", '@Foo::ISA is Mo::O';
+ok 'Foo'->isa('Mo::_'), 'Foo isa Mo::_';
+is "@Foo::ISA", "Mo::_", '@Foo::ISA is Mo::_';
ok 'Foo'->can('new'), 'Foo can new';
ok 'Foo'->can('this'), 'Foo can this';
@@ -61,7 +61,7 @@ has guess => (
#============
package main;
-ok 'Bar'->isa('Mo::O'), 'Bar isa Mo::O';
+ok 'Bar'->isa('Mo::_'), 'Bar isa Mo::_';
ok 'Bar'->isa('Foo'), 'Bar isa Foo';
is "@Bar::ISA", 'Foo', '@Bar::ISA is Foo';
ok 'Bar'->can('new'), 'Bar can new';
@@ -76,7 +76,7 @@ my $b = Bar->new(
is ref($b), 'Bar', 'Object created';
ok $b->isa('Foo'), 'Inheritance works';
-ok $b->isa('Mo::O'), 'Bar isa Mo::O since Foo isa Mo::O';
+ok $b->isa('Mo::_'), 'Bar isa Mo::_ since Foo isa Mo::_';
is $b->this, 'thing', 'Read works in parent class';
is $b->that, 'thong', 'Read works in current class';
is ref($b->them), 'ARRAY', 'default works';
Please sign in to comment.
Something went wrong with that request. Please try again.