summaryrefslogtreecommitdiff
path: root/usr/src/libpiny
diff options
context:
space:
mode:
authorJulian Blake Kongslie <jblake@omgwallhack.org>2010-07-18 21:23:53 -0700
committerjblake+piny@omgwallhack.org <jblake@omgwallhack.org>2010-07-18 21:23:53 -0700
commitc0791a91fd301f0c18dcb3019de578f8280d21e4 (patch)
treefd2d2dbb787357ff12a65f11ab26a05052347670 /usr/src/libpiny
parentb86db831848482fb5f32d4e2c7cc94c37765eb4d (diff)
downloadpiny-code-c0791a91fd301f0c18dcb3019de578f8280d21e4.tar.gz
piny-code-c0791a91fd301f0c18dcb3019de578f8280d21e4.zip
Global configuration stuff.
Diffstat (limited to 'usr/src/libpiny')
-rw-r--r--usr/src/libpiny/debian/changelog6
-rw-r--r--usr/src/libpiny/debian/control2
-rw-r--r--usr/src/libpiny/lib/Piny.pm1
-rw-r--r--usr/src/libpiny/lib/Piny/Config.pm121
-rw-r--r--usr/src/libpiny/lib/Piny/Environment.pm2
-rw-r--r--usr/src/libpiny/lib/Piny/Repo.pm1
6 files changed, 131 insertions, 2 deletions
diff --git a/usr/src/libpiny/debian/changelog b/usr/src/libpiny/debian/changelog
index 1e99808..fc1ae42 100644
--- a/usr/src/libpiny/debian/changelog
+++ b/usr/src/libpiny/debian/changelog
@@ -1,3 +1,9 @@
+libpiny-perl (0.10) unstable; urgency=low
+
+ * Support for the global /etc/piny.conf stuff.
+
+ -- Julian Blake Kongslie <jblake@omgwallhack.org> Sun, 18 Jul 2010 21:23:28 -0700
+
libpiny-perl (0.9) unstable; urgency=low
* Creating new repos.
diff --git a/usr/src/libpiny/debian/control b/usr/src/libpiny/debian/control
index 7502717..a626cd8 100644
--- a/usr/src/libpiny/debian/control
+++ b/usr/src/libpiny/debian/control
@@ -7,7 +7,7 @@ Standards-version: 3.8.4
Package: libpiny-perl
Architecture: all
-Depends: ${perl:Depends}, ${misc:Depends}, libemail-valid-loose-perl, libmoose-perl
+Depends: ${perl:Depends}, ${misc:Depends}, libemail-valid-loose-perl, libmoose-perl, libmoosex-singleton-perl
Description: Perl interface for the piny infrastructure
This is a set of modules for accomplishing administrative tasks in the piny.be
infrastructure.
diff --git a/usr/src/libpiny/lib/Piny.pm b/usr/src/libpiny/lib/Piny.pm
index 2ed139b..54a5b00 100644
--- a/usr/src/libpiny/lib/Piny.pm
+++ b/usr/src/libpiny/lib/Piny.pm
@@ -5,6 +5,7 @@
# That way, you can "use Piny" and import all the Piny packages into your namespace in one fell swoop.
# Of course, you don't get to pass arguments to their import functions anymore.
+use Piny::Config;
use Piny::Email;
use Piny::Environment;
use Piny::Group;
diff --git a/usr/src/libpiny/lib/Piny/Config.pm b/usr/src/libpiny/lib/Piny/Config.pm
new file mode 100644
index 0000000..b30eccb
--- /dev/null
+++ b/usr/src/libpiny/lib/Piny/Config.pm
@@ -0,0 +1,121 @@
+# Copyright © 2010 Julian Blake Kongslie <jblake@omgwallhack.org>
+# Licensed under the BSD 3-clause license.
+
+package Piny::Config;
+
+use MooseX::Singleton;
+
+use YAML::Tiny qw( );
+
+# Attributes
+
+has '_conf' =>
+ ( is => 'ro'
+ , isa => 'HashRef[Str]'
+ , lazy_build => 1
+ , init_arg => undef
+ );
+
+has 'ikiwiki_destdir' =>
+ ( is => 'ro'
+ , isa => 'Str'
+ , lazy_build => 1
+ , init_arg => undef
+ );
+
+has 'ikiwiki_srcdir' =>
+ ( is => 'ro'
+ , isa => 'Str'
+ , lazy_build => 1
+ , init_arg => undef
+ );
+
+has 'ikiwiki_url' =>
+ ( is => 'ro'
+ , isa => 'Str'
+ , lazy_build => 1
+ , init_arg => undef
+ );
+
+has 'ikiwiki_secure_url' =>
+ ( is => 'ro'
+ , isa => 'Str'
+ , lazy_build => 1
+ , init_arg => undef
+ );
+
+has 'ikiwiki_secure_path' =>
+ ( is => 'ro'
+ , isa => 'Str'
+ , lazy_build => 1
+ , init_arg => undef
+ );
+
+# Builder methods
+
+sub _build__conf {
+ my ( $s ) = @_;
+
+ if ( -e "/etc/piny.conf" ) {
+ my $yaml = YAML::Tiny->new;
+ return $yaml->read( "/etc/piny.conf" );
+ } else {
+ return { };
+ };
+};
+
+sub _build_ikiwiki_destdir {
+ my ( $s ) = @_;
+
+ if ( exists $s->_conf->{"ikiwiki_destdir"} ) {
+ return $s->_conf->{"ikiwiki_destdir"};
+ } else {
+ return "/srv/www/piny.be/";
+ };
+};
+
+sub _build_ikiwiki_srcdir {
+ my ( $s ) = @_;
+
+ if ( exists $s->_conf->{"ikiwiki_srcdir"} ) {
+ return $s->_conf->{"ikiwiki_destdir"};
+ } else {
+ return "/srv/ikiwiki/";
+ };
+};
+
+sub _build_ikiwiki_url {
+ my ( $s ) = @_;
+
+ if ( exists $s->_conf->{"ikiwiki_url"} ) {
+ return $s->_conf->{"ikiwiki_url"};
+ } else {
+ return "http://piny.be/";
+ };
+};
+
+sub _build_ikiwiki_secure_url {
+ my ( $s ) = @_;
+
+ if ( exists $s->_conf->{"ikiwiki_secure_url"} ) {
+ return $s->_conf->{"ikiwiki_secure_url"};
+ } else {
+ return "https://secure.piny.be/repos/";
+ };
+};
+
+sub _build_ikiwiki_secure_path {
+ my ( $s ) = @_;
+
+ if ( exists $s->_conf->{"ikiwiki_secure_path"} ) {
+ return $s->_conf->{"ikiwiki_secure_path"};
+ } else {
+ return "/srv/www/secure.piny.be/repos/";
+ };
+};
+
+# Moose boilerplate
+
+__PACKAGE__->meta->make_immutable;
+
+1;
diff --git a/usr/src/libpiny/lib/Piny/Environment.pm b/usr/src/libpiny/lib/Piny/Environment.pm
index fcd4392..6cd3532 100644
--- a/usr/src/libpiny/lib/Piny/Environment.pm
+++ b/usr/src/libpiny/lib/Piny/Environment.pm
@@ -3,7 +3,7 @@
package Piny::Environment;
-use Moose;
+use MooseX::Singleton;
use Piny::User;
diff --git a/usr/src/libpiny/lib/Piny/Repo.pm b/usr/src/libpiny/lib/Piny/Repo.pm
index 5d617f6..62f01f3 100644
--- a/usr/src/libpiny/lib/Piny/Repo.pm
+++ b/usr/src/libpiny/lib/Piny/Repo.pm
@@ -12,6 +12,7 @@ use IO::Dir qw( );
use IkiWiki::FakeSetup qw( readSetup writeSetup );
+use Piny::Config;
use Piny::Environment;
use Piny::Group;
use Piny::User;