diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8de6d8f --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +_build +.build +o-* +cover_db +*~ +*# +*.bak +*.old +*.rej +*.swp +*.tmp + + diff --git a/Changes b/Changes new file mode 100644 index 0000000..f351f85 --- /dev/null +++ b/Changes @@ -0,0 +1,2 @@ +{{$NEXT}} + . First implementation. diff --git a/README b/README deleted file mode 100644 index e69de29..0000000 diff --git a/dist.ini b/dist.ini new file mode 100644 index 0000000..a50efd0 --- /dev/null +++ b/dist.ini @@ -0,0 +1,66 @@ +name = o +author = Damien "dams" Krotkine +license = Perl_5 +copyright_holder = Damien "dams" Krotkine +copyright_year = 2011 + +main_module = lib/o.pm + +; -- static meta-information +[MetaResources] +homepage = http://search.cpan.org/dist/o +repository = http://github.com/dams/o-pm + +; -- fetch & generate files +[GatherDir] + +; -- tests +[CompileTests] +;[CriticTests] +[MetaTests] +;[PodCoverageTests] +[ExtraTests] + +; -- remove files +[PruneCruft] +[ManifestSkip] + +; -- get prereqs +[AutoPrereqs] + +[Prereqs] +[Prereqs / TestRequires] + +; -- munge files +[NextRelease] +[PkgVersion] +[PodWeaver] +[Prepender] +copyright = 1 + +; -- dynamic meta information +; [InstallDirs] +[MetaProvides::Package] + + +; -- generate meta files +[License] +[MakeMaker] +;[ModuleBuild] +[MetaYAML] +[Readme] +[Manifest] ; should come last + +; -- release +[CheckChangeLog] +[Git::NextVersion] +first_version = 0.100 +[Git::Tag] +[Git::Check] +[Git::Commit] +[UploadToCPAN] +[Git::Push] +[Twitter] +hash-tags = #perl #mo #object #cpan #release +tweet_url = http://search.cpan.org/search?query={{$DIST}}&mode=all +tweet = Just released {{$DIST}}-{{$VERSION}} on CPAN : {{$URL}} diff --git a/lib/o.pm b/lib/o.pm new file mode 100644 index 0000000..0548929 --- /dev/null +++ b/lib/o.pm @@ -0,0 +1,53 @@ +package o; + +# ABSTRACT: syntactic sugar to make Mo one-liners easier + +use strict; +use warnings; + +BEGIN { + my $package; + sub import { + $package = $_[1] || 'Class'; + } + use Filter::Simple sub { s/^/package $package;\nuse Mo;\n/; } +} + +1; + +=head1 SYNOPSIS + + # create a Mo class on the fly ... + perl -Mo=Foo -e 'has bar => ( default => sub { q[baz] } ); print Foo->new->bar' # prints baz + +=head1 DESCRIPTION + +o.pm is a simple source filter that adds +C +to the beginning of your script and was entirely created because typing +C is annoying. + +=head1 INTERFACE + +o provides exactly one method and it's automatically called by perl: + +=over 4 + +=item B + +Pass a package name to import to be used by the source filter. The +package defaults to C if none is given. + +=back + +=head1 DEPENDENCIES + +You will need L and eventually L + +=head1 INCOMPATIBILITIES + +None reported. But it is a source filter and might have issues there. + +=head1 BUGS + +See L for details on reporting bugs. diff --git a/t/basic.t b/t/basic.t new file mode 100644 index 0000000..af0922e --- /dev/null +++ b/t/basic.t @@ -0,0 +1,7 @@ +use Test::More; + +plan tests => 1; + +is(`$^X -Mo=Foo -e 'has bar => ( default => sub { q[baz] } ); print Foo->new->bar'`, + 'baz'); +