File Coverage

blib/lib/XPlanner.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package XPlanner;
2              
3 2     2   22231 use strict;
  2         5  
  2         71  
4 2     2   11 use base qw(XPlanner::Object);
  2         5  
  2         1056  
5             our $VERSION = 0.01;
6              
7              
8 2     2   3558 use SOAP::Lite;
  0            
  0            
9             use YAML;
10             use URI;
11              
12              
13             =head1 NAME
14              
15             XPlanner - an interface to XPlanner (www.xplanner.org)
16              
17              
18             =head1 SYNOPSIS
19              
20             use XPlanner;
21              
22             my $xp = XPlanner->login($url, $user, $pass);
23              
24             my $people = $xp->people;
25             my $projects = $xp->projects;
26              
27              
28             =head1 DESCRIPTION
29              
30             This is an interface to XPlanner, an XP project management tool.
31              
32             =cut
33              
34             sub _init {
35             my $class = shift;
36             bless {}, $class;
37             }
38              
39              
40             sub AUTOLOAD {
41             my $self = shift;
42              
43             our $AUTOLOAD;
44             my($method) = $AUTOLOAD =~ /::([^:]+)$/;
45              
46             return $self->{_proxy}->$method(@_);
47             }
48              
49              
50             sub login {
51             my($class, $url, $user, $pass) = @_;
52              
53             $url = URI->new($url);
54             $url->userinfo("$user:$pass");
55              
56             my $self = $class->_init;
57              
58             my $proxy = SOAP::Lite->proxy($url);
59             $self->{_proxy} = $proxy;
60              
61             # Register deserializers for XPlanner types
62             foreach (qw(ProjectData IterationData UserStoryData TaskData
63             TimeEntryData NoteData PersonData))
64             {
65             $proxy->maptype->{$_} = 'http://xplanner.org/soap';
66             }
67              
68             # Register an automatic serializer for DateTime types
69             $proxy->typelookup->{dateTime} =
70             [11,
71             sub { $_[0] =~
72             m/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/
73             },
74             sub {
75             my($val, $name, $type, $attr) = @_;
76             return [$name,
77             {'xsi:type' => 'xsd:dateTime', %$attr},
78             $val];
79             }
80             ];
81              
82             $proxy->xmlschema('http://www.w3.org/2001/XMLSchema');
83              
84             return $self;
85             }
86              
87              
88             sub people {
89             my $self = shift;
90              
91             return $self->_map_from_soap('userId', 'getPeople', 'XPlanner::Person');
92             }
93              
94              
95             sub projects {
96             my $self = shift;
97              
98             return $self->_map_from_soap('name', 'getProjects', 'XPlanner::Project');
99             }
100              
101              
102             =head1 AUTHOR
103              
104             Michael G Schwern
105              
106              
107             =head1 COPYRIGHT
108              
109             Copyright 2004 by Michael G Schwern Eschwern@pobox.comE.
110              
111             This program is free software; you can redistribute it and/or
112             modify it under the same terms as Perl itself.
113              
114             See F
115              
116              
117             =head1 HISTORY
118              
119             Authored for Grant Street Group (grantstreet.com)
120              
121             Based on the XPlanner Perl SOAP examples available here
122             http://cvs.sourceforge.net/viewcvs.py/xplanner/xplanner/doc/soap-examples/perl/xplanner.pl?view=markup
123              
124             =cut
125              
126             1;