Skip to content

Commit

Permalink
first implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Damien Krotkine committed Sep 15, 2011
1 parent c19bb31 commit e445bdc
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitignore
@@ -0,0 +1,13 @@
_build
.build
o-*
cover_db
*~
*#
*.bak
*.old
*.rej
*.swp
*.tmp


2 changes: 2 additions & 0 deletions Changes
@@ -0,0 +1,2 @@
{{$NEXT}}
. First implementation.
Empty file removed README
Empty file.
66 changes: 66 additions & 0 deletions 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}}
53 changes: 53 additions & 0 deletions 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<package $name; use Mo;>
to the beginning of your script and was entirely created because typing
C<perl -e'package Foo; use Mo; ...'> is annoying.
=head1 INTERFACE
o provides exactly one method and it's automatically called by perl:
=over 4
=item B<import($package)>
Pass a package name to import to be used by the source filter. The
package defaults to C<Class> if none is given.
=back
=head1 DEPENDENCIES
You will need L<Filter::Simple> and eventually L<Mo>
=head1 INCOMPATIBILITIES
None reported. But it is a source filter and might have issues there.
=head1 BUGS
See L<Mo/BUGS> for details on reporting bugs.
7 changes: 7 additions & 0 deletions 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');

0 comments on commit e445bdc

Please sign in to comment.