Adding flatpak_repo to the possible fields in applications.

This is done so people can choose between flathub stables or
nightly external repositories.
This commit is contained in:
sergiotarxz 2022-03-24 23:57:09 +01:00
parent ea7c5b7471
commit fb50274fd3
7 changed files with 92 additions and 26 deletions

View File

@ -5,6 +5,8 @@ use v5.30.0;
use strict;
use warnings;
use Data::Dumper;
use Params::ValidationCompiler qw/validation_for/;
use Types::Standard qw/HasMethods InstanceOf Str HashRef/;
@ -42,7 +44,7 @@ use Types::Standard qw/HasMethods InstanceOf Str HashRef/;
INSERT INTO applications
(name, description, url,
developer, price, git_repo,
flatpak_builder_file, verified)
flatpak_builder_file, flatpak_repo, verified)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
RETURNING uuid;
EOF
@ -51,7 +53,8 @@ EOF
$application->name, $application->description,
$application->url, $application->developer->uuid,
$application->price, $application->git_repo,
$application->flatpak_builder_file, $application->verified
$application->flatpak_builder_file, $application->flatpak_repo,
$application->verified
);
my $uuid = $result->{uuid};
my $new_application = $self->recover_by_uuid( uuid => $uuid );
@ -86,7 +89,7 @@ EOF
SELECT uuid, date_creation, name,
description, url, developer,
price, git_repo, flatpak_builder_file,
verified
flatpak_repo, verified
FROM applications
WHERE developer = ?;
EOF
@ -112,7 +115,7 @@ EOF
SELECT uuid, date_creation, name,
description, url, developer,
price, git_repo, flatpak_builder_file,
verified
flatpak_repo, verified
FROM applications
WHERE uuid = ?
EOF
@ -148,6 +151,7 @@ sub _dbh {
return $self->{dbh};
}
1;
=encoding utf8
=head1 NAME

View File

@ -46,13 +46,14 @@ my @migrations = (
price INTEGER NOT NULL,
git_repo TEXT NOT NULL,
flatpak_builder_file TEXT NOT NULL,
flatpak_repo TEXT NOT NULL,
verified BOOL DEFAULT false,
PRIMARY KEY (uuid),
FOREIGN KEY (developer) REFERENCES developers (uuid)
);',
'CREATE TABLE releases (
uuid UUID NOT NULL DEFAULT gen_random_uuid(),
date timestamp DEFAULT NOW(),
date_creation timestamp DEFAULT NOW(),
application UUID NOT NULL,
tag TEXT NOT NULL,
name TEXT NOT NULL,

View File

