| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Net::Twitter::RandomUpdate; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 2285 | use strict; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 48 |  | 
| 4 | 1 |  |  | 1 |  | 7 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 35 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 1 |  |  | 1 |  | 409 | use Net::Twitter; | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | our $VERSION = join( '.', 1, map{ $_ - 53 } ( '$Rev: 59 $' =~ /(\d+)/g ) ); | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | my $quotes = [ | 
| 11 |  |  |  |  |  |  | 'How to store your baby walker: First, remove baby.', | 
| 12 |  |  |  |  |  |  | 'I get to go to lots of overseas places, like Canada.', | 
| 13 |  |  |  |  |  |  | 'The team has come along slow but fast.', | 
| 14 |  |  |  |  |  |  | 'Most cars on our roads have only one occupant, usually the driver.', | 
| 15 |  |  |  |  |  |  | 'Football players win football games.', | 
| 16 |  |  |  |  |  |  | 'Most lies about blondes are false.', | 
| 17 |  |  |  |  |  |  | 'I love California, I practically grew up in Phoenix.', | 
| 18 |  |  |  |  |  |  | 'Strangely, in slow motion replay, the ball seemed to hang in the air for even longer.', | 
| 19 |  |  |  |  |  |  | 'We\'re just physically not physical enough.', | 
| 20 |  |  |  |  |  |  | 'The world is more like it is now then it ever has before.', | 
| 21 |  |  |  |  |  |  | 'I cannot tell you how grateful I am -- I am filled with humidity.', | 
| 22 |  |  |  |  |  |  | 'I have a God-given talent. I got it from my dad.', | 
| 23 |  |  |  |  |  |  | 'Traditionally, most of Australia\'s imports come from overseas.', | 
| 24 |  |  |  |  |  |  | ]; | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | sub new { | 
| 27 |  |  |  |  |  |  | my ( $class, $notes ) = @_; | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | return bless( $notes || $quotes, $class ); | 
| 30 |  |  |  |  |  |  | } | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | { | 
| 33 |  |  |  |  |  |  | my $user; | 
| 34 |  |  |  |  |  |  | sub username { | 
| 35 |  |  |  |  |  |  | return $user = pop; | 
| 36 |  |  |  |  |  |  | } | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | my $pass; | 
| 39 |  |  |  |  |  |  | sub password { | 
| 40 |  |  |  |  |  |  | return $pass = pop; | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | my $reg = .05; | 
| 44 |  |  |  |  |  |  | sub regularity { | 
| 45 |  |  |  |  |  |  | return $reg = pop; | 
| 46 |  |  |  |  |  |  | } | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | sub tweet { | 
| 49 |  |  |  |  |  |  | return if ( rand() > $reg ); | 
| 50 |  |  |  |  |  |  | my ($self) = @_; | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | my $tweet = Net::Twitter->new( | 
| 53 |  |  |  |  |  |  | 'username' => $user, | 
| 54 |  |  |  |  |  |  | 'password' => $pass, | 
| 55 |  |  |  |  |  |  | 'source'   => 'randomupdate', | 
| 56 |  |  |  |  |  |  | ); | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | my @tweets = @$self; | 
| 59 |  |  |  |  |  |  | $tweet->update( $tweets[ int( rand( @tweets ) ) ] ); | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | return; | 
| 62 |  |  |  |  |  |  | } | 
| 63 |  |  |  |  |  |  | } | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | 1; | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | __END__ | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | =head1 NAME | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | Net::Twitter::RandomUpdate - Make people think you're paying attention to Twitter | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | Will submit a random tweet at generally random times with some canned quotes or | 
| 76 |  |  |  |  |  |  | quotes defined by the implementor. | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | =head1 METHODS | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | =head2 new( [ optional_quotes ] ); | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | Will return a new object. You can pass an OPTIONAL reference to an array with | 
| 83 |  |  |  |  |  |  | a list of tweets the module will choose from.  If ignored, the following will | 
| 84 |  |  |  |  |  |  | be used: | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | my $quotes = [ | 
| 87 |  |  |  |  |  |  | 'How to store your baby walker: First, remove baby.', | 
| 88 |  |  |  |  |  |  | 'I get to go to lots of overseas places, like Canada.', | 
| 89 |  |  |  |  |  |  | 'The team has come along slow but fast.', | 
| 90 |  |  |  |  |  |  | 'Most cars on our roads have only one occupant, usually the driver.', | 
| 91 |  |  |  |  |  |  | 'Football players win football games.', | 
| 92 |  |  |  |  |  |  | 'Most lies about blondes are false.', | 
| 93 |  |  |  |  |  |  | 'I love California, I practically grew up in Phoenix.', | 
| 94 |  |  |  |  |  |  | 'Strangely, in slow motion replay, the ball seemed to hang in the air for even longer.', | 
| 95 |  |  |  |  |  |  | 'We\'re just physically not physical enough.', | 
| 96 |  |  |  |  |  |  | 'The world is more like it is now then it ever has before.', | 
| 97 |  |  |  |  |  |  | 'I cannot tell you how grateful I am -- I am filled with humidity.', | 
| 98 |  |  |  |  |  |  | 'I have a God-given talent. I got it from my dad.', | 
| 99 |  |  |  |  |  |  | 'Traditionally, most of Australia\'s imports come from overseas.', | 
| 100 |  |  |  |  |  |  | ]; | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | =head2 tweet | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | Will send a tweet to the specified account if it falls within the random | 
| 105 |  |  |  |  |  |  | regularity selection. | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | =head1 ATTRIBUTES | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | =head2 regularity | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  | Default: .05 (will only tweet 5% of the time) | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | An integer <= 1 and >= 0, indicating the percentage of times you want | 
| 114 |  |  |  |  |  |  | the module to tweet.  Good for use in a crontab, for example. | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | =head2 username | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  | The username of the account. | 
| 119 |  |  |  |  |  |  |  | 
| 120 |  |  |  |  |  |  | =head2 password | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | The password of the account. | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | =head1 EXAMPLES | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | use Net::Twitter::RandomUpdate; | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | # Use the default tweet-set send a tweet 100% of the time | 
| 129 |  |  |  |  |  |  | my $rand = Net::Twitter::RandomUpdate->new(); | 
| 130 |  |  |  |  |  |  | $rand->regularity(1); | 
| 131 |  |  |  |  |  |  | $rand->password('pass'); | 
| 132 |  |  |  |  |  |  | $rand->username('user'); | 
| 133 |  |  |  |  |  |  | $rand->tweet(); | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  | # Use self-defined tweet-set, send a tweet 50% of the time | 
| 136 |  |  |  |  |  |  | my $rand = Net::Twitter::RandomUpdate->new( [ qw( hi ) ] ); | 
| 137 |  |  |  |  |  |  | $rand->regularity(.5); | 
| 138 |  |  |  |  |  |  | $rand->password('pass'); | 
| 139 |  |  |  |  |  |  | $rand->username('user'); | 
| 140 |  |  |  |  |  |  | $rand->tweet(); | 
| 141 |  |  |  |  |  |  |  | 
| 142 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 143 |  |  |  |  |  |  |  | 
| 144 |  |  |  |  |  |  | =over | 
| 145 |  |  |  |  |  |  |  | 
| 146 |  |  |  |  |  |  | =item L<Net::Twitter> | 
| 147 |  |  |  |  |  |  |  | 
| 148 |  |  |  |  |  |  | =back | 
| 149 |  |  |  |  |  |  |  | 
| 150 |  |  |  |  |  |  | =head1 AUTHOR | 
| 151 |  |  |  |  |  |  |  | 
| 152 |  |  |  |  |  |  | Trevor Hall, E<lt>wazzuteke@cpan.orgE<gt> | 
| 153 |  |  |  |  |  |  |  | 
| 154 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 155 |  |  |  |  |  |  |  | 
| 156 |  |  |  |  |  |  | Copyright (C) 2009 by Trevor Hall | 
| 157 |  |  |  |  |  |  |  | 
| 158 |  |  |  |  |  |  | This library is free software; you can redistribute it and/or modify | 
| 159 |  |  |  |  |  |  | it under the same terms as Perl itself. | 
| 160 |  |  |  |  |  |  |  | 
| 161 |  |  |  |  |  |  | =cut | 
| 162 |  |  |  |  |  |  |  |