blib/lib/WWW/WikiSpaces.pm

filter: Statementstmt 53.1% 17 / 32 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 0.0% 0 / 2 totaltotal 51.2% 20 / 39 CC 1 SCAR 3.4
CC
1
Cov
53%
new
2.0
post
2.0
BEGIN
1.0
CRAP 1.4
↑ Summary
1 package WWW::WikiSpaces;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use WWW::Mechanize;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 require Exporter;
8 1 our @ISA = qw(Exporter);
9  
10 1 our %EXPORT_TAGS = ( 'all' => [ qw(
11  
12 ) ] );
13  
14 1 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
15  
16 1 our @EXPORT = qw(post);
17  
18 1 our $VERSION = '0.01';
19  
20 0 ▶sub new() {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
21 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 $self->{mech}->submit_form(
32 form_number => 2,
33 fields => {
34 username => $self->{user},
35 password => $self->{pass},
36 },
37 0 button => 'go');
38
39 0 bless $self, $class;
40 0 return $self;
41 };
42  
43 0 ▶sub post($$) {
Subroutine post: not called CC=1 SCAR=6.9
Pod undocumented
44 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 1;
62  
63 __END__
↑ Summary