blib/lib/Module/Setup/Plugin/Site/GitHub.pm

filter: Statementstmt 87.3% 55 / 63 Branchbran 56.2% 18 / 32 Conditioncond 57.1% 4 / 7 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 88.8% 8 / 9 Podpod 66.6% 2 / 3 totaltotal 74.5% 88 / 118 CC 20 SCAR 25.9
CC
20
Cov
75%
finalize_create_skeleton
21.3
before_dump_config
5.3
_create_repository
2.0
CRAP 13.4
« blib/lib/Module/Setup/Devel.pm ↑ Summary blib/lib/Module/Setup/Flavor/SelectVC.pm »
1 package Module::Setup::Plugin::Site::GitHub;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use base 'Module::Setup::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶sub register {
Subroutine register: called CC=1 SCAR=0.0
Pod undocumented
9 3 my($self, ) = @_;
10 3 $self->add_trigger( before_dump_config => \&before_dump_config );
11 3 $self->add_trigger( finalize_create_skeleton => \&finalize_create_skeleton );
12 }
13  
14 1 ▶sub before_dump_config {
Subroutine before_dump_config: called CC=5 SCAR=16.7
Pod documented
15 1 my($self, $config) = @_;
16  
17 1 my %modules = (
18 readme_from => 'Module::Install::ReadmeFromPod',
19 readme_markdown_from => 'Module::Install::ReadmeMarkdownFromPod',
20 readme_pod_from => 'Module::Install::ReadmePodFromPod',
21 githubmeta => 'Module::Install::GithubMeta',
22 );
23  
24 1 ▶ while (my($name, $module) = each %modules) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %modules) 4 1 5
25 4 ▶ my $version = eval "require $module; 'installed '.\$$module\::VERSION;" || 'not installed';
Condition50%1/2
eval "require $module; 'installed '.\$${module}::VERSION;" || 'not installed'
l!l
04
MC/DC0%0/1
eval "require $module; 'installed '.\$${module}::VERSION;" || 'not installed'
eval "require $module; 'installed '.\$${module}::VERSION;"
Truth table50%1/2
A
A= eval "require $module; 'installed '.\$${module}::VERSION;"
Aresult
11
00
26 4 $config->{$name} = 0;
27 4 ▶ if ($self->dialog("use $name? (depend $module, $version [Yn] ", 'y') =~ /[Yy]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->dialog("use $name? (depend $module, $version [Yn] ", "y") =~ /[Yy]/) 0 4 4
28 0 $config->{$name} = 1;
29 }
30 }
31  
32 1 ▶ $config->{github_format} ||= 'p5-%s';
Condition50%1/2
$config->{"github_format"} ||= "p5-%s"
l!l
01
MC/DC0%0/1
$config->{"github_format"} ||= "p5-%s"
$config->{"github_format"}
Truth table50%1/2
A
A= $config->{"github_format"}
Aresult
11
00
33 1 $config->{github_format} = $self->dialog("github repository name format: ", $config->{github_format});
34 }
35  
36 # run github developer api
37 2 ▶sub finalize_create_skeleton {
Subroutine finalize_create_skeleton: called CC=16 SCAR=30.6
Pod documented
38 2 my $self = shift;
39 2 my $user = $self->shell('git config --get github.user');
40 2 chomp $user;
41 2 my $token = $self->shell('git config --get github.token');
42 2 chomp $token;
43 2 ▶ unless ($user && $token) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($user and $token) 1 1 2
Condition66%2/3
$user and $token
!ll&&!rl&&r
101
MC/DC50%1/2
$user and $token
$user $token
Truth table66%2/3
A and B
A= $userB= $token
ABresult
0X0
100
111
44 1 $self->log("set the github.token And github.user for git config if you wants the create github repository.");
45 1 return;
46 }
47  
48 1 ▶ if ($self->dialog("create GitHub repository? [Yn] ", 'y') =~ /[Yy]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->dialog("create GitHub repository? [Yn] ", "y") =~ /[Yy]/) 1 0 1
49 # create repository
50 1 my $name = sprintf $self->config->{github_format}, $self->distribute->dist_name;
51 1 $name = $self->dialog("github repository name: ", $name);
52  
53 1 my $description = 'Perl Module of ' . $self->distribute->module;
54 1 $description = $self->dialog("github repository description: ", $description);
55  
56 1 my $homepage = '';
57 1 $homepage = $self->dialog("github repository homepage: ", $homepage);
58  
59 1 my $public = 1;
60 1 ▶ if ($self->dialog("create private repository? [yN] ", 'n') =~ /[Yy]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->dialog("create private repository? [yN] ", "n") =~ /[Yy]/) 0 1 1
61 0 $public = 0;
62 }
63  
64 1 ▶ unless (_create_repository(
Branch: 1 branch
BranchTrueFalseTotal
unless (_create_repository("login", $user, "token", $token, "name", $name, "description", $description, "homepage", $homepage, "public", $public)) 0 1 1
65 login => $user,
66 token => $token,
67 name => $name,
68 description => $description,
69 homepage => $homepage,
70 public => $public,
71 )) {
72 0 $self->log('can not created on GitHub');
73 0 return;
74 }
75  
76 1 ▶ !$self->system('perl', 'Makefile.PL') or die $?;
Branch: 1 branch
BranchTrueFalseTotal
$self->system("perl", "Makefile.PL") and die $? 0 1 1
77 1 ▶ !$self->system('make', 'test') or die $?;
Branch: 1 branch
BranchTrueFalseTotal
$self->system("make", "test") and die $? 0 1 1
78 1 ▶ !$self->system('make', 'distclean') or die $?;
Branch: 1 branch
BranchTrueFalseTotal
$self->system("make", "distclean") and die $? 0 1 1
79 1 ▶ unless (-d '.git') {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d ".git") 1 0 1
80 1 ▶ !$self->system('git', 'init') or die $?;
Branch: 1 branch
BranchTrueFalseTotal
$self->system("git", "init") and die $? 0 1 1
81 1 ▶ !$self->system('git', 'add', '.') or die $?;
Branch: 1 branch
BranchTrueFalseTotal
$self->system("git", "add", ".") and die $? 0 1 1
82 1 ▶ !$self->system('git', 'commit', '-m', 'initial commit') or die $?;
Branch: 1 branch
BranchTrueFalseTotal
$self->system("git", "commit", "-m", "initial commit") and die $? 0 1 1
83 }
84 1 ▶ !$self->system('git', 'remote', 'add', 'origin', "git\@github.com:${user}/${name}.git") or die $?;
Branch: 1 branch
BranchTrueFalseTotal
$self->system("git", "remote", "add", "origin", "git\@github.com:$user/$name.git") and die $? 0 1 1
85  
86 1 ▶ if ($self->dialog("try git push to GitHub? [Yn] ", 'y') =~ /[Yy]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->dialog("try git push to GitHub? [Yn] ", "y") =~ /[Yy]/) 1 0 1
87 1 ▶ !$self->system('git', 'push', 'origin', 'master') or die $?;
Branch: 1 branch
BranchTrueFalseTotal
not $self->system("git", "push", "origin", "master") or die $? 1 0 1
88 }
89 }
90 }
91  
92 0 ▶sub _create_repository {
Subroutine _create_repository: not called CC=1 SCAR=6.9
93 0 my %args = @_;
94 0 my $ua = LWP::UserAgent->new(
95 agent => join('/', __PACKAGE__, $Module::Setup::VERSION),
96 cookie_jar => +{},
97 );
98 0 my $res = $ua->post(
99 'https://github.com/api/v2/json/repos/create' => \%args
100 );
101 0 $res->is_success;
102 }
103  
104 2 1;
« blib/lib/Module/Setup/Devel.pm ↑ Summary blib/lib/Module/Setup/Flavor/SelectVC.pm »