App-gcal

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

   "prereqs" : {
      "configure" : {
         "requires" : {
            "ExtUtils::MakeMaker" : "6.30"
         }
      },
      "runtime" : {
         "requires" : {
            "Class::ReturnValue" : 0,
            "Data::ICal" : 0,
            "DateTime::Format::ICal" : 0,
            "DateTime::TimeZone" : 0,
            "File::Basename" : 0,
            "Getopt::Long" : 0,
            "ICal::Format::Natural" : 0,
            "Net::Google::Calendar" : 0,
            "Net::Google::Calendar::Entry" : 0,
            "Net::Netrc" : 0,
            "strict" : 0,
            "warnings" : 0
         }
      },

META.yml  view on Meta::CPAN

dynamic_config: 0
generated_by: 'Dist::Zilla version 4.300006, CPAN::Meta::Converter version 2.113640'
license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: 1.4
name: App-gcal
requires:
  Class::ReturnValue: 0
  Data::ICal: 0
  DateTime::Format::ICal: 0
  DateTime::TimeZone: 0
  File::Basename: 0
  Getopt::Long: 0
  ICal::Format::Natural: 0
  Net::Google::Calendar: 0
  Net::Google::Calendar::Entry: 0
  Net::Netrc: 0
  strict: 0
  warnings: 0
resources:
  bugtracker: https://github.com/andrewrjones/gcal/issues

Makefile.PL  view on Meta::CPAN

  },
  "DISTNAME" => "App-gcal",
  "EXE_FILES" => [
    "bin/gcal"
  ],
  "LICENSE" => "perl",
  "NAME" => "App::gcal",
  "PREREQ_PM" => {
    "Class::ReturnValue" => 0,
    "Data::ICal" => 0,
    "DateTime::Format::ICal" => 0,
    "DateTime::TimeZone" => 0,
    "File::Basename" => 0,
    "Getopt::Long" => 0,
    "ICal::Format::Natural" => 0,
    "Net::Google::Calendar" => 0,
    "Net::Google::Calendar::Entry" => 0,
    "Net::Netrc" => 0,
    "strict" => 0,
    "warnings" => 0
  },
  "VERSION" => "1.121460",

lib/App/gcal.pm  view on Meta::CPAN

use strict;
use warnings;

package App::gcal;
{
  $App::gcal::VERSION = '1.121460';
}

use Class::ReturnValue;
use Data::ICal;
use DateTime::TimeZone;

# ABSTRACT: Command Line Interface interface to Google Calendar.

# cache the timezone lookup
my $localTZ = DateTime::TimeZone->new( name => 'local' );

my $gcal;


# entry point
sub run {
    my ( $args, $username, $password ) = @_;

    # loop over args
    for my $arg (@$args) {

lib/App/gcal.pm  view on Meta::CPAN

        my $tmp = $gcal->add_entry($event);
        die "Couldn't add event: $@\n" unless defined $tmp;
    }
}

# converts Data::ICal to Net::Google::Calendar::Entry
sub _create_new_gcal_event {
    my ($entry) = @_;

    require Net::Google::Calendar::Entry;
    require DateTime::Format::ICal;

    my $event = Net::Google::Calendar::Entry->new();

    $event->title( $entry->property('summary')->[0]->value );

    # ensure the times are in the local timezone
    my $dtstart = DateTime::Format::ICal->parse_datetime(
        $entry->property('dtstart')->[0]->value );
    $dtstart->set_time_zone($localTZ);
    my $dtend = DateTime::Format::ICal->parse_datetime(
        $entry->property('dtend')->[0]->value );
    $dtend->set_time_zone($localTZ);
    $event->when( $dtstart, $dtend );

    $event->status('confirmed');

    # optional
    if ( $entry->property('description') ) {
        $event->content( $entry->property('description')->[0]->value );
    }

t/01.t  view on Meta::CPAN

    'Journey Details: Cambridge (CBG) to Harlow Mill (HWM)' );
is( $gcal_event->location, 'Cambridge Rail Station, UK' );

# test quick add
my $quick_add_text =
  'Mar 31 1976 at 12:34. Lunch with Bob';    # from ICal::QuickAdd tests
my $iqa = App::gcal::_process_text($quick_add_text);
isa_ok( $iqa, 'Data::ICal' );

is( @{ $iqa->entries }[0]->property('summary')->[0]->value, 'Lunch with Bob' );
my $time = DateTime::Format::ICal->parse_datetime(
    @{ $iqa->entries }[0]->property('dtstart')->[0]->value );
is( $time->datetime, '1976-03-31T12:34:00' );
is( $time->datetime, '1976-03-31T12:34:00' );

$gcal_event = App::gcal::_create_new_gcal_event( @{ $iqa->entries }[0] );
isa_ok( $gcal_event, 'Net::Google::Calendar::Entry' );
is( $gcal_event->title, 'Lunch with Bob' );

$quick_add_text = '';
$iqa            = App::gcal::_process_text($quick_add_text);



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