App-PM-Announce

 view release on metacpan or  search on metacpan

lib/App/PM/Announce.pm  view on Meta::CPAN

        app => $self,
        username => $given->{username},
        password => $given->{password},
        uri => $given->{uri},
    );
}

sub _build_useperl_feed {
    my $self = shift;
    return undef unless my $given = $self->config->{feed}->{useperl};
    return App::PM::Announce::Feed::useperl->new(
        app => $self,
        username => $given->{username},
        password => $given->{password},
        promote => $given->{promote},
    );
}

has history => qw/is ro isa App::PM::Announce::History lazy_build 1/;
sub _build_history {
    my $self = shift;
    return App::PM::Announce::History->new( app => $self );
}

sub startup {
    my $self = shift;

    $self->logger->debug( "debug = " . $self->debug );
    $self->logger->debug( "verbose = " . $self->verbose );
    $self->logger->debug( "dry-run = " . $self->dry_run );

    my $home_dir = $self->home_dir;
    $self->logger->debug( "home_dir = $home_dir" );

    unless (-d $home_dir) {
        $self->logger->debug( "Making $home_dir because it does not exist" );
        $home_dir->mkpath;
    }

    # Gotta do this here
    $self->logger->add( Log::Dispatch::File->new( name => 'file', mode => 'append', min_level => 'info', filename => $self->log_file.'' ) );

    my $log_file = $self->log_file;
    $self->logger->debug( "log_file = $log_file" );

    my $config_file = $self->config_file;
    if (defined $config_file) {
        $self->logger->debug( "config_file = $config_file" );

        unless (-f $config_file) {
            $self->logger->debug( "Making $config_file stub because it does not exist" );
            $config_file->openw->print( <<_END_ );
# vim: set filetype=configgeneral:

# Replace 'An-Example-Group' with the real resource for your Meetup group
# Replace <venue> with the venue number you want to be the default

#<feed meetup>
#    username
#    password
#    uri http://www.meetup.com/An-Example-Group/calendar/?action=new
#    venue <venue>
#</feed>

# Replace <gid> with the gid of your group

#<feed linkedin>
#    username
#    password
#    uri http://www.linkedin.com/groupAnswers?start=&gid=<gid>
#</feed>

# Replace 'example.com' with a real host

#<feed greymatter>
#    username
#    password
#    uri http://example.com/cgi-bin/greymatter/gm.cgi
#</feed>

#<feed useperl>
#    username
#    password
#</feed>

_END_
        }
    }
}



sub announce {
    my $self = shift;
    my %event;
    if (ref $_[0]) {
        my $document = $self->parse( @_ );
        %event = %{ $document->header };
        $event{description} = $document->body;
    }
    else {
        %event = @_;
    }

    { # Validate, parse, and filter.

        $event{$_} = trim $event{$_} for qw/title venue/;

        die "Wasn't given a UUID for the event\n" unless $event{uuid};

        die "Wasn't given a title for the event\n" unless $event{title};

#        die "Wasn't given a venue for the event\n" unless $event{venue};

        die "Wasn't given a date & time for the event\n" unless $event{datetime};
        die "The date & time isn't a DateTime object\n" unless $event{datetime}->isa( 'DateTime' );
    }

    my (@report, $event, $result);
    my $uuid = $event{uuid};
    $event = $self->history->find_or_insert( $uuid )->{data};



( run in 3.181 seconds using v1.01-cache-2.11-cpan-5a3173703d6 )