summaryrefslogtreecommitdiffstats
path: root/lib/App/ArchLinux/PackagerTools
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2018-12-17 16:34:49 +0100
committerFlorian Pritz <bluewind@xinu.at>2018-12-17 16:34:49 +0100
commitdd551123400beb2e1ec0048d2ed19d82af3cc102 (patch)
treeed38252b6585f4e3a9abb41cb8893ea4fa00ee8e /lib/App/ArchLinux/PackagerTools
parentf2b5d9bacf8e109fe27cea8f68232d41fd3b3ea5 (diff)
downloadApp-ArchLinux-PackagerTools-dd551123400beb2e1ec0048d2ed19d82af3cc102.tar.gz
App-ArchLinux-PackagerTools-dd551123400beb2e1ec0048d2ed19d82af3cc102.tar.xz
Config: Load config from file only once
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib/App/ArchLinux/PackagerTools')
-rw-r--r--lib/App/ArchLinux/PackagerTools/Config.pm19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/App/ArchLinux/PackagerTools/Config.pm b/lib/App/ArchLinux/PackagerTools/Config.pm
index a58e82d..531e517 100644
--- a/lib/App/ArchLinux/PackagerTools/Config.pm
+++ b/lib/App/ArchLinux/PackagerTools/Config.pm
@@ -42,6 +42,7 @@ method new_no_defaults($class: $context, $deps = {}) {
my $self = {};
bless $self, $class;
$self->{deps} = $deps;
+ $self->{config} = $self->_load_config();
$context->{$class} = $self;
return $self;
}
@@ -59,8 +60,24 @@ Return config content as a hash.
=cut
method get_config() {
- my $config = $self->_get_default_config();
+ return $self->{config};
+}
+
+=head2 Private Methods
+
+=cut
+
+=head3 _load_config
+ my $conf = $config->_load_config();
+
+Load configuration from config file. You should use get_config() instead since
+that returns a cached in-memory copy.
+
+=cut
+
+method _load_config() {
+ my $config = $self->_get_default_config();
my $file = path(($ENV{XDG_CONFIG_HOME} // $ENV{HOME}."/.config")."/perlpkg/config.toml");
if ($file->exists) {
$log->debugf("Reading config file: %s", $file);