Name
GitHub::Crud - Create, Read, Update, Delete files on GitHub.
Synopsis
Create, Read, Update, Delete files on GitHub as described at:
https://developer.github.com/v3/repos/contents/#update-a-file
Prerequisites
sudo apt-get install curl
Example
use GitHub::Crud;
{my $g = GitHub::Crud::new();
$g->userid = "philiprbrenan";
$g->repository = "horses";
$g->gitFile = "test4.html";
$g->personalAccessToken = $pat;
my $d = dateTimeStamp."\n";
say STDERR
"\n Write : \n\n", dump($g->writeData($d x 100)),
"\n\n Read 1: \n\n", dump($g->readData->content),
"\n\n Delete: \n\n", dump($g->deleteData),
"\n\n Read 2: \n\n", dump($g->readData);
}
Creates a file by writing 100 lines of data to it, reads the file to get its attributes and contents, deletes the file, then tries to read the deleted file.
Parameters
The following parameters are available:
branch
Optional: branch name (you should create this branch manually first) or omit it for the default branch which is usually 'master'
gitFile
REQUIRED: File name on GitHub - this name can contain /
personalAccessToken
REQUIRED: a personal access token with scope "public_repo" as generated on page:
https://github.com/settings/tokens
You can delete this token on the same page to maintain the security of your GitHub account.
repository
REQUIRED: the name of your repository - you should create this repository first, manually
userid
REQUIRED: your user id on GitHub
onFail
Optional: a 𝘀𝘂𝗯 that will be called if a failure is detected, otherwise
Carp::confess
is called to display an error message
Methods available
new()
Create a new GitHub object
readData($gitHub)
Read data from a file on GitHub
Parameter Description
1 $gitHub GitHub object
writeData($gitHub, $data)
Write data into a GitHub file, creating the file if it is not there already
Parameter Description
1 $gitHub GitHub object
2 $data data to be written
deleteData($gitHub)
Delete a file already on GitHub
Parameter Description
1 $gitHub GitHub object
Index
"deleteData($gitHub)" "new()" "readData($gitHub)" "writeData($gitHub, $data)"
Installation
Standard Module::Build process for building and installing modules:
perl Build.PL
./Build
./Build test
./Build install
Author
philiprbrenan@gmail.com
http://www.appaapps.com
Copyright
Copyright (c) 2017 Philip R Brenan.
This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.