| 1 | package App::Nopaste::Service::Hpaste; | ||||||||||||
| 2 | |||||||||||||
| 3 | # Created: 西元2011年02月15日 19時51分40秒 | ||||||||||||
| 4 | # Last Edit: 2013 Nov 19, 05:15:30 PM | ||||||||||||
| 5 | # $Id$ | ||||||||||||
| 6 | |||||||||||||
| 7 | =head1 NAME | ||||||||||||
| 8 | |||||||||||||
| 9 | Hpaste.pm - Paste to http://hpaste.org, the Haskell paste site | ||||||||||||
| 10 | |||||||||||||
| 11 | =cut | ||||||||||||
| 12 | |||||||||||||
| 13 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | |||||||||||||
| 16 | =head1 SYNOPSIS | ||||||||||||
| 17 | |||||||||||||
| 18 | nopaste -s Hpaste -l haskell -n "Dr Bean" -d "Category theory" paste.txt | ||||||||||||
| 19 | |||||||||||||
| 20 | =cut | ||||||||||||
| 21 | |||||||||||||
| 22 | =head1 DESCRIPTION | ||||||||||||
| 23 | |||||||||||||
| 24 | hpaste requires a title, an author, and the paste. The default language is 'haskell.' No, it's 'perl', but it should be 'haskell'. | ||||||||||||
| 25 | |||||||||||||
| 26 | =cut | ||||||||||||
| 27 | |||||||||||||
| 28 | 1 | ▶ | use base 'App::Nopaste::Service'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 29 | |||||||||||||
| 30 | 1 | my $code; | |||||||||||
| 31 | 1 | my %Langs = ( | |||||||||||
| 32 | "" => "", | ||||||||||||
| 33 | "Haskell" => "haskell", | ||||||||||||
| 34 | "Agda" => "agda", | ||||||||||||
| 35 | "Bash/shell" => "bash", | ||||||||||||
| 36 | "C" => "c", | ||||||||||||
| 37 | "C++" => "cpp", | ||||||||||||
| 38 | "Common Lisp" => "lisp", | ||||||||||||
| 39 | "D" => "d", | ||||||||||||
| 40 | "Diff" => "diff", | ||||||||||||
| 41 | "Elisp" => "elisp", | ||||||||||||
| 42 | "Erlang" => "erlang", | ||||||||||||
| 43 | "Java" => "java", | ||||||||||||
| 44 | "JavaScript" => "javascript", | ||||||||||||
| 45 | "Literate Haskell" => "literatehaskell", | ||||||||||||
| 46 | "Lua" => "lua", | ||||||||||||
| 47 | "Objective-C" => "objectivec", | ||||||||||||
| 48 | "OCaml" => "ocaml", | ||||||||||||
| 49 | "Perl" => "perl", | ||||||||||||
| 50 | "Prolog" => "prolog", | ||||||||||||
| 51 | "Python" => "python", | ||||||||||||
| 52 | "Ruby" => "ruby", | ||||||||||||
| 53 | "Scala" => "scala", | ||||||||||||
| 54 | "SQL" => "sql", | ||||||||||||
| 55 | "TeX" => "tex", | ||||||||||||
| 56 | ); | ||||||||||||
| 57 | 1 | my %langs = map { lc($_) => $Langs{$_} } keys %Langs; | |||||||||||
| 58 | 1 | $code->{lang} = \%langs; | |||||||||||
| 59 | |||||||||||||
| 60 | $code->{chan} = { | ||||||||||||
| 61 | 1 | "" => "", | |||||||||||
| 62 | "haskell" => "#haskell", | ||||||||||||
| 63 | "xmonad" => "#xmonad", | ||||||||||||
| 64 | "javascript" => "#javascript", | ||||||||||||
| 65 | "python" => "#python", | ||||||||||||
| 66 | "ruby" => "#ruby", | ||||||||||||
| 67 | "lisp" => "#lisp", | ||||||||||||
| 68 | "scala" => "#scala", | ||||||||||||
| 69 | "agda" => "#agda", | ||||||||||||
| 70 | "coffeescript" => "#coffeescript", | ||||||||||||
| 71 | "arc" => "#arc", | ||||||||||||
| 72 | "c" => "##c", | ||||||||||||
| 73 | "clojure" => "#clojure", | ||||||||||||
| 74 | "scheme" => "#scheme", | ||||||||||||
| 75 | "prolog" => "##prolog", | ||||||||||||
| 76 | "emacs" => "#emacs", | ||||||||||||
| 77 | "hpaste" => "#hpaste", | ||||||||||||
| 78 | }; | ||||||||||||
| 79 | |||||||||||||
| 80 | 0 | ▶ | sub uri { "http://lpaste.net/" } | ||||||||||
|
Subroutine
uri: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 81 | |||||||||||||
| 82 | 0 | ▶ | sub fill_form { | ||||||||||
|
Subroutine
fill_form: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||
| 83 | 0 | my $self = shift; | |||||||||||
| 84 | 0 | my $mech = shift; | |||||||||||
| 85 | 0 | my %args = @_; | |||||||||||
| 86 | 0 | my $title; | |||||||||||
| 87 | 0 | ▶ | if ( $args{desc} ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 88 | 0 | $title = $args{desc}; | |||||||||||
| 89 | } | ||||||||||||
| 90 | else { | ||||||||||||
| 91 | 0 | my ($line, $remains) = split "\n", $args{text}; | |||||||||||
| 92 | 0 | $title = substr( $line, 0, 30 ); | |||||||||||
| 93 | } | ||||||||||||
| 94 | 0 | ▶ | my $lang = $code->{lang}->{ (lc $args{lang}) || "haskell" }; | ||||||||||
|
Condition0%0/2
lc $args{'lang'} || 'haskell'
MC/DC0%0/1
lc $args{'lang'} || 'haskell'
lc $args{'lang'}
Truth table0%0/2
A
A= lc $args{'lang'}
| |||||||||||||
| 95 | 0 | ▶ | my $chan = $code->{chan}->{ $args{chan} || "" }; | ||||||||||
|
Condition0%0/2
$args{'chan'} || ''
MC/DC0%0/1
$args{'chan'} || ''
$args{'chan'}
Truth table0%0/2
A
A= $args{'chan'}
| |||||||||||||
| 96 | |||||||||||||
| 97 | 0 | $mech->field( 'title' => $title ); | |||||||||||
| 98 | 0 | $mech->field( 'author' => $args{nick} ); | |||||||||||
| 99 | 0 | $mech->field( 'language' => $lang ); | |||||||||||
| 100 | 0 | $mech->field( 'channel' => $chan ); | |||||||||||
| 101 | 0 | $mech->field( 'paste' => $args{text} ); | |||||||||||
| 102 | 0 | $mech->click(); | |||||||||||
| 103 | } | ||||||||||||
| 104 | |||||||||||||
| 105 | 0 | ▶ | sub return { | ||||||||||
|
Subroutine
return: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 106 | 0 | my $self = shift; | |||||||||||
| 107 | 0 | my $mech = shift; | |||||||||||
| 108 | |||||||||||||
| 109 | 0 | my $link = $mech->uri(); | |||||||||||
| 110 | |||||||||||||
| 111 | 0 | ▶ | return (0, "No link to paste.") unless $link; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 112 | 0 | return (1, $link); | |||||||||||
| 113 | } | ||||||||||||
| 114 | |||||||||||||
| 115 | 1 | 1; | |||||||||||
| 116 | |||||||||||||
| 117 | |||||||||||||
| 118 | |||||||||||||
| 119 | =head1 AUTHOR | ||||||||||||
| 120 | |||||||||||||
| 121 | Dr Bean C<< <drbean at cpan, then a dot, (.), and org> >> | ||||||||||||
| 122 | |||||||||||||
| 123 | =head1 BUGS | ||||||||||||
| 124 | |||||||||||||
| 125 | Please report any bugs or feature requests to | ||||||||||||
| 126 | C<bug-/home/drbean/hpaste/lib/App/Nopaste/ServiceHpaste.pm at rt.cpan.org>, or through the web interface at | ||||||||||||
| 127 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=/home/drbean/hpaste/lib/App/Nopaste/ServiceHpaste.pm>. | ||||||||||||
| 128 | I will be notified, and then you'll automatically be notified of progress on | ||||||||||||
| 129 | your bug as I make changes. | ||||||||||||
| 130 | |||||||||||||
| 131 | =head1 SUPPORT | ||||||||||||
| 132 | |||||||||||||
| 133 | You can find documentation for this module with the perldoc command. | ||||||||||||
| 134 | |||||||||||||
| 135 | perldoc /home/drbean/hpaste/lib/App/Nopaste/ServiceHpaste.pm | ||||||||||||
| 136 | |||||||||||||
| 137 | You can also look for information at: | ||||||||||||
| 138 | |||||||||||||
| 139 | =over 4 | ||||||||||||
| 140 | |||||||||||||
| 141 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||
| 142 | |||||||||||||
| 143 | L<http://annocpan.org/dist//home/drbean/hpaste/lib/App/Nopaste/ServiceHpaste.pm> | ||||||||||||
| 144 | |||||||||||||
| 145 | =item * CPAN Ratings | ||||||||||||
| 146 | |||||||||||||
| 147 | L<http://cpanratings.perl.org/d//home/drbean/hpaste/lib/App/Nopaste/ServiceHpaste.pm> | ||||||||||||
| 148 | |||||||||||||
| 149 | =item * RT: CPAN's request tracker | ||||||||||||
| 150 | |||||||||||||
| 151 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=/home/drbean/hpaste/lib/App/Nopaste/ServiceHpaste.pm> | ||||||||||||
| 152 | |||||||||||||
| 153 | =item * Search CPAN | ||||||||||||
| 154 | |||||||||||||
| 155 | L<http://search.cpan.org/dist//home/drbean/hpaste/lib/App/Nopaste/ServiceHpaste.pm> | ||||||||||||
| 156 | |||||||||||||
| 157 | =back | ||||||||||||
| 158 | |||||||||||||
| 159 | =head1 ACKNOWLEDGEMENTS | ||||||||||||
| 160 | |||||||||||||
| 161 | =head1 COPYRIGHT & LICENSE | ||||||||||||
| 162 | |||||||||||||
| 163 | Copyright 2011 Dr Bean, all rights reserved. | ||||||||||||
| 164 | |||||||||||||
| 165 | This program is free software; you can redistribute it and/or modify it | ||||||||||||
| 166 | under the same terms as Perl itself. | ||||||||||||
| 167 | |||||||||||||
| 168 | =cut | ||||||||||||
| 169 | |||||||||||||
| 170 | 1 | 1; # End of /home/drbean/hpaste/lib/App/Nopaste/ServiceHpaste.pm | |||||||||||
| 171 | |||||||||||||
| 172 | # vim: set ts=8 sts=4 sw=4 noet: | ||||||||||||
| 173 | |||||||||||||