@ -5,6 +5,7 @@ use strict;
use warnings;
use Data::Dumper;
use Carp qw/cluck/;
use Params::ValidationCompiler qw/validation_for/;
use Types::Standard qw/Str InstanceOf Bool Num HasMethods/;
@ -26,6 +27,7 @@ use DateTime;
price => { type => Num },
git_repo => { type => Str },
flatpak_builder_file => { type => Str },
flatpak_repo => { type => Str },
verified => { type => Bool },
}
);
@ -163,6 +165,20 @@ use DateTime;
}
}
{
my $validator =
validation_for( params => [ { type => Str, optional => 1 } ] );
sub flatpak_repo {
my $self = shift;
if (@_) {
my ($new_flatpak_repo) = $validator->(@_);
$self->{flatpak_repo} = $new_flatpak_repo;
}
return $self->{flatpak_repo};
}
}
{
my $validator =
validation_for( params => [ { type => Bool, optional => 1 } ] );
@ -179,7 +195,7 @@ use DateTime;
{
my $validator =
validation_for( params => [ { type => Str, optional => 1 } ] );
validation_for( params => [ { type => Str, optional => 1 } ] );
sub git_repo {
my $self = shift;
@ -318,6 +334,14 @@ Allows to retrieve and set the application's git_repo.
Allows to retrieve and set the application's flatpak_builder_file.
=head2 flatpak_repo
my $flatpak_repo = $application->flatpak_repo;
$application->flatpak_repo($flatpak_repo);
Allows to retrieve and set the application's flatpak_repo.
=head2 verified
my $verified = $application->verified;

View File

@ -88,6 +88,9 @@ BEGIN {
'https://git.desfronificator.example.com/larry/desfronificator.git';
my $app_flatpak_builder_file =
'./resources/com.example.desfronificator.yml';
my $app_flatpak_repo =
'https://nightly.gnome.org/gnome-nightly.flatpakrepo';
my $app_verified = 0;
my $developer = Peace::Model::Developer->new(
@ -108,16 +111,18 @@ BEGIN {
price => $app_price,
git_repo => $app_git_repo,
flatpak_builder_file => $app_flatpak_builder_file,
flatpak_repo => $app_flatpak_repo,
verified => $app_verified,
developer => $developer,
),
Peace::Model::Application->new(
name => $app_name0,
name => $app_name1,
description => $app_description,
url => $app_url,
price => $app_price,
git_repo => $app_git_repo,
flatpak_builder_file => $app_flatpak_builder_file,
flatpak_repo => $app_flatpak_repo,
verified => $app_verified,
developer => $developer,
),
@ -129,7 +134,7 @@ BEGIN {
}
);
## WHEN
## WHEN
my $new_applications = $developer->applications;
## THEN

View File

@ -31,9 +31,12 @@ BEGIN {
my $app_description = 'Desfronifies the files.';
my $app_url = 'https://desfronificator.example.com';
my $app_price = '4.20';
my $app_git_repo = 'https://git.desfronificator.example.com/larry/desfronificator.git';
my $app_git_repo =
'https://git.desfronificator.example.com/larry/desfronificator.git';
my $app_flatpak_builder_file =
'./resources/com.example.desfronificator.yml';
my $app_flatpak_repo =
'https://nightly.gnome.org/gnome-nightly.flatpakrepo';
my $app_verified = 0;
my $developer = Peace::Model::Developer->new(
secret_bcrypt => $secret_bcrypt,
@ -52,6 +55,7 @@ BEGIN {
url => $app_url,
price => $app_price,
flatpak_builder_file => $app_flatpak_builder_file,
flatpak_repo => $app_flatpak_repo,
verified => $app_verified,
git_repo => $app_git_repo,
);
@ -76,9 +80,12 @@ BEGIN {
my $app_description = 'Desfronifies the files.';
my $app_url = 'desfronificator.example.com';
my $app_price = '4.20';
my $app_git_repo = 'https://git.desfronificator.example.com/larry/desfronificator.git';
my $app_git_repo =
'https://git.desfronificator.example.com/larry/desfronificator.git';
my $app_flatpak_builder_file =
'./resources/com.example.desfronificator.yml';
my $app_flatpak_repo =
'https://nightly.gnome.org/gnome-nightly.flatpakrepo';
my $app_verified = 0;
my $dbh = DBI->connect( 'DBI:Mock:', '', '' );
my $developer = Peace::Model::Developer->new(
@ -105,6 +112,7 @@ BEGIN {
url => $app_url,
price => $app_price,
flatpak_builder_file => $app_flatpak_builder_file,
flatpak_repo => $app_flatpak_repo,
verified => $app_verified,
git_repo => $app_git_repo,
dbh => $dbh,

View File

@ -23,7 +23,7 @@ BEGIN {
INSERT INTO applications
(name, description, url,
developer, price, git_repo,
flatpak_builder_file, verified)
flatpak_builder_file, flatpak_repo, verified)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
RETURNING uuid;
EOF
@ -47,6 +47,8 @@ EOF
'https://git.desfronificator.example.com/larry/desfronificator.git';
my $app_flatpak_builder_file =
'./resources/com.example.desfronificator.yml';
my $app_flatpak_repo =
'https://nightly.gnome.org/gnome-nightly.flatpakrepo';
my $app_verified = 0;
my $developer = Peace::Model::Developer->new(
uuid => $uuid,
@ -64,6 +66,7 @@ EOF
url => $app_url,
price => $app_price,
flatpak_builder_file => $app_flatpak_builder_file,
flatpak_repo => $app_flatpak_repo,
verified => $app_verified,
git_repo => $app_git_repo,
);
@ -78,7 +81,7 @@ EOF
SELECT uuid, date_creation, name,
description, url, developer,
price, git_repo, flatpak_builder_file,
verified
flatpak_repo, verified
FROM applications
WHERE uuid = ?
EOF
@ -92,7 +95,8 @@ EOF
'name', 'description',
'url', 'developer',
'price', 'git_repo',
'flatpak_builder_file', 'verified',
'flatpak_builder_file', 'flatpak_repo',
'verified',
],
[
$uuid,
@ -104,6 +108,7 @@ EOF
$app_price,
$app_git_repo,
$app_flatpak_builder_file,
$app_flatpak_repo,
$app_verified
]
],
@ -136,6 +141,8 @@ EOF
'https://git.desfronificator.example.com/larry/desfronificator.git';
my $app_flatpak_builder_file =
'./resources/com.example.desfronificator.yml';
my $app_flatpak_repo =
'https://nightly.gnome.org/gnome-nightly.flatpakrepo';
my $app_verified = 0;
my $developer = Peace::Model::Developer->new(
uuid => $uuid,
@ -153,7 +160,7 @@ EOF
SELECT uuid, date_creation, name,
description, url, developer,
price, git_repo, flatpak_builder_file,
verified
flatpak_repo, verified
FROM applications
WHERE uuid = ?
EOF
@ -167,7 +174,8 @@ EOF
'name', 'description',
'url', 'developer',
'price', 'git_repo',
'flatpak_builder_file', 'verified',
'flatpak_builder_file', 'flatpak_repo',
'verified',
],
[
$uuid,
@ -179,6 +187,7 @@ EOF
$app_price,
$app_git_repo,
$app_flatpak_builder_file,
$app_flatpak_repo,
$app_verified
]
],
@ -196,7 +205,7 @@ EOF
SELECT uuid, date_creation, name,
description, url, developer,
price, git_repo, flatpak_builder_file,
verified
flatpak_repo, verified
FROM applications
WHERE developer = ?;
EOF
@ -231,24 +240,33 @@ EOF
'https://git.desfronificator.example.com/larry/desfronificator.git';
my $app_flatpak_builder_file =
'./resources/com.example.desfronificator.yml';
my $app_flatpak_repo =
'https://nightly.gnome.org/gnome-nightly.flatpakrepo';
my $app_verified = 0;
my $iso8601 = DateTime::Format::Pg->new;
$dbh->{mock_add_resultset} = {
sql => $sql,
results => [
[
'uuid', 'date_creation',
'name', 'description',
'url', 'price',
'git_repo', 'flatpak_builder_file',
'verified', 'developer'
'uuid', 'date_creation',
'name', 'description',
'url', 'price',
'git_repo', 'flatpak_builder_file',
'flatpak_repo', 'verified',
'developer'
],
[
$app_uuid, $iso8601->format_datetime($app_date_creation),
$app_name, $app_description,
$app_url, $app_price,
$app_git_repo, $app_flatpak_builder_file,
$app_verified, $developer->uuid,
$app_uuid,
$iso8601->format_datetime($app_date_creation),
$app_name,
$app_description,
$app_url,
$app_price,
$app_git_repo,
$app_flatpak_builder_file,
$app_flatpak_repo,
$app_verified,
$developer->uuid,
],
]
};

View File

@ -34,6 +34,8 @@ BEGIN {
'https://git.desfronificator.example.com/larry/desfronificator.git';
my $app_flatpak_builder_file =
'./resources/com.example.desfronificator.yml';
my $app_flatpak_repo =
'https://nightly.gnome.org/gnome-nightly.flatpakrepo';
my $app_verified = 0;
my $app_developer = Peace::Model::Developer->new(
secret_bcrypt => $developer_secret_bcrypt,
@ -51,6 +53,7 @@ BEGIN {
url => $app_url,
price => $app_price,
flatpak_builder_file => $app_flatpak_builder_file,
flatpak_repo => $app_flatpak_repo,
verified => $app_verified,
git_repo => $app_git_repo,
);
@ -89,6 +92,8 @@ BEGIN {
'https://git.desfronificator.example.com/larry/desfronificator.git';
my $app_flatpak_builder_file =
'./resources/com.example.desfronificator.yml';
my $app_flatpak_repo =
'https://nightly.gnome.org/gnome-nightly.flatpakrepo';
my $app_verified = 0;
my $app_developer = Peace::Model::Developer->new(
secret_bcrypt => $developer_secret_bcrypt,
@ -106,6 +111,7 @@ BEGIN {
url => $app_url,
price => $app_price,
flatpak_builder_file => $app_flatpak_builder_file,
flatpak_repo => $app_flatpak_repo,
verified => $app_verified,
git_repo => $app_git_repo,
);