| 1 | package ExtUtils::MakeMaker::META_MERGE::GitHub; | ||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | our $VERSION = '0.03'; | |||||||||
| 6 | 1 | 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 | ▶ | my $this = shift; | ||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 58 | 1 | ▶ | my $class = ref($this) ? ref($this) : $this; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 1 | my $self = {@_}; | |||||||||
| 60 | 1 | bless $self, $class; | |||||||||
| 61 | 1 | 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 | ▶ | my $self = shift; | ||||||||
|
Subroutine
META_MERGE: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 74 | return ( | ||||||||||
| 75 | 1 | 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 | ▶ | my $self = shift; | ||||||||
|
Subroutine
owner: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 102 | 6 | ▶ | $self->{'owner'} = shift if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 103 | 6 | ▶ | die("Error: $PACKAGE property owner is required") unless $self->{'owner'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 104 | 6 | 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 | ▶ | my $self = shift; | ||||||||
|
Subroutine
repo: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 115 | 6 | ▶ | $self->{'repo'} = shift if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 116 | 6 | ▶ | die("Error: $PACKAGE property repo is required") unless $self->{'repo'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 117 | 6 | 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 | ▶ | my $self = shift; | ||||||||
|
Subroutine
version: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 130 | 2 | ▶ | $self->{'version'} = shift if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 131 | 2 | ▶ | $self->{'version'} = 2 unless $self->{'version'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 132 | 2 | 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 | ▶ | my $self = shift; | ||||||||
|
Subroutine
type: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||
| 146 | 1 | ▶ | $self->{'type'} = shift if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 147 | 1 | ▶ | $self->{'type'} = 'git' unless $self->{'type'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 148 | 1 | 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 | ▶ | my $self = shift; | ||||||||
|
Subroutine
base_url: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 161 | 4 | ▶ | $self->{'base_url'} = shift if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 162 | 4 | ▶ | $self->{'base_url'} = 'https://github.com' unless $self->{'base_url'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 163 | 4 | 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 | ▶ | my $self = shift; | ||||||||
|
Subroutine
base_ssh: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 176 | 2 | ▶ | $self->{'base_ssh'} = shift if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 177 | 2 | ▶ | $self->{'base_ssh'} = 'git@github.com' unless $self->{'base_ssh'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 178 | 2 | return $self->{'base_ssh'}; | |||||||||
| 179 | } | ||||||||||
| 180 | |||||||||||
| 181 | =head1 SEE ALSO | ||||||||||
| 182 | |||||||||||
| 183 | L<ExtUtils::MakeMaker> | ||||||||||
| 184 | |||||||||||
| 185 | L<https://github.com/metacpan/metacpan-web/issues/2408> | ||||||||||
| 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 | 1; | |||||||||