Nopaste/Service/Pastie.pm

filter: Statementstmt 46.4% 13 / 28 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 4 / 6 Podpod 100% 3 / 3 totaltotal 41.6% 20 / 48 CC 5 SCAR 20.3
CC
5
Cov
35%
fill_form
12.0
return
12.0
BEGIN
1.0
CRAP 7.6
« Nopaste/Service/PastebinCom.pm ↑ Summary Nopaste/Command.pm »
1 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package App::Nopaste::Service::Pastie;
4 # ABSTRACT: Service provider for Pastie - pastie.org
5  
6 2 our $VERSION = '1.013';
7  
8 2 ▶use parent 'App::Nopaste::Service';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 my %languages = (
11 "bash" => "13",
12 "c#" => "20",
13 "c/c++" => "7",
14 "css" => "8",
15 "diff" => "5",
16 "go" => "21",
17 "html (erb / rails)" => "12",
18 "html / xml" => "11",
19 "java" => "9",
20 "javascript" => "10",
21 "objective-c/c++" => "1",
22 "perl" => "18",
23 "php" => "15",
24 "plain text" => "6",
25 "python" => "16",
26 "ruby" => "3",
27 "ruby on rails" => "4",
28 "sql" => "14",
29 # hidden
30 "apache" => "22",
31 "clojure" => "38",
32 "d" => "26",
33 "erlang" => "27",
34 "fortran" => "28",
35 "haskell" => "29",
36 "ini" => "35",
37 "io" => "24",
38 "lisp" => "25",
39 "lua" => "23",
40 "makefile" => "31",
41 "nu" => "36",
42 "pascal" => "17",
43 "puppet" => "39",
44 "scala" => "32",
45 "scheme" => "33",
46 "smarty" => "34",
47 "tex" => "37",
48 # aliases
49 "sh" => "13",
50 "c" => "7",
51 "c++" => "7",
52 "objective-C" => "1",
53 "objective-C++" => "1",
54 "plain" => "6",
55 "raw" => "6",
56 "rails" => "4",
57 "html" => "11",
58 "xml" => "11",
59 "js" => "10",
60 "make" => "31",
61 );
62  
63 1 ▶sub uri { 'http://pastie.org/' }
Subroutine uri: called CC=1 SCAR=0.0
Pod documented
64  
65 0 ▶sub fill_form {
Subroutine fill_form: not called CC=3 SCAR=24.8
Pod documented
66 0 my $self = shift;
67 0 my $mech = shift;
68 0 my %args = @_;
69  
70 0 my $lang_id = $languages{"plain text"};
71 $lang_id = $languages{lc($args{lang})}
72 0 ▶ if (exists $args{lang} && exists $languages{lc($args{lang})});
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"lang"} and exists $languages{lc $args{"lang"}} 0 0 0
Condition0%0/3
exists $args{"lang"} and exists $languages{lc $args{"lang"}}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $args{"lang"} and exists $languages{lc $args{"lang"}}
exists $args{"lang"} exists $languages{lc $args{"lang"}}
Truth table0%0/3
A and B
A= exists $args{"lang"}B= exists $languages{lc $args{"lang"}}
ABresult
0X0
100
111
73  
74 $mech->submit_form(
75 fields => {
76 "paste[body]" => $args{text},
77 "paste[authorization]" => 'burger', # set with JS to avoid bots
78 "paste[restricted]" => $args{private},
79 0 "paste[parser_id]" => $lang_id,
80 },
81 );
82 }
83  
84 0 ▶sub return {
Subroutine return: not called CC=3 SCAR=24.8
Pod documented
85 0 my $self = shift;
86 0 my $mech = shift;
87  
88 0 my $prefix ='';
89 0 my ($id) = $mech->title =~ /\#(\d+)/;
90 0 ▶ if (!$id) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($id) 0 0 0
91 0 ($id) = $mech->content =~ m{http://pastie.org/\d+/wrap\?key=([a-z0-9]+)};
92 0 $prefix = 'private/';
93 }
94 0 ▶ return (0, "Could not construct paste link.") if !$id;
Branch: 1 branch
BranchTrueFalseTotal
unless $id 0 0 0
95 0 return (1, "http://pastie.org/$prefix$id");
96 }
97  
98 2 1;
99  
100 __END__
« Nopaste/Service/PastebinCom.pm ↑ Summary Nopaste/Command.pm »