diff options
author | Florian Pritz <bluewind@xinu.at> | 2018-12-17 00:38:24 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2018-12-17 00:38:24 +0100 |
commit | 90535df46d0d8b4052497a9dc0beacd8c186066f (patch) | |
tree | 147063c319cc1469d15af6f5e8c1355997ca0d7f /lib | |
parent | d7cd126cc8326f42713c20d2d95091156b44e58f (diff) | |
download | App-ArchLinux-PackagerTools-90535df46d0d8b4052497a9dc0beacd8c186066f.tar.gz App-ArchLinux-PackagerTools-90535df46d0d8b4052497a9dc0beacd8c186066f.tar.xz |
Use context variable to track singletons
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/App/ArchLinux/PackagerTools.pm | 6 | ||||
-rw-r--r-- | lib/App/ArchLinux/PackagerTools/CPAN.pm | 5 | ||||
-rw-r--r-- | lib/App/ArchLinux/PackagerTools/Pacman.pm | 2 |
3 files changed, 8 insertions, 5 deletions
diff --git a/lib/App/ArchLinux/PackagerTools.pm b/lib/App/ArchLinux/PackagerTools.pm index a4cd69e..0bd602a 100644 --- a/lib/App/ArchLinux/PackagerTools.pm +++ b/lib/App/ArchLinux/PackagerTools.pm @@ -38,9 +38,9 @@ Returns a new instance. =cut method new($class: $deps = {}) { - $deps->{config} //= App::ArchLinux::PackagerTools::Config->new(); - $deps->{cpan} //= App::ArchLinux::PackagerTools::CPAN->new(); - $deps->{pacman} //= App::ArchLinux::PackagerTools::Pacman->new({$deps->%{cpan}}); + $deps->{config} //= App::ArchLinux::PackagerTools::Config->new({$deps->%{context}}); + $deps->{cpan} //= App::ArchLinux::PackagerTools::CPAN->new({$deps->%{context}}); + $deps->{pacman} //= App::ArchLinux::PackagerTools::Pacman->new({$deps->%{context}}); return $class->new_no_defaults($deps); } diff --git a/lib/App/ArchLinux/PackagerTools/CPAN.pm b/lib/App/ArchLinux/PackagerTools/CPAN.pm index 1e1c86c..e7521b6 100644 --- a/lib/App/ArchLinux/PackagerTools/CPAN.pm +++ b/lib/App/ArchLinux/PackagerTools/CPAN.pm @@ -38,16 +38,19 @@ Returns a new instance. =cut method new($class: $deps = {}) { - $deps->{packages_details_fetcher} //= App::ArchLinux::PackagerTools::CPAN::PackagesDetailsFetcher->new(); + $deps->{packages_details_fetcher} //= App::ArchLinux::PackagerTools::CPAN::PackagesDetailsFetcher->new({$deps->%{context}}); return $class->new_no_defaults($deps); } method new_no_defaults($class: $deps = {}) { + return $deps->{context}->{__PACKAGE__} if defined $deps->{context}->{__PACKAGE__}; + my $self = {}; bless $self, $class; $self->{deps} = $deps; $self->{dist_lc_map} = {}; $self->{dists} = {}; + $deps->{context}->{__PACKAGE__} = $self; return $self; } diff --git a/lib/App/ArchLinux/PackagerTools/Pacman.pm b/lib/App/ArchLinux/PackagerTools/Pacman.pm index 39c78e5..f541721 100644 --- a/lib/App/ArchLinux/PackagerTools/Pacman.pm +++ b/lib/App/ArchLinux/PackagerTools/Pacman.pm @@ -36,7 +36,7 @@ Returns a new instance. method new($class: $deps = {}) { - $deps->{cpan} //= App::ArchLinux::PackagerTools::CPAN->new(); + $deps->{cpan} //= App::ArchLinux::PackagerTools::CPAN->new({$deps->%{context}}); $deps->{pkgname_cpan_name_map} //= { # pkgname => cpan_name 'perl-critic' => 'Perl::Critic', |