summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authorJulian Blake Kongslie <jblake@omgwallhack.org>2010-10-12 22:21:06 -0700
committerJulian Blake Kongslie <jblake@omgwallhack.org>2010-10-12 22:21:06 -0700
commitd2c9fbddc444988c7c391258b764b5f3b30fb5b7 (patch)
tree774c86d6e7e60b57e68efcb2c9fdb626a1f38b37 /usr
parentea40b04f0ff65bd56eead8bcaee007db7d39359f (diff)
downloadpiny-code-d2c9fbddc444988c7c391258b764b5f3b30fb5b7.tar.gz
piny-code-d2c9fbddc444988c7c391258b764b5f3b30fb5b7.zip
More constraints.
Diffstat (limited to 'usr')
-rw-r--r--usr/src/libpiny/lib/Piny/Config.pm34
1 files changed, 29 insertions, 5 deletions
diff --git a/usr/src/libpiny/lib/Piny/Config.pm b/usr/src/libpiny/lib/Piny/Config.pm
index a162e2a..4d63c32 100644
--- a/usr/src/libpiny/lib/Piny/Config.pm
+++ b/usr/src/libpiny/lib/Piny/Config.pm
@@ -21,6 +21,30 @@ subtype 'GitBool'
=> message { 'Not correct format for a git-compatible boolean.' }
;
+subtype 'Path'
+ => as 'Str'
+ => where { $_ =~ /^\// and -e $_ }
+ => message { 'Not an absolute path, or does not exist.' }
+ ;
+
+subtype 'PathDir'
+ => as 'Path'
+ => where { -d $_ }
+ => message { 'Not a directory.' }
+ ;
+
+subtype 'HttpUrl'
+ => as 'Str'
+ => where { $_ =~ /^http:\/\//i }
+ => message { 'Not a http:// URL.' }
+ ;
+
+subtype 'HttpsUrl'
+ => as 'Str'
+ => where { $_ =~ /^https:\/\//i }
+ => message { 'Not a https:// URL.' }
+ ;
+
# Attributes
has 'confpath' =>
@@ -178,11 +202,11 @@ sub tweakable {
# The tweakables
-tweakable "piny_ikiwikidestdir" => "/srv/www/piny.be/", 'Str';
-tweakable "piny_ikiwikisrcdir" => "/srv/ikiwiki/", 'Str';
-tweakable "piny_ikiwikiurl" => "http://piny.be/", 'Str';
-tweakable "piny_ikiwikisecureurl" => "https://secure.piny.be/", 'Str';
-tweakable "piny_ikiwikisecurepath" => "/srv/www/secure.piny.be/", 'Str';
+tweakable "piny_ikiwikidestdir" => "/srv/www/piny.be/", 'PathDir';
+tweakable "piny_ikiwikisrcdir" => "/srv/ikiwiki/", 'PathDir';
+tweakable "piny_ikiwikiurl" => "http://piny.be/", 'HttpUrl';
+tweakable "piny_ikiwikisecureurl" => "https://secure.piny.be/", 'HttpsUrl';
+tweakable "piny_ikiwikisecurepath" => "/srv/www/secure.piny.be/", 'PathDir';
tweakable "receive_denyNonFastforwards" => "true", 'GitBool';
# Moose boilerplate