File Coverage

blib/lib/ExtUtils/MakeMaker/META_MERGE/GitHub.pm
Criterion Covered Total %
statement 37 37 100.0
branch 18 26 69.2
condition n/a
subroutine 10 10 100.0
pod 8 8 100.0
total 73 81 90.1


line stmt bran cond sub pod time code
1             package ExtUtils::MakeMaker::META_MERGE::GitHub;
2 1     1   58744 use strict;
  1         2  
  1         24  
3 1     1   4 use warnings;
  1         2  
  1         421  
4              
5             our $VERSION = '0.02';
6             our $PACKAGE = __PACKAGE__;
7              
8             =head1 NAME
9              
10             ExtUtils::MakeMaker::META_MERGE::GitHub - Perl package to generate ExtUtils::MakeMaker META_MERGE for GitHub repositories
11              
12             =head1 SYNOPSIS
13              
14             Run the included script then copy and paste into your Makefile.PL
15              
16             perl-ExtUtils-MakeMaker-META_MERGE-GitHub.pl
17              
18             or
19              
20             perl-ExtUtils-MakeMaker-META_MERGE-GitHub.pl owner repository_name
21              
22             Generate the META_MERGE then copy and paste into your Makefile.PL
23              
24             use ExtUtils::MakeMaker::META_MERGE::GitHub;
25             use Data::Dumper qw{Dumper};
26             my $mm = ExtUtils::MakeMaker::META_MERGE::GitHub->new(owner=>"myowner", repo=>"myrepo");
27             my %META_MERGE = $mm->META_MERGE;
28             print Dumper(\%META_MERGE);
29              
30             Plugin to your Makefile.PL
31              
32             use ExtUtils::MakeMaker;
33             use ExtUtils::MakeMaker::META_MERGE::GitHub;
34             my $mm = ExtUtils::MakeMaker::META_MERGE::GitHub->new(owner=>"myowner", repo=>"myrepo");
35             WriteMakefile(
36             CONFIGURE_REQUIRES => {'ExtUtils::MakeMaker::META_MERGE::GitHub' => 0},
37             $mm->META_MERGE,
38             ...
39             );
40              
41             =head1 DESCRIPTION
42              
43             Generates the META_MERGE key and hash value for a normal GitHub repository.
44              
45             =head1 CONSTRUCTOR
46              
47             my $mm = ExtUtils::MakeMaker::META_MERGE::GitHub->new(
48             owner => "myowner",
49             repo => "myrepo"
50             );
51              
52             =head2 new
53              
54             =cut
55              
56             sub new {
57 1     1 1 74 my $this = shift;
58 1 50       4 my $class = ref($this) ? ref($this) : $this;
59 1         4 my $self = {@_};
60 1         2 bless $self, $class;
61 1         3 return $self;
62             }
63              
64             =head1 METHODS
65              
66             =head2 META_MERGE
67              
68             Returns then META_MERGE key and a hash reference value for a normal git hub repository.
69              
70             =cut
71              
72             sub META_MERGE {
73 1     1 1 2288 my $self = shift;
74             return (
75 1         4 META_MERGE => {
76             'meta-spec' => {version => $self->version},
77             'resources' => {
78             homepage => join('/', $self->base_url, $self->owner, $self->repo),
79             bugtracker => {
80             web => join('/', $self->base_url, $self->owner, $self->repo, 'issues'),
81             },
82             repository => {
83             type => $self->type,
84             url => join('/', join(':', $self->base_ssh, $self->owner), $self->repo . '.git'),
85             web => join('/', $self->base_url, $self->owner, $self->repo . '.git'),
86             },
87             },
88             },
89             );
90             }
91              
92             =head1 PROPERTIES
93              
94             =head2 owner
95              
96             Sets and returns the GitHub account owner login.
97              
98             =cut
99              
100             sub owner {
101 6     6 1 698 my $self = shift;
102 6 100       12 $self->{'owner'} = shift if @_;
103 6 50       11 die("Error: $PACKAGE property owner is required") unless $self->{'owner'};
104 6         17 return $self->{'owner'};
105             }
106              
107             =head2 repo
108              
109             Sets and returns the GitHub repository name.
110              
111             =cut
112              
113             sub repo {
114 6     6 1 9 my $self = shift;
115 6 100       11 $self->{'repo'} = shift if @_;
116 6 50       10 die("Error: $PACKAGE property repo is required") unless $self->{'repo'};
117 6         47 return $self->{'repo'};
118             }
119              
120             =head2 version
121              
122             Meta-Spec Version
123              
124             Default: 2
125              
126             =cut
127              
128             sub version {
129 2     2 1 4 my $self = shift;
130 2 50       6 $self->{'version'} = shift if @_;
131 2 100       8 $self->{'version'} = 2 unless $self->{'version'};
132 2         7 return $self->{'version'};
133              
134             }
135              
136             =head2 type
137              
138             Resource Repository Type
139              
140             Default: git
141              
142             =cut
143              
144             sub type {
145 1     1 1 1 my $self = shift;
146 1 50       15 $self->{'type'} = shift if @_;
147 1 50       4 $self->{'type'} = 'git' unless $self->{'type'};
148 1         5 return $self->{'type'};
149             }
150              
151             =head2 base_url
152              
153             Base URL for web client requests
154              
155             Default: https://github.com
156              
157             =cut
158              
159             sub base_url {
160 4     4 1 6 my $self = shift;
161 4 50       8 $self->{'base_url'} = shift if @_;
162 4 100       8 $self->{'base_url'} = 'https://github.com' unless $self->{'base_url'};
163 4         10 return $self->{'base_url'};
164             }
165              
166             =head2 base_ssh
167              
168             Base URL for ssh client requests
169              
170             Default: git@github.com
171              
172             =cut
173              
174             sub base_ssh {
175 2     2 1 4 my $self = shift;
176 2 50       5 $self->{'base_ssh'} = shift if @_;
177 2 100       6 $self->{'base_ssh'} = 'git@github.com' unless $self->{'base_ssh'};
178 2         5 return $self->{'base_ssh'};
179             }
180              
181             =head1 SEE ALSO
182              
183             L
184              
185             L
186              
187             =head1 AUTHOR
188              
189             Michael R. Davis
190              
191             =head1 COPYRIGHT AND LICENSE
192              
193             Copyright (C) 2022 by Michael R. Davis
194              
195             MIT LICENSE
196              
197             =cut
198              
199             1;