File Coverage

blib/lib/WWW/WikiSpaces.pm
Criterion Covered Total %
statement 9 24 37.5
branch n/a
condition n/a
subroutine 3 5 60.0
pod 0 2 0.0
total 12 31 38.7


line stmt bran cond sub pod time code
1             package WWW::WikiSpaces;
2              
3 1     1   247169 use strict;
  1         6  
  1         217  
4 1     1   12 use warnings;
  1         4  
  1         59  
5 1     1   312661 use WWW::Mechanize;
  1         271473  
  1         400  
6              
7             require Exporter;
8             our @ISA = qw(Exporter);
9              
10             our %EXPORT_TAGS = ( 'all' => [ qw(
11              
12             ) ] );
13              
14             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
15              
16             our @EXPORT = qw(post);
17              
18             our $VERSION = '0.01';
19              
20             sub new() {
21 0     0 0   my ($class, $home, $user, $pass) = @_;
22 0           my $self = {
23             mech => WWW::Mechanize->new(agent => 'Windows IE 6', cookie_jar => {}),
24             home => $home,
25             user => $user,
26             pass => $pass
27             };
28            
29 0           $self->{mech}->get('http://www.wikispaces.com/');
30 0           $self->{mech}->follow_link(url => 'http://www.wikispaces.com/site/signin');
31 0           $self->{mech}->submit_form(
32             form_number => 2,
33             fields => {
34             username => $self->{user},
35             password => $self->{pass},
36             },
37             button => 'go');
38            
39 0           bless $self, $class;
40 0           return $self;
41             };
42              
43             sub post($$) {
44 0     0 0   my ($self, $title, $text) = @_;
45            
46             # go to input title page for new post
47             #$self->{mech}->get('http://' . $self->{home} . '.wikispaces.com/');
48 0           $self->{mech}->get('http://' . $self->{home} . '.wikispaces.com/space/page');
49              
50             # fill title
51 0           $self->{mech}->form('newpage');
52 0           $self->{mech}->set_fields(page => $title);
53 0           $self->{mech}->click();
54              
55             # fill post
56 0           $self->{mech}->form('rte');
57 0           $self->{mech}->set_fields(WikispacesEditorContent => $text, comment => '', tagInput => '');
58 0           $self->{mech}->click_button(value => 'Save');
59             };
60              
61             1;
62              
63             __END__