Acme-PM-Paris-Meetings

 view release on metacpan or  search on metacpan

Build.PL  view on Meta::CPAN

use warnings;
use Module::Build;

Module::Build->new(
    module_name         => 'Acme::PM::Paris::Meetings',
    license             => 'perl',
    dist_author         => 'Olivier Mengué <dolmen@cpan.org>',
    dist_version_from   => 'lib/Acme/PM/Paris/Meetings.pm',
    script_files        => 'script/paris-pm',
    requires => {
        'DateTime::TimeZone' => 0,
        ($^O eq 'hpux' ? ('DateTime::TimeZone::HPUX' => '0.08') : ()),
        'DateTime::Format::ICal' => 0,
        'Exporter' => 0,
    },
    build_requires => {
        'Test::More' => 0,
    },
    add_to_cleanup      => [ 'Acme-PM-Paris-Meetings-*' ],
    create_makefile_pl => 'traditional',
)->create_build_script();

META.yml  view on Meta::CPAN

---
name: Acme-PM-Paris-Meetings
version: 200905.04
author:
  - 'Olivier Mengué <dolmen@cpan.org>'
abstract: Get the date/time of the next Paris.pm meeting!
license: perl
resources:
  license: http://dev.perl.org/licenses/
requires:
  DateTime::Format::ICal: 0
  DateTime::TimeZone: 0
  Exporter: 0
build_requires:
  Test::More: 0
provides:
  Acme::PM::Paris::Meetings:
    file: lib/Acme/PM/Paris/Meetings.pm
    version: 200905.04
generated_by: Module::Build version 0.33
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html

Makefile.PL  view on Meta::CPAN

(
          'PL_FILES' => {},
          'INSTALLDIRS' => 'site',
          'NAME' => 'Acme::PM::Paris::Meetings',
          'EXE_FILES' => [
                           'script/paris-pm'
                         ],
          'VERSION_FROM' => 'lib/Acme/PM/Paris/Meetings.pm',
          'PREREQ_PM' => {
                           'Test::More' => 0,
                           'DateTime::TimeZone' => 0,
                           'DateTime::Format::ICal' => 0,
                           'Exporter' => 0
                         }
        )
;

lib/Acme/PM/Paris/Meetings.pm  view on Meta::CPAN

package Acme::PM::Paris::Meetings;

use warnings;
use strict;

use DateTime::Format::ICal;

use Exporter 'import';
our @EXPORT = qw(next_meeting);

=head1 NAME

Acme::PM::Paris::Meetings - Get the date/time of the next Paris.pm meeting!

=head1 VERSION

lib/Acme/PM/Paris/Meetings.pm  view on Meta::CPAN


    $ paris-pm -3


One-liner:

    perl -MAcme::PM::Paris::Meetings -e "print next_meeting"

Longer:

    use DateTime;
    use Acme::PM::Paris::Meetings;

    my $rec = Acme::PM::Paris::Meetings::recurrence();
    my $dt = $rec->iterator->next(DateTime->now(time_zone => 'Europe/Paris'));
    ...

=cut



=head1 FUNCTIONS


=head2 recurrence

Returns a new DateTime::Set from which you can get the date/time of the planned
Paris.pm meeting for the following months.

=cut

sub recurrence
{
    my $dtstart = @_
                ? $_[0]
                : DateTime->now(time_zone => 'Europe/Paris',
                                locale => 'fr_FR')
                                ->truncate(to => 'day');
    DateTime::Format::ICal->parse_recurrence(
        recurrence => ical(),
        dtstart => $dtstart,
    );
}

=head2 next_meeting

Convenience function that returns the date/time of the next Paris.pm meeting
as a string formatted for french humans.

t/basic.t  view on Meta::CPAN

use strict;
use warnings;
use Test::More tests => 10;
use DateTime;
use Acme::PM::Paris::Meetings;


my $dt = DateTime->new(year => 2009,
                       month => 5,
                       day => 1,
                       time_zone => 'Europe/Paris');
isa_ok($dt, "DateTime");
# Basic DateTime check
is($dt->iso8601, "2009-05-01T00:00:00", "First of May 2009");

my $rec = Acme::PM::Paris::Meetings::recurrence($dt)->iterator;
can_ok($rec, 'next');
isa_ok($rec, 'DateTime::Set');


my $dt_meeting = $rec->next;
isa_ok($dt_meeting, "DateTime");
is($dt_meeting->iso8601, "2009-05-13T20:00:00", "Meeting of May 2009");
$dt_meeting = $rec->next;
isa_ok($dt_meeting, "DateTime");
is($dt_meeting->iso8601, "2009-06-10T20:00:00", "Meeting of June 2009");
$dt_meeting = $rec->next;
isa_ok($dt_meeting, "DateTime");
is($dt_meeting->iso8601, "2009-07-08T20:00:00", "Meeting of July 2009");



( run in 0.361 second using v1.01-cache-2.11-cpan-05444aca049 )