Commit 23707105ba61bc29dac5987758a731e2575388f6
1 parent
05eeb3ec
Exists in
master
Add config.yaml
Now, repositories informations come from the config.yaml file.
Showing
4 changed files
with
23 additions
and
12 deletions
Show diff stats
README.md
lib/CoprStatus.pm
| ... | ... | @@ -2,6 +2,7 @@ package CoprStatus; |
| 2 | 2 | use strict; |
| 3 | 3 | use warnings; |
| 4 | 4 | use JSON; |
| 5 | +use YAML::XS 'LoadFile'; | |
| 5 | 6 | use Text::Template; |
| 6 | 7 | use LWP::UserAgent; |
| 7 | 8 | use LWP::Simple; |
| ... | ... | @@ -10,6 +11,7 @@ $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0; |
| 10 | 11 | |
| 11 | 12 | # hash with repos data |
| 12 | 13 | our $info = {}; |
| 14 | +my $config = LoadFile('config.yaml'); | |
| 13 | 15 | |
| 14 | 16 | sub copr_monitor_url { |
| 15 | 17 | my ( $user, $repo ) = @_; |
| ... | ... | @@ -62,15 +64,19 @@ sub get_copr_versions { |
| 62 | 64 | |
| 63 | 65 | } |
| 64 | 66 | |
| 65 | -sub copr_info { | |
| 66 | - my ( $user, $repo, $branch ) = @_; | |
| 67 | - get_copr_versions($user, $repo); | |
| 68 | - get_specs($branch); | |
| 67 | +sub update_info { | |
| 68 | + my $user = $config->{User}; | |
| 69 | + foreach my $repo (@{$config->{Repositories}}) { | |
| 70 | + get_copr_versions($user, $repo); | |
| 71 | + } | |
| 72 | + | |
| 73 | + foreach my $branch (@{$config->{Branches}}) { | |
| 74 | + get_specs($branch); | |
| 75 | + } | |
| 69 | 76 | } |
| 70 | 77 | |
| 71 | 78 | sub compare_versions { |
| 72 | - copr_info('softwarepublico', 'v4', 'stable-4.1'); | |
| 73 | - copr_info('softwarepublico', 'v5', 'master'); | |
| 79 | + update_info(); | |
| 74 | 80 | my $match = {}; |
| 75 | 81 | foreach my $package (keys %{$info}) { |
| 76 | 82 | if($info->{$package}->{'v5_version'} eq $info->{$package}->{git_version_master}) { |
| ... | ... | @@ -85,8 +91,7 @@ sub compare_versions { |
| 85 | 91 | } |
| 86 | 92 | |
| 87 | 93 | sub info2html { |
| 88 | - copr_info('softwarepublico', 'v4', 'stable-4.1'); | |
| 89 | - copr_info('softwarepublico', 'v5', 'master'); | |
| 94 | + update_info(); | |
| 90 | 95 | my $table_entries=""; |
| 91 | 96 | foreach my $package (keys %{$info}) { |
| 92 | 97 | my $fill_v4_row; |
| ... | ... | @@ -147,8 +152,7 @@ sub serve_html { |
| 147 | 152 | }; |
| 148 | 153 | |
| 149 | 154 | sub serve_json { |
| 150 | - copr_info('softwarepublico', 'v4', 'stable-4.1'); | |
| 151 | - copr_info('softwarepublico', 'v5', 'master'); | |
| 155 | + update_info(); | |
| 152 | 156 | my $json = JSON->new->allow_nonref; |
| 153 | 157 | my $json_info = $json->encode($info); |
| 154 | 158 | return [ | ... | ... |
t/app.t