-
-
06 Jun 2012 01:40:03 UTC
- Distribution: Perl-Achievements
- Module version: v0.4.0
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues (0)
- Testers (131 / 145 / 14)
- Kwalitee
Bus factor: 1- % Coverage
- License: perl_5
- Perl: v5.10.0
- Activity
24 month- Tools
- Download (23.99KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Data::Printer
- DateTime::Functions
- Digest::SHA
- File::HomeDir
- File::Touch
- List::MoreUtils
- Method::Signatures
- Module::Pluggable
- Moose
- Moose::Role
- MooseX::App::Cmd
- MooseX::App::Cmd::Command
- MooseX::ClassAttribute
- MooseX::ConfigFromFile
- MooseX::Role::BuildInstanceOf
- MooseX::Role::Loggable
- MooseX::SemiAffordanceAccessor
- PPI
- Path::Class
- Template::Caribou
- Template::Caribou::Tags::HTML
- Template::Caribou::Utils
- YAML::Any
- strict
- warnings
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Perl::Achievements::Achievement - base role for achievements
VERSION
version 0.4.0
SYNOPSIS
package Perl::Achievements::Achievement::PerlAchiever; use strict; use warnings; use Moose; use MooseX::SemiAffordanceAccessor; with 'Perl::Achievements::Achievement'; has runs => ( traits => [ qw/ Counter Perl::Achievements::Role::ConfigItem / ], isa => 'Num', is => 'rw', default => 0, handles => { inc_runs => 'inc', }, ); sub scan { my $self = shift; $self->inc_runs; return unless $self->runs >= 2** $self->level; $self->inc_level; $self->unlock( sprintf "ran perl-achievements against %d scripts/modules", 2 ** ( $self->level - 1 ) ); } 1;
DESCRIPTION
Each type of achievement is a module consuming the Perl::Achievements::Achievement role.
To be able to preserve counters and states across runs, all attributes of the class having the Perl::Achievements::Role::ConfigItem trait will be serialized and saved in a yaml file in the
$PERL_ACHIEVEMENTS_HOME/achievements
directory.REQUIRED METHODS
scan()
scan
is the only required method by the role. It is typically invoked by the mainscan()
method of the main Perl::Achievements object, and is expected to inspect the current Perl file (available viappi()
) and unlock the achievement when the right conditions are met.METHODS
app()
Returns the Perl::Achievements object to which this achievement object belongs to.
ppi()
Returns the PPI::Document object corresponding to the Perl script currently under study.
log( $message )
Logs the $message.
log_debug( $message )
Debug-level logging.
level()
Returns the current achieved level. A level of undef means that the achievement has not been reached yet, whereas a level of 0 is used for achievements that don't have multiple levels.
set_level( $level )
Sets the level to $level.
inc_level( $increment )
Increments the level by the $increment. If the increment is not given, increment by 1.
unlock( $details )
Unlocks the achievement. An optional message can be passed, providing specific on the deed.
If not set manually beforehand, unlocking the achievement would automatically set the level to 0.
AUTHOR
Yanick Champoux <yanick@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Yanick Champoux.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Module Install Instructions
To install Perl::Achievements, copy and paste the appropriate command in to your terminal.
cpanm Perl::Achievements
perl -MCPAN -e shell install Perl::Achievements
For more information on module installation, please visit the detailed CPAN module installation guide.